@0xobelisk/sui-client 1.0.3 → 1.0.5

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 CHANGED
@@ -6,6 +6,7 @@ import { SuiInteractor } from './libs/suiInteractor';
6
6
  import { MapObjectStruct } from './types';
7
7
  import { SuiContractFactory } from './libs/suiContractFactory';
8
8
  import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
9
+ import { NetworkConfig } from './libs/suiInteractor';
9
10
  import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg } from './types';
10
11
  export declare function isUndefined(value?: unknown): value is undefined;
11
12
  export declare function withMeta<T extends {
@@ -39,20 +40,23 @@ export declare class Dubhe {
39
40
  get tx(): MapMoudleFuncTx;
40
41
  get object(): MapObjectStruct;
41
42
  view(dryResult: DevInspectResults): any[];
42
- state({ schema, field, objectId, storageType, params, }: {
43
+ state({ tx, schema, params, }: {
44
+ tx: Transaction;
45
+ schema: string;
46
+ params: any[];
47
+ }): Promise<any[] | undefined>;
48
+ parseState({ schema, objectId, storageType, params, }: {
43
49
  schema: string;
44
- field: string;
45
50
  objectId: string;
46
51
  storageType: string;
47
52
  params: any[];
48
- }): Promise<any[]>;
53
+ }): Promise<any[] | undefined>;
49
54
  /**
50
- * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
51
55
  * else:
52
56
  * it will generate signer from the mnemonic with the given derivePathParams.
53
57
  * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
54
58
  */
55
- getKeypair(derivePathParams?: DerivePathParams): import("@mysten/sui/dist/cjs/keypairs/ed25519").Ed25519Keypair;
59
+ getSigner(derivePathParams?: DerivePathParams): import("@mysten/sui/dist/cjs/keypairs/ed25519").Ed25519Keypair;
56
60
  /**
57
61
  * @description Switch the current account with the given derivePathParams
58
62
  * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
@@ -67,6 +71,10 @@ export declare class Dubhe {
67
71
  getPackageId(): string;
68
72
  getMetadata(): SuiMoveNormalizedModules | undefined;
69
73
  getNetwork(): import("./types").NetworkType | undefined;
74
+ getNetworkConfig(): NetworkConfig;
75
+ getTxExplorerUrl(txHash: string): string;
76
+ getAccountExplorerUrl(address: string): string;
77
+ getExplorerUrl(): string;
70
78
  /**
71
79
  * Request some SUI from faucet
72
80
  * @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
@@ -79,7 +87,8 @@ export declare class Dubhe {
79
87
  getObjects(objectIds: string[]): Promise<SuiObjectData[]>;
80
88
  signTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/dist/cjs/cryptography").SignatureWithBytes>;
81
89
  signAndSendTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
82
- sendTxn(transactionBlock: Uint8Array | string, signature: string | string[]): Promise<SuiTransactionBlockResponse>;
90
+ sendTx(transaction: Uint8Array | string, signature: string | string[]): Promise<SuiTransactionBlockResponse>;
91
+ waitForTransaction(digest: string): Promise<SuiTransactionBlockResponse>;
83
92
  /**
84
93
  * Transfer the given amount of SUI to the recipient
85
94
  * @param recipient
package/dist/index.js CHANGED
@@ -641,6 +641,27 @@ var SuiInteractor = class {
641
641
  }
642
642
  throw new Error("Failed to send transaction with all fullnodes");
643
643
  }
644
+ async waitForTransaction({
645
+ digest,
646
+ timeout = 60 * 1e3,
647
+ pollInterval = 2 * 1e3
648
+ }) {
649
+ for (const clientIdx in this.clients) {
650
+ try {
651
+ return await this.clients[clientIdx].waitForTransaction({
652
+ digest,
653
+ timeout,
654
+ pollInterval
655
+ });
656
+ } catch (err) {
657
+ console.warn(
658
+ `Failed to wait for transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`
659
+ );
660
+ await delay(2e3);
661
+ }
662
+ }
663
+ throw new Error("Failed to wait for transaction with all fullnodes");
664
+ }
644
665
  async getObjects(ids, options) {
645
666
  const opts = options ?? {
646
667
  showContent: true,
@@ -853,6 +874,56 @@ var SuiInteractor = class {
853
874
  }
854
875
  };
855
876
 
877
+ // src/libs/suiInteractor/defaultConfig.ts
878
+ var getDefaultURL = (networkType = "testnet") => {
879
+ switch (networkType) {
880
+ case "localnet":
881
+ return {
882
+ fullNode: "http://127.0.0.1:9000",
883
+ graphql: "http://127.0.0.1:9125",
884
+ network: "localnet",
885
+ txExplorer: "https://explorer.polymedia.app/txblock/:txHash?network=local",
886
+ accountExplorer: "https://explorer.polymedia.app/address/:address?network=local",
887
+ explorer: "https://explorer.polymedia.app?network=local"
888
+ };
889
+ case "devnet":
890
+ return {
891
+ fullNode: "https://fullnode.devnet.sui.io:443",
892
+ network: "devnet",
893
+ txExplorer: "https://suiscan.xyz/devnet/tx/:txHash",
894
+ accountExplorer: "https://suiscan.xyz/devnet/address/:address",
895
+ explorer: "https://suiscan.xyz/devnet"
896
+ };
897
+ case "testnet":
898
+ return {
899
+ fullNode: "https://fullnode.testnet.sui.io:443",
900
+ graphql: "https://sui-testnet.mystenlabs.com/graphql",
901
+ network: "testnet",
902
+ txExplorer: "https://suiscan.xyz/testnet/tx/:txHash",
903
+ accountExplorer: "https://suiscan.xyz/testnet/address/:address",
904
+ explorer: "https://suiscan.xyz/testnet"
905
+ };
906
+ case "mainnet":
907
+ return {
908
+ fullNode: "https://fullnode.mainnet.sui.io:443",
909
+ graphql: "https://sui-mainnet.mystenlabs.com/graphql",
910
+ network: "mainnet",
911
+ txExplorer: "https://suiscan.xyz/mainnet/tx/:txHash",
912
+ accountExplorer: "https://suiscan.xyz/mainnet/address/:address",
913
+ explorer: "https://suiscan.xyz/mainnet"
914
+ };
915
+ default:
916
+ return {
917
+ fullNode: "https://fullnode.testnet.sui.io:443",
918
+ graphql: "https://sui-testnet.mystenlabs.com/graphql",
919
+ network: "testnet",
920
+ txExplorer: "https://suiscan.xyz/testnet/tx/:txHash",
921
+ accountExplorer: "https://suiscan.xyz/testnet/address/:address",
922
+ explorer: "https://suiscan.xyz/testnet"
923
+ };
924
+ }
925
+ };
926
+
856
927
  // src/libs/suiContractFactory/index.ts
857
928
  var SuiContractFactory = class {
858
929
  // readonly #query: MapMessageQuery<ApiTypes> = {};
@@ -948,6 +1019,12 @@ function numberToAddressHex(num) {
948
1019
  const paddedHex = "0x" + hex.padStart(64, "0");
949
1020
  return paddedHex;
950
1021
  }
1022
+ function normalizePackageId(input) {
1023
+ const withPrefix = input.startsWith("0x") ? input : "0x" + input;
1024
+ const withoutPrefix = withPrefix.slice(2);
1025
+ const normalized = withoutPrefix.replace(/^0+/, "");
1026
+ return "0x" + normalized;
1027
+ }
951
1028
 
952
1029
  // src/dubhe.ts
953
1030
  var import_bcs3 = require("@mysten/bcs");
@@ -1010,7 +1087,7 @@ function createTx(meta, fn) {
1010
1087
  }
1011
1088
  );
1012
1089
  }
1013
- var _query, _tx, _object, _exec, _read, _bcs, _processKeyParameter, processKeyParameter_fn;
1090
+ var _query, _tx, _object, _exec, _read, _getVectorDepth, _bcs, _bcsenum, _processKeyParameter, processKeyParameter_fn;
1014
1091
  var Dubhe = class {
1015
1092
  /**
1016
1093
  * Support the following ways to init the DubheClient:
@@ -1153,6 +1230,12 @@ var Dubhe = class {
1153
1230
  });
1154
1231
  return await this.inspectTxn(tx);
1155
1232
  });
1233
+ __privateAdd(this, _getVectorDepth, (field) => {
1234
+ if (typeof field === "object" && "Vector" in field) {
1235
+ return 1 + __privateGet(this, _getVectorDepth).call(this, field.Vector);
1236
+ }
1237
+ return 0;
1238
+ });
1156
1239
  __privateAdd(this, _bcs, (bcsmeta) => {
1157
1240
  let loopFlag = false;
1158
1241
  const bcsJson = {};
@@ -1230,39 +1313,64 @@ var Dubhe = class {
1230
1313
  }
1231
1314
  return;
1232
1315
  case "Vector":
1233
- switch (value) {
1234
- case "U8":
1235
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u8());
1236
- return;
1237
- case "U16":
1238
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u16());
1239
- return;
1240
- case "U32":
1241
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u32());
1242
- return;
1243
- case "U64":
1244
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u64());
1245
- return;
1246
- case "U128":
1247
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u128());
1248
- return;
1249
- case "U256":
1250
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u256());
1251
- return;
1252
- case "Bool":
1253
- bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.bool());
1254
- return;
1255
- case "Address":
1256
- bcsJson[objName] = import_bcs3.bcs.vector(
1257
- import_bcs3.bcs.bytes(32).transform({
1258
- // To change the input type, you need to provide a type definition for the input
1259
- input: (val) => (0, import_bcs3.fromHEX)(val),
1260
- output: (val) => (0, import_bcs3.toHEX)(val)
1261
- })
1262
- );
1316
+ if (typeof value === "string") {
1317
+ switch (value) {
1318
+ case "U8":
1319
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u8());
1320
+ return;
1321
+ case "U16":
1322
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u16());
1323
+ return;
1324
+ case "U32":
1325
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u32());
1326
+ return;
1327
+ case "U64":
1328
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u64());
1329
+ return;
1330
+ case "U128":
1331
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u128());
1332
+ return;
1333
+ case "U256":
1334
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u256());
1335
+ return;
1336
+ case "Bool":
1337
+ bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.bool());
1338
+ return;
1339
+ case "Address":
1340
+ bcsJson[objName] = import_bcs3.bcs.vector(
1341
+ import_bcs3.bcs.bytes(32).transform({
1342
+ // To change the input type, you need to provide a type definition for the input
1343
+ input: (val) => (0, import_bcs3.fromHEX)(val),
1344
+ output: (val) => (0, import_bcs3.toHEX)(val)
1345
+ })
1346
+ );
1347
+ return;
1348
+ default:
1349
+ }
1350
+ }
1351
+ if (typeof value === "object") {
1352
+ const vectorDepth = __privateGet(this, _getVectorDepth).call(this, value);
1353
+ let innerType = value;
1354
+ for (let i = 0; i < vectorDepth; i++) {
1355
+ innerType = innerType.Vector;
1356
+ }
1357
+ if ("Struct" in innerType) {
1358
+ const structType2 = innerType.Struct;
1359
+ const structId = `${structType2.address}::${structType2.module}::${structType2.name}`;
1360
+ let bcsType = __privateGet(this, _object)[structId];
1361
+ if (!bcsType) {
1362
+ loopFlag = true;
1363
+ return;
1364
+ }
1365
+ let baseType = bcsType;
1366
+ for (let i = 0; i <= vectorDepth; i++) {
1367
+ baseType = import_bcs3.bcs.vector(baseType);
1368
+ }
1369
+ bcsJson[objName] = baseType;
1263
1370
  return;
1264
- default:
1371
+ }
1265
1372
  }
1373
+ return;
1266
1374
  case "TypeParameter":
1267
1375
  bcsJson[objName] = import_bcs3.bcs.u128();
1268
1376
  return;
@@ -1313,10 +1421,178 @@ var Dubhe = class {
1313
1421
  loopFlag
1314
1422
  };
1315
1423
  });
1424
+ __privateAdd(this, _bcsenum, (bcsmeta) => {
1425
+ let loopFlag = false;
1426
+ const variantJson = {};
1427
+ Object.entries(bcsmeta.objectType.variants).forEach(([name, type]) => {
1428
+ if (type.length > 0) {
1429
+ Object.entries(type).forEach(([index, value]) => {
1430
+ const objType = value.type;
1431
+ const objName = value.name;
1432
+ switch (typeof objType) {
1433
+ case "object":
1434
+ for (const [key, value2] of Object.entries(objType)) {
1435
+ switch (key) {
1436
+ case "Struct":
1437
+ const structType = value2;
1438
+ if (structType.address === "0x1" && structType.module === "ascii" && structType.name === "String") {
1439
+ variantJson[objName] = import_bcs3.bcs.string();
1440
+ return;
1441
+ } else if (structType.address === "0x2" && structType.module === "object" && structType.name === "UID") {
1442
+ variantJson[objName] = import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
1443
+ input: (id) => (0, import_bcs3.fromHEX)(id),
1444
+ output: (id) => (0, import_bcs3.toHEX)(Uint8Array.from(id))
1445
+ });
1446
+ return;
1447
+ } else if (structType.address === "0x2" && structType.module === "object" && structType.name === "ID") {
1448
+ variantJson[objName] = import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
1449
+ input: (id) => (0, import_bcs3.fromHEX)(id),
1450
+ output: (id) => (0, import_bcs3.toHEX)(Uint8Array.from(id))
1451
+ });
1452
+ return;
1453
+ } else if (structType.address === "0x2" && structType.module === "bag" && structType.name === "Bag") {
1454
+ variantJson[objName] = import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
1455
+ input: (id) => (0, import_bcs3.fromHEX)(id),
1456
+ output: (id) => (0, import_bcs3.toHEX)(Uint8Array.from(id))
1457
+ });
1458
+ return;
1459
+ } else if (structType.address === "0x1" && structType.module === "option" && structType.name === "Option") {
1460
+ switch (structType.typeArguments[0]) {
1461
+ case "U8":
1462
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u8());
1463
+ return;
1464
+ case "U16":
1465
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u16());
1466
+ return;
1467
+ case "U32":
1468
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u32());
1469
+ return;
1470
+ case "U64":
1471
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u64());
1472
+ return;
1473
+ case "U128":
1474
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u128());
1475
+ return;
1476
+ case "U256":
1477
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u256());
1478
+ return;
1479
+ case "Bool":
1480
+ variantJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.bool());
1481
+ return;
1482
+ case "Address":
1483
+ variantJson[objName] = import_bcs3.bcs.option(
1484
+ import_bcs3.bcs.bytes(32).transform({
1485
+ // To change the input type, you need to provide a type definition for the input
1486
+ input: (val) => (0, import_bcs3.fromHEX)(val),
1487
+ output: (val) => (0, import_bcs3.toHEX)(val)
1488
+ })
1489
+ );
1490
+ return;
1491
+ default:
1492
+ }
1493
+ } else {
1494
+ if (this.object[`${structType.address}::${structType.module}::${structType.name}`] === void 0) {
1495
+ loopFlag = true;
1496
+ } else {
1497
+ variantJson[objName] = this.object[`${structType.address}::${structType.module}::${structType.name}`];
1498
+ return;
1499
+ }
1500
+ }
1501
+ return;
1502
+ case "Vector":
1503
+ if (typeof value2 === "string") {
1504
+ switch (value2) {
1505
+ case "U8":
1506
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u8());
1507
+ return;
1508
+ case "U16":
1509
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u16());
1510
+ return;
1511
+ case "U32":
1512
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u32());
1513
+ return;
1514
+ case "U64":
1515
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u64());
1516
+ return;
1517
+ case "U128":
1518
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u128());
1519
+ return;
1520
+ case "U256":
1521
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u256());
1522
+ return;
1523
+ case "Bool":
1524
+ variantJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.bool());
1525
+ return;
1526
+ case "Address":
1527
+ variantJson[objName] = import_bcs3.bcs.vector(
1528
+ import_bcs3.bcs.bytes(32).transform({
1529
+ // To change the input type, you need to provide a type definition for the input
1530
+ input: (val) => (0, import_bcs3.fromHEX)(val),
1531
+ output: (val) => (0, import_bcs3.toHEX)(val)
1532
+ })
1533
+ );
1534
+ return;
1535
+ default:
1536
+ }
1537
+ }
1538
+ case "TypeParameter":
1539
+ variantJson[objName] = import_bcs3.bcs.u128();
1540
+ return;
1541
+ default:
1542
+ throw new Error("Unsupported type");
1543
+ }
1544
+ }
1545
+ return;
1546
+ case "string":
1547
+ switch (objType) {
1548
+ case "U8":
1549
+ variantJson[objName] = import_bcs3.bcs.u8();
1550
+ return;
1551
+ case "U16":
1552
+ variantJson[objName] = import_bcs3.bcs.u16();
1553
+ return;
1554
+ case "U32":
1555
+ variantJson[objName] = import_bcs3.bcs.u32();
1556
+ return;
1557
+ case "U64":
1558
+ variantJson[objName] = import_bcs3.bcs.u64();
1559
+ return;
1560
+ case "U128":
1561
+ variantJson[objName] = import_bcs3.bcs.u128();
1562
+ return;
1563
+ case "U256":
1564
+ variantJson[objName] = import_bcs3.bcs.u256();
1565
+ return;
1566
+ case "Bool":
1567
+ variantJson[objName] = import_bcs3.bcs.bool();
1568
+ return;
1569
+ case "Address":
1570
+ variantJson[objName] = import_bcs3.bcs.bytes(32).transform({
1571
+ // To change the input type, you need to provide a type definition for the input
1572
+ input: (val) => (0, import_bcs3.fromHEX)(val),
1573
+ output: (val) => (0, import_bcs3.toHEX)(val)
1574
+ });
1575
+ return;
1576
+ default:
1577
+ return;
1578
+ }
1579
+ default:
1580
+ throw new Error("Unsupported type");
1581
+ }
1582
+ });
1583
+ } else {
1584
+ variantJson[name] = null;
1585
+ }
1586
+ });
1587
+ return {
1588
+ bcs: import_bcs3.bcs.enum(bcsmeta.objectName, variantJson),
1589
+ loopFlag
1590
+ };
1591
+ });
1316
1592
  this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
1317
1593
  fullnodeUrls = fullnodeUrls || [(0, import_client2.getFullnodeUrl)(networkType ?? "mainnet")];
1318
1594
  this.suiInteractor = new SuiInteractor(fullnodeUrls, networkType);
1319
- this.packageId = packageId;
1595
+ this.packageId = packageId ? normalizePackageId(packageId) : void 0;
1320
1596
  if (metadata !== void 0) {
1321
1597
  this.metadata = metadata;
1322
1598
  const maxLoopNum = 5;
@@ -1329,6 +1605,30 @@ var Dubhe = class {
1329
1605
  const data = moudlevalue;
1330
1606
  const moduleName = data.name;
1331
1607
  const objMoudleId = `${packageId}::${moduleName}`;
1608
+ if (data.enums) {
1609
+ Object.entries(data.enums).forEach(([enumName, enumType]) => {
1610
+ const objectId = `${objMoudleId}::${enumName}`;
1611
+ const bcsmeta = {
1612
+ objectId,
1613
+ objectName: enumName,
1614
+ objectType: enumType
1615
+ };
1616
+ let bcsObj = __privateGet(this, _bcsenum).call(this, bcsmeta);
1617
+ if (bcsObj.loopFlag === true) {
1618
+ loopFlag = bcsObj.loopFlag;
1619
+ }
1620
+ if (__privateGet(this, _object)[objectId] === void 0) {
1621
+ __privateGet(this, _object)[objectId] = bcsObj.bcs;
1622
+ __privateGet(this, _object)[`vector<${objectId}>`] = import_bcs3.bcs.vector(bcsObj.bcs);
1623
+ __privateGet(this, _object)[`vector<vector<${objectId}>>`] = import_bcs3.bcs.vector(
1624
+ import_bcs3.bcs.vector(bcsObj.bcs)
1625
+ );
1626
+ __privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = import_bcs3.bcs.option(
1627
+ bcsObj.bcs
1628
+ );
1629
+ }
1630
+ });
1631
+ }
1332
1632
  Object.entries(data.structs).forEach(([objectName, objectType]) => {
1333
1633
  const objectId = `${objMoudleId}::${objectName}`;
1334
1634
  const bcsmeta = {
@@ -1502,15 +1802,33 @@ var Dubhe = class {
1502
1802
  }
1503
1803
  }
1504
1804
  async state({
1805
+ tx,
1806
+ schema,
1807
+ params
1808
+ }) {
1809
+ const moduleName = `schema`;
1810
+ const functionName = `get_${schema}`;
1811
+ let queryResponse = void 0;
1812
+ try {
1813
+ queryResponse = await this.query[moduleName][functionName]({
1814
+ tx,
1815
+ params
1816
+ });
1817
+ if (queryResponse.effects.status.status !== "success") {
1818
+ return void 0;
1819
+ }
1820
+ } catch {
1821
+ return void 0;
1822
+ }
1823
+ return this.view(queryResponse);
1824
+ }
1825
+ async parseState({
1505
1826
  schema,
1506
- field,
1507
1827
  objectId,
1508
1828
  storageType,
1509
1829
  params
1510
1830
  }) {
1511
1831
  const tx = new import_transactions3.Transaction();
1512
- const moduleName = `${schema}_schema`;
1513
- const functionName = `get_${field}`;
1514
1832
  const schemaObject = tx.object(objectId);
1515
1833
  const storageValueMatch = storageType.match(/^StorageValue<(.+)>$/);
1516
1834
  const storageMapMatch = storageType.match(/^StorageMap<(.+),\s*(.+)>$/);
@@ -1545,19 +1863,18 @@ var Dubhe = class {
1545
1863
  `Invalid storage type: ${storageType}. Must be StorageValue<V>, StorageMap<K,V>, or StorageDoubleMap<K1,K2,V>`
1546
1864
  );
1547
1865
  }
1548
- const queryResponse = await this.query[moduleName][functionName]({
1866
+ return this.state({
1549
1867
  tx,
1868
+ schema,
1550
1869
  params: processedParams
1551
1870
  });
1552
- return this.view(queryResponse);
1553
1871
  }
1554
1872
  /**
1555
- * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
1556
1873
  * else:
1557
1874
  * it will generate signer from the mnemonic with the given derivePathParams.
1558
1875
  * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
1559
1876
  */
1560
- getKeypair(derivePathParams) {
1877
+ getSigner(derivePathParams) {
1561
1878
  return this.accountManager.getKeyPair(derivePathParams);
1562
1879
  }
1563
1880
  /**
@@ -1586,6 +1903,18 @@ var Dubhe = class {
1586
1903
  getNetwork() {
1587
1904
  return this.suiInteractor.network;
1588
1905
  }
1906
+ getNetworkConfig() {
1907
+ return getDefaultURL(this.getNetwork());
1908
+ }
1909
+ getTxExplorerUrl(txHash) {
1910
+ return this.getNetworkConfig().txExplorer.replace(":txHash", txHash);
1911
+ }
1912
+ getAccountExplorerUrl(address) {
1913
+ return this.getNetworkConfig().accountExplorer.replace(":address", address);
1914
+ }
1915
+ getExplorerUrl() {
1916
+ return this.getNetworkConfig().explorer;
1917
+ }
1589
1918
  /**
1590
1919
  * Request some SUI from faucet
1591
1920
  * @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
@@ -1625,15 +1954,18 @@ var Dubhe = class {
1625
1954
  }
1626
1955
  const txBlock = tx instanceof SuiTx ? tx.tx : tx;
1627
1956
  const txBytes = txBlock instanceof import_transactions3.Transaction ? await txBlock.build({ client: this.client() }) : txBlock;
1628
- const keyPair = this.getKeypair(derivePathParams);
1957
+ const keyPair = this.getSigner(derivePathParams);
1629
1958
  return await keyPair.signTransaction(txBytes);
1630
1959
  }
1631
1960
  async signAndSendTxn(tx, derivePathParams) {
1632
1961
  const { bytes, signature } = await this.signTxn(tx, derivePathParams);
1633
- return this.suiInteractor.sendTx(bytes, signature);
1962
+ return this.sendTx(bytes, signature);
1963
+ }
1964
+ async sendTx(transaction, signature) {
1965
+ return this.suiInteractor.sendTx(transaction, signature);
1634
1966
  }
1635
- async sendTxn(transactionBlock, signature) {
1636
- return this.suiInteractor.sendTx(transactionBlock, signature);
1967
+ async waitForTransaction(digest) {
1968
+ return this.suiInteractor.waitForTransaction({ digest });
1637
1969
  }
1638
1970
  /**
1639
1971
  * Transfer the given amount of SUI to the recipient
@@ -1817,7 +2149,9 @@ _tx = new WeakMap();
1817
2149
  _object = new WeakMap();
1818
2150
  _exec = new WeakMap();
1819
2151
  _read = new WeakMap();
2152
+ _getVectorDepth = new WeakMap();
1820
2153
  _bcs = new WeakMap();
2154
+ _bcsenum = new WeakMap();
1821
2155
  _processKeyParameter = new WeakSet();
1822
2156
  processKeyParameter_fn = function(tx, keyType, value) {
1823
2157
  switch (keyType.toLowerCase()) {