@0xobelisk/sui-client 1.1.10 → 1.1.12
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 +14 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +59 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -16
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +9 -5
- package/dist/libs/suiTxBuilder/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -1
- package/package.json +1 -1
- package/src/dubhe.ts +63 -8
- package/src/index.ts +11 -0
- package/src/libs/suiIndexerClient/index.ts +15 -11
- package/src/types/index.ts +12 -1
package/dist/dubhe.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ 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';
|
|
11
|
-
import { ConnectionResponse, IndexerTransaction, IndexerEvent, IndexerSchema, SuiIndexerClient, StorageResponse, StorageItemResponse } from './libs/suiIndexerClient';
|
|
10
|
+
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg, SubscribableType, IndexerTransactionResult } from './types';
|
|
11
|
+
import { ConnectionResponse, IndexerTransaction, IndexerEvent, IndexerSchema, SuiIndexerClient, StorageResponse, StorageItemResponse, JsonPathOrder } from './libs/suiIndexerClient';
|
|
12
12
|
import { Http } from './libs/http';
|
|
13
13
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
14
14
|
export declare function withMeta<T extends {
|
|
@@ -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;
|
|
@@ -81,7 +88,7 @@ export declare class Dubhe {
|
|
|
81
88
|
checkpoint?: string;
|
|
82
89
|
orderBy?: string[];
|
|
83
90
|
}): Promise<ConnectionResponse<IndexerEvent>>;
|
|
84
|
-
getSchemas({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, }: {
|
|
91
|
+
getSchemas({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, jsonOrderBy, }: {
|
|
85
92
|
name?: string;
|
|
86
93
|
key1?: any;
|
|
87
94
|
key2?: any;
|
|
@@ -92,8 +99,9 @@ export declare class Dubhe {
|
|
|
92
99
|
first?: number;
|
|
93
100
|
after?: string;
|
|
94
101
|
orderBy?: string[];
|
|
102
|
+
jsonOrderBy?: JsonPathOrder[];
|
|
95
103
|
}): Promise<ConnectionResponse<IndexerSchema>>;
|
|
96
|
-
getStorage({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, }: {
|
|
104
|
+
getStorage({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, jsonOrderBy, }: {
|
|
97
105
|
name?: string;
|
|
98
106
|
key1?: any;
|
|
99
107
|
key2?: any;
|
|
@@ -104,6 +112,7 @@ export declare class Dubhe {
|
|
|
104
112
|
first?: number;
|
|
105
113
|
after?: string;
|
|
106
114
|
orderBy?: string[];
|
|
115
|
+
jsonOrderBy?: JsonPathOrder[];
|
|
107
116
|
}): Promise<StorageResponse<IndexerSchema>>;
|
|
108
117
|
getStorageItem({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, }: {
|
|
109
118
|
name: 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, JsonPathOrder, JsonValueType, } from './libs/suiIndexerClient';
|
package/dist/index.js
CHANGED
|
@@ -1172,7 +1172,8 @@ var SuiIndexerClient = class {
|
|
|
1172
1172
|
$last_update_checkpoint: String,
|
|
1173
1173
|
$last_update_digest: String,
|
|
1174
1174
|
$value: JSON,
|
|
1175
|
-
$orderBy: [SchemaOrderField!]
|
|
1175
|
+
$orderBy: [SchemaOrderField!],
|
|
1176
|
+
$jsonOrderBy: [JsonPathOrder!]
|
|
1176
1177
|
) {
|
|
1177
1178
|
schemas(
|
|
1178
1179
|
first: $first,
|
|
@@ -1184,7 +1185,8 @@ var SuiIndexerClient = class {
|
|
|
1184
1185
|
last_update_checkpoint: $last_update_checkpoint,
|
|
1185
1186
|
last_update_digest: $last_update_digest,
|
|
1186
1187
|
value: $value,
|
|
1187
|
-
orderBy: $orderBy
|
|
1188
|
+
orderBy: $orderBy,
|
|
1189
|
+
jsonOrderBy: $jsonOrderBy
|
|
1188
1190
|
) {
|
|
1189
1191
|
edges {
|
|
1190
1192
|
cursor
|
|
@@ -1249,7 +1251,8 @@ var SuiIndexerClient = class {
|
|
|
1249
1251
|
value,
|
|
1250
1252
|
first,
|
|
1251
1253
|
after,
|
|
1252
|
-
orderBy
|
|
1254
|
+
orderBy,
|
|
1255
|
+
jsonOrderBy
|
|
1253
1256
|
}) {
|
|
1254
1257
|
const schemas = await this.getSchemas({
|
|
1255
1258
|
name,
|
|
@@ -1261,7 +1264,8 @@ var SuiIndexerClient = class {
|
|
|
1261
1264
|
value,
|
|
1262
1265
|
first,
|
|
1263
1266
|
after,
|
|
1264
|
-
orderBy
|
|
1267
|
+
orderBy,
|
|
1268
|
+
jsonOrderBy
|
|
1265
1269
|
});
|
|
1266
1270
|
const data = schemas.edges.map((edge) => edge.node);
|
|
1267
1271
|
const result = data.map((item) => parseValue(item.value));
|
|
@@ -2319,25 +2323,60 @@ var Dubhe = class {
|
|
|
2319
2323
|
async getTransaction(digest) {
|
|
2320
2324
|
return await this.suiIndexerClient.getTransaction(digest);
|
|
2321
2325
|
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Wait for the transaction to be processed by the indexer and return all transaction-related data
|
|
2328
|
+
* @param digest transaction digest
|
|
2329
|
+
* @param options option parameters
|
|
2330
|
+
* @returns result object containing transaction, events and schema data
|
|
2331
|
+
*/
|
|
2322
2332
|
async waitForIndexerTransaction(digest, options) {
|
|
2323
2333
|
const {
|
|
2324
2334
|
checkInterval = 100,
|
|
2325
2335
|
timeout = 3e4,
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
// 300 times default max retries
|
|
2336
|
+
maxRetries = 300,
|
|
2337
|
+
pageSize = 100
|
|
2329
2338
|
} = options ?? {};
|
|
2330
2339
|
const startTime = Date.now();
|
|
2331
2340
|
let retryCount = 0;
|
|
2332
2341
|
while (retryCount < maxRetries) {
|
|
2333
2342
|
try {
|
|
2334
2343
|
if (Date.now() - startTime > timeout) {
|
|
2335
|
-
throw new Error(`
|
|
2344
|
+
throw new Error(`Waiting for transaction ${digest} timed out`);
|
|
2336
2345
|
}
|
|
2337
2346
|
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
2338
|
-
const
|
|
2339
|
-
if (
|
|
2340
|
-
|
|
2347
|
+
const tx = await this.getTransaction(digest);
|
|
2348
|
+
if (tx) {
|
|
2349
|
+
const events = [];
|
|
2350
|
+
const schemaChanges = [];
|
|
2351
|
+
let hasNextEventsPage = true;
|
|
2352
|
+
let eventsCursor;
|
|
2353
|
+
while (hasNextEventsPage) {
|
|
2354
|
+
const eventsResponse = await this.getEvents({
|
|
2355
|
+
digest,
|
|
2356
|
+
first: pageSize,
|
|
2357
|
+
after: eventsCursor
|
|
2358
|
+
});
|
|
2359
|
+
events.push(...eventsResponse.edges.map((edge) => edge.node));
|
|
2360
|
+
hasNextEventsPage = eventsResponse.pageInfo.hasNextPage;
|
|
2361
|
+
eventsCursor = eventsResponse.pageInfo.endCursor;
|
|
2362
|
+
}
|
|
2363
|
+
let hasNextSchemasPage = true;
|
|
2364
|
+
let schemasCursor;
|
|
2365
|
+
while (hasNextSchemasPage) {
|
|
2366
|
+
const schemasResponse = await this.getStorage({
|
|
2367
|
+
last_update_digest: digest,
|
|
2368
|
+
first: pageSize,
|
|
2369
|
+
after: schemasCursor
|
|
2370
|
+
});
|
|
2371
|
+
schemaChanges.push(...schemasResponse.data);
|
|
2372
|
+
hasNextSchemasPage = schemasResponse.pageInfo.hasNextPage;
|
|
2373
|
+
schemasCursor = schemasResponse.pageInfo.endCursor;
|
|
2374
|
+
}
|
|
2375
|
+
return {
|
|
2376
|
+
tx,
|
|
2377
|
+
events,
|
|
2378
|
+
schemaChanges
|
|
2379
|
+
};
|
|
2341
2380
|
}
|
|
2342
2381
|
retryCount++;
|
|
2343
2382
|
} catch (error) {
|
|
@@ -2347,7 +2386,7 @@ var Dubhe = class {
|
|
|
2347
2386
|
}
|
|
2348
2387
|
}
|
|
2349
2388
|
throw new Error(
|
|
2350
|
-
`
|
|
2389
|
+
`Reached maximum retries (${maxRetries}), failed to wait for transaction ${digest}`
|
|
2351
2390
|
);
|
|
2352
2391
|
}
|
|
2353
2392
|
async getEvents({
|
|
@@ -2379,7 +2418,8 @@ var Dubhe = class {
|
|
|
2379
2418
|
value,
|
|
2380
2419
|
first,
|
|
2381
2420
|
after,
|
|
2382
|
-
orderBy
|
|
2421
|
+
orderBy,
|
|
2422
|
+
jsonOrderBy
|
|
2383
2423
|
}) {
|
|
2384
2424
|
return await this.suiIndexerClient.getSchemas({
|
|
2385
2425
|
name,
|
|
@@ -2391,7 +2431,8 @@ var Dubhe = class {
|
|
|
2391
2431
|
value,
|
|
2392
2432
|
first,
|
|
2393
2433
|
after,
|
|
2394
|
-
orderBy
|
|
2434
|
+
orderBy,
|
|
2435
|
+
jsonOrderBy
|
|
2395
2436
|
});
|
|
2396
2437
|
}
|
|
2397
2438
|
async getStorage({
|
|
@@ -2404,7 +2445,8 @@ var Dubhe = class {
|
|
|
2404
2445
|
value,
|
|
2405
2446
|
first,
|
|
2406
2447
|
after,
|
|
2407
|
-
orderBy
|
|
2448
|
+
orderBy,
|
|
2449
|
+
jsonOrderBy
|
|
2408
2450
|
}) {
|
|
2409
2451
|
return await this.suiIndexerClient.getStorage({
|
|
2410
2452
|
name,
|
|
@@ -2416,7 +2458,8 @@ var Dubhe = class {
|
|
|
2416
2458
|
value,
|
|
2417
2459
|
first,
|
|
2418
2460
|
after,
|
|
2419
|
-
orderBy
|
|
2461
|
+
orderBy,
|
|
2462
|
+
jsonOrderBy
|
|
2420
2463
|
});
|
|
2421
2464
|
}
|
|
2422
2465
|
async getStorageItem({
|