diff --git a/packages/secure-clients/src/SolanaClient/BackpackSolanaWallet.ts b/packages/secure-clients/src/SolanaClient/BackpackSolanaWallet.ts index 1ce79aead..ae2e8dd2d 100644 --- a/packages/secure-clients/src/SolanaClient/BackpackSolanaWallet.ts +++ b/packages/secure-clients/src/SolanaClient/BackpackSolanaWallet.ts @@ -1,6 +1,11 @@ import { Blockchain } from "@coral-xyz/common"; import type { SVMClient } from "@coral-xyz/secure-background/clients"; import type { SecureEvent } from "@coral-xyz/secure-background/types"; +import type { + SolanaSignInInput} from "@solana/wallet-standard-features"; +import { + SolanaSignInOutput, +} from "@solana/wallet-standard-features"; import type { Commitment, ConfirmOptions, @@ -26,7 +31,6 @@ import { deserializeTransaction, isVersionedTransaction, } from "./utils/transaction-helpers"; -import { SolanaSignInInput, SolanaSignInOutput } from "@solana/wallet-standard-features" export class BackpackSolanaWallet { private secureSvmClient: SVMClient; @@ -135,9 +139,7 @@ export class BackpackSolanaWallet { return decode(svmResponse.response.signedMessage); } - public async signIn( - input?: SolanaSignInInput - ): Promise<{ + public async signIn(input?: SolanaSignInInput): Promise<{ signedMessage: string; signature: string; publicKey: string; @@ -145,7 +147,7 @@ export class BackpackSolanaWallet { }> { const svmResponse = await this.secureSvmClient.signIn({ blockchain: Blockchain.SOLANA, - input + input, }); if (!svmResponse.response) { throw svmResponse.error; @@ -154,7 +156,7 @@ export class BackpackSolanaWallet { } private async prepareTransaction< - T extends Transaction | VersionedTransaction + T extends Transaction | VersionedTransaction, >(request: { publicKey: PublicKey; tx: T; @@ -169,11 +171,6 @@ export class BackpackSolanaWallet { const commitment = request.commitment; if (!isVersionedTransaction(tx)) { - if (signers) { - signers.forEach((s: Signer) => { - tx.partialSign(s); - }); - } if (!tx.feePayer) { tx.feePayer = publicKey; } @@ -181,6 +178,11 @@ export class BackpackSolanaWallet { const { blockhash } = await connection.getLatestBlockhash(commitment); tx.recentBlockhash = blockhash; } + if (signers) { + signers.forEach((s: Signer) => { + tx.partialSign(s); + }); + } } else { if (signers) { tx.sign(signers); @@ -227,7 +229,7 @@ export class BackpackSolanaWallet { } public async signAllTransactions< - T extends Transaction | VersionedTransaction + T extends Transaction | VersionedTransaction, >( request: { publicKey: PublicKey; @@ -366,22 +368,22 @@ export class BackpackSolanaWallet { const signersOrConf = "message" in tx ? ({ - accounts: { - encoding: "base64", - addresses: [ - ...(request.includedAccounts ?? []), - publicKey.toString(), - ], - }, - } as SimulateTransactionConfig) + accounts: { + encoding: "base64", + addresses: [ + ...(request.includedAccounts ?? []), + publicKey.toString(), + ], + }, + } as SimulateTransactionConfig) : undefined; const response = await (isVersionedTransaction(preparedTx) ? connection.simulateTransaction(preparedTx, signersOrConf) : this.connection.simulateTransaction(preparedTx, undefined, [ - ...(request.includedAccounts?.map((p) => new PublicKey(p)) ?? []), - publicKey, - ])); + ...(request.includedAccounts?.map((p) => new PublicKey(p)) ?? []), + publicKey, + ])); return response.value; }