From cdbf9af7a6f765f2ac5ec6f23de7b20ef0244599 Mon Sep 17 00:00:00 2001 From: Ilja Date: Tue, 15 Mar 2022 11:29:42 +0200 Subject: [PATCH] Add feePayer and recentBlockhash to solana's signTransaction --- wallets/react-wallet-v2/src/lib/Solana.ts | 16 ++++++++++++---- .../src/utils/SolanaRequestHandlerUtil.ts | 6 +++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/wallets/react-wallet-v2/src/lib/Solana.ts b/wallets/react-wallet-v2/src/lib/Solana.ts index abd3f29..d305caf 100644 --- a/wallets/react-wallet-v2/src/lib/Solana.ts +++ b/wallets/react-wallet-v2/src/lib/Solana.ts @@ -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 diff --git a/wallets/react-wallet-v2/src/utils/SolanaRequestHandlerUtil.ts b/wallets/react-wallet-v2/src/utils/SolanaRequestHandlerUtil.ts index 3a66282..06451c0 100644 --- a/wallets/react-wallet-v2/src/utils/SolanaRequestHandlerUtil.ts +++ b/wallets/react-wallet-v2/src/utils/SolanaRequestHandlerUtil.ts @@ -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: