fix: fallback to connection commitment when confirming transactions (#13285)

* fix: fallback to connection commitment when confirming transactions

* chore: bump

* chore: fix tests
This commit is contained in:
Justin Starry 2020-10-30 01:22:53 +08:00 committed by GitHub
parent 636ae12621
commit 7b3f96ab30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View File

@ -2163,8 +2163,6 @@ export class Connection {
/**
* Confirm the transaction identified by the specified signature.
*
* If `commitment` is not specified, default to 'max'.
*/
async confirmTransaction(
signature: TransactionSignature,
@ -2180,7 +2178,7 @@ export class Connection {
assert(decodedSignature.length === 64, 'signature has invalid length');
const start = Date.now();
const subscriptionCommitment: Commitment = commitment || 'max';
const subscriptionCommitment = commitment || this.commitment;
let subscriptionId;
let response: RpcResponseAndContext<SignatureResult> | null = null;

View File

@ -129,6 +129,7 @@ describe('load BPF Rust program', () => {
transaction,
[payerAccount],
{
commitment: 'max',
skipPreflight: true,
},
);

View File

@ -1351,7 +1351,7 @@ describe('token methods', () => {
return;
}
const connection = new Connection(url);
const connection = new Connection(url, 'recent');
const newAccount = new Account().publicKey;
let testToken: Token;
@ -1364,7 +1364,6 @@ describe('token methods', () => {
const payerAccount = new Account();
await connection.confirmTransaction(
await connection.requestAirdrop(payerAccount.publicKey, 100000000000),
'single',
);
const mintOwner = new Account();
@ -1402,7 +1401,7 @@ describe('token methods', () => {
new u64(1),
);
await connection.confirmTransaction(testSignature);
await connection.confirmTransaction(testSignature, 'max');
testOwner = accountOwner;
testToken = token;