coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

Bug: provider.sendAndConfirm() maxSupportedTransactionVersion #2921

Closed czkz closed 2 months ago

czkz commented 2 months ago

Got the following error after calling provider.sendAndConfirm(VersionedTransaction):

SolanaJSONRPCError: failed to get transaction: Transaction version (0) is not supported by the requesting client. Please try the request again with the following configuration parameter: "maxSupportedTransactionVersion": 0

sendAndConfirm() doesn't set maxSupportedTransactionVersion in getTransaction(): https://github.com/coral-xyz/anchor/blob/fefa69519fb9b875cac72469b8d5021f8c2d90a5/ts/packages/anchor/src/provider.ts#L177-L179

It should probably be like this:

const failedTx = await this.connection.getTransaction(txSig, {
  commitment: "confirmed",
  maxSupportedTransactionVersion: isVersionedTransaction(tx) ? 0 : undefined
});
acheroncrypto commented 2 months ago

It should probably be like this:

const failedTx = await this.connection.getTransaction(txSig, {
  commitment: "confirmed",
  maxSupportedTransactionVersion: isVersionedTransaction(tx) ? 0 : undefined
});

Yeah, this looks better. Feel free to PR this fix.