@0xobelisk/sui-client 1.0.6 → 1.0.8
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 +18 -1
- package/dist/index.js +338 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +345 -10
- package/dist/index.mjs.map +1 -1
- package/dist/libs/http/errors.d.ts +28 -0
- package/dist/libs/http/http.d.ts +21 -0
- package/dist/libs/http/index.d.ts +4 -0
- package/dist/libs/http/types.d.ts +1 -0
- package/dist/libs/http/ws-adapter.d.ts +6 -0
- package/dist/libs/suiIndexerClient/index.d.ts +95 -0
- package/dist/libs/suiIndexerClient/types.d.ts +0 -0
- package/dist/libs/suiInteractor/defaultConfig.d.ts +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +15 -10
- package/src/dubhe.ts +70 -1
- package/src/libs/http/errors.ts +122 -0
- package/src/libs/http/http.ts +153 -0
- package/src/libs/http/index.ts +4 -0
- package/src/libs/http/types.ts +1 -0
- package/src/libs/http/ws-adapter.ts +36 -0
- package/src/libs/suiIndexerClient/index.ts +232 -0
- package/src/libs/suiIndexerClient/types.ts +0 -0
- package/src/libs/suiInteractor/defaultConfig.ts +6 -0
- package/src/types/index.ts +5 -0
- package/src/utils/index.ts +9 -0
package/dist/dubhe.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { SuiContractFactory } from './libs/suiContractFactory';
|
|
|
8
8
|
import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
|
|
9
9
|
import { NetworkConfig } from './libs/suiInteractor';
|
|
10
10
|
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg } from './types';
|
|
11
|
+
import { ConnectionResponse, OrderBy, Schema, SuiIndexerClient } from './libs/suiIndexerClient';
|
|
12
|
+
import { Http } from './libs/http';
|
|
11
13
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
12
14
|
export declare function withMeta<T extends {
|
|
13
15
|
meta: SuiMoveMoudleFuncType;
|
|
@@ -18,8 +20,10 @@ export declare function withMeta<T extends {
|
|
|
18
20
|
*/
|
|
19
21
|
export declare class Dubhe {
|
|
20
22
|
#private;
|
|
23
|
+
http: Http;
|
|
21
24
|
accountManager: SuiAccountManager;
|
|
22
25
|
suiInteractor: SuiInteractor;
|
|
26
|
+
suiIndexerClient: SuiIndexerClient;
|
|
23
27
|
contractFactory: SuiContractFactory;
|
|
24
28
|
packageId: string | undefined;
|
|
25
29
|
metadata: SuiMoveNormalizedModules | undefined;
|
|
@@ -35,7 +39,7 @@ export declare class Dubhe {
|
|
|
35
39
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
36
40
|
* @param packageId
|
|
37
41
|
*/
|
|
38
|
-
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, }?: DubheParams);
|
|
42
|
+
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, customFetch, defaultOptions, indexerUrl, indexerWsUrl, }?: DubheParams);
|
|
39
43
|
get query(): MapMoudleFuncQuery;
|
|
40
44
|
get tx(): MapMoudleFuncTx;
|
|
41
45
|
get object(): MapObjectStruct;
|
|
@@ -51,6 +55,18 @@ export declare class Dubhe {
|
|
|
51
55
|
storageType: string;
|
|
52
56
|
params: any[];
|
|
53
57
|
}): Promise<any[] | undefined>;
|
|
58
|
+
getStorage({ name, key1, key2, first, after, last, before, orderBy, distinct, }: {
|
|
59
|
+
name: string;
|
|
60
|
+
key1?: string;
|
|
61
|
+
key2?: string;
|
|
62
|
+
first?: number;
|
|
63
|
+
after?: string;
|
|
64
|
+
last?: number;
|
|
65
|
+
before?: string;
|
|
66
|
+
orderBy?: OrderBy;
|
|
67
|
+
distinct?: boolean;
|
|
68
|
+
}): Promise<ConnectionResponse<Schema>>;
|
|
69
|
+
subscribe(names: string[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
54
70
|
/**
|
|
55
71
|
* else:
|
|
56
72
|
* it will generate signer from the mnemonic with the given derivePathParams.
|
|
@@ -83,6 +99,7 @@ export declare class Dubhe {
|
|
|
83
99
|
getBalance(coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
|
|
84
100
|
balanceOf(accountAddress?: string, coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
|
|
85
101
|
client(): import("@mysten/sui/client").SuiClient;
|
|
102
|
+
indexerClient(): SuiIndexerClient;
|
|
86
103
|
getObject(objectId: string): Promise<SuiObjectData>;
|
|
87
104
|
getObjects(objectIds: string[]): Promise<SuiObjectData[]>;
|
|
88
105
|
signTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/dist/cjs/cryptography").SignatureWithBytes>;
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,6 @@ var import_bcs4 = require("@mysten/bcs");
|
|
|
69
69
|
|
|
70
70
|
// src/dubhe.ts
|
|
71
71
|
var import_keccak256 = __toESM(require("keccak256"));
|
|
72
|
-
var import_client2 = require("@mysten/sui/client");
|
|
73
72
|
var import_transactions3 = require("@mysten/sui/transactions");
|
|
74
73
|
var import_bcs2 = require("@mysten/bcs");
|
|
75
74
|
|
|
@@ -891,7 +890,8 @@ var getDefaultURL = (networkType = "testnet") => {
|
|
|
891
890
|
network: "localnet",
|
|
892
891
|
txExplorer: "https://explorer.polymedia.app/txblock/:txHash?network=local",
|
|
893
892
|
accountExplorer: "https://explorer.polymedia.app/address/:address?network=local",
|
|
894
|
-
explorer: "https://explorer.polymedia.app?network=local"
|
|
893
|
+
explorer: "https://explorer.polymedia.app?network=local",
|
|
894
|
+
indexerUrl: "http://127.0.0.1:3001"
|
|
895
895
|
};
|
|
896
896
|
case "devnet":
|
|
897
897
|
return {
|
|
@@ -899,7 +899,8 @@ var getDefaultURL = (networkType = "testnet") => {
|
|
|
899
899
|
network: "devnet",
|
|
900
900
|
txExplorer: "https://suiscan.xyz/devnet/tx/:txHash",
|
|
901
901
|
accountExplorer: "https://suiscan.xyz/devnet/address/:address",
|
|
902
|
-
explorer: "https://suiscan.xyz/devnet"
|
|
902
|
+
explorer: "https://suiscan.xyz/devnet",
|
|
903
|
+
indexerUrl: "http://127.0.0.1:3001"
|
|
903
904
|
};
|
|
904
905
|
case "testnet":
|
|
905
906
|
return {
|
|
@@ -908,7 +909,8 @@ var getDefaultURL = (networkType = "testnet") => {
|
|
|
908
909
|
network: "testnet",
|
|
909
910
|
txExplorer: "https://suiscan.xyz/testnet/tx/:txHash",
|
|
910
911
|
accountExplorer: "https://suiscan.xyz/testnet/address/:address",
|
|
911
|
-
explorer: "https://suiscan.xyz/testnet"
|
|
912
|
+
explorer: "https://suiscan.xyz/testnet",
|
|
913
|
+
indexerUrl: "http://127.0.0.1:3001"
|
|
912
914
|
};
|
|
913
915
|
case "mainnet":
|
|
914
916
|
return {
|
|
@@ -917,7 +919,8 @@ var getDefaultURL = (networkType = "testnet") => {
|
|
|
917
919
|
network: "mainnet",
|
|
918
920
|
txExplorer: "https://suiscan.xyz/mainnet/tx/:txHash",
|
|
919
921
|
accountExplorer: "https://suiscan.xyz/mainnet/address/:address",
|
|
920
|
-
explorer: "https://suiscan.xyz/mainnet"
|
|
922
|
+
explorer: "https://suiscan.xyz/mainnet",
|
|
923
|
+
indexerUrl: "http://127.0.0.1:3001"
|
|
921
924
|
};
|
|
922
925
|
default:
|
|
923
926
|
return {
|
|
@@ -926,7 +929,8 @@ var getDefaultURL = (networkType = "testnet") => {
|
|
|
926
929
|
network: "testnet",
|
|
927
930
|
txExplorer: "https://suiscan.xyz/testnet/tx/:txHash",
|
|
928
931
|
accountExplorer: "https://suiscan.xyz/testnet/address/:address",
|
|
929
|
-
explorer: "https://suiscan.xyz/testnet"
|
|
932
|
+
explorer: "https://suiscan.xyz/testnet",
|
|
933
|
+
indexerUrl: "http://127.0.0.1:3001"
|
|
930
934
|
};
|
|
931
935
|
}
|
|
932
936
|
};
|
|
@@ -1032,6 +1036,14 @@ function normalizePackageId(input) {
|
|
|
1032
1036
|
const normalized = withoutPrefix.replace(/^0+/, "");
|
|
1033
1037
|
return "0x" + normalized;
|
|
1034
1038
|
}
|
|
1039
|
+
function convertHttpToWebSocket(url) {
|
|
1040
|
+
if (url.startsWith("https://")) {
|
|
1041
|
+
return url.replace("https://", "wss://");
|
|
1042
|
+
} else if (url.startsWith("http://")) {
|
|
1043
|
+
return url.replace("http://", "ws://");
|
|
1044
|
+
}
|
|
1045
|
+
return url;
|
|
1046
|
+
}
|
|
1035
1047
|
|
|
1036
1048
|
// src/dubhe.ts
|
|
1037
1049
|
var import_bcs3 = require("@mysten/bcs");
|
|
@@ -1059,6 +1071,283 @@ var ContractDataParsingError = class extends Error {
|
|
|
1059
1071
|
}
|
|
1060
1072
|
};
|
|
1061
1073
|
|
|
1074
|
+
// src/libs/suiIndexerClient/index.ts
|
|
1075
|
+
var SuiIndexerClient = class {
|
|
1076
|
+
constructor(http) {
|
|
1077
|
+
this.http = http;
|
|
1078
|
+
}
|
|
1079
|
+
async fetchGraphql(query, variables) {
|
|
1080
|
+
return this.http.fetchGraphql({ query, variables });
|
|
1081
|
+
}
|
|
1082
|
+
async getTransactions(params) {
|
|
1083
|
+
const query = `
|
|
1084
|
+
query GetTransactions($first: Int, $after: String, $last: Int, $before: String, $checkpoint: Int, $orderBy: TransactionOrderBy, $distinct: Boolean) {
|
|
1085
|
+
transactions(first: $first, after: $after, last: $last, before: $before, checkpoint: $checkpoint, orderBy: $orderBy, distinct: $distinct) {
|
|
1086
|
+
edges {
|
|
1087
|
+
cursor
|
|
1088
|
+
node {
|
|
1089
|
+
id
|
|
1090
|
+
checkpoint
|
|
1091
|
+
digest
|
|
1092
|
+
created_at
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
pageInfo {
|
|
1096
|
+
hasNextPage
|
|
1097
|
+
hasPreviousPage
|
|
1098
|
+
startCursor
|
|
1099
|
+
endCursor
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
`;
|
|
1104
|
+
const response = await this.fetchGraphql(query, params);
|
|
1105
|
+
return response.transactions;
|
|
1106
|
+
}
|
|
1107
|
+
async getSchemas(params) {
|
|
1108
|
+
const query = `
|
|
1109
|
+
query GetSchemas($first: Int, $after: String, $last: Int, $before: String, $name: String, $key1: String, $key2: String, $orderBy: SchemaOrderBy, $distinct: Boolean) {
|
|
1110
|
+
schemas(first: $first, after: $after, last: $last, before: $before, name: $name, key1: $key1, key2: $key2, orderBy: $orderBy, distinct: $distinct) {
|
|
1111
|
+
edges {
|
|
1112
|
+
cursor
|
|
1113
|
+
node {
|
|
1114
|
+
id
|
|
1115
|
+
name
|
|
1116
|
+
key1
|
|
1117
|
+
key2
|
|
1118
|
+
value
|
|
1119
|
+
last_update_checkpoint
|
|
1120
|
+
last_update_digest
|
|
1121
|
+
is_removed
|
|
1122
|
+
created_at
|
|
1123
|
+
updated_at
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
pageInfo {
|
|
1127
|
+
hasNextPage
|
|
1128
|
+
hasPreviousPage
|
|
1129
|
+
startCursor
|
|
1130
|
+
endCursor
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
`;
|
|
1135
|
+
const response = await this.fetchGraphql(query, params);
|
|
1136
|
+
return response.schemas;
|
|
1137
|
+
}
|
|
1138
|
+
async getEvents(params) {
|
|
1139
|
+
const query = `
|
|
1140
|
+
query GetEvents($first: Int, $after: String, $last: Int, $before: String, $name: String, $checkpoint: String, $orderBy: EventOrderBy, $distinct: Boolean) {
|
|
1141
|
+
events(first: $first, after: $after, last: $last, before: $before, name: $name, checkpoint: $checkpoint, orderBy: $orderBy, distinct: $distinct) {
|
|
1142
|
+
edges {
|
|
1143
|
+
cursor
|
|
1144
|
+
node {
|
|
1145
|
+
id
|
|
1146
|
+
checkpoint
|
|
1147
|
+
digest
|
|
1148
|
+
name
|
|
1149
|
+
value
|
|
1150
|
+
created_at
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
pageInfo {
|
|
1154
|
+
hasNextPage
|
|
1155
|
+
hasPreviousPage
|
|
1156
|
+
startCursor
|
|
1157
|
+
endCursor
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
`;
|
|
1162
|
+
const response = await this.fetchGraphql(query, params);
|
|
1163
|
+
return response.events;
|
|
1164
|
+
}
|
|
1165
|
+
async getStorage({
|
|
1166
|
+
name,
|
|
1167
|
+
key1,
|
|
1168
|
+
key2,
|
|
1169
|
+
first,
|
|
1170
|
+
after,
|
|
1171
|
+
last,
|
|
1172
|
+
before,
|
|
1173
|
+
orderBy,
|
|
1174
|
+
distinct
|
|
1175
|
+
}) {
|
|
1176
|
+
const schemas = await this.getSchemas({
|
|
1177
|
+
name,
|
|
1178
|
+
key1,
|
|
1179
|
+
key2,
|
|
1180
|
+
first,
|
|
1181
|
+
after,
|
|
1182
|
+
last,
|
|
1183
|
+
before,
|
|
1184
|
+
orderBy,
|
|
1185
|
+
distinct
|
|
1186
|
+
});
|
|
1187
|
+
return schemas;
|
|
1188
|
+
}
|
|
1189
|
+
async subscribe(names, handleData) {
|
|
1190
|
+
return this.http.subscribe(names, handleData);
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
// src/libs/http/errors.ts
|
|
1195
|
+
var BaseError = class extends Error {
|
|
1196
|
+
constructor(message, code, type) {
|
|
1197
|
+
super(message);
|
|
1198
|
+
this.code = code;
|
|
1199
|
+
this.type = type;
|
|
1200
|
+
this.name = this.constructor.name;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
var HttpError = class extends BaseError {
|
|
1204
|
+
constructor(message, code) {
|
|
1205
|
+
super(message, code, "ERROR_HTTP");
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
var GraphQLError = class extends BaseError {
|
|
1209
|
+
constructor(message) {
|
|
1210
|
+
super(message, 400, "ERROR_GRAPHQL");
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
var ParseError = class extends BaseError {
|
|
1214
|
+
constructor(message) {
|
|
1215
|
+
super(message, 500, "ERROR_PARSE");
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
// src/libs/http/ws-adapter.ts
|
|
1220
|
+
function createWebSocketClient(url) {
|
|
1221
|
+
if (typeof window !== "undefined") {
|
|
1222
|
+
return new WebSocket(url);
|
|
1223
|
+
} else {
|
|
1224
|
+
try {
|
|
1225
|
+
require.resolve("ws");
|
|
1226
|
+
const WebSocket2 = require("ws");
|
|
1227
|
+
return new WebSocket2(url);
|
|
1228
|
+
} catch (e) {
|
|
1229
|
+
console.error("Failed to load WebSocket implementation:", e);
|
|
1230
|
+
throw new Error(
|
|
1231
|
+
'WebSocket implementation not available. Please install the "ws" package.'
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// src/libs/http/http.ts
|
|
1238
|
+
var Http = class {
|
|
1239
|
+
constructor(apiEndpoint, wsEndpoint, customFetch, defaultOptions) {
|
|
1240
|
+
this.customFetch = customFetch;
|
|
1241
|
+
this.apiEndpoint = apiEndpoint;
|
|
1242
|
+
this.graphqlEndpoint = apiEndpoint + "/graphql";
|
|
1243
|
+
this.wsEndpoint = wsEndpoint;
|
|
1244
|
+
this.defaultOptions = defaultOptions;
|
|
1245
|
+
}
|
|
1246
|
+
getFetch() {
|
|
1247
|
+
return this.customFetch || fetch;
|
|
1248
|
+
}
|
|
1249
|
+
async fetch(url) {
|
|
1250
|
+
try {
|
|
1251
|
+
const fetchFn = this.getFetch();
|
|
1252
|
+
const response = await fetchFn(url, {
|
|
1253
|
+
...this.defaultOptions
|
|
1254
|
+
});
|
|
1255
|
+
if (!response.ok) {
|
|
1256
|
+
throw new HttpError(
|
|
1257
|
+
`HTTP error! status: ${response.status}`,
|
|
1258
|
+
response.status
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
return response;
|
|
1262
|
+
} catch (error) {
|
|
1263
|
+
if (error instanceof HttpError) {
|
|
1264
|
+
throw error;
|
|
1265
|
+
}
|
|
1266
|
+
throw new HttpError(`Failed to fetch: ${error.message}`, 500);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
async fetchGraphql({
|
|
1270
|
+
query,
|
|
1271
|
+
variables
|
|
1272
|
+
}) {
|
|
1273
|
+
try {
|
|
1274
|
+
const isFirstPage = variables?.after === "first";
|
|
1275
|
+
const fetchFn = this.getFetch();
|
|
1276
|
+
const response = await fetchFn(this.graphqlEndpoint, {
|
|
1277
|
+
method: "POST",
|
|
1278
|
+
headers: {
|
|
1279
|
+
"Content-Type": "application/json",
|
|
1280
|
+
Accept: "application/json"
|
|
1281
|
+
},
|
|
1282
|
+
body: JSON.stringify({
|
|
1283
|
+
query,
|
|
1284
|
+
variables: {
|
|
1285
|
+
...variables,
|
|
1286
|
+
after: isFirstPage ? void 0 : variables?.after
|
|
1287
|
+
}
|
|
1288
|
+
}),
|
|
1289
|
+
...this.defaultOptions
|
|
1290
|
+
});
|
|
1291
|
+
if (!response.ok) {
|
|
1292
|
+
const errorData = await response.json();
|
|
1293
|
+
if (errorData.errors?.[0]?.message?.includes("Syntax Error")) {
|
|
1294
|
+
throw new GraphQLError(
|
|
1295
|
+
`GraphQL syntax error: ${errorData.errors[0].message}`
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
if (errorData.errors?.length > 0) {
|
|
1299
|
+
throw new GraphQLError(
|
|
1300
|
+
errorData.errors[0].message || "Unknown GraphQL error"
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
throw new HttpError(
|
|
1304
|
+
`HTTP error: ${JSON.stringify(errorData)}`,
|
|
1305
|
+
response.status
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
const data = await response.json();
|
|
1309
|
+
if (data.errors) {
|
|
1310
|
+
throw new GraphQLError(
|
|
1311
|
+
data.errors[0]?.message || "GraphQL query failed"
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
return data.data;
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
if (error instanceof BaseError) {
|
|
1317
|
+
throw error;
|
|
1318
|
+
}
|
|
1319
|
+
if (error instanceof SyntaxError) {
|
|
1320
|
+
throw new ParseError("Failed to parse JSON response");
|
|
1321
|
+
}
|
|
1322
|
+
throw new HttpError(
|
|
1323
|
+
`Failed to fetch GraphQL: ${error.message}`,
|
|
1324
|
+
500
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
async subscribe(names, handleData) {
|
|
1329
|
+
const ws = createWebSocketClient(this.wsEndpoint);
|
|
1330
|
+
ws.onopen = () => {
|
|
1331
|
+
console.log("Connected to the WebSocket server");
|
|
1332
|
+
const subscribeMessage = JSON.stringify({
|
|
1333
|
+
type: "subscribe",
|
|
1334
|
+
names
|
|
1335
|
+
});
|
|
1336
|
+
ws.send(subscribeMessage);
|
|
1337
|
+
};
|
|
1338
|
+
ws.onmessage = (event) => {
|
|
1339
|
+
handleData(JSON.parse(event.data.toString()));
|
|
1340
|
+
};
|
|
1341
|
+
ws.onclose = () => {
|
|
1342
|
+
console.log("Disconnected from the WebSocket server");
|
|
1343
|
+
};
|
|
1344
|
+
ws.onerror = (error) => {
|
|
1345
|
+
console.error(`WebSocket error:`, error);
|
|
1346
|
+
};
|
|
1347
|
+
return ws;
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1062
1351
|
// src/dubhe.ts
|
|
1063
1352
|
function isUndefined(value) {
|
|
1064
1353
|
return value === void 0;
|
|
@@ -1114,7 +1403,11 @@ var Dubhe = class {
|
|
|
1114
1403
|
networkType,
|
|
1115
1404
|
fullnodeUrls,
|
|
1116
1405
|
packageId,
|
|
1117
|
-
metadata
|
|
1406
|
+
metadata,
|
|
1407
|
+
customFetch,
|
|
1408
|
+
defaultOptions,
|
|
1409
|
+
indexerUrl,
|
|
1410
|
+
indexerWsUrl
|
|
1118
1411
|
} = {}) {
|
|
1119
1412
|
__privateAdd(this, _processKeyParameter);
|
|
1120
1413
|
__privateAdd(this, _query, {});
|
|
@@ -1596,9 +1889,15 @@ var Dubhe = class {
|
|
|
1596
1889
|
loopFlag
|
|
1597
1890
|
};
|
|
1598
1891
|
});
|
|
1892
|
+
networkType = networkType ?? "mainnet";
|
|
1893
|
+
const defaultParams = getDefaultURL(networkType);
|
|
1599
1894
|
this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
|
|
1600
|
-
fullnodeUrls = fullnodeUrls || [
|
|
1895
|
+
fullnodeUrls = fullnodeUrls || [defaultParams.fullNode];
|
|
1601
1896
|
this.suiInteractor = new SuiInteractor(fullnodeUrls, networkType);
|
|
1897
|
+
indexerUrl = indexerUrl || defaultParams.indexerUrl;
|
|
1898
|
+
indexerWsUrl = indexerWsUrl || convertHttpToWebSocket(indexerUrl);
|
|
1899
|
+
this.http = new Http(indexerUrl, indexerWsUrl, customFetch, defaultOptions);
|
|
1900
|
+
this.suiIndexerClient = new SuiIndexerClient(this.http);
|
|
1602
1901
|
this.packageId = packageId ? normalizePackageId(packageId) : void 0;
|
|
1603
1902
|
if (metadata !== void 0) {
|
|
1604
1903
|
this.metadata = metadata;
|
|
@@ -1876,6 +2175,32 @@ var Dubhe = class {
|
|
|
1876
2175
|
params: processedParams
|
|
1877
2176
|
});
|
|
1878
2177
|
}
|
|
2178
|
+
async getStorage({
|
|
2179
|
+
name,
|
|
2180
|
+
key1,
|
|
2181
|
+
key2,
|
|
2182
|
+
first,
|
|
2183
|
+
after,
|
|
2184
|
+
last,
|
|
2185
|
+
before,
|
|
2186
|
+
orderBy,
|
|
2187
|
+
distinct
|
|
2188
|
+
}) {
|
|
2189
|
+
return await this.suiIndexerClient.getStorage({
|
|
2190
|
+
name,
|
|
2191
|
+
key1,
|
|
2192
|
+
key2,
|
|
2193
|
+
first,
|
|
2194
|
+
after,
|
|
2195
|
+
last,
|
|
2196
|
+
before,
|
|
2197
|
+
orderBy,
|
|
2198
|
+
distinct
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
async subscribe(names, handleData) {
|
|
2202
|
+
return this.suiIndexerClient.subscribe(names, handleData);
|
|
2203
|
+
}
|
|
1879
2204
|
/**
|
|
1880
2205
|
* else:
|
|
1881
2206
|
* it will generate signer from the mnemonic with the given derivePathParams.
|
|
@@ -1949,6 +2274,9 @@ var Dubhe = class {
|
|
|
1949
2274
|
client() {
|
|
1950
2275
|
return this.suiInteractor.currentClient;
|
|
1951
2276
|
}
|
|
2277
|
+
indexerClient() {
|
|
2278
|
+
return this.suiIndexerClient;
|
|
2279
|
+
}
|
|
1952
2280
|
async getObject(objectId) {
|
|
1953
2281
|
return this.suiInteractor.getObject(objectId);
|
|
1954
2282
|
}
|
|
@@ -2241,9 +2569,9 @@ var MultiSigClient = class _MultiSigClient {
|
|
|
2241
2569
|
};
|
|
2242
2570
|
|
|
2243
2571
|
// src/metadata/index.ts
|
|
2244
|
-
var
|
|
2572
|
+
var import_client3 = require("@mysten/sui/client");
|
|
2245
2573
|
async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
2246
|
-
fullnodeUrls = fullnodeUrls || [(0,
|
|
2574
|
+
fullnodeUrls = fullnodeUrls || [(0, import_client3.getFullnodeUrl)(networkType)];
|
|
2247
2575
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
2248
2576
|
if (packageId !== void 0) {
|
|
2249
2577
|
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(
|