From 7e273213e37bfcc0bd77fd8e3df85e8a6d37fa12 Mon Sep 17 00:00:00 2001 From: mmjee Date: Thu, 2 Nov 2023 04:52:56 +0530 Subject: [PATCH] Added support for sign transaction and a little bit of refactoring --- src/solana.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/solana.ts b/src/solana.ts index 9d6e471..5e6557d 100644 --- a/src/solana.ts +++ b/src/solana.ts @@ -35,6 +35,11 @@ export class ArcanaSolanaAPI { case 'signMessage': { return this.parseSignatureResponse(response as SignatureResRaw) } + case 'signTransaction': { + return this.web3Module.VersionedTransaction.deserialize( + bs58.decode(response as string) + ) + } default: { return response } @@ -48,15 +53,26 @@ export class ArcanaSolanaAPI { } } - async signMessage(data: Uint8Array, display: string): Promise { - const response = (await this.p.request({ + signMessage(data: Uint8Array, display: string): Promise { + const r = this.request({ method: 'signMessage', params: { message: this.bs58Module.encode(data), display, }, - })) as SignatureResRaw + }) + return r as Promise + } - return this.parseSignatureResponse(response) + signTransaction( + tx: Web3Module.VersionedTransaction | Web3Module.Transaction + ): Promise { + const r = this.request({ + method: 'signTransaction', + params: { + message: this.bs58Module.encode(tx.serialize()), + }, + }) + return r as Promise } }