Skip to content

Commit

Permalink
v0.29.0: deprecate txSearch when using BroadcastTxCommit (#6)
Browse files Browse the repository at this point in the history
* v0.29.0: deprecate txSearch when using BroadcastTxCommit

* pack native client

* remove queryTransaction method

* move return to try block
  • Loading branch information
jaredvu authored Aug 17, 2023
1 parent c8d6fe9 commit 8227d9f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
25 changes: 13 additions & 12 deletions v4-client-js/__native__/__ios__/v4-native-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -192854,24 +192854,25 @@ class TendermintClient {
*/
async broadcastTransactionCommit(tx) {
const result = await this.broadcastTransactionSync(tx);
const transactionId = (0, encoding_1.toHex)(result.hash).toUpperCase();
return this.queryTransaction(`tx.hash='${transactionId}'`);
return this.queryHash(result.hash);
}
/**
* @description Query for a transaction on-chain with retries specified by
* @description Using tx method, query for a transaction on-chain with retries specified by
* the client BroadcastOptions.
*
* @throws TimeoutError if the transaction is not committed on-chain within the timeout limit.
* @returns An indexed transaction containing information about the transaction when committed.
*/
async queryTransaction(query, time = 0) {
async queryHash(hash, time = 0) {
const now = Date.now();
const transactionId = (0, encoding_1.toHex)(hash).toUpperCase();
if (time >= this.broadcastOptions.broadcastTimeoutMs) {
throw new stargate_1.TimeoutError(`Transaction with query [${query}] was submitted but was not yet found on the chain. You might want to check later. Query timed out after ${this.broadcastOptions.broadcastTimeoutMs / 1000} seconds.`, query);
throw new stargate_1.TimeoutError(`Transaction with hash [${hash}] was submitted but was not yet found on the chain. You might want to check later. Query timed out after ${this.broadcastOptions.broadcastTimeoutMs / 1000} seconds.`, transactionId);
}
await (0, utils_1.sleep)(this.broadcastOptions.broadcastPollIntervalMs);
const results = await this.baseClient.txSearchAll({ query });
const mappedResults = results.txs.map((tx) => {
// If the transaction is not found, the tx method will throw an Internal Error.
try {
const tx = await this.baseClient.tx({ hash });
return {
height: tx.height,
hash: (0, encoding_1.toHex)(tx.hash).toUpperCase(),
Expand All @@ -192895,10 +192896,10 @@ class TendermintClient {
};
}),
};
});
return mappedResults.length !== 0
? mappedResults[0]
: this.queryTransaction(query, time + Date.now() - now);
}
catch (error) {
return this.queryHash(hash, time + Date.now() - now);
}
}
/**
* @description Set the broadcast options for this module.
Expand All @@ -192908,7 +192909,7 @@ class TendermintClient {
}
}
exports.TendermintClient = TendermintClient;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVuZGVybWludENsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jbGllbnRzL21vZHVsZXMvdGVuZGVybWludENsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrQ0FBeUM7QUFDekMsdUNBQXNDO0FBQ3RDLCtDQUkwQjtBQUMxQiwyREFJZ0M7QUFVaEMseUNBQXNDO0FBRXRDLDBDQUFxRDtBQUdyRCxNQUFhLGdCQUFnQjtJQUkzQixZQUNFLFVBQThCLEVBQzlCLGdCQUFrQztRQUVsQyxJQUFJLENBQUMsVUFBVSxHQUFHLFVBQVUsQ0FBQztRQUM3QixJQUFJLENBQUMsZ0JBQWdCLEdBQUcsZ0JBQWdCLENBQUM7SUFDM0MsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxLQUFLLENBQUMsUUFBUSxDQUFDLE1BQWU7UUFDNUIsTUFBTSxRQUFRLEdBQWtCLE1BQU0sSUFBSSxDQUFDLFVBQVUsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDcEUsT0FBTztZQUNMLEVBQUUsRUFBRSxJQUFBLGdCQUFLLEVBQUMsUUFBUSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxXQUFXLEVBQUU7WUFDOUMsTUFBTSxFQUFFO2dCQUNOLE9BQU8sRUFBRTtvQkFDUCxLQUFLLEVBQUUsSUFBSSxhQUFNLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FB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sSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxRQUFRLEVBQUU7Z0NBQ3JDLEtBQUssRUFBRSxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQyxRQUFRLEVBQUU7NkJBQzFDLENBQUM7d0JBQ0osQ0FBQyxDQUFDO3FCQUNILENBQUM7Z0JBQ0osQ0FBQyxDQUFDO2FBQ0gsQ0FBQztTQUNIO1FBQUMsT0FBTyxLQUFLLEVBQUU7WUFDZCxPQUFPLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxFQUFFLElBQUksR0FBRyxJQUFJLENBQUMsR0FBRyxFQUFFLEdBQUcsR0FBRyxDQUFDLENBQUM7U0FDdEQ7SUFDSCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxtQkFBbUIsQ0FBQyxnQkFBa0M7UUFDcEQsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGdCQUFnQixDQUFDO0lBQzNDLENBQUM7Q0FDRjtBQS9KRCw0Q0ErSkMifQ==

/***/ }),

