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 bs58 from 'bs58'
|
||||||
import nacl from 'tweetnacl'
|
import nacl from 'tweetnacl'
|
||||||
|
|
||||||
@ -25,10 +25,18 @@ export class Solana {
|
|||||||
return signature
|
return signature
|
||||||
}
|
}
|
||||||
|
|
||||||
public async signTransaction(transaction: TransactionInstructionCtorFields) {
|
public async signTransaction(
|
||||||
const tx = new Transaction()
|
feePayer: string,
|
||||||
tx.add(transaction)
|
recentBlockhash: string,
|
||||||
|
instructions: TransactionInstructionCtorFields
|
||||||
|
) {
|
||||||
|
const tx = new Transaction({
|
||||||
|
feePayer: new PublicKey(feePayer),
|
||||||
|
recentBlockhash
|
||||||
|
})
|
||||||
|
tx.add(instructions)
|
||||||
await tx.sign(this.keypair)
|
await tx.sign(this.keypair)
|
||||||
|
console.log(tx)
|
||||||
const { signature } = tx.signatures[tx.signatures.length - 1]
|
const { signature } = tx.signatures[tx.signatures.length - 1]
|
||||||
|
|
||||||
return signature
|
return signature
|
||||||
|
@ -15,7 +15,11 @@ export async function approveSolanaRequest(requestEvent: RequestEvent) {
|
|||||||
return formatJsonRpcResult(id, signedMessage)
|
return formatJsonRpcResult(id, signedMessage)
|
||||||
|
|
||||||
case SOLANA_SIGNING_METHODS.SOLANA_SIGN_TRANSACTION:
|
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)
|
return formatJsonRpcResult(id, signedTransaction)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user