@iota/graphql-transport 0.1.0
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/CHANGELOG.md +13 -0
- package/LICENSE +201 -0
- package/README.md +100 -0
- package/dist/cjs/generated/queries.d.ts +9134 -0
- package/dist/cjs/generated/queries.js +3530 -0
- package/dist/cjs/generated/queries.js.map +7 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/mappers/bcs.d.ts +4 -0
- package/dist/cjs/mappers/bcs.js +71 -0
- package/dist/cjs/mappers/bcs.js.map +7 -0
- package/dist/cjs/mappers/checkpint.d.ts +3 -0
- package/dist/cjs/mappers/checkpint.js +63 -0
- package/dist/cjs/mappers/checkpint.js.map +7 -0
- package/dist/cjs/mappers/display.d.ts +8 -0
- package/dist/cjs/mappers/display.js +43 -0
- package/dist/cjs/mappers/display.js.map +7 -0
- package/dist/cjs/mappers/move.d.ts +57 -0
- package/dist/cjs/mappers/move.js +215 -0
- package/dist/cjs/mappers/move.js.map +7 -0
- package/dist/cjs/mappers/object.d.ts +8 -0
- package/dist/cjs/mappers/object.js +80 -0
- package/dist/cjs/mappers/object.js.map +7 -0
- package/dist/cjs/mappers/owner.d.ts +3 -0
- package/dist/cjs/mappers/owner.js +48 -0
- package/dist/cjs/mappers/owner.js.map +7 -0
- package/dist/cjs/mappers/stakes.d.ts +3 -0
- package/dist/cjs/mappers/stakes.js +48 -0
- package/dist/cjs/mappers/stakes.js.map +7 -0
- package/dist/cjs/mappers/transaction-block.d.ts +6 -0
- package/dist/cjs/mappers/transaction-block.js +314 -0
- package/dist/cjs/mappers/transaction-block.js.map +7 -0
- package/dist/cjs/mappers/util.d.ts +2 -0
- package/dist/cjs/mappers/util.js +31 -0
- package/dist/cjs/mappers/util.js.map +7 -0
- package/dist/cjs/mappers/validator.d.ts +3 -0
- package/dist/cjs/mappers/validator.js +66 -0
- package/dist/cjs/mappers/validator.js.map +7 -0
- package/dist/cjs/methods.d.ts +19 -0
- package/dist/cjs/methods.js +1276 -0
- package/dist/cjs/methods.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/transport.d.ts +43 -0
- package/dist/cjs/transport.js +153 -0
- package/dist/cjs/transport.js.map +7 -0
- package/dist/esm/generated/queries.d.ts +9134 -0
- package/dist/esm/generated/queries.js +3510 -0
- package/dist/esm/generated/queries.js.map +7 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/mappers/bcs.d.ts +4 -0
- package/dist/esm/mappers/bcs.js +51 -0
- package/dist/esm/mappers/bcs.js.map +7 -0
- package/dist/esm/mappers/checkpint.d.ts +3 -0
- package/dist/esm/mappers/checkpint.js +43 -0
- package/dist/esm/mappers/checkpint.js.map +7 -0
- package/dist/esm/mappers/display.d.ts +8 -0
- package/dist/esm/mappers/display.js +23 -0
- package/dist/esm/mappers/display.js.map +7 -0
- package/dist/esm/mappers/move.d.ts +57 -0
- package/dist/esm/mappers/move.js +195 -0
- package/dist/esm/mappers/move.js.map +7 -0
- package/dist/esm/mappers/object.d.ts +8 -0
- package/dist/esm/mappers/object.js +60 -0
- package/dist/esm/mappers/object.js.map +7 -0
- package/dist/esm/mappers/owner.d.ts +3 -0
- package/dist/esm/mappers/owner.js +28 -0
- package/dist/esm/mappers/owner.js.map +7 -0
- package/dist/esm/mappers/stakes.d.ts +3 -0
- package/dist/esm/mappers/stakes.js +28 -0
- package/dist/esm/mappers/stakes.js.map +7 -0
- package/dist/esm/mappers/transaction-block.d.ts +6 -0
- package/dist/esm/mappers/transaction-block.js +294 -0
- package/dist/esm/mappers/transaction-block.js.map +7 -0
- package/dist/esm/mappers/util.d.ts +2 -0
- package/dist/esm/mappers/util.js +11 -0
- package/dist/esm/mappers/util.js.map +7 -0
- package/dist/esm/mappers/validator.d.ts +3 -0
- package/dist/esm/mappers/validator.js +46 -0
- package/dist/esm/mappers/validator.js.map +7 -0
- package/dist/esm/methods.d.ts +19 -0
- package/dist/esm/methods.js +1306 -0
- package/dist/esm/methods.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/transport.d.ts +43 -0
- package/dist/esm/transport.js +133 -0
- package/dist/esm/transport.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,1276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var methods_exports = {};
|
|
20
|
+
__export(methods_exports, {
|
|
21
|
+
RPC_METHODS: () => RPC_METHODS,
|
|
22
|
+
UnsupportedMethodError: () => UnsupportedMethodError,
|
|
23
|
+
UnsupportedParamError: () => UnsupportedParamError
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(methods_exports);
|
|
26
|
+
var import_bcs = require("@iota/bcs");
|
|
27
|
+
var import_transactions = require("@iota/iota-sdk/transactions");
|
|
28
|
+
var import_utils = require("@iota/iota-sdk/utils");
|
|
29
|
+
var import_queries = require("./generated/queries.js");
|
|
30
|
+
var import_bcs2 = require("./mappers/bcs.js");
|
|
31
|
+
var import_checkpint = require("./mappers/checkpint.js");
|
|
32
|
+
var import_move = require("./mappers/move.js");
|
|
33
|
+
var import_object = require("./mappers/object.js");
|
|
34
|
+
var import_stakes = require("./mappers/stakes.js");
|
|
35
|
+
var import_transaction_block = require("./mappers/transaction-block.js");
|
|
36
|
+
var import_util = require("./mappers/util.js");
|
|
37
|
+
var import_validator = require("./mappers/validator.js");
|
|
38
|
+
const RPC_METHODS = {
|
|
39
|
+
async getRpcApiVersion(transport) {
|
|
40
|
+
const res = await transport.graphqlRequest({
|
|
41
|
+
query: "query { __typename }",
|
|
42
|
+
variables: {}
|
|
43
|
+
});
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
throw new Error("Failed to fetch");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
info: {
|
|
49
|
+
version: res.headers.get("x-iota-rpc-version") ?? void 0
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
async getCoins(transport, [owner, coinType, cursor, limit]) {
|
|
54
|
+
const { nodes: coins, pageInfo } = await transport.graphqlQuery(
|
|
55
|
+
{
|
|
56
|
+
query: import_queries.GetCoinsDocument,
|
|
57
|
+
variables: {
|
|
58
|
+
owner,
|
|
59
|
+
type: coinType,
|
|
60
|
+
cursor,
|
|
61
|
+
first: limit
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
(data) => data.address?.coins
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
data: coins.map((coin) => ({
|
|
68
|
+
balance: coin.coinBalance,
|
|
69
|
+
coinObjectId: coin.address,
|
|
70
|
+
coinType: (0, import_util.toShortTypeString)(
|
|
71
|
+
(0, import_utils.normalizeStructTag)((0, import_utils.parseStructTag)(coin.contents?.type.repr).typeParams[0])
|
|
72
|
+
),
|
|
73
|
+
digest: coin.digest,
|
|
74
|
+
previousTransaction: coin.previousTransactionBlock?.digest,
|
|
75
|
+
version: String(coin.version)
|
|
76
|
+
})),
|
|
77
|
+
nextCursor: pageInfo.endCursor,
|
|
78
|
+
hasNextPage: pageInfo.hasNextPage
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
async getAllCoins(transport, inputs) {
|
|
82
|
+
const { nodes: coins, pageInfo } = await transport.graphqlQuery(
|
|
83
|
+
{
|
|
84
|
+
query: import_queries.GetCoinsDocument,
|
|
85
|
+
variables: {
|
|
86
|
+
owner: inputs[0],
|
|
87
|
+
cursor: inputs[1],
|
|
88
|
+
first: inputs[2]
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
(data) => data.address?.coins
|
|
92
|
+
);
|
|
93
|
+
return {
|
|
94
|
+
data: coins.map((coin) => ({
|
|
95
|
+
balance: coin.coinBalance,
|
|
96
|
+
coinObjectId: coin.address,
|
|
97
|
+
coinType: (0, import_util.toShortTypeString)(
|
|
98
|
+
(0, import_utils.normalizeStructTag)((0, import_utils.parseStructTag)(coin.contents?.type.repr).typeParams[0])
|
|
99
|
+
),
|
|
100
|
+
digest: coin.digest,
|
|
101
|
+
previousTransaction: coin.previousTransactionBlock?.digest,
|
|
102
|
+
version: String(coin.version)
|
|
103
|
+
})),
|
|
104
|
+
nextCursor: pageInfo.endCursor,
|
|
105
|
+
hasNextPage: pageInfo.hasNextPage
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
async getBalance(transport, inputs) {
|
|
109
|
+
const balance = await transport.graphqlQuery(
|
|
110
|
+
{
|
|
111
|
+
query: import_queries.GetBalanceDocument,
|
|
112
|
+
variables: {
|
|
113
|
+
owner: inputs[0],
|
|
114
|
+
type: inputs[1]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
(data) => data.address?.balance
|
|
118
|
+
);
|
|
119
|
+
return {
|
|
120
|
+
coinType: (0, import_util.toShortTypeString)(balance.coinType?.repr),
|
|
121
|
+
coinObjectCount: balance.coinObjectCount,
|
|
122
|
+
totalBalance: balance.totalBalance,
|
|
123
|
+
lockedBalance: {}
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
async getAllBalances(transport, inputs) {
|
|
127
|
+
const balances = await transport.graphqlQuery(
|
|
128
|
+
{
|
|
129
|
+
query: import_queries.GetAllBalancesDocument,
|
|
130
|
+
variables: {
|
|
131
|
+
owner: inputs[0]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
(data) => data.address?.balances?.nodes
|
|
135
|
+
);
|
|
136
|
+
return balances.map((balance) => ({
|
|
137
|
+
coinType: (0, import_util.toShortTypeString)(balance.coinType?.repr),
|
|
138
|
+
coinObjectCount: balance.coinObjectCount,
|
|
139
|
+
totalBalance: balance.totalBalance,
|
|
140
|
+
lockedBalance: {}
|
|
141
|
+
}));
|
|
142
|
+
},
|
|
143
|
+
async getCoinMetadata(transport, inputs) {
|
|
144
|
+
const metadata = await transport.graphqlQuery(
|
|
145
|
+
{
|
|
146
|
+
query: import_queries.GetCoinMetadataDocument,
|
|
147
|
+
variables: {
|
|
148
|
+
coinType: inputs[0]
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
(data) => data.coinMetadata
|
|
152
|
+
);
|
|
153
|
+
return {
|
|
154
|
+
decimals: metadata.decimals,
|
|
155
|
+
name: metadata.name,
|
|
156
|
+
symbol: metadata.symbol,
|
|
157
|
+
description: metadata.description,
|
|
158
|
+
iconUrl: metadata.iconUrl,
|
|
159
|
+
id: metadata.address
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
async getTotalSupply(transport, inputs) {
|
|
163
|
+
const metadata = await transport.graphqlQuery(
|
|
164
|
+
{
|
|
165
|
+
query: import_queries.GetTotalSupplyDocument,
|
|
166
|
+
variables: {
|
|
167
|
+
coinType: inputs[0]
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
(data) => data.coinMetadata
|
|
171
|
+
);
|
|
172
|
+
return {
|
|
173
|
+
value: BigInt(metadata.supply).toString()
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
async getMoveFunctionArgTypes(transport, [pkg, module2, fn]) {
|
|
177
|
+
const moveModule = await transport.graphqlQuery(
|
|
178
|
+
{
|
|
179
|
+
query: import_queries.GetMoveFunctionArgTypesDocument,
|
|
180
|
+
variables: {
|
|
181
|
+
module: module2,
|
|
182
|
+
packageId: pkg,
|
|
183
|
+
function: fn
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
(data) => data.object?.asMovePackage?.module?.function?.parameters
|
|
187
|
+
);
|
|
188
|
+
return moveModule.map((parameter) => {
|
|
189
|
+
if (!parameter.signature.body.datatype) {
|
|
190
|
+
return "Pure";
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
Object: parameter.signature.ref === "&" ? "ByImmutableReference" : parameter.signature.ref === "&mut" ? "ByMutableReference" : "ByValue"
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
async getNormalizedMoveFunction(transport, [pkg, module2, fn]) {
|
|
198
|
+
const moveFunction = await transport.graphqlQuery(
|
|
199
|
+
{
|
|
200
|
+
query: import_queries.GetNormalizedMoveFunctionDocument,
|
|
201
|
+
variables: {
|
|
202
|
+
module: module2,
|
|
203
|
+
packageId: pkg,
|
|
204
|
+
function: fn
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
(data) => data.object?.asMovePackage?.module?.function
|
|
208
|
+
);
|
|
209
|
+
return (0, import_move.mapNormalizedMoveFunction)(moveFunction);
|
|
210
|
+
},
|
|
211
|
+
async getNormalizedMoveModulesByPackage(transport, [pkg]) {
|
|
212
|
+
const movePackage = await transport.graphqlQuery(
|
|
213
|
+
{
|
|
214
|
+
query: import_queries.GetNormalizedMoveModulesByPackageDocument,
|
|
215
|
+
variables: {
|
|
216
|
+
packageId: pkg
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
(data) => data.object?.asMovePackage
|
|
220
|
+
);
|
|
221
|
+
let hasNextPage = movePackage.modules?.pageInfo.hasNextPage ?? false;
|
|
222
|
+
let cursor = movePackage.modules?.pageInfo.endCursor;
|
|
223
|
+
while (hasNextPage) {
|
|
224
|
+
const page = await transport.graphqlQuery(
|
|
225
|
+
{
|
|
226
|
+
query: import_queries.GetNormalizedMoveModulesByPackageDocument,
|
|
227
|
+
variables: {
|
|
228
|
+
packageId: pkg,
|
|
229
|
+
cursor
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
(data) => data.object?.asMovePackage
|
|
233
|
+
);
|
|
234
|
+
movePackage.modules?.nodes.push(...page.modules?.nodes ?? []);
|
|
235
|
+
hasNextPage = page.modules?.pageInfo.hasNextPage ?? false;
|
|
236
|
+
cursor = page.modules?.pageInfo.endCursor;
|
|
237
|
+
}
|
|
238
|
+
const address = (0, import_util.toShortTypeString)(movePackage.address);
|
|
239
|
+
const modules = {};
|
|
240
|
+
for (const moveModule of movePackage.modules?.nodes ?? []) {
|
|
241
|
+
let hasMoreFriends = moveModule.friends?.pageInfo.hasNextPage ?? false;
|
|
242
|
+
let hasMoreFunctions = moveModule.functions?.pageInfo.hasNextPage ?? false;
|
|
243
|
+
let hasMoreStructs = moveModule.structs?.pageInfo.hasNextPage ?? false;
|
|
244
|
+
let afterFriends = moveModule.friends?.pageInfo.endCursor;
|
|
245
|
+
let afterFunctions = moveModule.functions?.pageInfo.endCursor;
|
|
246
|
+
let afterStructs = moveModule.structs?.pageInfo.endCursor;
|
|
247
|
+
while (hasMoreFriends || hasMoreStructs || hasMoreFunctions) {
|
|
248
|
+
const page = await transport.graphqlQuery(
|
|
249
|
+
{
|
|
250
|
+
query: import_queries.PaginateMoveModuleListsDocument,
|
|
251
|
+
variables: {
|
|
252
|
+
module: moveModule.name,
|
|
253
|
+
packageId: pkg,
|
|
254
|
+
hasMoreFriends,
|
|
255
|
+
hasMoreFunctions,
|
|
256
|
+
hasMoreStructs,
|
|
257
|
+
afterFriends,
|
|
258
|
+
afterFunctions,
|
|
259
|
+
afterStructs
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
(data) => data.object?.asMovePackage?.module
|
|
263
|
+
);
|
|
264
|
+
moveModule.friends.nodes.push(...page.friends?.nodes ?? []);
|
|
265
|
+
moveModule.functions?.nodes.push(...page.functions?.nodes ?? []);
|
|
266
|
+
moveModule.structs?.nodes.push(...page.structs?.nodes ?? []);
|
|
267
|
+
hasMoreFriends = page.friends?.pageInfo.hasNextPage ?? false;
|
|
268
|
+
hasMoreFunctions = page.functions?.pageInfo.hasNextPage ?? false;
|
|
269
|
+
hasMoreStructs = page.structs?.pageInfo.hasNextPage ?? false;
|
|
270
|
+
afterFriends = page.friends?.pageInfo.endCursor;
|
|
271
|
+
afterFunctions = page.functions?.pageInfo.endCursor;
|
|
272
|
+
afterStructs = page.structs?.pageInfo.endCursor;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
movePackage.modules?.nodes.forEach((module2) => {
|
|
276
|
+
modules[module2.name] = (0, import_move.mapNormalizedMoveModule)(module2, address);
|
|
277
|
+
});
|
|
278
|
+
return modules;
|
|
279
|
+
},
|
|
280
|
+
async getNormalizedMoveModule(transport, [pkg, module2]) {
|
|
281
|
+
const moveModule = await transport.graphqlQuery(
|
|
282
|
+
{
|
|
283
|
+
query: import_queries.GetNormalizedMoveModuleDocument,
|
|
284
|
+
variables: {
|
|
285
|
+
module: module2,
|
|
286
|
+
packageId: pkg
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
(data) => data.object?.asMovePackage?.module
|
|
290
|
+
);
|
|
291
|
+
let hasMoreFriends = moveModule.friends?.pageInfo.hasNextPage ?? false;
|
|
292
|
+
let hasMoreFunctions = moveModule.functions?.pageInfo.hasNextPage ?? false;
|
|
293
|
+
let hasMoreStructs = moveModule.structs?.pageInfo.hasNextPage ?? false;
|
|
294
|
+
let afterFriends = moveModule.friends?.pageInfo.endCursor;
|
|
295
|
+
let afterFunctions = moveModule.functions?.pageInfo.endCursor;
|
|
296
|
+
let afterStructs = moveModule.structs?.pageInfo.endCursor;
|
|
297
|
+
while (hasMoreFriends || hasMoreStructs || hasMoreFunctions) {
|
|
298
|
+
const page = await transport.graphqlQuery(
|
|
299
|
+
{
|
|
300
|
+
query: import_queries.PaginateMoveModuleListsDocument,
|
|
301
|
+
variables: {
|
|
302
|
+
module: module2,
|
|
303
|
+
packageId: pkg,
|
|
304
|
+
hasMoreFriends,
|
|
305
|
+
hasMoreFunctions,
|
|
306
|
+
hasMoreStructs,
|
|
307
|
+
afterFriends,
|
|
308
|
+
afterFunctions,
|
|
309
|
+
afterStructs
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
(data) => data.object?.asMovePackage?.module
|
|
313
|
+
);
|
|
314
|
+
moveModule.friends.nodes.push(...page.friends?.nodes ?? []);
|
|
315
|
+
moveModule.functions?.nodes.push(...page.functions?.nodes ?? []);
|
|
316
|
+
moveModule.structs?.nodes.push(...page.structs?.nodes ?? []);
|
|
317
|
+
hasMoreFriends = page.friends?.pageInfo.hasNextPage ?? false;
|
|
318
|
+
hasMoreFunctions = page.functions?.pageInfo.hasNextPage ?? false;
|
|
319
|
+
hasMoreStructs = page.structs?.pageInfo.hasNextPage ?? false;
|
|
320
|
+
afterFriends = page.friends?.pageInfo.endCursor;
|
|
321
|
+
afterFunctions = page.functions?.pageInfo.endCursor;
|
|
322
|
+
afterStructs = page.structs?.pageInfo.endCursor;
|
|
323
|
+
}
|
|
324
|
+
return (0, import_move.mapNormalizedMoveModule)(moveModule, (0, import_utils.normalizeIotaAddress)(pkg));
|
|
325
|
+
},
|
|
326
|
+
async getNormalizedMoveStruct(transport, [pkg, module2, struct]) {
|
|
327
|
+
const moveStruct = await transport.graphqlQuery(
|
|
328
|
+
{
|
|
329
|
+
query: import_queries.GetNormalizedMoveStructDocument,
|
|
330
|
+
variables: {
|
|
331
|
+
packageId: pkg,
|
|
332
|
+
module: module2,
|
|
333
|
+
struct
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
(data) => data.object?.asMovePackage?.module?.struct
|
|
337
|
+
);
|
|
338
|
+
return (0, import_move.mapNormalizedMoveStruct)(moveStruct);
|
|
339
|
+
},
|
|
340
|
+
async getOwnedObjects(transport, [owner, { filter: inputFilter, options }, cursor, limit]) {
|
|
341
|
+
let filter;
|
|
342
|
+
let typeFilter;
|
|
343
|
+
if (inputFilter) {
|
|
344
|
+
if ("Package" in inputFilter) {
|
|
345
|
+
typeFilter = inputFilter.Package;
|
|
346
|
+
} else if ("MoveModule" in inputFilter) {
|
|
347
|
+
typeFilter = `${inputFilter.MoveModule.package}::${inputFilter.MoveModule.module}`;
|
|
348
|
+
} else if ("StructType" in inputFilter) {
|
|
349
|
+
typeFilter = inputFilter.StructType;
|
|
350
|
+
}
|
|
351
|
+
filter = {
|
|
352
|
+
objectIds: "ObjectIds" in inputFilter ? inputFilter.ObjectIds : "ObjectId" in inputFilter ? [inputFilter.ObjectId] : void 0,
|
|
353
|
+
type: typeFilter,
|
|
354
|
+
owner: "ObjectOwner" in inputFilter ? inputFilter.ObjectOwner : "AddressOwner" in inputFilter ? inputFilter.AddressOwner : void 0
|
|
355
|
+
};
|
|
356
|
+
const unsupportedFilters = ["MatchAll", "MatchAny", "MatchNone", "Version"];
|
|
357
|
+
for (const unsupportedFilter of unsupportedFilters) {
|
|
358
|
+
if (unsupportedFilter in inputFilter) {
|
|
359
|
+
throw new UnsupportedParamError("getOwnedObjects", unsupportedFilter);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const { nodes: objects, pageInfo } = await transport.graphqlQuery(
|
|
364
|
+
{
|
|
365
|
+
query: import_queries.GetOwnedObjectsDocument,
|
|
366
|
+
variables: {
|
|
367
|
+
owner,
|
|
368
|
+
limit,
|
|
369
|
+
cursor,
|
|
370
|
+
showBcs: options?.showBcs,
|
|
371
|
+
showContent: options?.showContent,
|
|
372
|
+
showOwner: options?.showOwner,
|
|
373
|
+
showPreviousTransaction: options?.showPreviousTransaction,
|
|
374
|
+
showStorageRebate: options?.showStorageRebate,
|
|
375
|
+
showType: options?.showType,
|
|
376
|
+
filter
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
(data) => data.address?.objects
|
|
380
|
+
);
|
|
381
|
+
return {
|
|
382
|
+
hasNextPage: pageInfo.hasNextPage,
|
|
383
|
+
nextCursor: pageInfo.endCursor,
|
|
384
|
+
data: objects.map((object) => ({
|
|
385
|
+
data: (0, import_object.mapGraphQLMoveObjectToRpcObject)(object, options ?? {})
|
|
386
|
+
}))
|
|
387
|
+
};
|
|
388
|
+
},
|
|
389
|
+
async getObject(transport, [id, options]) {
|
|
390
|
+
const object = await transport.graphqlQuery(
|
|
391
|
+
{
|
|
392
|
+
query: import_queries.GetObjectDocument,
|
|
393
|
+
variables: {
|
|
394
|
+
id,
|
|
395
|
+
showBcs: options?.showBcs,
|
|
396
|
+
showContent: options?.showContent,
|
|
397
|
+
showOwner: options?.showOwner,
|
|
398
|
+
showPreviousTransaction: options?.showPreviousTransaction,
|
|
399
|
+
showStorageRebate: options?.showStorageRebate,
|
|
400
|
+
showType: options?.showType
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
(data) => data.object
|
|
404
|
+
);
|
|
405
|
+
return {
|
|
406
|
+
data: (0, import_object.mapGraphQLObjectToRpcObject)(object, options ?? {})
|
|
407
|
+
};
|
|
408
|
+
},
|
|
409
|
+
async tryGetPastObject(transport, [id, version, options]) {
|
|
410
|
+
const data = await transport.graphqlQuery({
|
|
411
|
+
query: import_queries.TryGetPastObjectDocument,
|
|
412
|
+
variables: {
|
|
413
|
+
id,
|
|
414
|
+
version,
|
|
415
|
+
showBcs: options?.showBcs,
|
|
416
|
+
showContent: options?.showContent,
|
|
417
|
+
showOwner: options?.showOwner,
|
|
418
|
+
showPreviousTransaction: options?.showPreviousTransaction,
|
|
419
|
+
showStorageRebate: options?.showStorageRebate,
|
|
420
|
+
showType: options?.showType
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
if (!data.current) {
|
|
424
|
+
return {
|
|
425
|
+
details: "Could not find the referenced object",
|
|
426
|
+
status: "ObjectNotExists"
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (!data.object) {
|
|
430
|
+
return data.current.version < Number(version) ? {
|
|
431
|
+
status: "VersionTooHigh",
|
|
432
|
+
details: {
|
|
433
|
+
asked_version: String(version),
|
|
434
|
+
latest_version: String(data.current.version),
|
|
435
|
+
object_id: data.current.address
|
|
436
|
+
}
|
|
437
|
+
} : {
|
|
438
|
+
status: "VersionNotFound",
|
|
439
|
+
details: [data.current.address, String(version)]
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
status: "VersionFound",
|
|
444
|
+
details: (0, import_object.mapGraphQLObjectToRpcObject)(data.object, options ?? {})
|
|
445
|
+
};
|
|
446
|
+
},
|
|
447
|
+
async multiGetObjects(transport, [ids, options]) {
|
|
448
|
+
const objects = await transport.graphqlQuery(
|
|
449
|
+
{
|
|
450
|
+
query: import_queries.MultiGetObjectsDocument,
|
|
451
|
+
variables: {
|
|
452
|
+
ids,
|
|
453
|
+
showBcs: options?.showBcs,
|
|
454
|
+
showContent: options?.showContent,
|
|
455
|
+
showOwner: options?.showOwner,
|
|
456
|
+
showPreviousTransaction: options?.showPreviousTransaction,
|
|
457
|
+
showStorageRebate: options?.showStorageRebate,
|
|
458
|
+
showType: options?.showType,
|
|
459
|
+
limit: ids.length
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
(data) => data.objects?.nodes
|
|
463
|
+
);
|
|
464
|
+
return objects.map((object) => ({
|
|
465
|
+
data: (0, import_object.mapGraphQLObjectToRpcObject)(object, options ?? {})
|
|
466
|
+
}));
|
|
467
|
+
},
|
|
468
|
+
async queryTransactionBlocks(transport, [{ filter, options }, cursor, limit = 20, descending]) {
|
|
469
|
+
const pagination = descending ? {
|
|
470
|
+
last: limit,
|
|
471
|
+
before: cursor
|
|
472
|
+
} : {
|
|
473
|
+
first: limit,
|
|
474
|
+
after: cursor
|
|
475
|
+
};
|
|
476
|
+
const unsupportedFilters = ["FromOrToAddress", "FromAndToAddress", "TransactionKindIn"];
|
|
477
|
+
if (filter) {
|
|
478
|
+
for (const unsupportedFilter of unsupportedFilters) {
|
|
479
|
+
if (unsupportedFilter in filter) {
|
|
480
|
+
throw new UnsupportedParamError("queryTransactionBlocks", unsupportedFilter);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const { nodes: transactionBlocks, pageInfo } = await transport.graphqlQuery(
|
|
485
|
+
{
|
|
486
|
+
query: import_queries.QueryTransactionBlocksDocument,
|
|
487
|
+
variables: {
|
|
488
|
+
...pagination,
|
|
489
|
+
showBalanceChanges: options?.showBalanceChanges,
|
|
490
|
+
showEffects: options?.showEffects,
|
|
491
|
+
showObjectChanges: options?.showObjectChanges,
|
|
492
|
+
showRawInput: options?.showRawInput,
|
|
493
|
+
showInput: options?.showInput,
|
|
494
|
+
filter: filter ? {
|
|
495
|
+
atCheckpoint: "Checkpoint" in filter ? Number.parseInt(filter.Checkpoint) : void 0,
|
|
496
|
+
function: "MoveFunction" in filter ? `${filter.MoveFunction.package}::${filter.MoveFunction.module}::${filter.MoveFunction.function}` : void 0,
|
|
497
|
+
inputObject: "InputObject" in filter ? filter.InputObject : void 0,
|
|
498
|
+
changedObject: "ChangedObject" in filter ? filter.ChangedObject : void 0,
|
|
499
|
+
signAddress: "FromAddress" in filter ? filter.FromAddress : void 0,
|
|
500
|
+
recvAddress: "ToAddress" in filter ? filter.ToAddress : void 0,
|
|
501
|
+
kind: "TransactionKind" in filter ? filter.TransactionKind === "ProgrammableTransaction" ? import_queries.TransactionBlockKindInput.ProgrammableTx : import_queries.TransactionBlockKindInput.SystemTx : void 0
|
|
502
|
+
} : {}
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
(data) => data.transactionBlocks
|
|
506
|
+
);
|
|
507
|
+
for (const transactionBlock of transactionBlocks) {
|
|
508
|
+
await paginateTransactionBlockLists(transport, transactionBlock);
|
|
509
|
+
}
|
|
510
|
+
if (pagination.last) {
|
|
511
|
+
transactionBlocks.reverse();
|
|
512
|
+
}
|
|
513
|
+
return {
|
|
514
|
+
hasNextPage: pagination.last ? pageInfo.hasPreviousPage : pageInfo.hasNextPage,
|
|
515
|
+
nextCursor: pagination.last ? pageInfo.startCursor : pageInfo.endCursor,
|
|
516
|
+
data: transactionBlocks.map(
|
|
517
|
+
(transactionBlock) => (0, import_transaction_block.mapGraphQLTransactionBlockToRpcTransactionBlock)(transactionBlock, options ?? {})
|
|
518
|
+
)
|
|
519
|
+
};
|
|
520
|
+
},
|
|
521
|
+
async getTransactionBlock(transport, [digest, options]) {
|
|
522
|
+
const transactionBlock = await transport.graphqlQuery(
|
|
523
|
+
{
|
|
524
|
+
query: import_queries.GetTransactionBlockDocument,
|
|
525
|
+
variables: {
|
|
526
|
+
digest,
|
|
527
|
+
showBalanceChanges: options?.showBalanceChanges,
|
|
528
|
+
showEffects: options?.showEffects,
|
|
529
|
+
showObjectChanges: options?.showObjectChanges,
|
|
530
|
+
showRawInput: options?.showRawInput,
|
|
531
|
+
showInput: options?.showInput
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
(data) => data.transactionBlock
|
|
535
|
+
);
|
|
536
|
+
await paginateTransactionBlockLists(transport, transactionBlock);
|
|
537
|
+
return (0, import_transaction_block.mapGraphQLTransactionBlockToRpcTransactionBlock)(transactionBlock, options);
|
|
538
|
+
},
|
|
539
|
+
async multiGetTransactionBlocks(transport, [digests, options]) {
|
|
540
|
+
const transactionBlocks = await transport.graphqlQuery(
|
|
541
|
+
{
|
|
542
|
+
query: import_queries.MultiGetTransactionBlocksDocument,
|
|
543
|
+
variables: {
|
|
544
|
+
digests,
|
|
545
|
+
showBalanceChanges: options?.showBalanceChanges,
|
|
546
|
+
showEffects: options?.showEffects,
|
|
547
|
+
showObjectChanges: options?.showObjectChanges,
|
|
548
|
+
showRawInput: options?.showRawInput,
|
|
549
|
+
showInput: options?.showInput,
|
|
550
|
+
limit: digests.length
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
(data) => data.transactionBlocks?.nodes
|
|
554
|
+
);
|
|
555
|
+
for (const transactionBlock of transactionBlocks) {
|
|
556
|
+
await paginateTransactionBlockLists(transport, transactionBlock);
|
|
557
|
+
}
|
|
558
|
+
return transactionBlocks.map(
|
|
559
|
+
(transactionBlock) => (0, import_transaction_block.mapGraphQLTransactionBlockToRpcTransactionBlock)(transactionBlock, options)
|
|
560
|
+
);
|
|
561
|
+
},
|
|
562
|
+
async getTotalTransactionBlocks(transport) {
|
|
563
|
+
return transport.graphqlQuery(
|
|
564
|
+
{
|
|
565
|
+
query: import_queries.GetTotalTransactionBlocksDocument
|
|
566
|
+
},
|
|
567
|
+
(data) => BigInt(data.checkpoint?.networkTotalTransactions)
|
|
568
|
+
);
|
|
569
|
+
},
|
|
570
|
+
async getReferenceGasPrice(transport) {
|
|
571
|
+
const epoch = await transport.graphqlQuery(
|
|
572
|
+
{
|
|
573
|
+
query: import_queries.GetReferenceGasPriceDocument,
|
|
574
|
+
variables: {}
|
|
575
|
+
},
|
|
576
|
+
(data) => data.epoch
|
|
577
|
+
);
|
|
578
|
+
return BigInt(epoch.referenceGasPrice);
|
|
579
|
+
},
|
|
580
|
+
async getStakes(transport, [owner]) {
|
|
581
|
+
const stakes = await transport.graphqlQuery(
|
|
582
|
+
{
|
|
583
|
+
query: import_queries.GetStakesDocument,
|
|
584
|
+
variables: {
|
|
585
|
+
owner
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
(data) => data.address?.stakedIotas?.nodes
|
|
589
|
+
);
|
|
590
|
+
return (0, import_stakes.mapGraphQLStakeToRpcStake)(stakes);
|
|
591
|
+
},
|
|
592
|
+
async getStakesByIds(transport, [stakedIotaIds]) {
|
|
593
|
+
const stakes = await transport.graphqlQuery(
|
|
594
|
+
{
|
|
595
|
+
query: import_queries.GetStakesByIdsDocument,
|
|
596
|
+
variables: {
|
|
597
|
+
ids: stakedIotaIds
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
(data) => data.objects?.nodes.map((node) => node?.asMoveObject?.asStakedIota).filter(Boolean)
|
|
601
|
+
);
|
|
602
|
+
return (0, import_stakes.mapGraphQLStakeToRpcStake)(stakes);
|
|
603
|
+
},
|
|
604
|
+
async getLatestIotaSystemState(transport) {
|
|
605
|
+
const systemState = await transport.graphqlQuery(
|
|
606
|
+
{
|
|
607
|
+
query: import_queries.GetLatestIotaSystemStateDocument
|
|
608
|
+
},
|
|
609
|
+
(data) => data.epoch
|
|
610
|
+
);
|
|
611
|
+
let hasMoreValidators = systemState.validatorSet?.activeValidators?.pageInfo.hasNextPage ?? false;
|
|
612
|
+
let afterValidators = systemState.validatorSet?.activeValidators?.pageInfo.endCursor;
|
|
613
|
+
while (hasMoreValidators) {
|
|
614
|
+
const page = await transport.graphqlQuery(
|
|
615
|
+
{
|
|
616
|
+
query: import_queries.PaginateEpochValidatorsDocument,
|
|
617
|
+
variables: {
|
|
618
|
+
id: systemState.epochId,
|
|
619
|
+
after: afterValidators
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
(data) => data.epoch
|
|
623
|
+
);
|
|
624
|
+
systemState.validatorSet?.activeValidators?.nodes.push(
|
|
625
|
+
...page.validatorSet?.activeValidators?.nodes ?? []
|
|
626
|
+
);
|
|
627
|
+
hasMoreValidators = page.validatorSet?.activeValidators?.pageInfo.hasNextPage ?? false;
|
|
628
|
+
afterValidators = page.validatorSet?.activeValidators?.pageInfo.endCursor;
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
activeValidators: systemState.validatorSet?.activeValidators?.nodes.map(
|
|
632
|
+
import_validator.mapGraphQlValidatorToRpcValidator
|
|
633
|
+
),
|
|
634
|
+
atRiskValidators: systemState.validatorSet?.activeValidators.nodes?.filter((validator) => validator.atRisk).map((validator) => [validator.address.address, validator.atRisk.toString()]),
|
|
635
|
+
epoch: String(systemState.epochId),
|
|
636
|
+
epochDurationMs: String(
|
|
637
|
+
new Date(systemState.endTimestamp).getTime() - new Date(systemState.startTimestamp).getTime()
|
|
638
|
+
),
|
|
639
|
+
epochStartTimestampMs: String(new Date(systemState.startTimestamp).getTime()),
|
|
640
|
+
inactivePoolsSize: String(systemState.validatorSet?.inactivePoolsSize),
|
|
641
|
+
iotaTotalSupply: String(systemState.iotaTotalSupply),
|
|
642
|
+
maxValidatorCount: String(systemState.systemParameters?.maxValidatorCount),
|
|
643
|
+
minValidatorJoiningStake: String(
|
|
644
|
+
systemState.systemParameters?.minValidatorJoiningStake
|
|
645
|
+
),
|
|
646
|
+
pendingActiveValidatorsSize: String(
|
|
647
|
+
systemState.validatorSet?.pendingActiveValidatorsSize
|
|
648
|
+
),
|
|
649
|
+
pendingRemovals: systemState.validatorSet?.pendingRemovals?.map((idx) => String(idx)) ?? [],
|
|
650
|
+
protocolVersion: String(systemState.protocolConfigs?.protocolVersion),
|
|
651
|
+
referenceGasPrice: String(systemState.referenceGasPrice),
|
|
652
|
+
safeMode: systemState.safeMode?.enabled,
|
|
653
|
+
safeModeComputationRewards: String(systemState.safeMode?.gasSummary?.computationCost),
|
|
654
|
+
safeModeNonRefundableStorageFee: String(
|
|
655
|
+
systemState.safeMode?.gasSummary?.nonRefundableStorageFee
|
|
656
|
+
),
|
|
657
|
+
safeModeStorageRebates: String(systemState.safeMode?.gasSummary?.storageRebate),
|
|
658
|
+
safeModeStorageCharges: String(systemState.safeMode?.gasSummary?.storageCost),
|
|
659
|
+
stakingPoolMappingsSize: String(systemState.validatorSet?.stakingPoolMappingsSize),
|
|
660
|
+
storageFundNonRefundableBalance: String(systemState.storageFund?.nonRefundableBalance),
|
|
661
|
+
storageFundTotalObjectStorageRebates: String(
|
|
662
|
+
systemState.storageFund?.totalObjectStorageRebates
|
|
663
|
+
),
|
|
664
|
+
systemStateVersion: String(systemState.systemStateVersion),
|
|
665
|
+
totalStake: systemState.validatorSet?.totalStake,
|
|
666
|
+
validatorCandidatesSize: systemState.validatorSet?.validatorCandidatesSize?.toString(),
|
|
667
|
+
validatorLowStakeGracePeriod: systemState.systemParameters?.validatorLowStakeGracePeriod,
|
|
668
|
+
validatorLowStakeThreshold: systemState.systemParameters?.validatorLowStakeThreshold,
|
|
669
|
+
validatorReportRecords: [],
|
|
670
|
+
// TODO
|
|
671
|
+
validatorVeryLowStakeThreshold: systemState.systemParameters?.validatorVeryLowStakeThreshold,
|
|
672
|
+
validatorCandidatesId: "",
|
|
673
|
+
// TODO
|
|
674
|
+
inactivePoolsId: "",
|
|
675
|
+
// TODO
|
|
676
|
+
pendingActiveValidatorsId: "",
|
|
677
|
+
// TODO
|
|
678
|
+
stakingPoolMappingsId: ""
|
|
679
|
+
// TODO
|
|
680
|
+
};
|
|
681
|
+
},
|
|
682
|
+
async queryEvents(transport, [query, cursor, limit, descending]) {
|
|
683
|
+
const pagination = descending ? { last: limit, before: cursor } : { first: limit, after: cursor };
|
|
684
|
+
const filter = {
|
|
685
|
+
sender: "Sender" in query ? query.Sender : void 0,
|
|
686
|
+
transactionDigest: "Transaction" in query ? query.Transaction : void 0,
|
|
687
|
+
eventType: "MoveEventType" in query ? query.MoveEventType : void 0,
|
|
688
|
+
emittingModule: "MoveModule" in query ? `${query.MoveModule.package}::${query.MoveModule.module}` : void 0
|
|
689
|
+
};
|
|
690
|
+
if ("MoveEventType" in query) {
|
|
691
|
+
filter.eventType = query.MoveEventType;
|
|
692
|
+
} else if ("MoveEventModule" in query) {
|
|
693
|
+
filter.eventType = `${query.MoveEventModule.package}::${query.MoveEventModule.module}`;
|
|
694
|
+
}
|
|
695
|
+
const unsupportedFilters = [
|
|
696
|
+
"Package",
|
|
697
|
+
"MoveEventField",
|
|
698
|
+
"Any",
|
|
699
|
+
"All",
|
|
700
|
+
"And",
|
|
701
|
+
"Or",
|
|
702
|
+
"TimeRange"
|
|
703
|
+
];
|
|
704
|
+
if (query) {
|
|
705
|
+
for (const unsupportedFilter of unsupportedFilters) {
|
|
706
|
+
if (unsupportedFilter in query) {
|
|
707
|
+
throw new UnsupportedParamError("queryEvents", unsupportedFilter);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const { nodes: events, pageInfo } = await transport.graphqlQuery(
|
|
712
|
+
{
|
|
713
|
+
query: import_queries.QueryEventsDocument,
|
|
714
|
+
variables: {
|
|
715
|
+
...pagination,
|
|
716
|
+
filter
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
(data) => data.events
|
|
720
|
+
);
|
|
721
|
+
if (pagination.last) {
|
|
722
|
+
events.reverse();
|
|
723
|
+
}
|
|
724
|
+
return {
|
|
725
|
+
hasNextPage: pagination.last ? pageInfo.hasPreviousPage : pageInfo.hasNextPage,
|
|
726
|
+
nextCursor: pagination.last ? pageInfo.startCursor : pageInfo.endCursor,
|
|
727
|
+
data: events.map((event) => ({
|
|
728
|
+
bcs: event.bcs,
|
|
729
|
+
id: {
|
|
730
|
+
eventSeq: "",
|
|
731
|
+
// TODO
|
|
732
|
+
txDigest: ""
|
|
733
|
+
// TODO
|
|
734
|
+
},
|
|
735
|
+
packageId: event.sendingModule?.package.address,
|
|
736
|
+
parsedJson: event.json ? JSON.parse(event.json) : void 0,
|
|
737
|
+
sender: event.sender?.address,
|
|
738
|
+
timestampMs: new Date(event.timestamp).getTime().toString(),
|
|
739
|
+
transactionModule: `${event.sendingModule?.package.address}::${event.sendingModule?.name}`,
|
|
740
|
+
type: (0, import_util.toShortTypeString)(event.type?.repr)
|
|
741
|
+
}))
|
|
742
|
+
};
|
|
743
|
+
},
|
|
744
|
+
async devInspectTransactionBlock(transport, [sender, devInspectTxBytes, gasPrice]) {
|
|
745
|
+
const { transaction, error, results } = await transport.graphqlQuery(
|
|
746
|
+
{
|
|
747
|
+
query: import_queries.DevInspectTransactionBlockDocument,
|
|
748
|
+
variables: {
|
|
749
|
+
txBytes: devInspectTxBytes,
|
|
750
|
+
txMeta: {
|
|
751
|
+
gasPrice: Number.parseInt(gasPrice),
|
|
752
|
+
sender
|
|
753
|
+
},
|
|
754
|
+
showEffects: true,
|
|
755
|
+
showEvents: true
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
(data) => data.dryRunTransactionBlock
|
|
759
|
+
);
|
|
760
|
+
if (!transaction) {
|
|
761
|
+
throw new Error("Unexpected error during dry run");
|
|
762
|
+
}
|
|
763
|
+
const result = (0, import_transaction_block.mapGraphQLTransactionBlockToRpcTransactionBlock)(transaction, {
|
|
764
|
+
showEffects: true,
|
|
765
|
+
showEvents: true
|
|
766
|
+
});
|
|
767
|
+
return {
|
|
768
|
+
error,
|
|
769
|
+
effects: result.effects,
|
|
770
|
+
events: result.events,
|
|
771
|
+
results: results?.map((result2) => ({
|
|
772
|
+
mutableReferenceOutputs: result2.mutatedReferences?.map(
|
|
773
|
+
(ref) => [
|
|
774
|
+
ref.input.__typename === "GasCoin" ? "GasCoin" : ref.input.__typename === "Input" ? {
|
|
775
|
+
Input: ref.input.inputIndex
|
|
776
|
+
} : typeof ref.input.resultIndex === "number" ? {
|
|
777
|
+
NestedResult: [ref.input.cmd, ref.input.resultIndex]
|
|
778
|
+
} : {
|
|
779
|
+
Result: ref.input.cmd
|
|
780
|
+
},
|
|
781
|
+
Array.from((0, import_bcs.fromB64)(ref.bcs)),
|
|
782
|
+
(0, import_util.toShortTypeString)(ref.type.repr)
|
|
783
|
+
]
|
|
784
|
+
),
|
|
785
|
+
returnValues: result2.returnValues?.map((value) => [
|
|
786
|
+
Array.from((0, import_bcs.fromB64)(value.bcs)),
|
|
787
|
+
(0, import_util.toShortTypeString)(value.type.repr)
|
|
788
|
+
])
|
|
789
|
+
}))
|
|
790
|
+
};
|
|
791
|
+
},
|
|
792
|
+
async getDynamicFields(transport, [parentId, cursor, limit]) {
|
|
793
|
+
const { nodes: fields, pageInfo } = await transport.graphqlQuery(
|
|
794
|
+
{
|
|
795
|
+
query: import_queries.GetDynamicFieldsDocument,
|
|
796
|
+
variables: {
|
|
797
|
+
parentId,
|
|
798
|
+
first: limit,
|
|
799
|
+
cursor
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
(data) => data.object?.dynamicFields
|
|
803
|
+
);
|
|
804
|
+
return {
|
|
805
|
+
data: fields.map((field) => ({
|
|
806
|
+
bcsName: field.name?.bcs && (0, import_bcs.toB58)((0, import_bcs.fromB64)(field.name.bcs)),
|
|
807
|
+
digest: field.value?.__typename === "MoveObject" ? field.value.digest : void 0,
|
|
808
|
+
name: {
|
|
809
|
+
type: (0, import_util.toShortTypeString)(field.name?.type.repr),
|
|
810
|
+
value: field.name?.json
|
|
811
|
+
},
|
|
812
|
+
objectId: field.value?.__typename === "MoveObject" ? field.value.address : void 0,
|
|
813
|
+
objectType: field.value?.__typename === "MoveObject" ? field.value.contents?.type.repr : field.value?.type.repr,
|
|
814
|
+
type: field.value?.__typename === "MoveObject" ? "DynamicObject" : "DynamicField",
|
|
815
|
+
version: field.value?.__typename === "MoveObject" ? field.value.version : void 0
|
|
816
|
+
})),
|
|
817
|
+
nextCursor: pageInfo.endCursor ?? null,
|
|
818
|
+
hasNextPage: pageInfo.hasNextPage
|
|
819
|
+
};
|
|
820
|
+
},
|
|
821
|
+
async getDynamicFieldObject(transport, [parentId, name]) {
|
|
822
|
+
const nameLayout = await transport.graphqlQuery(
|
|
823
|
+
{
|
|
824
|
+
query: import_queries.GetTypeLayoutDocument,
|
|
825
|
+
variables: {
|
|
826
|
+
type: name.type
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
(data) => data.type.layout
|
|
830
|
+
);
|
|
831
|
+
const bcsName = (0, import_bcs2.mapJsonToBcs)(name.value, nameLayout);
|
|
832
|
+
const parent = await transport.graphqlQuery(
|
|
833
|
+
{
|
|
834
|
+
query: import_queries.GetDynamicFieldObjectDocument,
|
|
835
|
+
variables: {
|
|
836
|
+
parentId,
|
|
837
|
+
name: {
|
|
838
|
+
type: name.type,
|
|
839
|
+
bcs: bcsName
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
(data) => {
|
|
844
|
+
return data.object?.dynamicObjectField?.value?.__typename === "MoveObject" ? data.object.dynamicObjectField.value.owner?.__typename === "Parent" ? data.object.dynamicObjectField.value.owner.parent : void 0 : void 0;
|
|
845
|
+
}
|
|
846
|
+
);
|
|
847
|
+
return {
|
|
848
|
+
data: {
|
|
849
|
+
content: {
|
|
850
|
+
dataType: "moveObject",
|
|
851
|
+
...(0, import_move.moveDataToRpcContent)(
|
|
852
|
+
parent?.asMoveObject?.contents?.data,
|
|
853
|
+
parent?.asMoveObject?.contents?.type.layout
|
|
854
|
+
),
|
|
855
|
+
hasPublicTransfer: parent?.asMoveObject?.hasPublicTransfer
|
|
856
|
+
},
|
|
857
|
+
digest: parent?.digest,
|
|
858
|
+
objectId: parent?.address,
|
|
859
|
+
type: (0, import_util.toShortTypeString)(parent?.asMoveObject?.contents?.type.repr),
|
|
860
|
+
version: parent?.version.toString(),
|
|
861
|
+
storageRebate: parent.storageRebate,
|
|
862
|
+
previousTransaction: parent.previousTransactionBlock?.digest,
|
|
863
|
+
owner: parent.owner?.__typename === "Parent" ? {
|
|
864
|
+
ObjectOwner: parent.owner.parent?.address
|
|
865
|
+
} : void 0
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
},
|
|
869
|
+
async executeTransactionBlock(transport, [txBytes, signatures, options, _requestType]) {
|
|
870
|
+
const { effects, errors } = await transport.graphqlQuery(
|
|
871
|
+
{
|
|
872
|
+
query: import_queries.ExecuteTransactionBlockDocument,
|
|
873
|
+
variables: {
|
|
874
|
+
txBytes,
|
|
875
|
+
signatures,
|
|
876
|
+
showBalanceChanges: options?.showBalanceChanges,
|
|
877
|
+
showEffects: options?.showEffects,
|
|
878
|
+
showInput: options?.showInput,
|
|
879
|
+
showEvents: options?.showEvents,
|
|
880
|
+
showObjectChanges: options?.showObjectChanges,
|
|
881
|
+
showRawInput: options?.showRawInput
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
(data) => data.executeTransactionBlock
|
|
885
|
+
);
|
|
886
|
+
if (!effects?.transactionBlock) {
|
|
887
|
+
const txb = import_transactions.TransactionBlock.from((0, import_bcs.fromB64)(txBytes));
|
|
888
|
+
return { errors: errors ?? void 0, digest: await txb.getDigest() };
|
|
889
|
+
}
|
|
890
|
+
await paginateTransactionBlockLists(transport, effects.transactionBlock);
|
|
891
|
+
return (0, import_transaction_block.mapGraphQLTransactionBlockToRpcTransactionBlock)(
|
|
892
|
+
effects.transactionBlock,
|
|
893
|
+
options,
|
|
894
|
+
errors
|
|
895
|
+
);
|
|
896
|
+
},
|
|
897
|
+
async dryRunTransactionBlock(transport, [txBytes]) {
|
|
898
|
+
const txb = import_transactions.TransactionBlock.from((0, import_bcs.fromB64)(txBytes));
|
|
899
|
+
const { transaction, error } = await transport.graphqlQuery(
|
|
900
|
+
{
|
|
901
|
+
query: import_queries.DryRunTransactionBlockDocument,
|
|
902
|
+
variables: {
|
|
903
|
+
txBytes,
|
|
904
|
+
showBalanceChanges: true,
|
|
905
|
+
showEffects: true,
|
|
906
|
+
showEvents: true,
|
|
907
|
+
showObjectChanges: true,
|
|
908
|
+
showInput: true
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
(data) => data.dryRunTransactionBlock
|
|
912
|
+
);
|
|
913
|
+
if (error || !transaction) {
|
|
914
|
+
throw new Error(error ?? "Unexpected error during dry run");
|
|
915
|
+
}
|
|
916
|
+
const result = (0, import_transaction_block.mapGraphQLTransactionBlockToRpcTransactionBlock)(
|
|
917
|
+
{ ...transaction, digest: await txb.getDigest() },
|
|
918
|
+
{
|
|
919
|
+
showBalanceChanges: true,
|
|
920
|
+
showEffects: true,
|
|
921
|
+
showEvents: true,
|
|
922
|
+
showObjectChanges: true,
|
|
923
|
+
showInput: true
|
|
924
|
+
}
|
|
925
|
+
);
|
|
926
|
+
return {
|
|
927
|
+
input: result.transaction?.data,
|
|
928
|
+
balanceChanges: result.balanceChanges,
|
|
929
|
+
effects: result.effects,
|
|
930
|
+
events: result.events,
|
|
931
|
+
objectChanges: result.objectChanges
|
|
932
|
+
};
|
|
933
|
+
},
|
|
934
|
+
async getLatestCheckpointSequenceNumber(transport) {
|
|
935
|
+
const sequenceNumber = await transport.graphqlQuery(
|
|
936
|
+
{
|
|
937
|
+
query: import_queries.GetLatestCheckpointSequenceNumberDocument
|
|
938
|
+
},
|
|
939
|
+
(data) => data.checkpoint?.sequenceNumber
|
|
940
|
+
);
|
|
941
|
+
return sequenceNumber.toString();
|
|
942
|
+
},
|
|
943
|
+
async getCheckpoint(transport, [id]) {
|
|
944
|
+
const checkpoint = await transport.graphqlQuery(
|
|
945
|
+
{
|
|
946
|
+
query: import_queries.GetCheckpointDocument,
|
|
947
|
+
variables: {
|
|
948
|
+
id: typeof id === "number" || (0, import_util.isNumericString)(id) ? {
|
|
949
|
+
sequenceNumber: Number.parseInt(id.toString(), 10)
|
|
950
|
+
} : {
|
|
951
|
+
digest: id
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
(data) => data.checkpoint
|
|
956
|
+
);
|
|
957
|
+
await paginateCheckpointLists(transport, checkpoint);
|
|
958
|
+
return (0, import_checkpint.mapGraphQLCheckpointToRpcCheckpoint)(checkpoint);
|
|
959
|
+
},
|
|
960
|
+
async getCheckpoints(transport, [cursor, limit, descendingOrder]) {
|
|
961
|
+
const pagination = descendingOrder ? { last: limit, before: cursor } : { first: limit, after: cursor };
|
|
962
|
+
const { nodes: checkpoints, pageInfo } = await transport.graphqlQuery(
|
|
963
|
+
{
|
|
964
|
+
query: import_queries.GetCheckpointsDocument,
|
|
965
|
+
variables: {
|
|
966
|
+
...pagination
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
(data) => data.checkpoints
|
|
970
|
+
);
|
|
971
|
+
for (const checkpoint of checkpoints) {
|
|
972
|
+
await paginateCheckpointLists(transport, checkpoint);
|
|
973
|
+
}
|
|
974
|
+
if (pagination.last) {
|
|
975
|
+
checkpoints.reverse();
|
|
976
|
+
}
|
|
977
|
+
return {
|
|
978
|
+
hasNextPage: pagination.last ? pageInfo.hasPreviousPage : pageInfo.hasNextPage,
|
|
979
|
+
nextCursor: pagination.last ? pageInfo.startCursor : pageInfo.endCursor,
|
|
980
|
+
data: checkpoints.map((checkpoint) => (0, import_checkpint.mapGraphQLCheckpointToRpcCheckpoint)(checkpoint))
|
|
981
|
+
};
|
|
982
|
+
},
|
|
983
|
+
async getCommitteeInfo(transport, [epoch]) {
|
|
984
|
+
const { validatorSet, epochId } = await transport.graphqlQuery(
|
|
985
|
+
{
|
|
986
|
+
query: import_queries.GetCommitteeInfoDocument,
|
|
987
|
+
variables: {
|
|
988
|
+
epochId: epoch ? Number.parseInt(epoch) : void 0
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
(data) => data.epoch
|
|
992
|
+
);
|
|
993
|
+
let hasNextPage = validatorSet?.activeValidators?.pageInfo.hasNextPage;
|
|
994
|
+
let after = validatorSet?.activeValidators?.pageInfo.endCursor;
|
|
995
|
+
while (hasNextPage) {
|
|
996
|
+
const page = await transport.graphqlQuery(
|
|
997
|
+
{
|
|
998
|
+
query: import_queries.GetCommitteeInfoDocument,
|
|
999
|
+
variables: {
|
|
1000
|
+
epochId: epoch ? Number.parseInt(epoch) : void 0,
|
|
1001
|
+
after
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
(data) => data.epoch?.validatorSet?.activeValidators
|
|
1005
|
+
);
|
|
1006
|
+
validatorSet?.activeValidators.nodes.push(...page.nodes);
|
|
1007
|
+
hasNextPage = page.pageInfo.hasNextPage;
|
|
1008
|
+
after = page.pageInfo.endCursor;
|
|
1009
|
+
}
|
|
1010
|
+
return {
|
|
1011
|
+
epoch: epochId.toString(),
|
|
1012
|
+
validators: validatorSet?.activeValidators?.nodes.map((val) => [
|
|
1013
|
+
val.credentials?.protocolPubKey,
|
|
1014
|
+
String(val.votingPower)
|
|
1015
|
+
])
|
|
1016
|
+
};
|
|
1017
|
+
},
|
|
1018
|
+
async getCurrentEpoch(transport) {
|
|
1019
|
+
const epoch = await transport.graphqlQuery(
|
|
1020
|
+
{
|
|
1021
|
+
query: import_queries.GetCurrentEpochDocument
|
|
1022
|
+
},
|
|
1023
|
+
(data) => data.epoch
|
|
1024
|
+
);
|
|
1025
|
+
let hasNextPage = epoch.validatorSet?.activeValidators?.pageInfo.hasNextPage;
|
|
1026
|
+
let after = epoch.validatorSet?.activeValidators?.pageInfo.endCursor;
|
|
1027
|
+
while (hasNextPage) {
|
|
1028
|
+
const page = await transport.graphqlQuery(
|
|
1029
|
+
{
|
|
1030
|
+
query: import_queries.PaginateEpochValidatorsDocument,
|
|
1031
|
+
variables: {
|
|
1032
|
+
id: epoch.epochId,
|
|
1033
|
+
after
|
|
1034
|
+
}
|
|
1035
|
+
},
|
|
1036
|
+
(data) => data.epoch?.validatorSet?.activeValidators
|
|
1037
|
+
);
|
|
1038
|
+
epoch.validatorSet?.activeValidators?.nodes.push(...page.nodes);
|
|
1039
|
+
hasNextPage = page.pageInfo.hasNextPage;
|
|
1040
|
+
after = page.pageInfo.endCursor;
|
|
1041
|
+
}
|
|
1042
|
+
return {
|
|
1043
|
+
epoch: String(epoch.epochId),
|
|
1044
|
+
validators: epoch.validatorSet?.activeValidators?.nodes.map(
|
|
1045
|
+
import_validator.mapGraphQlValidatorToRpcValidator
|
|
1046
|
+
),
|
|
1047
|
+
epochTotalTransactions: "0",
|
|
1048
|
+
// TODO
|
|
1049
|
+
firstCheckpointId: epoch.firstCheckpoint?.nodes[0]?.sequenceNumber.toString(),
|
|
1050
|
+
endOfEpochInfo: null,
|
|
1051
|
+
referenceGasPrice: Number.parseInt(epoch.referenceGasPrice, 10),
|
|
1052
|
+
epochStartTimestamp: new Date(epoch.startTimestamp).getTime().toString()
|
|
1053
|
+
};
|
|
1054
|
+
},
|
|
1055
|
+
async getValidatorsApy(transport) {
|
|
1056
|
+
const epoch = await transport.graphqlQuery(
|
|
1057
|
+
{
|
|
1058
|
+
query: import_queries.GetValidatorsApyDocument
|
|
1059
|
+
},
|
|
1060
|
+
(data) => data.epoch
|
|
1061
|
+
);
|
|
1062
|
+
let hasNextPage = epoch.validatorSet?.activeValidators?.pageInfo.hasNextPage;
|
|
1063
|
+
let after = epoch.validatorSet?.activeValidators?.pageInfo.endCursor;
|
|
1064
|
+
while (hasNextPage) {
|
|
1065
|
+
const page = await transport.graphqlQuery(
|
|
1066
|
+
{
|
|
1067
|
+
query: import_queries.PaginateEpochValidatorsDocument,
|
|
1068
|
+
variables: {
|
|
1069
|
+
id: epoch.epochId,
|
|
1070
|
+
after
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
(data) => data.epoch
|
|
1074
|
+
);
|
|
1075
|
+
epoch.validatorSet?.activeValidators?.nodes.push(
|
|
1076
|
+
...page.validatorSet?.activeValidators?.nodes ?? []
|
|
1077
|
+
);
|
|
1078
|
+
hasNextPage = page.validatorSet?.activeValidators?.pageInfo.hasNextPage;
|
|
1079
|
+
after = page.validatorSet?.activeValidators?.pageInfo.endCursor;
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
epoch: String(epoch.epochId),
|
|
1083
|
+
apys: epoch.validatorSet?.activeValidators?.nodes.map((validator) => ({
|
|
1084
|
+
address: validator.address.address,
|
|
1085
|
+
apy: typeof validator.apy === "number" ? validator.apy / 100 : null
|
|
1086
|
+
}))
|
|
1087
|
+
};
|
|
1088
|
+
},
|
|
1089
|
+
async getChainIdentifier(transport) {
|
|
1090
|
+
const identifier = await transport.graphqlQuery(
|
|
1091
|
+
{
|
|
1092
|
+
query: import_queries.GetChainIdentifierDocument
|
|
1093
|
+
},
|
|
1094
|
+
(data) => data.chainIdentifier
|
|
1095
|
+
);
|
|
1096
|
+
return identifier;
|
|
1097
|
+
},
|
|
1098
|
+
async getProtocolConfig(transport, [version]) {
|
|
1099
|
+
const protocolConfig = await transport.graphqlQuery(
|
|
1100
|
+
{
|
|
1101
|
+
query: import_queries.GetProtocolConfigDocument,
|
|
1102
|
+
variables: {
|
|
1103
|
+
protocolVersion: version ? Number.parseInt(version) : void 0
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
(data) => data.protocolConfig
|
|
1107
|
+
);
|
|
1108
|
+
const featureFlags = {};
|
|
1109
|
+
const attributes = {};
|
|
1110
|
+
const configTypeMap = {
|
|
1111
|
+
max_arguments: "u32",
|
|
1112
|
+
max_gas_payment_objects: "u32",
|
|
1113
|
+
max_modules_in_publish: "u32",
|
|
1114
|
+
max_programmable_tx_commands: "u32",
|
|
1115
|
+
max_pure_argument_size: "u32",
|
|
1116
|
+
max_type_argument_depth: "u32",
|
|
1117
|
+
max_type_arguments: "u32",
|
|
1118
|
+
move_binary_format_version: "u32",
|
|
1119
|
+
random_beacon_reduction_allowed_delta: "u16",
|
|
1120
|
+
random_beacon_dkg_timeout_round: "u32",
|
|
1121
|
+
random_beacon_reduction_lower_bound: "u32",
|
|
1122
|
+
scoring_decision_cutoff_value: "f64",
|
|
1123
|
+
scoring_decision_mad_divisor: "f64",
|
|
1124
|
+
group_ops_bls12381_msm_max_len: "u32",
|
|
1125
|
+
binary_module_handles: "u16",
|
|
1126
|
+
binary_struct_handles: "u16",
|
|
1127
|
+
binary_function_handles: "u16",
|
|
1128
|
+
binary_function_instantiations: "u16",
|
|
1129
|
+
binary_signatures: "u16",
|
|
1130
|
+
binary_constant_pool: "u16",
|
|
1131
|
+
binary_identifiers: "u16",
|
|
1132
|
+
binary_address_identifiers: "u16",
|
|
1133
|
+
binary_struct_defs: "u16",
|
|
1134
|
+
binary_struct_def_instantiations: "u16",
|
|
1135
|
+
binary_function_defs: "u16",
|
|
1136
|
+
binary_field_handles: "u16",
|
|
1137
|
+
binary_field_instantiations: "u16",
|
|
1138
|
+
binary_friend_decls: "u16",
|
|
1139
|
+
max_package_dependencies: "u32"
|
|
1140
|
+
};
|
|
1141
|
+
for (const { key, value } of protocolConfig.configs) {
|
|
1142
|
+
attributes[key] = value === null ? null : {
|
|
1143
|
+
[configTypeMap[key] ?? "u64"]: value
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
for (const { key, value } of protocolConfig.featureFlags) {
|
|
1147
|
+
featureFlags[key] = value;
|
|
1148
|
+
}
|
|
1149
|
+
return {
|
|
1150
|
+
maxSupportedProtocolVersion: protocolConfig.protocolVersion?.toString(),
|
|
1151
|
+
minSupportedProtocolVersion: "1",
|
|
1152
|
+
protocolVersion: protocolConfig.protocolVersion?.toString(),
|
|
1153
|
+
attributes,
|
|
1154
|
+
featureFlags
|
|
1155
|
+
};
|
|
1156
|
+
},
|
|
1157
|
+
async resolveNameServiceAddress(transport, [name]) {
|
|
1158
|
+
const data = await transport.graphqlQuery({
|
|
1159
|
+
query: import_queries.ResolveNameServiceAddressDocument,
|
|
1160
|
+
variables: {
|
|
1161
|
+
domain: name
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
return data.resolveIotansAddress?.address ?? null;
|
|
1165
|
+
},
|
|
1166
|
+
async resolveNameServiceNames(transport, [address, cursor, limit]) {
|
|
1167
|
+
const iotansRegistrations = await transport.graphqlQuery(
|
|
1168
|
+
{
|
|
1169
|
+
query: import_queries.ResolveNameServiceNamesDocument,
|
|
1170
|
+
variables: {
|
|
1171
|
+
address,
|
|
1172
|
+
cursor,
|
|
1173
|
+
limit
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
(data) => data.address?.iotansRegistrations
|
|
1177
|
+
);
|
|
1178
|
+
return {
|
|
1179
|
+
hasNextPage: iotansRegistrations.pageInfo.hasNextPage,
|
|
1180
|
+
nextCursor: iotansRegistrations.pageInfo.endCursor ?? null,
|
|
1181
|
+
data: iotansRegistrations?.nodes.map((node) => node.domain) ?? []
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
class UnsupportedParamError extends Error {
|
|
1186
|
+
constructor(method, param) {
|
|
1187
|
+
super(`Parameter ${param} is not supported for ${method} in the GraphQL API`);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
class UnsupportedMethodError extends Error {
|
|
1191
|
+
constructor(method) {
|
|
1192
|
+
super(`Method ${method} is not supported in the GraphQL API`);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
async function paginateTransactionBlockLists(transport, transactionBlock) {
|
|
1196
|
+
let hasMoreEvents = transactionBlock.effects?.events?.pageInfo.hasNextPage ?? false;
|
|
1197
|
+
let hasMoreBalanceChanges = transactionBlock.effects?.balanceChanges?.pageInfo.hasNextPage ?? false;
|
|
1198
|
+
let hasMoreObjectChanges = transactionBlock.effects?.objectChanges?.pageInfo.hasNextPage ?? false;
|
|
1199
|
+
let hasMoreDependencies = transactionBlock.effects?.dependencies?.pageInfo.hasNextPage ?? false;
|
|
1200
|
+
let afterEvents = transactionBlock.effects?.events?.pageInfo.endCursor;
|
|
1201
|
+
let afterBalanceChanges = transactionBlock.effects?.balanceChanges?.pageInfo.endCursor;
|
|
1202
|
+
let afterObjectChanges = transactionBlock.effects?.objectChanges?.pageInfo.endCursor;
|
|
1203
|
+
let afterDependencies = transactionBlock.effects?.dependencies?.pageInfo.endCursor;
|
|
1204
|
+
while (hasMoreEvents || hasMoreBalanceChanges || hasMoreObjectChanges || hasMoreDependencies) {
|
|
1205
|
+
const page = await transport.graphqlQuery(
|
|
1206
|
+
{
|
|
1207
|
+
query: import_queries.PaginateTransactionBlockListsDocument,
|
|
1208
|
+
variables: {
|
|
1209
|
+
digest: transactionBlock.digest,
|
|
1210
|
+
afterEvents,
|
|
1211
|
+
afterBalanceChanges,
|
|
1212
|
+
afterObjectChanges,
|
|
1213
|
+
afterDependencies,
|
|
1214
|
+
hasMoreEvents,
|
|
1215
|
+
hasMoreBalanceChanges,
|
|
1216
|
+
hasMoreObjectChanges,
|
|
1217
|
+
hasMoreDependencies
|
|
1218
|
+
}
|
|
1219
|
+
},
|
|
1220
|
+
(data) => data.transactionBlock?.effects
|
|
1221
|
+
);
|
|
1222
|
+
transactionBlock.effects?.events?.nodes.push(...page.events?.nodes ?? []);
|
|
1223
|
+
transactionBlock.effects?.balanceChanges?.nodes.push(...page.balanceChanges?.nodes ?? []);
|
|
1224
|
+
transactionBlock.effects?.objectChanges?.nodes.push(...page.objectChanges?.nodes ?? []);
|
|
1225
|
+
transactionBlock.effects?.dependencies?.nodes.push(...page.dependencies?.nodes ?? []);
|
|
1226
|
+
hasMoreEvents = page.events?.pageInfo.hasNextPage ?? false;
|
|
1227
|
+
hasMoreBalanceChanges = page.balanceChanges?.pageInfo.hasNextPage ?? false;
|
|
1228
|
+
hasMoreObjectChanges = page.objectChanges?.pageInfo.hasNextPage ?? false;
|
|
1229
|
+
hasMoreDependencies = page.dependencies?.pageInfo.hasNextPage ?? false;
|
|
1230
|
+
afterEvents = page.events?.pageInfo.endCursor;
|
|
1231
|
+
afterBalanceChanges = page.balanceChanges?.pageInfo.endCursor;
|
|
1232
|
+
afterObjectChanges = page.objectChanges?.pageInfo.endCursor;
|
|
1233
|
+
afterDependencies = page.dependencies?.pageInfo.endCursor;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
async function paginateCheckpointLists(transport, checkpoint) {
|
|
1237
|
+
let hasNextPage = checkpoint.transactionBlocks.pageInfo.hasNextPage;
|
|
1238
|
+
let after = checkpoint.transactionBlocks.pageInfo.endCursor;
|
|
1239
|
+
while (hasNextPage) {
|
|
1240
|
+
const page = await transport.graphqlQuery(
|
|
1241
|
+
{
|
|
1242
|
+
query: import_queries.PaginateCheckpointTransactionBlocksDocument,
|
|
1243
|
+
variables: {
|
|
1244
|
+
id: { digest: checkpoint.digest },
|
|
1245
|
+
after
|
|
1246
|
+
}
|
|
1247
|
+
},
|
|
1248
|
+
(data) => data.checkpoint?.transactionBlocks
|
|
1249
|
+
);
|
|
1250
|
+
checkpoint.transactionBlocks.nodes.push(...page.nodes);
|
|
1251
|
+
hasNextPage = page.pageInfo.hasNextPage;
|
|
1252
|
+
after = page.pageInfo.endCursor;
|
|
1253
|
+
}
|
|
1254
|
+
const endOfEpochTx = checkpoint.endOfEpoch.nodes[0];
|
|
1255
|
+
if (endOfEpochTx?.kind?.__typename === "EndOfEpochTransaction" && endOfEpochTx.kind?.transactions.nodes[0].__typename === "ChangeEpochTransaction" && endOfEpochTx.kind.transactions.nodes[0].epoch?.epochId) {
|
|
1256
|
+
const validatorSet = endOfEpochTx.kind.transactions.nodes[0].epoch.validatorSet;
|
|
1257
|
+
let hasNextPage2 = validatorSet?.activeValidators.pageInfo.hasNextPage;
|
|
1258
|
+
let after2 = validatorSet?.activeValidators.pageInfo.endCursor;
|
|
1259
|
+
while (hasNextPage2) {
|
|
1260
|
+
const page = await transport.graphqlQuery(
|
|
1261
|
+
{
|
|
1262
|
+
query: import_queries.GetCommitteeInfoDocument,
|
|
1263
|
+
variables: {
|
|
1264
|
+
epochId: endOfEpochTx.kind.transactions.nodes[0].epoch?.epochId,
|
|
1265
|
+
after: after2
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
(data) => data.epoch?.validatorSet?.activeValidators
|
|
1269
|
+
);
|
|
1270
|
+
validatorSet?.activeValidators.nodes.push(...page.nodes);
|
|
1271
|
+
hasNextPage2 = page.pageInfo?.hasNextPage;
|
|
1272
|
+
after2 = page.pageInfo?.endCursor;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
//# sourceMappingURL=methods.js.map
|