@0xobelisk/sui-client 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dubhe.d.ts +6 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/dubhe.ts +49 -0
- package/src/libs/suiIndexerClient/index.ts +10 -0
package/dist/dubhe.d.ts
CHANGED
|
@@ -63,6 +63,12 @@ export declare class Dubhe {
|
|
|
63
63
|
checkpoint?: number;
|
|
64
64
|
orderBy?: string[];
|
|
65
65
|
}): Promise<ConnectionResponse<IndexerTransaction>>;
|
|
66
|
+
getTransaction(digest: string): Promise<IndexerTransaction | undefined>;
|
|
67
|
+
awaitIndexerTransaction(digest: string, options?: {
|
|
68
|
+
checkInterval?: number;
|
|
69
|
+
timeout?: number;
|
|
70
|
+
maxRetries?: number;
|
|
71
|
+
}): Promise<IndexerTransaction | undefined>;
|
|
66
72
|
getEvents({ first, after, name, sender, digest, checkpoint, orderBy, }: {
|
|
67
73
|
first?: number;
|
|
68
74
|
after?: string;
|
package/dist/index.js
CHANGED
|
@@ -1153,6 +1153,13 @@ var SuiIndexerClient = class {
|
|
|
1153
1153
|
const response = await this.fetchGraphql(query, params);
|
|
1154
1154
|
return response.transactions;
|
|
1155
1155
|
}
|
|
1156
|
+
async getTransaction(digest) {
|
|
1157
|
+
const response = await this.getTransactions({
|
|
1158
|
+
first: 1,
|
|
1159
|
+
digest
|
|
1160
|
+
});
|
|
1161
|
+
return response.edges[0]?.node;
|
|
1162
|
+
}
|
|
1156
1163
|
async getSchemas(params) {
|
|
1157
1164
|
const query = `
|
|
1158
1165
|
query GetSchemas(
|
|
@@ -2299,6 +2306,40 @@ var Dubhe = class {
|
|
|
2299
2306
|
orderBy
|
|
2300
2307
|
});
|
|
2301
2308
|
}
|
|
2309
|
+
async getTransaction(digest) {
|
|
2310
|
+
return await this.suiIndexerClient.getTransaction(digest);
|
|
2311
|
+
}
|
|
2312
|
+
async awaitIndexerTransaction(digest, options) {
|
|
2313
|
+
const {
|
|
2314
|
+
checkInterval = 100,
|
|
2315
|
+
timeout = 3e4,
|
|
2316
|
+
// 30 seconds default timeout
|
|
2317
|
+
maxRetries = 300
|
|
2318
|
+
// 300 times default max retries
|
|
2319
|
+
} = options ?? {};
|
|
2320
|
+
const startTime = Date.now();
|
|
2321
|
+
let retryCount = 0;
|
|
2322
|
+
while (retryCount < maxRetries) {
|
|
2323
|
+
try {
|
|
2324
|
+
if (Date.now() - startTime > timeout) {
|
|
2325
|
+
throw new Error(`Timeout waiting for transaction ${digest}`);
|
|
2326
|
+
}
|
|
2327
|
+
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
2328
|
+
const transaction = await this.getTransaction(digest);
|
|
2329
|
+
if (transaction) {
|
|
2330
|
+
return transaction;
|
|
2331
|
+
}
|
|
2332
|
+
retryCount++;
|
|
2333
|
+
} catch (error) {
|
|
2334
|
+
throw new Error(
|
|
2335
|
+
`Error while waiting for transaction ${digest}: ${error}`
|
|
2336
|
+
);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
throw new Error(
|
|
2340
|
+
`Max retries (${maxRetries}) reached while waiting for transaction ${digest}`
|
|
2341
|
+
);
|
|
2342
|
+
}
|
|
2302
2343
|
async getEvents({
|
|
2303
2344
|
first,
|
|
2304
2345
|
after,
|