From ccbbb25ce238cb5e8bede323bddb8e5d3cf65c7d Mon Sep 17 00:00:00 2001 From: mmjee Date: Thu, 2 Nov 2023 04:59:32 +0530 Subject: [PATCH] Pre-encode things --- src/solana.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/solana.ts b/src/solana.ts index 5e6557d..165c5d9 100644 --- a/src/solana.ts +++ b/src/solana.ts @@ -29,8 +29,23 @@ export class ArcanaSolanaAPI { return this.p.connected } - async request(args: RequestArguments): Promise { + async request(_args: RequestArguments): Promise { + const args = structuredClone(_args) + + switch (args.method) { + case 'signMessage': { + const p = args.params as { + message: string | Uint8Array | Buffer + display: string + } + if (Buffer.isBuffer(p.message) || p.message instanceof Uint8Array) { + p.message = this.bs58Module.encode(p.message) + } + } + } + const response = await this.p.request(args) + switch (args.method) { case 'signMessage': { return this.parseSignatureResponse(response as SignatureResRaw)