@0xobelisk/sui-client 1.0.8 → 1.0.9
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 +28 -8
- package/dist/index.js +112 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -29
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +29 -31
- package/dist/libs/suiIndexerClient/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/dubhe.ts +78 -14
- package/src/libs/suiIndexerClient/index.ts +74 -51
- package/src/libs/suiIndexerClient/utils.ts +23 -0
package/dist/index.mjs
CHANGED
|
@@ -1045,6 +1045,27 @@ var ContractDataParsingError = class extends Error {
|
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
1047
|
|
|
1048
|
+
// src/libs/suiIndexerClient/utils.ts
|
|
1049
|
+
var parseValue = (value) => {
|
|
1050
|
+
if (typeof value !== "string") {
|
|
1051
|
+
return value;
|
|
1052
|
+
}
|
|
1053
|
+
try {
|
|
1054
|
+
const parsed = JSON.parse(value);
|
|
1055
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
1056
|
+
if ("variant" in parsed) {
|
|
1057
|
+
return parsed.variant;
|
|
1058
|
+
}
|
|
1059
|
+
if ("fields" in parsed) {
|
|
1060
|
+
return parsed.fields;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return parsed;
|
|
1064
|
+
} catch (error) {
|
|
1065
|
+
return value;
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1048
1069
|
// src/libs/suiIndexerClient/index.ts
|
|
1049
1070
|
var SuiIndexerClient = class {
|
|
1050
1071
|
constructor(http) {
|
|
@@ -1055,8 +1076,8 @@ var SuiIndexerClient = class {
|
|
|
1055
1076
|
}
|
|
1056
1077
|
async getTransactions(params) {
|
|
1057
1078
|
const query = `
|
|
1058
|
-
query GetTransactions($first: Int, $after: String, $
|
|
1059
|
-
transactions(first: $first, after: $after,
|
|
1079
|
+
query GetTransactions($first: Int, $after: String, $checkpoint: Int, $orderBy: [TransactionOrderField!]) {
|
|
1080
|
+
transactions(first: $first, after: $after, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
1060
1081
|
edges {
|
|
1061
1082
|
cursor
|
|
1062
1083
|
node {
|
|
@@ -1068,10 +1089,9 @@ var SuiIndexerClient = class {
|
|
|
1068
1089
|
}
|
|
1069
1090
|
pageInfo {
|
|
1070
1091
|
hasNextPage
|
|
1071
|
-
hasPreviousPage
|
|
1072
|
-
startCursor
|
|
1073
1092
|
endCursor
|
|
1074
1093
|
}
|
|
1094
|
+
totalCount
|
|
1075
1095
|
}
|
|
1076
1096
|
}
|
|
1077
1097
|
`;
|
|
@@ -1080,8 +1100,8 @@ var SuiIndexerClient = class {
|
|
|
1080
1100
|
}
|
|
1081
1101
|
async getSchemas(params) {
|
|
1082
1102
|
const query = `
|
|
1083
|
-
query GetSchemas($first: Int, $after: String, $
|
|
1084
|
-
schemas(first: $first, after: $after,
|
|
1103
|
+
query GetSchemas($first: Int, $after: String, $name: String, $key1: String, $key2: String, $orderBy: [SchemaOrderField!]) {
|
|
1104
|
+
schemas(first: $first, after: $after, name: $name, key1: $key1, key2: $key2, orderBy: $orderBy) {
|
|
1085
1105
|
edges {
|
|
1086
1106
|
cursor
|
|
1087
1107
|
node {
|
|
@@ -1099,10 +1119,9 @@ var SuiIndexerClient = class {
|
|
|
1099
1119
|
}
|
|
1100
1120
|
pageInfo {
|
|
1101
1121
|
hasNextPage
|
|
1102
|
-
hasPreviousPage
|
|
1103
|
-
startCursor
|
|
1104
1122
|
endCursor
|
|
1105
1123
|
}
|
|
1124
|
+
totalCount
|
|
1106
1125
|
}
|
|
1107
1126
|
}
|
|
1108
1127
|
`;
|
|
@@ -1111,8 +1130,8 @@ var SuiIndexerClient = class {
|
|
|
1111
1130
|
}
|
|
1112
1131
|
async getEvents(params) {
|
|
1113
1132
|
const query = `
|
|
1114
|
-
query GetEvents($first: Int, $after: String, $
|
|
1115
|
-
events(first: $first, after: $after,
|
|
1133
|
+
query GetEvents($first: Int, $after: String, $name: String, $checkpoint: String, $orderBy: [EventOrderField!]) {
|
|
1134
|
+
events(first: $first, after: $after, name: $name, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
1116
1135
|
edges {
|
|
1117
1136
|
cursor
|
|
1118
1137
|
node {
|
|
@@ -1126,10 +1145,9 @@ var SuiIndexerClient = class {
|
|
|
1126
1145
|
}
|
|
1127
1146
|
pageInfo {
|
|
1128
1147
|
hasNextPage
|
|
1129
|
-
hasPreviousPage
|
|
1130
|
-
startCursor
|
|
1131
1148
|
endCursor
|
|
1132
1149
|
}
|
|
1150
|
+
totalCount
|
|
1133
1151
|
}
|
|
1134
1152
|
}
|
|
1135
1153
|
`;
|
|
@@ -1142,10 +1160,7 @@ var SuiIndexerClient = class {
|
|
|
1142
1160
|
key2,
|
|
1143
1161
|
first,
|
|
1144
1162
|
after,
|
|
1145
|
-
|
|
1146
|
-
before,
|
|
1147
|
-
orderBy,
|
|
1148
|
-
distinct
|
|
1163
|
+
orderBy
|
|
1149
1164
|
}) {
|
|
1150
1165
|
const schemas = await this.getSchemas({
|
|
1151
1166
|
name,
|
|
@@ -1153,12 +1168,37 @@ var SuiIndexerClient = class {
|
|
|
1153
1168
|
key2,
|
|
1154
1169
|
first,
|
|
1155
1170
|
after,
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1171
|
+
orderBy
|
|
1172
|
+
});
|
|
1173
|
+
const data = schemas.edges.map((edge) => edge.node);
|
|
1174
|
+
const value = data.map((item) => parseValue(item.value));
|
|
1175
|
+
return {
|
|
1176
|
+
data,
|
|
1177
|
+
value,
|
|
1178
|
+
pageInfo: schemas.pageInfo,
|
|
1179
|
+
totalCount: schemas.totalCount
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
async getStorageItem({
|
|
1183
|
+
name,
|
|
1184
|
+
key1,
|
|
1185
|
+
key2
|
|
1186
|
+
}) {
|
|
1187
|
+
const schemas = await this.getSchemas({
|
|
1188
|
+
name,
|
|
1189
|
+
key1,
|
|
1190
|
+
key2,
|
|
1191
|
+
first: 1
|
|
1160
1192
|
});
|
|
1161
|
-
|
|
1193
|
+
const data = schemas.edges[0]?.node;
|
|
1194
|
+
if (!data) {
|
|
1195
|
+
return void 0;
|
|
1196
|
+
}
|
|
1197
|
+
const value = parseValue(data.value);
|
|
1198
|
+
return {
|
|
1199
|
+
data,
|
|
1200
|
+
value
|
|
1201
|
+
};
|
|
1162
1202
|
}
|
|
1163
1203
|
async subscribe(names, handleData) {
|
|
1164
1204
|
return this.http.subscribe(names, handleData);
|
|
@@ -2149,16 +2189,48 @@ var Dubhe = class {
|
|
|
2149
2189
|
params: processedParams
|
|
2150
2190
|
});
|
|
2151
2191
|
}
|
|
2192
|
+
async getTransactions({
|
|
2193
|
+
first,
|
|
2194
|
+
after,
|
|
2195
|
+
orderBy
|
|
2196
|
+
}) {
|
|
2197
|
+
return await this.suiIndexerClient.getTransactions({
|
|
2198
|
+
first,
|
|
2199
|
+
after,
|
|
2200
|
+
orderBy
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
async getEvents({
|
|
2204
|
+
first,
|
|
2205
|
+
after,
|
|
2206
|
+
orderBy
|
|
2207
|
+
}) {
|
|
2208
|
+
return await this.suiIndexerClient.getEvents({ first, after, orderBy });
|
|
2209
|
+
}
|
|
2210
|
+
async getSchemas({
|
|
2211
|
+
name,
|
|
2212
|
+
key1,
|
|
2213
|
+
key2,
|
|
2214
|
+
first,
|
|
2215
|
+
after,
|
|
2216
|
+
orderBy
|
|
2217
|
+
}) {
|
|
2218
|
+
return await this.suiIndexerClient.getSchemas({
|
|
2219
|
+
name,
|
|
2220
|
+
key1,
|
|
2221
|
+
key2,
|
|
2222
|
+
first,
|
|
2223
|
+
after,
|
|
2224
|
+
orderBy
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2152
2227
|
async getStorage({
|
|
2153
2228
|
name,
|
|
2154
2229
|
key1,
|
|
2155
2230
|
key2,
|
|
2156
2231
|
first,
|
|
2157
2232
|
after,
|
|
2158
|
-
|
|
2159
|
-
before,
|
|
2160
|
-
orderBy,
|
|
2161
|
-
distinct
|
|
2233
|
+
orderBy
|
|
2162
2234
|
}) {
|
|
2163
2235
|
return await this.suiIndexerClient.getStorage({
|
|
2164
2236
|
name,
|
|
@@ -2166,11 +2238,20 @@ var Dubhe = class {
|
|
|
2166
2238
|
key2,
|
|
2167
2239
|
first,
|
|
2168
2240
|
after,
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2241
|
+
orderBy
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
async getStorageItem({
|
|
2245
|
+
name,
|
|
2246
|
+
key1,
|
|
2247
|
+
key2
|
|
2248
|
+
}) {
|
|
2249
|
+
const response = await this.suiIndexerClient.getStorageItem({
|
|
2250
|
+
name,
|
|
2251
|
+
key1,
|
|
2252
|
+
key2
|
|
2173
2253
|
});
|
|
2254
|
+
return response;
|
|
2174
2255
|
}
|
|
2175
2256
|
async subscribe(names, handleData) {
|
|
2176
2257
|
return this.suiIndexerClient.subscribe(names, handleData);
|