From 37060d4192ccb1565e1a15cdb1b342508acac588 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 9 Dec 2022 12:18:23 +0100 Subject: [PATCH] ts: Fix sendTransaction to work with NodeWallet --- ts/client/src/utils/rpc.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ts/client/src/utils/rpc.ts b/ts/client/src/utils/rpc.ts index 81ca28070..0f8f1df20 100644 --- a/ts/client/src/utils/rpc.ts +++ b/ts/client/src/utils/rpc.ts @@ -1,4 +1,5 @@ import { AnchorProvider } from '@project-serum/anchor'; +import NodeWallet from '@project-serum/anchor/dist/cjs/nodewallet'; import { AddressLookupTableAccount, MessageV0, @@ -31,12 +32,16 @@ export async function sendTransaction( vtx.sign([...opts?.additionalSigners]); } - if (typeof payer.signTransaction === 'function') { + if ( + typeof payer.signTransaction === 'function' && + !(payer instanceof NodeWallet) + ) { vtx = (await payer.signTransaction( vtx as any, )) as unknown as VersionedTransaction; } else { - vtx.sign([((provider as AnchorProvider).wallet as any).payer as Signer]); + // Maybe this path is only correct for NodeWallet? + vtx.sign([(payer as any).payer as Signer]); } const signature = await connection.sendRawTransaction(vtx.serialize(), {