diff --git a/packages/core/base/src/adapter.ts b/packages/core/base/src/adapter.ts index a3525a4c1..c356505cb 100644 --- a/packages/core/base/src/adapter.ts +++ b/packages/core/base/src/adapter.ts @@ -1,10 +1,24 @@ -import type { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { Commitment, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js'; import EventEmitter from 'eventemitter3'; import { type WalletError, WalletNotConnectedError } from './errors.js'; import type { SupportedTransactionVersions, TransactionOrVersionedTransaction } from './transaction.js'; export { EventEmitter }; +type BlockhashFetcher = (config?: { + commitment?: Commitment; + minContextSlot?: number; +}) => Promise<{ blockhash: string }>; + +export interface ConnectionContext { + commitment?: Commitment; + getLatestBlockhash: BlockhashFetcher; + sendRawTransaction( + rawTransaction: Buffer | Uint8Array | Array, + options?: SendOptions + ): Promise; +} + export interface WalletAdapterEvents { connect(publicKey: PublicKey): void; disconnect(): void; @@ -35,7 +49,7 @@ export interface WalletAdapterProps { disconnect(): Promise; sendTransaction( transaction: TransactionOrVersionedTransaction, - connection: Connection, + connectionContext: ConnectionContext, options?: SendTransactionOptions ): Promise; } @@ -96,13 +110,13 @@ export abstract class BaseWalletAdapter abstract sendTransaction( transaction: TransactionOrVersionedTransaction, - connection: Connection, + connectionContext: ConnectionContext, options?: SendTransactionOptions ): Promise; protected async prepareTransaction( transaction: Transaction, - connection: Connection, + blockhashFetchingContext: Readonly<{ getLatestBlockhash: BlockhashFetcher }>, options: SendOptions = {} ): Promise { const publicKey = this.publicKey; @@ -112,7 +126,7 @@ export abstract class BaseWalletAdapter transaction.recentBlockhash = transaction.recentBlockhash || ( - await connection.getLatestBlockhash({ + await blockhashFetchingContext.getLatestBlockhash({ commitment: options.preflightCommitment, minContextSlot: options.minContextSlot, }) diff --git a/packages/core/base/src/signer.ts b/packages/core/base/src/signer.ts index 76f147b00..07ca92228 100644 --- a/packages/core/base/src/signer.ts +++ b/packages/core/base/src/signer.ts @@ -1,7 +1,8 @@ import type { SolanaSignInInput, SolanaSignInOutput } from '@solana/wallet-standard-features'; -import type { Connection, TransactionSignature } from '@solana/web3.js'; +import type { TransactionSignature } from '@solana/web3.js'; import { BaseWalletAdapter, + type ConnectionContext, type SendTransactionOptions, type WalletAdapter, type WalletAdapterProps, @@ -26,7 +27,7 @@ export abstract class BaseSignerWalletAdapter { async sendTransaction( transaction: TransactionOrVersionedTransaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { let emit = true; @@ -47,7 +48,7 @@ export abstract class BaseSignerWalletAdapter const rawTransaction = transaction.serialize(); - return await connection.sendRawTransaction(rawTransaction, options); + return await connectionContext.sendRawTransaction(rawTransaction, options); } catch (error: any) { // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event if (error instanceof WalletSignTransactionError) { @@ -60,7 +61,7 @@ export abstract class BaseSignerWalletAdapter try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); @@ -68,7 +69,7 @@ export abstract class BaseSignerWalletAdapter const rawTransaction = transaction.serialize(); - return await connection.sendRawTransaction(rawTransaction, sendOptions); + return await connectionContext.sendRawTransaction(rawTransaction, sendOptions); } catch (error: any) { // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event if (error instanceof WalletSignTransactionError) { diff --git a/packages/wallets/alpha/src/adapter.ts b/packages/wallets/alpha/src/adapter.ts index 85404422b..d16ed61cc 100644 --- a/packages/wallets/alpha/src/adapter.ts +++ b/packages/wallets/alpha/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface AlphaWalletEvents { @@ -158,7 +158,7 @@ export class AlphaWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -168,11 +168,11 @@ export class AlphaWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/avana/src/adapter.ts b/packages/wallets/avana/src/adapter.ts index 3ebb23ef0..d3ad0dfb1 100644 --- a/packages/wallets/avana/src/adapter.ts +++ b/packages/wallets/avana/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface AvanaWalletEvents { @@ -160,7 +160,7 @@ export class AvanaWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -170,11 +170,11 @@ export class AvanaWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/coinbase/src/adapter.ts b/packages/wallets/coinbase/src/adapter.ts index 08405e404..2425070c4 100644 --- a/packages/wallets/coinbase/src/adapter.ts +++ b/packages/wallets/coinbase/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, isVersionedTransaction, @@ -16,7 +16,6 @@ import { WalletSignTransactionError, } from '@solana/wallet-adapter-base'; import type { - Connection, SendOptions, Transaction, VersionedTransaction, @@ -157,7 +156,7 @@ export class CoinbaseWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: T, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -170,11 +169,11 @@ export class CoinbaseWalletAdapter extends BaseMessageSignerWalletAdapter { if (isVersionedTransaction(transaction)) { signers?.length && transaction.sign(signers); } else { - transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T; + transaction = (await this.prepareTransaction(transaction, connectionContext, sendOptions)) as T; signers?.length && (transaction as Transaction).partialSign(...signers); } - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/nufi/src/adapter.ts b/packages/wallets/nufi/src/adapter.ts index 2356ffcf5..8c401cea5 100644 --- a/packages/wallets/nufi/src/adapter.ts +++ b/packages/wallets/nufi/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, isVersionedTransaction, @@ -16,13 +16,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { - Connection, - Transaction, - TransactionSignature, - TransactionVersion, - VersionedTransaction, -} from '@solana/web3.js'; +import type { Transaction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface NufiWalletEvents { @@ -161,7 +155,7 @@ export class NufiWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: T, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -174,11 +168,11 @@ export class NufiWalletAdapter extends BaseMessageSignerWalletAdapter { if (isVersionedTransaction(transaction)) { signers?.length && transaction.sign(signers); } else { - transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T; + transaction = (await this.prepareTransaction(transaction, connectionContext, sendOptions)) as T; signers?.length && (transaction as Transaction).partialSign(...signers); } - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction); return signature; } catch (error: any) { diff --git a/packages/wallets/phantom/src/adapter.ts b/packages/wallets/phantom/src/adapter.ts index 56475cfd9..5a7c879fe 100644 --- a/packages/wallets/phantom/src/adapter.ts +++ b/packages/wallets/phantom/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, isIosAndRedirectable, @@ -18,7 +18,6 @@ import { WalletSignTransactionError, } from '@solana/wallet-adapter-base'; import type { - Connection, SendOptions, Transaction, TransactionSignature, @@ -193,7 +192,7 @@ export class PhantomWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: T, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -206,11 +205,11 @@ export class PhantomWalletAdapter extends BaseMessageSignerWalletAdapter { if (isVersionedTransaction(transaction)) { signers?.length && transaction.sign(signers); } else { - transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T; + transaction = (await this.prepareTransaction(transaction, connectionContext, sendOptions)) as T; signers?.length && (transaction as Transaction).partialSign(...signers); } - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index 3e1b1a11c..dbd26ab7a 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface SaifuWalletEvents { @@ -158,7 +158,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -169,11 +169,11 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; @@ -187,7 +187,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { throw error; } - return await super.sendTransaction(transaction, connection, options); + return await super.sendTransaction(transaction, connectionContext, options); } async signTransaction(transaction: T): Promise { diff --git a/packages/wallets/sky/src/adapter.ts b/packages/wallets/sky/src/adapter.ts index 874e278cc..11ba9fc64 100644 --- a/packages/wallets/sky/src/adapter.ts +++ b/packages/wallets/sky/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface SkyWalletEvents { @@ -155,7 +155,7 @@ export class SkyWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -165,11 +165,11 @@ export class SkyWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/solflare/src/adapter.ts b/packages/wallets/solflare/src/adapter.ts index 089773327..acb25b118 100644 --- a/packages/wallets/solflare/src/adapter.ts +++ b/packages/wallets/solflare/src/adapter.ts @@ -1,4 +1,4 @@ -import type { WalletAdapterNetwork, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, WalletAdapterNetwork, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, WalletConfigError, @@ -20,7 +20,7 @@ import { type SendTransactionOptions, } from '@solana/wallet-adapter-base'; import type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js'; -import { PublicKey, type Connection, type TransactionSignature } from '@solana/web3.js'; +import { PublicKey, type TransactionSignature } from '@solana/web3.js'; import type { default as Solflare } from '@solflare-wallet/sdk'; import { detectAndRegisterSolflareMetaMaskWallet } from './metamask/detect.js'; @@ -183,7 +183,7 @@ export class SolflareWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: T, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -196,11 +196,11 @@ export class SolflareWalletAdapter extends BaseMessageSignerWalletAdapter { if (isVersionedTransaction(transaction)) { signers?.length && transaction.sign(signers); } else { - transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T; + transaction = (await this.prepareTransaction(transaction, connectionContext, sendOptions)) as T; signers?.length && (transaction as Transaction).partialSign(...signers); } - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; return await wallet.signAndSendTransaction(transaction, sendOptions); } catch (error: any) { diff --git a/packages/wallets/tokenary/src/adapter.ts b/packages/wallets/tokenary/src/adapter.ts index 565f391ef..89cd079d9 100644 --- a/packages/wallets/tokenary/src/adapter.ts +++ b/packages/wallets/tokenary/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface TokenaryWalletEvents { @@ -156,7 +156,7 @@ export class TokenaryWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -166,11 +166,11 @@ export class TokenaryWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/torus/src/adapter.ts b/packages/wallets/torus/src/adapter.ts index bbe1a2a1c..058a13026 100644 --- a/packages/wallets/torus/src/adapter.ts +++ b/packages/wallets/torus/src/adapter.ts @@ -1,4 +1,4 @@ -import type { SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, WalletAccountError, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; import type { default as Torus, TorusParams } from '@toruslabs/solana-embed'; @@ -147,7 +147,7 @@ export class TorusWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -157,11 +157,11 @@ export class TorusWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; diff --git a/packages/wallets/trust/src/adapter.ts b/packages/wallets/trust/src/adapter.ts index 5da29d556..7479c68ac 100644 --- a/packages/wallets/trust/src/adapter.ts +++ b/packages/wallets/trust/src/adapter.ts @@ -1,4 +1,4 @@ -import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; +import type { ConnectionContext, EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, @@ -15,7 +15,7 @@ import { WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; -import type { Connection, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import type { SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface TrustWalletEvents { @@ -160,7 +160,7 @@ export class TrustWalletAdapter extends BaseMessageSignerWalletAdapter { async sendTransaction( transaction: Transaction, - connection: Connection, + connectionContext: ConnectionContext, options: SendTransactionOptions = {} ): Promise { try { @@ -170,11 +170,11 @@ export class TrustWalletAdapter extends BaseMessageSignerWalletAdapter { try { const { signers, ...sendOptions } = options; - transaction = await this.prepareTransaction(transaction, connection, sendOptions); + transaction = await this.prepareTransaction(transaction, connectionContext, sendOptions); signers?.length && transaction.partialSign(...signers); - sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; + sendOptions.preflightCommitment = sendOptions.preflightCommitment || connectionContext.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature;