@0xobelisk/sui-client 1.1.0 → 1.1.2
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 +21 -4
- package/dist/index.js +111 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -23
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +14 -2
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/dubhe.ts +99 -31
- package/src/libs/suiIndexerClient/index.ts +56 -6
- package/src/types/index.ts +4 -0
package/dist/dubhe.d.ts
CHANGED
|
@@ -65,26 +65,38 @@ export declare class Dubhe {
|
|
|
65
65
|
after?: string;
|
|
66
66
|
orderBy?: string[];
|
|
67
67
|
}): Promise<ConnectionResponse<IndexerEvent>>;
|
|
68
|
-
getSchemas({ name, key1, key2, first, after, orderBy, }: {
|
|
68
|
+
getSchemas({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, }: {
|
|
69
69
|
name?: string;
|
|
70
70
|
key1?: string;
|
|
71
71
|
key2?: string;
|
|
72
|
+
is_removed?: boolean;
|
|
73
|
+
last_update_checkpoint?: string;
|
|
74
|
+
last_update_digest?: string;
|
|
75
|
+
value?: any;
|
|
72
76
|
first?: number;
|
|
73
77
|
after?: string;
|
|
74
78
|
orderBy?: string[];
|
|
75
79
|
}): Promise<ConnectionResponse<IndexerSchema>>;
|
|
76
|
-
getStorage({ name, key1, key2, first, after, orderBy, }: {
|
|
80
|
+
getStorage({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, }: {
|
|
77
81
|
name?: string;
|
|
78
82
|
key1?: string;
|
|
79
83
|
key2?: string;
|
|
84
|
+
is_removed?: boolean;
|
|
85
|
+
last_update_checkpoint?: string;
|
|
86
|
+
last_update_digest?: string;
|
|
87
|
+
value?: any;
|
|
80
88
|
first?: number;
|
|
81
89
|
after?: string;
|
|
82
90
|
orderBy?: string[];
|
|
83
91
|
}): Promise<StorageResponse<IndexerSchema>>;
|
|
84
|
-
getStorageItem({ name, key1, key2, }: {
|
|
92
|
+
getStorageItem({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, }: {
|
|
85
93
|
name: string;
|
|
86
94
|
key1?: string;
|
|
87
95
|
key2?: string;
|
|
96
|
+
is_removed?: boolean;
|
|
97
|
+
last_update_checkpoint?: string;
|
|
98
|
+
last_update_digest?: string;
|
|
99
|
+
value?: any;
|
|
88
100
|
}): Promise<StorageItemResponse<IndexerSchema> | undefined>;
|
|
89
101
|
subscribe(names: string[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
90
102
|
/**
|
|
@@ -123,7 +135,12 @@ export declare class Dubhe {
|
|
|
123
135
|
getObject(objectId: string): Promise<SuiObjectData>;
|
|
124
136
|
getObjects(objectIds: string[]): Promise<SuiObjectData[]>;
|
|
125
137
|
signTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/dist/cjs/cryptography").SignatureWithBytes>;
|
|
126
|
-
signAndSendTxn(tx
|
|
138
|
+
signAndSendTxn({ tx, derivePathParams, onSuccess, onError, }: {
|
|
139
|
+
tx: Uint8Array | Transaction | SuiTx;
|
|
140
|
+
derivePathParams?: DerivePathParams;
|
|
141
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
142
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
143
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
127
144
|
sendTx(transaction: Uint8Array | string, signature: string | string[]): Promise<SuiTransactionBlockResponse>;
|
|
128
145
|
waitForTransaction(digest: string): Promise<SuiTransactionBlockResponse>;
|
|
129
146
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1148,8 +1148,30 @@ var SuiIndexerClient = class {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
async getSchemas(params) {
|
|
1150
1150
|
const query = `
|
|
1151
|
-
query GetSchemas(
|
|
1152
|
-
|
|
1151
|
+
query GetSchemas(
|
|
1152
|
+
$first: Int,
|
|
1153
|
+
$after: String,
|
|
1154
|
+
$name: String,
|
|
1155
|
+
$key1: String,
|
|
1156
|
+
$key2: String,
|
|
1157
|
+
$is_removed: Boolean,
|
|
1158
|
+
$last_update_checkpoint: String,
|
|
1159
|
+
$last_update_digest: String,
|
|
1160
|
+
$value: JSON,
|
|
1161
|
+
$orderBy: [SchemaOrderField!]
|
|
1162
|
+
) {
|
|
1163
|
+
schemas(
|
|
1164
|
+
first: $first,
|
|
1165
|
+
after: $after,
|
|
1166
|
+
name: $name,
|
|
1167
|
+
key1: $key1,
|
|
1168
|
+
key2: $key2,
|
|
1169
|
+
is_removed: $is_removed,
|
|
1170
|
+
last_update_checkpoint: $last_update_checkpoint,
|
|
1171
|
+
last_update_digest: $last_update_digest,
|
|
1172
|
+
value: $value,
|
|
1173
|
+
orderBy: $orderBy
|
|
1174
|
+
) {
|
|
1153
1175
|
edges {
|
|
1154
1176
|
cursor
|
|
1155
1177
|
node {
|
|
@@ -1206,6 +1228,10 @@ var SuiIndexerClient = class {
|
|
|
1206
1228
|
name,
|
|
1207
1229
|
key1,
|
|
1208
1230
|
key2,
|
|
1231
|
+
is_removed = false,
|
|
1232
|
+
last_update_checkpoint,
|
|
1233
|
+
last_update_digest,
|
|
1234
|
+
value,
|
|
1209
1235
|
first,
|
|
1210
1236
|
after,
|
|
1211
1237
|
orderBy
|
|
@@ -1214,15 +1240,19 @@ var SuiIndexerClient = class {
|
|
|
1214
1240
|
name,
|
|
1215
1241
|
key1,
|
|
1216
1242
|
key2,
|
|
1243
|
+
is_removed,
|
|
1244
|
+
last_update_checkpoint,
|
|
1245
|
+
last_update_digest,
|
|
1246
|
+
value,
|
|
1217
1247
|
first,
|
|
1218
1248
|
after,
|
|
1219
1249
|
orderBy
|
|
1220
1250
|
});
|
|
1221
1251
|
const data = schemas.edges.map((edge) => edge.node);
|
|
1222
|
-
const
|
|
1252
|
+
const result = data.map((item) => parseValue(item.value));
|
|
1223
1253
|
return {
|
|
1224
1254
|
data,
|
|
1225
|
-
value,
|
|
1255
|
+
value: result,
|
|
1226
1256
|
pageInfo: schemas.pageInfo,
|
|
1227
1257
|
totalCount: schemas.totalCount
|
|
1228
1258
|
};
|
|
@@ -1230,22 +1260,30 @@ var SuiIndexerClient = class {
|
|
|
1230
1260
|
async getStorageItem({
|
|
1231
1261
|
name,
|
|
1232
1262
|
key1,
|
|
1233
|
-
key2
|
|
1263
|
+
key2,
|
|
1264
|
+
is_removed,
|
|
1265
|
+
last_update_checkpoint,
|
|
1266
|
+
last_update_digest,
|
|
1267
|
+
value
|
|
1234
1268
|
}) {
|
|
1235
1269
|
const schemas = await this.getSchemas({
|
|
1236
1270
|
name,
|
|
1237
1271
|
key1,
|
|
1238
1272
|
key2,
|
|
1273
|
+
is_removed,
|
|
1274
|
+
last_update_checkpoint,
|
|
1275
|
+
last_update_digest,
|
|
1276
|
+
value,
|
|
1239
1277
|
first: 1
|
|
1240
1278
|
});
|
|
1241
1279
|
const data = schemas.edges[0]?.node;
|
|
1242
1280
|
if (!data) {
|
|
1243
1281
|
return void 0;
|
|
1244
1282
|
}
|
|
1245
|
-
const
|
|
1283
|
+
const result = parseValue(data.value);
|
|
1246
1284
|
return {
|
|
1247
1285
|
data,
|
|
1248
|
-
value
|
|
1286
|
+
value: result
|
|
1249
1287
|
};
|
|
1250
1288
|
}
|
|
1251
1289
|
async subscribe(names, handleData) {
|
|
@@ -1439,9 +1477,11 @@ function createTx(meta, fn) {
|
|
|
1439
1477
|
tx,
|
|
1440
1478
|
params,
|
|
1441
1479
|
typeArguments,
|
|
1442
|
-
isRaw
|
|
1480
|
+
isRaw,
|
|
1481
|
+
onSuccess,
|
|
1482
|
+
onError
|
|
1443
1483
|
}) => {
|
|
1444
|
-
return await fn(tx, params, typeArguments, isRaw);
|
|
1484
|
+
return await fn(tx, params, typeArguments, isRaw, onSuccess, onError);
|
|
1445
1485
|
}
|
|
1446
1486
|
);
|
|
1447
1487
|
}
|
|
@@ -1562,7 +1602,7 @@ var Dubhe = class {
|
|
|
1562
1602
|
value: import_bcs3.bcs.u64()
|
|
1563
1603
|
})
|
|
1564
1604
|
});
|
|
1565
|
-
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1605
|
+
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw, onSuccess, onError) => {
|
|
1566
1606
|
if (isRaw === true) {
|
|
1567
1607
|
return tx.moveCall({
|
|
1568
1608
|
target: `${this.contractFactory.packageId}::${meta.moduleName}::${meta.funcName}`,
|
|
@@ -1575,7 +1615,7 @@ var Dubhe = class {
|
|
|
1575
1615
|
arguments: params,
|
|
1576
1616
|
typeArguments
|
|
1577
1617
|
});
|
|
1578
|
-
return await this.signAndSendTxn(tx);
|
|
1618
|
+
return await this.signAndSendTxn({ tx, onSuccess, onError });
|
|
1579
1619
|
});
|
|
1580
1620
|
__privateAdd(this, _read, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1581
1621
|
if (isRaw === true) {
|
|
@@ -2034,7 +2074,7 @@ var Dubhe = class {
|
|
|
2034
2074
|
if (isUndefined(__privateGet(this, _tx)[moduleName][funcName])) {
|
|
2035
2075
|
__privateGet(this, _tx)[moduleName][funcName] = createTx(
|
|
2036
2076
|
meta,
|
|
2037
|
-
(tx, p, typeArguments, isRaw) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw)
|
|
2077
|
+
(tx, p, typeArguments, isRaw, onSuccess, onError) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw, onSuccess, onError)
|
|
2038
2078
|
);
|
|
2039
2079
|
}
|
|
2040
2080
|
}
|
|
@@ -2259,6 +2299,10 @@ var Dubhe = class {
|
|
|
2259
2299
|
name,
|
|
2260
2300
|
key1,
|
|
2261
2301
|
key2,
|
|
2302
|
+
is_removed,
|
|
2303
|
+
last_update_checkpoint,
|
|
2304
|
+
last_update_digest,
|
|
2305
|
+
value,
|
|
2262
2306
|
first,
|
|
2263
2307
|
after,
|
|
2264
2308
|
orderBy
|
|
@@ -2267,6 +2311,10 @@ var Dubhe = class {
|
|
|
2267
2311
|
name,
|
|
2268
2312
|
key1,
|
|
2269
2313
|
key2,
|
|
2314
|
+
is_removed,
|
|
2315
|
+
last_update_checkpoint,
|
|
2316
|
+
last_update_digest,
|
|
2317
|
+
value,
|
|
2270
2318
|
first,
|
|
2271
2319
|
after,
|
|
2272
2320
|
orderBy
|
|
@@ -2276,6 +2324,10 @@ var Dubhe = class {
|
|
|
2276
2324
|
name,
|
|
2277
2325
|
key1,
|
|
2278
2326
|
key2,
|
|
2327
|
+
is_removed,
|
|
2328
|
+
last_update_checkpoint,
|
|
2329
|
+
last_update_digest,
|
|
2330
|
+
value,
|
|
2279
2331
|
first,
|
|
2280
2332
|
after,
|
|
2281
2333
|
orderBy
|
|
@@ -2284,6 +2336,10 @@ var Dubhe = class {
|
|
|
2284
2336
|
name,
|
|
2285
2337
|
key1,
|
|
2286
2338
|
key2,
|
|
2339
|
+
is_removed,
|
|
2340
|
+
last_update_checkpoint,
|
|
2341
|
+
last_update_digest,
|
|
2342
|
+
value,
|
|
2287
2343
|
first,
|
|
2288
2344
|
after,
|
|
2289
2345
|
orderBy
|
|
@@ -2292,12 +2348,20 @@ var Dubhe = class {
|
|
|
2292
2348
|
async getStorageItem({
|
|
2293
2349
|
name,
|
|
2294
2350
|
key1,
|
|
2295
|
-
key2
|
|
2351
|
+
key2,
|
|
2352
|
+
is_removed,
|
|
2353
|
+
last_update_checkpoint,
|
|
2354
|
+
last_update_digest,
|
|
2355
|
+
value
|
|
2296
2356
|
}) {
|
|
2297
2357
|
const response = await this.suiIndexerClient.getStorageItem({
|
|
2298
2358
|
name,
|
|
2299
2359
|
key1,
|
|
2300
|
-
key2
|
|
2360
|
+
key2,
|
|
2361
|
+
is_removed,
|
|
2362
|
+
last_update_checkpoint,
|
|
2363
|
+
last_update_digest,
|
|
2364
|
+
value
|
|
2301
2365
|
});
|
|
2302
2366
|
return response;
|
|
2303
2367
|
}
|
|
@@ -2395,9 +2459,33 @@ var Dubhe = class {
|
|
|
2395
2459
|
const keyPair = this.getSigner(derivePathParams);
|
|
2396
2460
|
return await keyPair.signTransaction(txBytes);
|
|
2397
2461
|
}
|
|
2398
|
-
async signAndSendTxn(
|
|
2399
|
-
|
|
2400
|
-
|
|
2462
|
+
async signAndSendTxn({
|
|
2463
|
+
tx,
|
|
2464
|
+
derivePathParams,
|
|
2465
|
+
onSuccess,
|
|
2466
|
+
onError
|
|
2467
|
+
}) {
|
|
2468
|
+
try {
|
|
2469
|
+
const { bytes, signature } = await this.signTxn(tx, derivePathParams);
|
|
2470
|
+
const result = await this.sendTx(bytes, signature);
|
|
2471
|
+
if (result.effects?.status.status === "success") {
|
|
2472
|
+
if (onSuccess) {
|
|
2473
|
+
await onSuccess(result);
|
|
2474
|
+
}
|
|
2475
|
+
} else {
|
|
2476
|
+
if (onError) {
|
|
2477
|
+
await onError(
|
|
2478
|
+
new Error(`Transaction failed: ${result.effects?.status.error}`)
|
|
2479
|
+
);
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
return result;
|
|
2483
|
+
} catch (error) {
|
|
2484
|
+
if (onError) {
|
|
2485
|
+
await onError(error);
|
|
2486
|
+
}
|
|
2487
|
+
throw error;
|
|
2488
|
+
}
|
|
2401
2489
|
}
|
|
2402
2490
|
async sendTx(transaction, signature) {
|
|
2403
2491
|
return this.suiInteractor.sendTx(transaction, signature);
|
|
@@ -2414,7 +2502,7 @@ var Dubhe = class {
|
|
|
2414
2502
|
async transferSui(recipient, amount, derivePathParams) {
|
|
2415
2503
|
const tx = new SuiTx();
|
|
2416
2504
|
tx.transferSui(recipient, amount);
|
|
2417
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2505
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2418
2506
|
}
|
|
2419
2507
|
/**
|
|
2420
2508
|
* Transfer to mutliple recipients
|
|
@@ -2425,7 +2513,7 @@ var Dubhe = class {
|
|
|
2425
2513
|
async transferSuiToMany(recipients, amounts, derivePathParams) {
|
|
2426
2514
|
const tx = new SuiTx();
|
|
2427
2515
|
tx.transferSuiToMany(recipients, amounts);
|
|
2428
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2516
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2429
2517
|
}
|
|
2430
2518
|
/**
|
|
2431
2519
|
* Transfer the given amounts of coin to multiple recipients
|
|
@@ -2449,7 +2537,7 @@ var Dubhe = class {
|
|
|
2449
2537
|
recipients,
|
|
2450
2538
|
amounts
|
|
2451
2539
|
);
|
|
2452
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2540
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2453
2541
|
}
|
|
2454
2542
|
async transferCoin(recipient, amount, coinType, derivePathParams) {
|
|
2455
2543
|
return this.transferCoinToMany(
|
|
@@ -2462,7 +2550,7 @@ var Dubhe = class {
|
|
|
2462
2550
|
async transferObjects(objects, recipient, derivePathParams) {
|
|
2463
2551
|
const tx = new SuiTx();
|
|
2464
2552
|
tx.transferObjects(objects, recipient);
|
|
2465
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2553
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2466
2554
|
}
|
|
2467
2555
|
async moveCall(callParams) {
|
|
2468
2556
|
const {
|
|
@@ -2473,7 +2561,7 @@ var Dubhe = class {
|
|
|
2473
2561
|
} = callParams;
|
|
2474
2562
|
const tx = new SuiTx();
|
|
2475
2563
|
tx.moveCall(target, args, typeArguments);
|
|
2476
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2564
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2477
2565
|
}
|
|
2478
2566
|
/**
|
|
2479
2567
|
* Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount
|
|
@@ -2500,7 +2588,7 @@ var Dubhe = class {
|
|
|
2500
2588
|
async stakeSui(amount, validatorAddr, derivePathParams) {
|
|
2501
2589
|
const tx = new SuiTx();
|
|
2502
2590
|
tx.stakeSui(amount, validatorAddr);
|
|
2503
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
2591
|
+
return this.signAndSendTxn({ tx, derivePathParams });
|
|
2504
2592
|
}
|
|
2505
2593
|
/**
|
|
2506
2594
|
* Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.
|