@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/index.mjs
CHANGED
|
@@ -1126,6 +1126,13 @@ var SuiIndexerClient = class {
|
|
|
1126
1126
|
const response = await this.fetchGraphql(query, params);
|
|
1127
1127
|
return response.transactions;
|
|
1128
1128
|
}
|
|
1129
|
+
async getTransaction(digest) {
|
|
1130
|
+
const response = await this.getTransactions({
|
|
1131
|
+
first: 1,
|
|
1132
|
+
digest
|
|
1133
|
+
});
|
|
1134
|
+
return response.edges[0]?.node;
|
|
1135
|
+
}
|
|
1129
1136
|
async getSchemas(params) {
|
|
1130
1137
|
const query = `
|
|
1131
1138
|
query GetSchemas(
|
|
@@ -2272,6 +2279,40 @@ var Dubhe = class {
|
|
|
2272
2279
|
orderBy
|
|
2273
2280
|
});
|
|
2274
2281
|
}
|
|
2282
|
+
async getTransaction(digest) {
|
|
2283
|
+
return await this.suiIndexerClient.getTransaction(digest);
|
|
2284
|
+
}
|
|
2285
|
+
async awaitIndexerTransaction(digest, options) {
|
|
2286
|
+
const {
|
|
2287
|
+
checkInterval = 100,
|
|
2288
|
+
timeout = 3e4,
|
|
2289
|
+
// 30 seconds default timeout
|
|
2290
|
+
maxRetries = 300
|
|
2291
|
+
// 300 times default max retries
|
|
2292
|
+
} = options ?? {};
|
|
2293
|
+
const startTime = Date.now();
|
|
2294
|
+
let retryCount = 0;
|
|
2295
|
+
while (retryCount < maxRetries) {
|
|
2296
|
+
try {
|
|
2297
|
+
if (Date.now() - startTime > timeout) {
|
|
2298
|
+
throw new Error(`Timeout waiting for transaction ${digest}`);
|
|
2299
|
+
}
|
|
2300
|
+
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
2301
|
+
const transaction = await this.getTransaction(digest);
|
|
2302
|
+
if (transaction) {
|
|
2303
|
+
return transaction;
|
|
2304
|
+
}
|
|
2305
|
+
retryCount++;
|
|
2306
|
+
} catch (error) {
|
|
2307
|
+
throw new Error(
|
|
2308
|
+
`Error while waiting for transaction ${digest}: ${error}`
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
throw new Error(
|
|
2313
|
+
`Max retries (${maxRetries}) reached while waiting for transaction ${digest}`
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2275
2316
|
async getEvents({
|
|
2276
2317
|
first,
|
|
2277
2318
|
after,
|