Clear timeout before resolving/rejecting

This commit is contained in:
Simon Warta 2021-05-18 11:33:21 +02:00
parent 5cd4041666
commit 33ff4754a7
2 changed files with 20 additions and 6 deletions

View File

@ -259,9 +259,16 @@ export class CosmWasmClient {
}
const transactionId = toHex(broadcasted.hash).toUpperCase();
return new Promise((resolve, reject) =>
pollForTx(transactionId)
.then(resolve, reject)
.finally(() => clearTimeout(txPollTimeout)),
pollForTx(transactionId).then(
(value) => {
clearTimeout(txPollTimeout);
resolve(value);
},
(error) => {
clearTimeout(txPollTimeout);
reject(error);
},
),
);
}

View File

@ -351,9 +351,16 @@ export class StargateClient {
}
const transactionId = toHex(broadcasted.hash).toUpperCase();
return new Promise((resolve, reject) =>
pollForTx(transactionId)
.then(resolve, reject)
.finally(() => clearTimeout(txPollTimeout)),
pollForTx(transactionId).then(
(value) => {
clearTimeout(txPollTimeout);
resolve(value);
},
(error) => {
clearTimeout(txPollTimeout);
reject(error);
},
),
);
}