@0xobelisk/sui-client 1.1.10 → 1.1.11
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 +9 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -8
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +0 -4
- package/dist/types/index.d.ts +6 -1
- package/package.json +1 -1
- package/src/dubhe.ts +56 -8
- package/src/index.ts +9 -0
- package/src/libs/suiIndexerClient/index.ts +0 -10
- package/src/types/index.ts +12 -1
package/dist/dubhe.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { MapObjectStruct } from './types';
|
|
|
7
7
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
8
8
|
import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
|
|
9
9
|
import { NetworkConfig } from './libs/suiInteractor';
|
|
10
|
-
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg, SubscribableType } from './types';
|
|
10
|
+
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg, SubscribableType, IndexerTransactionResult } from './types';
|
|
11
11
|
import { ConnectionResponse, IndexerTransaction, IndexerEvent, IndexerSchema, SuiIndexerClient, StorageResponse, StorageItemResponse } from './libs/suiIndexerClient';
|
|
12
12
|
import { Http } from './libs/http';
|
|
13
13
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
@@ -67,11 +67,18 @@ export declare class Dubhe {
|
|
|
67
67
|
orderBy?: string[];
|
|
68
68
|
}): Promise<ConnectionResponse<IndexerTransaction>>;
|
|
69
69
|
getTransaction(digest: string): Promise<IndexerTransaction | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Wait for the transaction to be processed by the indexer and return all transaction-related data
|
|
72
|
+
* @param digest transaction digest
|
|
73
|
+
* @param options option parameters
|
|
74
|
+
* @returns result object containing transaction, events and schema data
|
|
75
|
+
*/
|
|
70
76
|
waitForIndexerTransaction(digest: string, options?: {
|
|
71
77
|
checkInterval?: number;
|
|
72
78
|
timeout?: number;
|
|
73
79
|
maxRetries?: number;
|
|
74
|
-
|
|
80
|
+
pageSize?: number;
|
|
81
|
+
}): Promise<IndexerTransactionResult>;
|
|
75
82
|
getEvents({ first, after, name, sender, digest, checkpoint, orderBy, }: {
|
|
76
83
|
first?: number;
|
|
77
84
|
after?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export { SuiContractFactory } from './libs/suiContractFactory';
|
|
|
14
14
|
export { SubscriptionKind } from './libs/suiIndexerClient';
|
|
15
15
|
export { loadMetadata } from './metadata';
|
|
16
16
|
export type * from './types';
|
|
17
|
+
export type { IndexerEvent, IndexerSchema, IndexerTransaction, ConnectionResponse, StorageResponse, StorageItemResponse, PageInfo, } from './libs/suiIndexerClient';
|
package/dist/index.js
CHANGED
|
@@ -2319,25 +2319,60 @@ var Dubhe = class {
|
|
|
2319
2319
|
async getTransaction(digest) {
|
|
2320
2320
|
return await this.suiIndexerClient.getTransaction(digest);
|
|
2321
2321
|
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Wait for the transaction to be processed by the indexer and return all transaction-related data
|
|
2324
|
+
* @param digest transaction digest
|
|
2325
|
+
* @param options option parameters
|
|
2326
|
+
* @returns result object containing transaction, events and schema data
|
|
2327
|
+
*/
|
|
2322
2328
|
async waitForIndexerTransaction(digest, options) {
|
|
2323
2329
|
const {
|
|
2324
2330
|
checkInterval = 100,
|
|
2325
2331
|
timeout = 3e4,
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
// 300 times default max retries
|
|
2332
|
+
maxRetries = 300,
|
|
2333
|
+
pageSize = 100
|
|
2329
2334
|
} = options ?? {};
|
|
2330
2335
|
const startTime = Date.now();
|
|
2331
2336
|
let retryCount = 0;
|
|
2332
2337
|
while (retryCount < maxRetries) {
|
|
2333
2338
|
try {
|
|
2334
2339
|
if (Date.now() - startTime > timeout) {
|
|
2335
|
-
throw new Error(`
|
|
2340
|
+
throw new Error(`Waiting for transaction ${digest} timed out`);
|
|
2336
2341
|
}
|
|
2337
2342
|
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
2338
|
-
const
|
|
2339
|
-
if (
|
|
2340
|
-
|
|
2343
|
+
const tx = await this.getTransaction(digest);
|
|
2344
|
+
if (tx) {
|
|
2345
|
+
const events = [];
|
|
2346
|
+
const schemaChanges = [];
|
|
2347
|
+
let hasNextEventsPage = true;
|
|
2348
|
+
let eventsCursor;
|
|
2349
|
+
while (hasNextEventsPage) {
|
|
2350
|
+
const eventsResponse = await this.getEvents({
|
|
2351
|
+
digest,
|
|
2352
|
+
first: pageSize,
|
|
2353
|
+
after: eventsCursor
|
|
2354
|
+
});
|
|
2355
|
+
events.push(...eventsResponse.edges.map((edge) => edge.node));
|
|
2356
|
+
hasNextEventsPage = eventsResponse.pageInfo.hasNextPage;
|
|
2357
|
+
eventsCursor = eventsResponse.pageInfo.endCursor;
|
|
2358
|
+
}
|
|
2359
|
+
let hasNextSchemasPage = true;
|
|
2360
|
+
let schemasCursor;
|
|
2361
|
+
while (hasNextSchemasPage) {
|
|
2362
|
+
const schemasResponse = await this.getStorage({
|
|
2363
|
+
last_update_digest: digest,
|
|
2364
|
+
first: pageSize,
|
|
2365
|
+
after: schemasCursor
|
|
2366
|
+
});
|
|
2367
|
+
schemaChanges.push(...schemasResponse.data);
|
|
2368
|
+
hasNextSchemasPage = schemasResponse.pageInfo.hasNextPage;
|
|
2369
|
+
schemasCursor = schemasResponse.pageInfo.endCursor;
|
|
2370
|
+
}
|
|
2371
|
+
return {
|
|
2372
|
+
tx,
|
|
2373
|
+
events,
|
|
2374
|
+
schemaChanges
|
|
2375
|
+
};
|
|
2341
2376
|
}
|
|
2342
2377
|
retryCount++;
|
|
2343
2378
|
} catch (error) {
|
|
@@ -2347,7 +2382,7 @@ var Dubhe = class {
|
|
|
2347
2382
|
}
|
|
2348
2383
|
}
|
|
2349
2384
|
throw new Error(
|
|
2350
|
-
`
|
|
2385
|
+
`Reached maximum retries (${maxRetries}), failed to wait for transaction ${digest}`
|
|
2351
2386
|
);
|
|
2352
2387
|
}
|
|
2353
2388
|
async getEvents({
|