Add feePayer and recentBlockhash to solana's signTransaction
This commit is contained in:
parent
8ba122d703
commit
cdbf9af7a6
@ -1,4 +1,4 @@
|
||||
import { Keypair, Transaction, TransactionInstructionCtorFields } from '@solana/web3.js'
|
||||
import { Keypair, PublicKey, Transaction, TransactionInstructionCtorFields } from '@solana/web3.js'
|
||||
import bs58 from 'bs58'
|
||||
import nacl from 'tweetnacl'
|
||||
|
||||
@ -25,10 +25,18 @@ export class Solana {
|
||||
return signature
|
||||
}
|
||||
|
||||
public async signTransaction(transaction: TransactionInstructionCtorFields) {
|
||||
const tx = new Transaction()
|
||||
tx.add(transaction)
|
||||
public async signTransaction(
|
||||
feePayer: string,
|
||||
recentBlockhash: string,
|
||||
instructions: TransactionInstructionCtorFields
|
||||
) {
|
||||
const tx = new Transaction({
|
||||
feePayer: new PublicKey(feePayer),
|
||||
recentBlockhash
|
||||
})
|
||||
tx.add(instructions)
|
||||
await tx.sign(this.keypair)
|
||||
console.log(tx)
|
||||
const { signature } = tx.signatures[tx.signatures.length - 1]
|
||||
|
||||
return signature
|
||||
|
@ -15,7 +15,11 @@ export async function approveSolanaRequest(requestEvent: RequestEvent) {
|
||||
return formatJsonRpcResult(id, signedMessage)
|
||||
|
||||
case SOLANA_SIGNING_METHODS.SOLANA_SIGN_TRANSACTION:
|
||||
const signedTransaction = await wallet.signTransaction(params.instructions)
|
||||
const signedTransaction = await wallet.signTransaction(
|
||||
params.feePayer,
|
||||
params.recentBlockhash,
|
||||
params.instructions
|
||||
)
|
||||
return formatJsonRpcResult(id, signedTransaction)
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user