Expand Down
2 changes: 1 addition & 1 deletion v4-client-js/__native__/__ios__/v4-native-client.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v4-client-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v4-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dydxprotocol/v4-client",
"version": "0.28.1",
"version": "0.29.0",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Expand Down
30 changes: 15 additions & 15 deletions v4-client-js/src/clients/modules/tendermintClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
BroadcastTxAsyncResponse,
BroadcastTxSyncResponse,
TxResponse,
TxSearchResponse,
Event,
} from '@cosmjs/tendermint-rpc/build/tendermint37';
import { sleep } from '@cosmjs/utils';
Expand Down Expand Up @@ -117,35 +116,38 @@ export class TendermintClient {
tx: Uint8Array,
): Promise<IndexedTx> {
const result: BroadcastTxSyncResponse = await this.broadcastTransactionSync(tx);
const transactionId: string = toHex(result.hash).toUpperCase();
return this.queryTransaction(`tx.hash='${transactionId}'`);
return this.queryHash(result.hash);
}

/**
* @description Query for a transaction on-chain with retries specified by
* @description Using tx method, query for a transaction on-chain with retries specified by
* the client BroadcastOptions.
*
* @throws TimeoutError if the transaction is not committed on-chain within the timeout limit.
* @returns An indexed transaction containing information about the transaction when committed.
*/
async queryTransaction(
query: string,
async queryHash(
hash: Uint8Array,
time: number = 0,
): Promise<IndexedTx> {
const now: number = Date.now();
const transactionId: string = toHex(hash).toUpperCase();

if (time >= this.broadcastOptions.broadcastTimeoutMs) {
throw new TimeoutError(
`Transaction with query [${query}] was submitted but was not yet found on the chain. You might want to check later. Query timed out after ${
`Transaction with hash [${hash}] was submitted but was not yet found on the chain. You might want to check later. Query timed out after ${
this.broadcastOptions.broadcastTimeoutMs / 1000
} seconds.`,
query,
transactionId,
);
}

await sleep(this.broadcastOptions.broadcastPollIntervalMs);

const results: TxSearchResponse = await this.baseClient.txSearchAll({ query });
const mappedResults: readonly IndexedTx[] = results.txs.map((tx: TxResponse) => {
// If the transaction is not found, the tx method will throw an Internal Error.
try {
const tx: TxResponse = await this.baseClient.tx({ hash });

return {
height: tx.height,
hash: toHex(tx.hash).toUpperCase(),
Expand All @@ -169,11 +171,9 @@ export class TendermintClient {
};
}),
};
});

return mappedResults.length !== 0
? mappedResults[0]
: this.queryTransaction(query, time + Date.now() - now);
} catch (error) {
return this.queryHash(hash, time + Date.now() - now);
}
}

/**
Expand Down

0 comments on commit 8227d9f

Please sign in to comment.