@0xobelisk/sui-client 1.2.0-pre.4 → 1.2.0-pre.40

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/index.js CHANGED
@@ -51,7 +51,6 @@ __export(src_exports, {
51
51
  BcsType: () => import_bcs4.BcsType,
52
52
  Dubhe: () => Dubhe,
53
53
  MultiSigClient: () => MultiSigClient,
54
- SubscriptionKind: () => SubscriptionKind,
55
54
  SuiAccountManager: () => SuiAccountManager,
56
55
  SuiContractFactory: () => SuiContractFactory,
57
56
  SuiTx: () => SuiTx,
@@ -1037,14 +1036,6 @@ function normalizePackageId(input) {
1037
1036
  const normalized = withoutPrefix.replace(/^0+/, "");
1038
1037
  return "0x" + normalized;
1039
1038
  }
1040
- function convertHttpToWebSocket(url) {
1041
- if (url.startsWith("https://")) {
1042
- return url.replace("https://", "wss://");
1043
- } else if (url.startsWith("http://")) {
1044
- return url.replace("http://", "ws://");
1045
- }
1046
- return url;
1047
- }
1048
1039
 
1049
1040
  // src/dubhe.ts
1050
1041
  var import_bcs3 = require("@mysten/bcs");
@@ -1072,398 +1063,6 @@ var ContractDataParsingError = class extends Error {
1072
1063
  }
1073
1064
  };
1074
1065
 
1075
- // src/libs/suiIndexerClient/utils.ts
1076
- var parseData = (data) => {
1077
- if (typeof data !== "object" || data === null) {
1078
- return data;
1079
- }
1080
- if (Array.isArray(data)) {
1081
- return data.map((item) => parseData(item));
1082
- }
1083
- const parsedData = {};
1084
- for (const key in data) {
1085
- if (Object.prototype.hasOwnProperty.call(data, key)) {
1086
- const value = data[key];
1087
- if (typeof value === "object" && value !== null) {
1088
- if ("variant" in value) {
1089
- parsedData[key] = value.variant;
1090
- } else if ("fields" in value) {
1091
- parsedData[key] = parseData(value.fields);
1092
- } else {
1093
- parsedData[key] = parseData(value);
1094
- }
1095
- } else {
1096
- parsedData[key] = value;
1097
- }
1098
- }
1099
- }
1100
- return parsedData;
1101
- };
1102
- var parseValue = (value) => {
1103
- if (typeof value !== "object" || value === null) {
1104
- return value;
1105
- }
1106
- if (Array.isArray(value)) {
1107
- return value.map((item) => parseValue(item));
1108
- }
1109
- if ("variant" in value) {
1110
- return value.variant;
1111
- }
1112
- if ("fields" in value) {
1113
- return parseData(value.fields);
1114
- }
1115
- return parseData(value);
1116
- };
1117
-
1118
- // src/libs/suiIndexerClient/index.ts
1119
- var SubscriptionKind = /* @__PURE__ */ ((SubscriptionKind2) => {
1120
- SubscriptionKind2["Event"] = "event";
1121
- SubscriptionKind2["Schema"] = "schema";
1122
- return SubscriptionKind2;
1123
- })(SubscriptionKind || {});
1124
- var SuiIndexerClient = class {
1125
- constructor(http) {
1126
- this.http = http;
1127
- }
1128
- async fetchGraphql(query, variables) {
1129
- return this.http.fetchGraphql({ query, variables });
1130
- }
1131
- async getTransactions(params) {
1132
- const query = `
1133
- query GetTransactions($first: Int, $after: String, $sender: String, $digest: String, $checkpoint: Int, $orderBy: [TransactionOrderField!]) {
1134
- transactions(first: $first, after: $after, sender: $sender, digest: $digest, checkpoint: $checkpoint, orderBy: $orderBy) {
1135
- edges {
1136
- cursor
1137
- node {
1138
- id
1139
- checkpoint
1140
- digest
1141
- sender
1142
- created_at
1143
- }
1144
- }
1145
- pageInfo {
1146
- hasNextPage
1147
- endCursor
1148
- }
1149
- totalCount
1150
- }
1151
- }
1152
- `;
1153
- const response = await this.fetchGraphql(query, params);
1154
- return response.transactions;
1155
- }
1156
- async getTransaction(digest) {
1157
- const response = await this.getTransactions({
1158
- first: 1,
1159
- digest
1160
- });
1161
- return response.edges[0]?.node;
1162
- }
1163
- async getSchemas(params) {
1164
- const query = `
1165
- query GetSchemas(
1166
- $first: Int,
1167
- $after: String,
1168
- $name: String,
1169
- $key1: JSON,
1170
- $key2: JSON,
1171
- $is_removed: Boolean,
1172
- $last_update_checkpoint: String,
1173
- $last_update_digest: String,
1174
- $value: JSON,
1175
- $orderBy: [SchemaOrderField!],
1176
- $jsonOrderBy: [JsonPathOrder!]
1177
- ) {
1178
- schemas(
1179
- first: $first,
1180
- after: $after,
1181
- name: $name,
1182
- key1: $key1,
1183
- key2: $key2,
1184
- is_removed: $is_removed,
1185
- last_update_checkpoint: $last_update_checkpoint,
1186
- last_update_digest: $last_update_digest,
1187
- value: $value,
1188
- orderBy: $orderBy,
1189
- jsonOrderBy: $jsonOrderBy
1190
- ) {
1191
- edges {
1192
- cursor
1193
- node {
1194
- id
1195
- name
1196
- key1
1197
- key2
1198
- value
1199
- last_update_checkpoint
1200
- last_update_digest
1201
- is_removed
1202
- created_at
1203
- updated_at
1204
- }
1205
- }
1206
- pageInfo {
1207
- hasNextPage
1208
- endCursor
1209
- }
1210
- totalCount
1211
- }
1212
- }
1213
- `;
1214
- const response = await this.fetchGraphql(query, params);
1215
- return response.schemas;
1216
- }
1217
- async getEvents(params) {
1218
- const query = `
1219
- query GetEvents($first: Int, $after: String, $name: String, $sender: String, $digest: String, $checkpoint: String, $orderBy: [EventOrderField!]) {
1220
- events(first: $first, after: $after, name: $name, sender: $sender, digest: $digest, checkpoint: $checkpoint, orderBy: $orderBy) {
1221
- edges {
1222
- cursor
1223
- node {
1224
- id
1225
- checkpoint
1226
- digest
1227
- name
1228
- sender
1229
- value
1230
- created_at
1231
- }
1232
- }
1233
- pageInfo {
1234
- hasNextPage
1235
- endCursor
1236
- }
1237
- totalCount
1238
- }
1239
- }
1240
- `;
1241
- const response = await this.fetchGraphql(query, params);
1242
- return response.events;
1243
- }
1244
- async getStorage({
1245
- name,
1246
- key1,
1247
- key2,
1248
- is_removed = false,
1249
- last_update_checkpoint,
1250
- last_update_digest,
1251
- value,
1252
- first,
1253
- after,
1254
- orderBy,
1255
- jsonOrderBy
1256
- }) {
1257
- const schemas = await this.getSchemas({
1258
- name,
1259
- key1,
1260
- key2,
1261
- is_removed,
1262
- last_update_checkpoint,
1263
- last_update_digest,
1264
- value,
1265
- first,
1266
- after,
1267
- orderBy,
1268
- jsonOrderBy
1269
- });
1270
- const data = schemas.edges.map((edge) => edge.node);
1271
- const result = data.map((item) => parseValue(item.value));
1272
- return {
1273
- data,
1274
- value: result,
1275
- pageInfo: schemas.pageInfo,
1276
- totalCount: schemas.totalCount
1277
- };
1278
- }
1279
- async getStorageItem({
1280
- name,
1281
- key1,
1282
- key2,
1283
- is_removed,
1284
- last_update_checkpoint,
1285
- last_update_digest,
1286
- value
1287
- }) {
1288
- const schemas = await this.getSchemas({
1289
- name,
1290
- key1,
1291
- key2,
1292
- is_removed,
1293
- last_update_checkpoint,
1294
- last_update_digest,
1295
- value,
1296
- first: 1
1297
- });
1298
- const data = schemas.edges[0]?.node;
1299
- if (!data) {
1300
- return void 0;
1301
- }
1302
- const result = parseValue(data.value);
1303
- return {
1304
- data,
1305
- value: result
1306
- };
1307
- }
1308
- async subscribe(types, handleData) {
1309
- return this.http.subscribe(types, handleData);
1310
- }
1311
- };
1312
-
1313
- // src/libs/http/errors.ts
1314
- var BaseError = class extends Error {
1315
- constructor(message, code, type) {
1316
- super(message);
1317
- this.code = code;
1318
- this.type = type;
1319
- this.name = this.constructor.name;
1320
- }
1321
- };
1322
- var HttpError = class extends BaseError {
1323
- constructor(message, code) {
1324
- super(message, code, "ERROR_HTTP");
1325
- }
1326
- };
1327
- var GraphQLError = class extends BaseError {
1328
- constructor(message) {
1329
- super(message, 400, "ERROR_GRAPHQL");
1330
- }
1331
- };
1332
- var ParseError = class extends BaseError {
1333
- constructor(message) {
1334
- super(message, 500, "ERROR_PARSE");
1335
- }
1336
- };
1337
-
1338
- // src/libs/http/ws-adapter.ts
1339
- function createWebSocketClient(url) {
1340
- if (typeof window !== "undefined") {
1341
- return new WebSocket(url);
1342
- } else {
1343
- try {
1344
- require.resolve("ws");
1345
- const WebSocket2 = require("ws");
1346
- return new WebSocket2(url);
1347
- } catch (e) {
1348
- console.error("Failed to load WebSocket implementation:", e);
1349
- throw new Error(
1350
- 'WebSocket implementation not available. Please install the "ws" package.'
1351
- );
1352
- }
1353
- }
1354
- }
1355
-
1356
- // src/libs/http/http.ts
1357
- var Http = class {
1358
- constructor(apiEndpoint, wsEndpoint, customFetch, defaultOptions) {
1359
- this.customFetch = customFetch;
1360
- this.apiEndpoint = apiEndpoint;
1361
- this.graphqlEndpoint = apiEndpoint + "/graphql";
1362
- this.wsEndpoint = wsEndpoint;
1363
- this.defaultOptions = defaultOptions;
1364
- }
1365
- getFetch() {
1366
- return this.customFetch || fetch;
1367
- }
1368
- async fetch(url) {
1369
- try {
1370
- const fetchFn = this.getFetch();
1371
- const response = await fetchFn(url, {
1372
- ...this.defaultOptions
1373
- });
1374
- if (!response.ok) {
1375
- throw new HttpError(
1376
- `HTTP error! status: ${response.status}`,
1377
- response.status
1378
- );
1379
- }
1380
- return response;
1381
- } catch (error) {
1382
- if (error instanceof HttpError) {
1383
- throw error;
1384
- }
1385
- throw new HttpError(`Failed to fetch: ${error.message}`, 500);
1386
- }
1387
- }
1388
- async fetchGraphql({
1389
- query,
1390
- variables
1391
- }) {
1392
- try {
1393
- const isFirstPage = variables?.after === "first";
1394
- const fetchFn = this.getFetch();
1395
- const response = await fetchFn(this.graphqlEndpoint, {
1396
- method: "POST",
1397
- headers: {
1398
- "Content-Type": "application/json",
1399
- Accept: "application/json"
1400
- },
1401
- body: JSON.stringify({
1402
- query,
1403
- variables: {
1404
- ...variables,
1405
- after: isFirstPage ? void 0 : variables?.after
1406
- }
1407
- }),
1408
- ...this.defaultOptions
1409
- });
1410
- if (!response.ok) {
1411
- const errorData = await response.json();
1412
- if (errorData.errors?.[0]?.message?.includes("Syntax Error")) {
1413
- throw new GraphQLError(
1414
- `GraphQL syntax error: ${errorData.errors[0].message}`
1415
- );
1416
- }
1417
- if (errorData.errors?.length > 0) {
1418
- throw new GraphQLError(
1419
- errorData.errors[0].message || "Unknown GraphQL error"
1420
- );
1421
- }
1422
- throw new HttpError(
1423
- `HTTP error: ${JSON.stringify(errorData)}`,
1424
- response.status
1425
- );
1426
- }
1427
- const data = await response.json();
1428
- if (data.errors) {
1429
- throw new GraphQLError(
1430
- data.errors[0]?.message || "GraphQL query failed"
1431
- );
1432
- }
1433
- return data.data;
1434
- } catch (error) {
1435
- if (error instanceof BaseError) {
1436
- throw error;
1437
- }
1438
- if (error instanceof SyntaxError) {
1439
- throw new ParseError("Failed to parse JSON response");
1440
- }
1441
- throw new HttpError(
1442
- `Failed to fetch GraphQL: ${error.message}`,
1443
- 500
1444
- );
1445
- }
1446
- }
1447
- async subscribe(types, handleData) {
1448
- const ws = createWebSocketClient(this.wsEndpoint);
1449
- ws.onopen = () => {
1450
- console.log("Connected to the WebSocket server");
1451
- const subscribeMessage = JSON.stringify(types);
1452
- ws.send(subscribeMessage);
1453
- };
1454
- ws.onmessage = (event) => {
1455
- handleData(JSON.parse(event.data.toString()));
1456
- };
1457
- ws.onclose = () => {
1458
- console.log("Disconnected from the WebSocket server");
1459
- };
1460
- ws.onerror = (error) => {
1461
- console.error(`WebSocket error:`, error);
1462
- };
1463
- return ws;
1464
- }
1465
- };
1466
-
1467
1066
  // src/dubhe.ts
1468
1067
  function isUndefined(value) {
1469
1068
  return value === void 0;
@@ -1521,12 +1120,274 @@ var Dubhe = class {
1521
1120
  networkType,
1522
1121
  fullnodeUrls,
1523
1122
  packageId,
1524
- metadata,
1525
- customFetch,
1526
- defaultOptions,
1527
- indexerUrl,
1528
- indexerWsUrl
1123
+ metadata
1529
1124
  } = {}) {
1125
+ // async getTransactions({
1126
+ // first,
1127
+ // after,
1128
+ // sender,
1129
+ // digest,
1130
+ // checkpoint,
1131
+ // packageId,
1132
+ // module,
1133
+ // functionName,
1134
+ // orderBy,
1135
+ // showEvent,
1136
+ // }: {
1137
+ // first?: number;
1138
+ // after?: string;
1139
+ // sender?: string;
1140
+ // digest?: string;
1141
+ // checkpoint?: number;
1142
+ // packageId?: string;
1143
+ // module?: string;
1144
+ // functionName?: string[];
1145
+ // orderBy?: string[];
1146
+ // showEvent?: boolean;
1147
+ // }): Promise<ConnectionResponse<IndexerTransaction>> {
1148
+ // return await this.suiIndexerClient.getTransactions({
1149
+ // first,
1150
+ // after,
1151
+ // sender,
1152
+ // digest,
1153
+ // checkpoint,
1154
+ // packageId,
1155
+ // module,
1156
+ // functionName,
1157
+ // orderBy,
1158
+ // showEvent,
1159
+ // });
1160
+ // }
1161
+ // async getTransaction(
1162
+ // digest: string
1163
+ // ): Promise<IndexerTransaction | undefined> {
1164
+ // return await this.suiIndexerClient.getTransaction(digest);
1165
+ // }
1166
+ // /**
1167
+ // * Wait for the transaction to be processed by the indexer and return all transaction-related data
1168
+ // * @param digest transaction digest
1169
+ // * @param options option parameters
1170
+ // * @returns result object containing transaction, events and schema data
1171
+ // */
1172
+ // async waitForIndexerTransaction(
1173
+ // digest: string,
1174
+ // options?: {
1175
+ // checkInterval?: number;
1176
+ // timeout?: number;
1177
+ // maxRetries?: number;
1178
+ // pageSize?: number;
1179
+ // }
1180
+ // ): Promise<IndexerTransactionResult> {
1181
+ // const {
1182
+ // checkInterval = 100,
1183
+ // timeout = 30000,
1184
+ // maxRetries = 300,
1185
+ // pageSize = 100,
1186
+ // } = options ?? {};
1187
+ // const startTime = Date.now();
1188
+ // let retryCount = 0;
1189
+ // while (retryCount < maxRetries) {
1190
+ // try {
1191
+ // if (Date.now() - startTime > timeout) {
1192
+ // throw new Error(`Waiting for transaction ${digest} timed out`);
1193
+ // }
1194
+ // await new Promise((resolve) => setTimeout(resolve, checkInterval));
1195
+ // const tx = await this.getTransaction(digest);
1196
+ // if (tx) {
1197
+ // const events: IndexerEvent[] = [];
1198
+ // const schemaChanges: IndexerSchema[] = [];
1199
+ // let hasNextEventsPage = true;
1200
+ // let eventsCursor: string | undefined;
1201
+ // while (hasNextEventsPage) {
1202
+ // const eventsResponse = await this.getEvents({
1203
+ // digest,
1204
+ // first: pageSize,
1205
+ // after: eventsCursor,
1206
+ // });
1207
+ // events.push(...eventsResponse.edges.map((edge) => edge.node));
1208
+ // hasNextEventsPage = eventsResponse.pageInfo.hasNextPage;
1209
+ // eventsCursor = eventsResponse.pageInfo.endCursor;
1210
+ // }
1211
+ // let hasNextSchemasPage = true;
1212
+ // let schemasCursor: string | undefined;
1213
+ // while (hasNextSchemasPage) {
1214
+ // const schemasResponse = await this.getStorage({
1215
+ // last_update_digest: digest,
1216
+ // first: pageSize,
1217
+ // after: schemasCursor,
1218
+ // });
1219
+ // schemaChanges.push(...schemasResponse.data);
1220
+ // hasNextSchemasPage = schemasResponse.pageInfo.hasNextPage;
1221
+ // schemasCursor = schemasResponse.pageInfo.endCursor;
1222
+ // }
1223
+ // return {
1224
+ // tx,
1225
+ // events,
1226
+ // schemaChanges,
1227
+ // };
1228
+ // }
1229
+ // retryCount++;
1230
+ // } catch (error) {
1231
+ // throw new Error(
1232
+ // `Error while waiting for transaction ${digest}: ${error}`
1233
+ // );
1234
+ // }
1235
+ // }
1236
+ // throw new Error(
1237
+ // `Reached maximum retries (${maxRetries}), failed to wait for transaction ${digest}`
1238
+ // );
1239
+ // }
1240
+ // async getEvents({
1241
+ // first,
1242
+ // after,
1243
+ // names,
1244
+ // sender,
1245
+ // digest,
1246
+ // checkpoint,
1247
+ // orderBy,
1248
+ // }: {
1249
+ // first?: number;
1250
+ // after?: string;
1251
+ // names?: string[];
1252
+ // sender?: string;
1253
+ // digest?: string;
1254
+ // checkpoint?: string;
1255
+ // orderBy?: string[];
1256
+ // }): Promise<ConnectionResponse<IndexerEvent>> {
1257
+ // return await this.suiIndexerClient.getEvents({
1258
+ // first,
1259
+ // after,
1260
+ // names,
1261
+ // sender,
1262
+ // digest,
1263
+ // checkpoint,
1264
+ // orderBy,
1265
+ // });
1266
+ // }
1267
+ // async getSchemas({
1268
+ // name,
1269
+ // key1,
1270
+ // key2,
1271
+ // is_removed,
1272
+ // last_update_checkpoint,
1273
+ // last_update_digest,
1274
+ // value,
1275
+ // first,
1276
+ // after,
1277
+ // orderBy,
1278
+ // jsonOrderBy,
1279
+ // }: {
1280
+ // name?: string;
1281
+ // key1?: any;
1282
+ // key2?: any;
1283
+ // is_removed?: boolean;
1284
+ // last_update_checkpoint?: string;
1285
+ // last_update_digest?: string;
1286
+ // value?: any;
1287
+ // first?: number;
1288
+ // after?: string;
1289
+ // orderBy?: string[];
1290
+ // jsonOrderBy?: JsonPathOrder[];
1291
+ // }): Promise<ConnectionResponse<IndexerSchema>> {
1292
+ // return await this.suiIndexerClient.getSchemas({
1293
+ // name,
1294
+ // key1,
1295
+ // key2,
1296
+ // is_removed,
1297
+ // last_update_checkpoint,
1298
+ // last_update_digest,
1299
+ // value,
1300
+ // first,
1301
+ // after,
1302
+ // orderBy,
1303
+ // jsonOrderBy,
1304
+ // });
1305
+ // }
1306
+ // async getStorage({
1307
+ // name,
1308
+ // key1,
1309
+ // key2,
1310
+ // is_removed,
1311
+ // last_update_checkpoint,
1312
+ // last_update_digest,
1313
+ // value,
1314
+ // first,
1315
+ // after,
1316
+ // orderBy,
1317
+ // jsonOrderBy,
1318
+ // }: {
1319
+ // name?: string;
1320
+ // key1?: any;
1321
+ // key2?: any;
1322
+ // is_removed?: boolean;
1323
+ // last_update_checkpoint?: string;
1324
+ // last_update_digest?: string;
1325
+ // value?: any;
1326
+ // first?: number;
1327
+ // after?: string;
1328
+ // orderBy?: string[];
1329
+ // jsonOrderBy?: JsonPathOrder[];
1330
+ // }): Promise<StorageResponse<IndexerSchema>> {
1331
+ // return await this.suiIndexerClient.getStorage({
1332
+ // name,
1333
+ // key1,
1334
+ // key2,
1335
+ // is_removed,
1336
+ // last_update_checkpoint,
1337
+ // last_update_digest,
1338
+ // value,
1339
+ // first,
1340
+ // after,
1341
+ // orderBy,
1342
+ // jsonOrderBy,
1343
+ // });
1344
+ // }
1345
+ // async getStorageItem({
1346
+ // name,
1347
+ // key1,
1348
+ // key2,
1349
+ // is_removed,
1350
+ // last_update_checkpoint,
1351
+ // last_update_digest,
1352
+ // value,
1353
+ // }: {
1354
+ // name: string;
1355
+ // key1?: any;
1356
+ // key2?: any;
1357
+ // is_removed?: boolean;
1358
+ // last_update_checkpoint?: string;
1359
+ // last_update_digest?: string;
1360
+ // value?: any;
1361
+ // }): Promise<StorageItemResponse<IndexerSchema> | undefined> {
1362
+ // const response = await this.suiIndexerClient.getStorageItem({
1363
+ // name,
1364
+ // key1,
1365
+ // key2,
1366
+ // is_removed,
1367
+ // last_update_checkpoint,
1368
+ // last_update_digest,
1369
+ // value,
1370
+ // });
1371
+ // return response;
1372
+ // }
1373
+ // async subscribe({
1374
+ // types,
1375
+ // handleData,
1376
+ // onOpen,
1377
+ // onClose,
1378
+ // }: {
1379
+ // types: SubscribableType[];
1380
+ // handleData: (data: any) => void;
1381
+ // onOpen?: () => void;
1382
+ // onClose?: () => void;
1383
+ // }): Promise<WebSocket> {
1384
+ // return this.suiIndexerClient.subscribe({
1385
+ // types,
1386
+ // handleData,
1387
+ // onOpen,
1388
+ // onClose,
1389
+ // });
1390
+ // }
1530
1391
  __privateAdd(this, _processKeyParameter);
1531
1392
  __privateAdd(this, _query, {});
1532
1393
  __privateAdd(this, _tx, {});
@@ -2012,10 +1873,6 @@ var Dubhe = class {
2012
1873
  this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
2013
1874
  fullnodeUrls = fullnodeUrls || [defaultParams.fullNode];
2014
1875
  this.suiInteractor = new SuiInteractor(fullnodeUrls, networkType);
2015
- indexerUrl = indexerUrl || defaultParams.indexerUrl;
2016
- indexerWsUrl = indexerWsUrl || convertHttpToWebSocket(indexerUrl);
2017
- this.http = new Http(indexerUrl, indexerWsUrl, customFetch, defaultOptions);
2018
- this.suiIndexerClient = new SuiIndexerClient(this.http);
2019
1876
  this.packageId = packageId ? normalizePackageId(packageId) : void 0;
2020
1877
  if (metadata !== void 0) {
2021
1878
  this.metadata = metadata;
@@ -2303,188 +2160,6 @@ var Dubhe = class {
2303
2160
  customModuleName
2304
2161
  });
2305
2162
  }
2306
- async getTransactions({
2307
- first,
2308
- after,
2309
- sender,
2310
- digest,
2311
- checkpoint,
2312
- orderBy
2313
- }) {
2314
- return await this.suiIndexerClient.getTransactions({
2315
- first,
2316
- after,
2317
- sender,
2318
- digest,
2319
- checkpoint,
2320
- orderBy
2321
- });
2322
- }
2323
- async getTransaction(digest) {
2324
- return await this.suiIndexerClient.getTransaction(digest);
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
- */
2332
- async waitForIndexerTransaction(digest, options) {
2333
- const {
2334
- checkInterval = 100,
2335
- timeout = 3e4,
2336
- maxRetries = 300,
2337
- pageSize = 100
2338
- } = options ?? {};
2339
- const startTime = Date.now();
2340
- let retryCount = 0;
2341
- while (retryCount < maxRetries) {
2342
- try {
2343
- if (Date.now() - startTime > timeout) {
2344
- throw new Error(`Waiting for transaction ${digest} timed out`);
2345
- }
2346
- await new Promise((resolve) => setTimeout(resolve, checkInterval));
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
- };
2380
- }
2381
- retryCount++;
2382
- } catch (error) {
2383
- throw new Error(
2384
- `Error while waiting for transaction ${digest}: ${error}`
2385
- );
2386
- }
2387
- }
2388
- throw new Error(
2389
- `Reached maximum retries (${maxRetries}), failed to wait for transaction ${digest}`
2390
- );
2391
- }
2392
- async getEvents({
2393
- first,
2394
- after,
2395
- name,
2396
- sender,
2397
- digest,
2398
- checkpoint,
2399
- orderBy
2400
- }) {
2401
- return await this.suiIndexerClient.getEvents({
2402
- first,
2403
- after,
2404
- name,
2405
- sender,
2406
- digest,
2407
- checkpoint,
2408
- orderBy
2409
- });
2410
- }
2411
- async getSchemas({
2412
- name,
2413
- key1,
2414
- key2,
2415
- is_removed,
2416
- last_update_checkpoint,
2417
- last_update_digest,
2418
- value,
2419
- first,
2420
- after,
2421
- orderBy,
2422
- jsonOrderBy
2423
- }) {
2424
- return await this.suiIndexerClient.getSchemas({
2425
- name,
2426
- key1,
2427
- key2,
2428
- is_removed,
2429
- last_update_checkpoint,
2430
- last_update_digest,
2431
- value,
2432
- first,
2433
- after,
2434
- orderBy,
2435
- jsonOrderBy
2436
- });
2437
- }
2438
- async getStorage({
2439
- name,
2440
- key1,
2441
- key2,
2442
- is_removed,
2443
- last_update_checkpoint,
2444
- last_update_digest,
2445
- value,
2446
- first,
2447
- after,
2448
- orderBy,
2449
- jsonOrderBy
2450
- }) {
2451
- return await this.suiIndexerClient.getStorage({
2452
- name,
2453
- key1,
2454
- key2,
2455
- is_removed,
2456
- last_update_checkpoint,
2457
- last_update_digest,
2458
- value,
2459
- first,
2460
- after,
2461
- orderBy,
2462
- jsonOrderBy
2463
- });
2464
- }
2465
- async getStorageItem({
2466
- name,
2467
- key1,
2468
- key2,
2469
- is_removed,
2470
- last_update_checkpoint,
2471
- last_update_digest,
2472
- value
2473
- }) {
2474
- const response = await this.suiIndexerClient.getStorageItem({
2475
- name,
2476
- key1,
2477
- key2,
2478
- is_removed,
2479
- last_update_checkpoint,
2480
- last_update_digest,
2481
- value
2482
- });
2483
- return response;
2484
- }
2485
- async subscribe(types, handleData) {
2486
- return this.suiIndexerClient.subscribe(types, handleData);
2487
- }
2488
2163
  /**
2489
2164
  * else:
2490
2165
  * it will generate signer from the mnemonic with the given derivePathParams.
@@ -2558,9 +2233,6 @@ var Dubhe = class {
2558
2233
  client() {
2559
2234
  return this.suiInteractor.currentClient;
2560
2235
  }
2561
- indexerClient() {
2562
- return this.suiIndexerClient;
2563
- }
2564
2236
  async getObject(objectId) {
2565
2237
  return this.suiInteractor.getObject(objectId);
2566
2238
  }
@@ -2840,9 +2512,9 @@ var import_multisig = require("@mysten/sui/multisig");
2840
2512
 
2841
2513
  // src/libs/multiSig/publickey.ts
2842
2514
  var import_ed255193 = require("@mysten/sui/keypairs/ed25519");
2843
- var import_utils6 = require("@mysten/sui/utils");
2515
+ var import_utils5 = require("@mysten/sui/utils");
2844
2516
  function ed25519PublicKeyFromBase64(rawPubkey) {
2845
- let bytes = (0, import_utils6.fromB64)(rawPubkey);
2517
+ let bytes = (0, import_utils5.fromB64)(rawPubkey);
2846
2518
  if (bytes.length !== 32 && bytes.length !== 33)
2847
2519
  throw "invalid pubkey length";
2848
2520
  bytes = bytes.length === 33 ? bytes.slice(1) : bytes;
@@ -2893,7 +2565,6 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
2893
2565
  BcsType,
2894
2566
  Dubhe,
2895
2567
  MultiSigClient,
2896
- SubscriptionKind,
2897
2568
  SuiAccountManager,
2898
2569
  SuiContractFactory,
2899
2570
  SuiTx,