@sentio/sdk-bundle 2.61.0-rc.2 → 2.61.0-rc.4
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/lib/aptos/builtin/0x1.js +5 -7
- package/lib/aptos/builtin/0x3.js +6 -8
- package/lib/aptos/builtin/0x4.js +6 -8
- package/lib/aptos/builtin/index.js +7 -9
- package/lib/aptos/builtin/index.js.map +1 -1
- package/lib/aptos/ext/index.js +5 -7
- package/lib/aptos/ext/index.js.map +1 -1
- package/lib/aptos/index.js +5 -7
- package/lib/btc/index.js +2 -3
- package/lib/btc/index.js.map +1 -1
- package/lib/{chunk-OD6FL4VS.js → chunk-3U72IHGI.js} +3 -5
- package/lib/{chunk-OD6FL4VS.js.map → chunk-3U72IHGI.js.map} +1 -1
- package/lib/{chunk-4BUIMDJ2.js → chunk-63C2SM23.js} +3 -5
- package/lib/{chunk-4BUIMDJ2.js.map → chunk-63C2SM23.js.map} +1 -1
- package/lib/{chunk-43HP4DQZ.js → chunk-B4NQDXHJ.js} +51 -3
- package/lib/chunk-B4NQDXHJ.js.map +1 -0
- package/lib/{chunk-SA6EVEF3.js → chunk-FSFHO32Q.js} +8 -12
- package/lib/{chunk-SA6EVEF3.js.map → chunk-FSFHO32Q.js.map} +1 -1
- package/lib/{chunk-DHPXVIOI.js → chunk-GXWFPPVN.js} +3 -5
- package/lib/{chunk-DHPXVIOI.js.map → chunk-GXWFPPVN.js.map} +1 -1
- package/lib/{chunk-742S42NO.js → chunk-HFODIGHI.js} +449 -1
- package/lib/chunk-HFODIGHI.js.map +1 -0
- package/lib/{chunk-63RPKHNV.js → chunk-JM77GOBI.js} +5 -5
- package/lib/{chunk-GNJ4FJ6M.js → chunk-NEDO74L4.js} +2 -2
- package/lib/{chunk-AIRBHETL.js → chunk-NF66PTSR.js} +4 -4
- package/lib/{chunk-Y4VWRXPJ.js → chunk-O2FX3ST4.js} +2 -2
- package/lib/{chunk-5LEP7IFP.js → chunk-OUQN675E.js} +16 -16
- package/lib/{chunk-2UBTY7RU.js → chunk-P4MCMQEQ.js} +2 -2
- package/lib/{chunk-LP3F7TLM.js → chunk-PSLT5TLU.js} +554 -3
- package/lib/chunk-PSLT5TLU.js.map +1 -0
- package/lib/{chunk-C33DZMWZ.js → chunk-RNKAUU7M.js} +3 -3
- package/lib/{chunk-KORR4KWH.js → chunk-RQEJ6VYV.js} +1684 -267
- package/lib/chunk-RQEJ6VYV.js.map +1 -0
- package/lib/{chunk-DNXKWX3C.js → chunk-TBCNZKOI.js} +15 -15
- package/lib/{chunk-23ATGE5K.js → chunk-V7GMUFEU.js} +11 -11
- package/lib/{chunk-GQ543QK7.js → chunk-VOZ7XW36.js} +2 -2
- package/lib/{chunk-XBLI6KNQ.js → chunk-W5VWFQZQ.js} +18 -18
- package/lib/{chunk-6RTCDLBK.js → chunk-XLNIFS5I.js} +2 -2
- package/lib/eth/builtin/eacaggregatorproxy.js +2 -3
- package/lib/eth/builtin/erc1155.js +3 -4
- package/lib/eth/builtin/erc20.js +2 -3
- package/lib/eth/builtin/erc721.js +2 -3
- package/lib/eth/builtin/index.js +4 -5
- package/lib/eth/builtin/index.js.map +1 -1
- package/lib/eth/builtin/weth9.js +3 -4
- package/lib/eth/index.js +2 -3
- package/lib/fuel/index.js +2 -3
- package/lib/iota/builtin/0x1.js +11 -6
- package/lib/iota/builtin/0x2.js +12 -7
- package/lib/iota/builtin/0x3.js +13 -8
- package/lib/iota/builtin/index.js +13 -8
- package/lib/iota/builtin/index.js.map +1 -1
- package/lib/iota/ext/index.js +5 -8
- package/lib/iota/ext/index.js.map +1 -1
- package/lib/iota/index.js +10 -5
- package/lib/stark/index.js +2 -4
- package/lib/stark/index.js.map +1 -1
- package/lib/sui/builtin/0x1.js +9 -13
- package/lib/sui/builtin/0x2.js +10 -14
- package/lib/sui/builtin/0x3.js +11 -15
- package/lib/sui/builtin/index.js +11 -15
- package/lib/sui/builtin/index.js.map +1 -1
- package/lib/sui/ext/index.js +5 -7
- package/lib/sui/ext/index.js.map +1 -1
- package/lib/sui/index.js +10 -14
- package/lib/testing/index.js +18 -23
- package/lib/testing/index.js.map +1 -1
- package/lib/utils/index.js +2 -3
- package/package.json +2 -2
- package/lib/chunk-43HP4DQZ.js.map +0 -1
- package/lib/chunk-742S42NO.js.map +0 -1
- package/lib/chunk-KORR4KWH.js.map +0 -1
- package/lib/chunk-LP3F7TLM.js.map +0 -1
- package/lib/chunk-OZTZ5YWM.js +0 -456
- package/lib/chunk-OZTZ5YWM.js.map +0 -1
- package/lib/chunk-P7O6NN6M.js +0 -562
- package/lib/chunk-P7O6NN6M.js.map +0 -1
- package/lib/chunk-XEXUSO2Q.js +0 -1469
- package/lib/chunk-XEXUSO2Q.js.map +0 -1
- package/lib/chunk-Z2CE3JTO.js +0 -56
- package/lib/chunk-Z2CE3JTO.js.map +0 -1
- /package/lib/{chunk-63RPKHNV.js.map → chunk-JM77GOBI.js.map} +0 -0
- /package/lib/{chunk-GNJ4FJ6M.js.map → chunk-NEDO74L4.js.map} +0 -0
- /package/lib/{chunk-AIRBHETL.js.map → chunk-NF66PTSR.js.map} +0 -0
- /package/lib/{chunk-Y4VWRXPJ.js.map → chunk-O2FX3ST4.js.map} +0 -0
- /package/lib/{chunk-5LEP7IFP.js.map → chunk-OUQN675E.js.map} +0 -0
- /package/lib/{chunk-2UBTY7RU.js.map → chunk-P4MCMQEQ.js.map} +0 -0
- /package/lib/{chunk-C33DZMWZ.js.map → chunk-RNKAUU7M.js.map} +0 -0
- /package/lib/{chunk-DNXKWX3C.js.map → chunk-TBCNZKOI.js.map} +0 -0
- /package/lib/{chunk-23ATGE5K.js.map → chunk-V7GMUFEU.js.map} +0 -0
- /package/lib/{chunk-GQ543QK7.js.map → chunk-VOZ7XW36.js.map} +0 -0
- /package/lib/{chunk-XBLI6KNQ.js.map → chunk-W5VWFQZQ.js.map} +0 -0
- /package/lib/{chunk-6RTCDLBK.js.map → chunk-XLNIFS5I.js.map} +0 -0
package/lib/chunk-XEXUSO2Q.js
DELETED
|
@@ -1,1469 +0,0 @@
|
|
|
1
|
-
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
IotaClient,
|
|
4
|
-
IotaNetwork,
|
|
5
|
-
getClient,
|
|
6
|
-
iotaBcs,
|
|
7
|
-
normalizeIotaAddress,
|
|
8
|
-
normalizeIotaObjectId
|
|
9
|
-
} from "./chunk-LP3F7TLM.js";
|
|
10
|
-
import {
|
|
11
|
-
getHandlerName,
|
|
12
|
-
proxyProcessor
|
|
13
|
-
} from "./chunk-43HP4DQZ.js";
|
|
14
|
-
import {
|
|
15
|
-
ANY_TYPE,
|
|
16
|
-
AbstractMoveCoder,
|
|
17
|
-
ChainAdapter,
|
|
18
|
-
InternalMoveFunctionVisibility,
|
|
19
|
-
MoveAccountContext,
|
|
20
|
-
MoveContext,
|
|
21
|
-
SPLITTER,
|
|
22
|
-
TypeDescriptor,
|
|
23
|
-
accountAddressString,
|
|
24
|
-
accountTypeString,
|
|
25
|
-
moduleQname,
|
|
26
|
-
parseMoveType
|
|
27
|
-
} from "./chunk-N3RF2ACU.js";
|
|
28
|
-
import {
|
|
29
|
-
ALL_ADDRESS,
|
|
30
|
-
MoveFetchConfig,
|
|
31
|
-
MoveOwnerType,
|
|
32
|
-
TemplateInstanceState,
|
|
33
|
-
normalizeLabels
|
|
34
|
-
} from "./chunk-5J7XO34J.js";
|
|
35
|
-
import {
|
|
36
|
-
require_lib
|
|
37
|
-
} from "./chunk-5GXMJVJP.js";
|
|
38
|
-
import {
|
|
39
|
-
__name,
|
|
40
|
-
__toESM
|
|
41
|
-
} from "./chunk-R7PMHHKJ.js";
|
|
42
|
-
|
|
43
|
-
// src/iota/iota-processor.ts
|
|
44
|
-
import { ListStateStorage } from "@sentio/runtime";
|
|
45
|
-
var import_nice_grpc = __toESM(require_lib(), 1);
|
|
46
|
-
|
|
47
|
-
// ../../node_modules/.pnpm/@typemove+iota@1.11.0_typescript@5.5.2/node_modules/@typemove/iota/dist/esm/models.js
|
|
48
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
49
|
-
|
|
50
|
-
// ../../node_modules/.pnpm/@typemove+iota@1.11.0_typescript@5.5.2/node_modules/@typemove/iota/dist/esm/transaction.js
|
|
51
|
-
function isTransactionArgument(value) {
|
|
52
|
-
if (typeof value !== "object")
|
|
53
|
-
return false;
|
|
54
|
-
if (value === null || value === void 0)
|
|
55
|
-
return false;
|
|
56
|
-
return value.$kind === "GasCoin" || value.$kind === "Result" || value.$kind === "NestedResult" || value.$kind === "Input";
|
|
57
|
-
}
|
|
58
|
-
__name(isTransactionArgument, "isTransactionArgument");
|
|
59
|
-
function transactionArgumentOrObject(value, transactionBlock) {
|
|
60
|
-
if (isTransactionArgument(value)) {
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
return transactionBlock.object(value);
|
|
64
|
-
}
|
|
65
|
-
__name(transactionArgumentOrObject, "transactionArgumentOrObject");
|
|
66
|
-
function transactionArgumentOrPure(value, transactionBlock) {
|
|
67
|
-
if (isTransactionArgument(value)) {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
return typeof value == "string" ? transactionBlock.pure.string(value) : transactionBlock.pure.u64(value);
|
|
71
|
-
}
|
|
72
|
-
__name(transactionArgumentOrPure, "transactionArgumentOrPure");
|
|
73
|
-
function transactionArgumentOrPureAddress(value, transactionBlock) {
|
|
74
|
-
if (isTransactionArgument(value)) {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
return transactionBlock.pure.address(value);
|
|
78
|
-
}
|
|
79
|
-
__name(transactionArgumentOrPureAddress, "transactionArgumentOrPureAddress");
|
|
80
|
-
function transactionArgumentOrPureU8(value, transactionBlock) {
|
|
81
|
-
if (isTransactionArgument(value)) {
|
|
82
|
-
return value;
|
|
83
|
-
}
|
|
84
|
-
return transactionBlock.pure.u8(value);
|
|
85
|
-
}
|
|
86
|
-
__name(transactionArgumentOrPureU8, "transactionArgumentOrPureU8");
|
|
87
|
-
function transactionArgumentOrPureU16(value, transactionBlock) {
|
|
88
|
-
if (isTransactionArgument(value)) {
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
return transactionBlock.pure.u16(value);
|
|
92
|
-
}
|
|
93
|
-
__name(transactionArgumentOrPureU16, "transactionArgumentOrPureU16");
|
|
94
|
-
function transactionArgumentOrPureU32(value, transactionBlock) {
|
|
95
|
-
if (isTransactionArgument(value)) {
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
return transactionBlock.pure.u32(value);
|
|
99
|
-
}
|
|
100
|
-
__name(transactionArgumentOrPureU32, "transactionArgumentOrPureU32");
|
|
101
|
-
function transactionArgumentOrPureU64(value, transactionBlock) {
|
|
102
|
-
if (isTransactionArgument(value)) {
|
|
103
|
-
return value;
|
|
104
|
-
}
|
|
105
|
-
return transactionBlock.pure.u64(value);
|
|
106
|
-
}
|
|
107
|
-
__name(transactionArgumentOrPureU64, "transactionArgumentOrPureU64");
|
|
108
|
-
function transactionArgumentOrPureU128(value, transactionBlock) {
|
|
109
|
-
if (isTransactionArgument(value)) {
|
|
110
|
-
return value;
|
|
111
|
-
}
|
|
112
|
-
return transactionBlock.pure.u128(value);
|
|
113
|
-
}
|
|
114
|
-
__name(transactionArgumentOrPureU128, "transactionArgumentOrPureU128");
|
|
115
|
-
function transactionArgumentOrPureU256(value, transactionBlock) {
|
|
116
|
-
if (isTransactionArgument(value)) {
|
|
117
|
-
return value;
|
|
118
|
-
}
|
|
119
|
-
return transactionBlock.pure.u256(value);
|
|
120
|
-
}
|
|
121
|
-
__name(transactionArgumentOrPureU256, "transactionArgumentOrPureU256");
|
|
122
|
-
function transactionArgumentOrPureBool(value, transactionBlock) {
|
|
123
|
-
if (isTransactionArgument(value)) {
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
return transactionBlock.pure.bool(value);
|
|
127
|
-
}
|
|
128
|
-
__name(transactionArgumentOrPureBool, "transactionArgumentOrPureBool");
|
|
129
|
-
function transactionArgumentOrVec(value, transactionBlock) {
|
|
130
|
-
if (isTransactionArgument(value)) {
|
|
131
|
-
return value;
|
|
132
|
-
}
|
|
133
|
-
return transactionBlock.makeMoveVec({
|
|
134
|
-
elements: value.map((a) => transactionBlock.object(a))
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
__name(transactionArgumentOrVec, "transactionArgumentOrVec");
|
|
138
|
-
|
|
139
|
-
// ../../node_modules/.pnpm/@typemove+iota@1.11.0_typescript@5.5.2/node_modules/@typemove/iota/dist/esm/to-internal.js
|
|
140
|
-
function toInternalModule(module) {
|
|
141
|
-
return {
|
|
142
|
-
address: module.address,
|
|
143
|
-
exposedFunctions: Object.entries(module.exposedFunctions).map(([n, f]) => toInternalFunction(n, f)),
|
|
144
|
-
name: module.name,
|
|
145
|
-
structs: Object.entries(module.structs).map(([n, s]) => toInternalStruct(n, s)),
|
|
146
|
-
enums: []
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
__name(toInternalModule, "toInternalModule");
|
|
150
|
-
function toInternalFunction(name, func) {
|
|
151
|
-
let visibility;
|
|
152
|
-
switch (func.visibility) {
|
|
153
|
-
case "Private":
|
|
154
|
-
visibility = InternalMoveFunctionVisibility.PRIVATE;
|
|
155
|
-
break;
|
|
156
|
-
case "Public":
|
|
157
|
-
visibility = InternalMoveFunctionVisibility.PUBLIC;
|
|
158
|
-
break;
|
|
159
|
-
case "Friend":
|
|
160
|
-
visibility = InternalMoveFunctionVisibility.FRIEND;
|
|
161
|
-
break;
|
|
162
|
-
default:
|
|
163
|
-
throw Error("No visibility for function" + name);
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
typeParams: func.typeParameters.map((p) => {
|
|
167
|
-
return { constraints: p.abilities };
|
|
168
|
-
}),
|
|
169
|
-
isEntry: func.isEntry,
|
|
170
|
-
name,
|
|
171
|
-
params: func.parameters.map(toTypeDescriptor),
|
|
172
|
-
return: func.return.map(toTypeDescriptor),
|
|
173
|
-
visibility
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
__name(toInternalFunction, "toInternalFunction");
|
|
177
|
-
function toInternalStruct(name, struct) {
|
|
178
|
-
return {
|
|
179
|
-
abilities: struct.abilities.abilities,
|
|
180
|
-
fields: struct.fields.map(toInternalField),
|
|
181
|
-
typeParams: struct.typeParameters.map((p) => {
|
|
182
|
-
return { constraints: p.constraints.abilities };
|
|
183
|
-
}),
|
|
184
|
-
isNative: false,
|
|
185
|
-
isEvent: false,
|
|
186
|
-
name
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
__name(toInternalStruct, "toInternalStruct");
|
|
190
|
-
function toInternalField(module) {
|
|
191
|
-
return {
|
|
192
|
-
name: module.name,
|
|
193
|
-
type: toTypeDescriptor(module.type)
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
__name(toInternalField, "toInternalField");
|
|
197
|
-
function toTypeDescriptor(normalizedType) {
|
|
198
|
-
if (typeof normalizedType === "string") {
|
|
199
|
-
return new TypeDescriptor(normalizedType);
|
|
200
|
-
}
|
|
201
|
-
if ("Struct" in normalizedType) {
|
|
202
|
-
const qname = [normalizedType.Struct.address, normalizedType.Struct.module, normalizedType.Struct.name].join(SPLITTER);
|
|
203
|
-
const args = normalizedType.Struct.typeArguments.map(toTypeDescriptor);
|
|
204
|
-
return new TypeDescriptor(qname, args);
|
|
205
|
-
}
|
|
206
|
-
if ("Vector" in normalizedType) {
|
|
207
|
-
return new TypeDescriptor("Vector", [toTypeDescriptor(normalizedType.Vector)]);
|
|
208
|
-
}
|
|
209
|
-
if ("TypeParameter" in normalizedType) {
|
|
210
|
-
return new TypeDescriptor("T" + normalizedType.TypeParameter);
|
|
211
|
-
}
|
|
212
|
-
if ("Reference" in normalizedType) {
|
|
213
|
-
const res = toTypeDescriptor(normalizedType.Reference);
|
|
214
|
-
res.reference = true;
|
|
215
|
-
return res;
|
|
216
|
-
}
|
|
217
|
-
if ("MutableReference" in normalizedType) {
|
|
218
|
-
const res = toTypeDescriptor(normalizedType.MutableReference);
|
|
219
|
-
res.reference = true;
|
|
220
|
-
res.mutable = true;
|
|
221
|
-
return res;
|
|
222
|
-
}
|
|
223
|
-
throw new Error("Unexpected sui type");
|
|
224
|
-
}
|
|
225
|
-
__name(toTypeDescriptor, "toTypeDescriptor");
|
|
226
|
-
|
|
227
|
-
// ../../node_modules/.pnpm/@typemove+iota@1.11.0_typescript@5.5.2/node_modules/@typemove/iota/dist/esm/sui-chain-adapter.js
|
|
228
|
-
var IotaChainAdapter = class extends ChainAdapter {
|
|
229
|
-
static {
|
|
230
|
-
__name(this, "IotaChainAdapter");
|
|
231
|
-
}
|
|
232
|
-
async getChainId() {
|
|
233
|
-
return this.client.getChainIdentifier();
|
|
234
|
-
}
|
|
235
|
-
// static INSTANCE = new IotaChainAdapter()
|
|
236
|
-
client;
|
|
237
|
-
constructor(client) {
|
|
238
|
-
super();
|
|
239
|
-
this.client = client;
|
|
240
|
-
}
|
|
241
|
-
async fetchModule(account, module) {
|
|
242
|
-
return await this.client.getNormalizedMoveModule({ package: account, module });
|
|
243
|
-
}
|
|
244
|
-
async fetchModules(account) {
|
|
245
|
-
const modules = await this.client.getNormalizedMoveModulesByPackage({
|
|
246
|
-
package: account
|
|
247
|
-
});
|
|
248
|
-
return Object.values(modules);
|
|
249
|
-
}
|
|
250
|
-
getMeaningfulFunctionParams(params) {
|
|
251
|
-
return params;
|
|
252
|
-
}
|
|
253
|
-
toInternalModules(modules) {
|
|
254
|
-
return Object.values(modules).map(toInternalModule);
|
|
255
|
-
}
|
|
256
|
-
getAllEventStructs(modules) {
|
|
257
|
-
const eventMap = /* @__PURE__ */ new Map();
|
|
258
|
-
for (const module of modules) {
|
|
259
|
-
const qname = moduleQname(module);
|
|
260
|
-
for (const struct of module.structs) {
|
|
261
|
-
const abilities = new Set(struct.abilities);
|
|
262
|
-
if (abilities.has("Drop") && abilities.has("Copy")) {
|
|
263
|
-
eventMap.set(qname + SPLITTER + struct.name, struct);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return eventMap;
|
|
268
|
-
}
|
|
269
|
-
getType(base) {
|
|
270
|
-
return base.type;
|
|
271
|
-
}
|
|
272
|
-
getData(val) {
|
|
273
|
-
if (val === void 0) {
|
|
274
|
-
throw Error("val is undefined");
|
|
275
|
-
}
|
|
276
|
-
if ("parsedJson" in val) {
|
|
277
|
-
return val.parsedJson;
|
|
278
|
-
}
|
|
279
|
-
if (val.dataType === "moveObject") {
|
|
280
|
-
return val.fields;
|
|
281
|
-
}
|
|
282
|
-
if ("fields" in val) {
|
|
283
|
-
if ("type" in val && Object.keys(val).length === 2) {
|
|
284
|
-
return val.fields;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return val;
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
// ../../node_modules/.pnpm/@typemove+iota@1.11.0_typescript@5.5.2/node_modules/@typemove/iota/dist/esm/move-coder.js
|
|
292
|
-
var MoveCoder = class extends AbstractMoveCoder {
|
|
293
|
-
static {
|
|
294
|
-
__name(this, "MoveCoder");
|
|
295
|
-
}
|
|
296
|
-
constructor(client) {
|
|
297
|
-
super(new IotaChainAdapter(client));
|
|
298
|
-
}
|
|
299
|
-
async maybeGetMoveEnum(type) {
|
|
300
|
-
return void 0;
|
|
301
|
-
}
|
|
302
|
-
load(module, address) {
|
|
303
|
-
let m = this.moduleMapping.get(module.address + "::" + module.name);
|
|
304
|
-
const mDeclared = this.moduleMapping.get(address + "::" + module.name);
|
|
305
|
-
if (m && mDeclared) {
|
|
306
|
-
return m;
|
|
307
|
-
}
|
|
308
|
-
this.accounts.add(module.address);
|
|
309
|
-
m = toInternalModule(module);
|
|
310
|
-
this.loadInternal(m, address);
|
|
311
|
-
return m;
|
|
312
|
-
}
|
|
313
|
-
async decode(data, type) {
|
|
314
|
-
switch (type.qname) {
|
|
315
|
-
case "0x1::ascii::Char":
|
|
316
|
-
if (data !== void 0 && typeof data !== "string") {
|
|
317
|
-
const byte = (await super.decode(data, type)).byte;
|
|
318
|
-
return String.fromCharCode(byte);
|
|
319
|
-
}
|
|
320
|
-
case "0x1::ascii::String":
|
|
321
|
-
if (data !== void 0 && typeof data !== "string") {
|
|
322
|
-
const bytes = (await super.decode(data, type)).bytes;
|
|
323
|
-
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
324
|
-
}
|
|
325
|
-
case "0x2::object::ID":
|
|
326
|
-
if (data !== void 0 && typeof data !== "string") {
|
|
327
|
-
const bytes = (await super.decode(data, type)).bytes;
|
|
328
|
-
return normalizeIotaObjectId(bytes);
|
|
329
|
-
}
|
|
330
|
-
case "0x2::url::Url":
|
|
331
|
-
if (data !== void 0 && typeof data !== "string") {
|
|
332
|
-
return (await super.decode(data, type)).url;
|
|
333
|
-
}
|
|
334
|
-
case "0x2::coin::Coin":
|
|
335
|
-
if (data !== void 0 && typeof data !== "string") {
|
|
336
|
-
const bytes = (await super.decode(data, type)).id.id.bytes;
|
|
337
|
-
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
338
|
-
}
|
|
339
|
-
return data;
|
|
340
|
-
case "0x2::balance::Balance":
|
|
341
|
-
if (data.value) {
|
|
342
|
-
const balance = await super.decode(data, type);
|
|
343
|
-
return balance.value;
|
|
344
|
-
}
|
|
345
|
-
return BigInt(data);
|
|
346
|
-
case "0x1::option::Option":
|
|
347
|
-
if (data === null) {
|
|
348
|
-
return data;
|
|
349
|
-
}
|
|
350
|
-
if (data.vec) {
|
|
351
|
-
let vec = await super.decode(data, type);
|
|
352
|
-
vec = vec.vec;
|
|
353
|
-
if (vec.length === 0) {
|
|
354
|
-
return null;
|
|
355
|
-
}
|
|
356
|
-
return vec[0];
|
|
357
|
-
}
|
|
358
|
-
return this.decode(data, type.typeArgs[0]);
|
|
359
|
-
case "Address":
|
|
360
|
-
const str = data;
|
|
361
|
-
return normalizeIotaAddress(str);
|
|
362
|
-
case "0x1::string::String":
|
|
363
|
-
if (typeof data !== "string") {
|
|
364
|
-
return new TextDecoder().decode(new Uint8Array(data.bytes));
|
|
365
|
-
}
|
|
366
|
-
default:
|
|
367
|
-
return super.decode(data, type);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
decodeEvent(event) {
|
|
371
|
-
return this.decodedStruct(event);
|
|
372
|
-
}
|
|
373
|
-
filterAndDecodeEvents(type, resources) {
|
|
374
|
-
if (typeof type === "string") {
|
|
375
|
-
type = parseMoveType(type);
|
|
376
|
-
}
|
|
377
|
-
return this.filterAndDecodeStruct(type, resources);
|
|
378
|
-
}
|
|
379
|
-
async getDynamicFields(objects, keyType = ANY_TYPE, valueType = ANY_TYPE) {
|
|
380
|
-
const type = new TypeDescriptor("0x2::dynamic_field::Field");
|
|
381
|
-
type.typeArgs = [keyType, valueType];
|
|
382
|
-
const res = await this.filterAndDecodeObjects(type, objects);
|
|
383
|
-
return res.map((o) => o.data_decoded);
|
|
384
|
-
}
|
|
385
|
-
filterAndDecodeObjects(type, objects) {
|
|
386
|
-
return this.filterAndDecodeStruct(type, objects);
|
|
387
|
-
}
|
|
388
|
-
async decodeFunctionPayload(payload, inputs) {
|
|
389
|
-
const functionType = [payload.package, payload.module, payload.function].join(SPLITTER);
|
|
390
|
-
const func = await this.getMoveFunction(functionType);
|
|
391
|
-
const params = this.adapter.getMeaningfulFunctionParams(func.params);
|
|
392
|
-
const args = [];
|
|
393
|
-
for (const value of payload.arguments || []) {
|
|
394
|
-
const argValue = value;
|
|
395
|
-
if ("Input" in argValue) {
|
|
396
|
-
const idx = argValue.Input;
|
|
397
|
-
const arg = inputs[idx];
|
|
398
|
-
if (arg.type === "pure") {
|
|
399
|
-
args.push(arg.value);
|
|
400
|
-
} else if (arg.type === "object") {
|
|
401
|
-
args.push(void 0);
|
|
402
|
-
} else {
|
|
403
|
-
console.error("unexpected function arg value");
|
|
404
|
-
args.push(void 0);
|
|
405
|
-
}
|
|
406
|
-
} else {
|
|
407
|
-
args.push(void 0);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
const argumentsTyped = await this.decodeArray(args, params, false);
|
|
411
|
-
return {
|
|
412
|
-
...payload,
|
|
413
|
-
arguments_decoded: argumentsTyped
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
bcsRegistered = /* @__PURE__ */ new Set();
|
|
417
|
-
bcsRegistry = /* @__PURE__ */ new Map();
|
|
418
|
-
async getBCSTypeWithArgs(type, args = []) {
|
|
419
|
-
const qname = type.qname;
|
|
420
|
-
const sig = type.getNormalizedSignature();
|
|
421
|
-
const cached = this.bcsRegistry.get(sig);
|
|
422
|
-
if (cached) {
|
|
423
|
-
return cached;
|
|
424
|
-
}
|
|
425
|
-
const lowerQname = qname.toLowerCase();
|
|
426
|
-
switch (lowerQname) {
|
|
427
|
-
case "u8":
|
|
428
|
-
case "u16":
|
|
429
|
-
case "u32":
|
|
430
|
-
case "u64":
|
|
431
|
-
case "u128":
|
|
432
|
-
case "u256":
|
|
433
|
-
case "bool":
|
|
434
|
-
return iotaBcs[lowerQname]();
|
|
435
|
-
case "address":
|
|
436
|
-
return iotaBcs.Address;
|
|
437
|
-
case "vector":
|
|
438
|
-
return iotaBcs.vector(args[0]);
|
|
439
|
-
default:
|
|
440
|
-
if (!qname.includes("::")) {
|
|
441
|
-
throw `Unimplemented builtin type ${qname}`;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
let moveStruct;
|
|
445
|
-
try {
|
|
446
|
-
moveStruct = await this.getMoveStruct(qname);
|
|
447
|
-
} catch (e) {
|
|
448
|
-
console.error("Invalid move address", qname);
|
|
449
|
-
throw e;
|
|
450
|
-
}
|
|
451
|
-
const structDef = {};
|
|
452
|
-
for (const field of moveStruct.fields) {
|
|
453
|
-
if (field.type.qname.startsWith("T") && args.length) {
|
|
454
|
-
const index = +field.type.qname.slice(1);
|
|
455
|
-
structDef[field.name] = args[index];
|
|
456
|
-
} else if (field.type.typeArgs.length && args.length) {
|
|
457
|
-
structDef[field.name] = await this.getBCSTypeWithArgs(field.type, args);
|
|
458
|
-
} else {
|
|
459
|
-
structDef[field.name] = await this.getBCSType(field.type);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return iotaBcs.struct(qname, structDef);
|
|
463
|
-
}
|
|
464
|
-
async getBCSType(type) {
|
|
465
|
-
const args = await Promise.all(type.typeArgs.map((x) => this.getBCSType(x)));
|
|
466
|
-
const bcsType = await this.getBCSTypeWithArgs(type, args);
|
|
467
|
-
this.bcsRegistry.set(type.getNormalizedSignature(), bcsType);
|
|
468
|
-
return bcsType;
|
|
469
|
-
}
|
|
470
|
-
async registerBCSTypes(type) {
|
|
471
|
-
const sig = type.getNormalizedSignature();
|
|
472
|
-
if (this.bcsRegistered.has(sig)) {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
this.bcsRegistered.add(sig);
|
|
476
|
-
const bcsType = await this.getBCSType(type);
|
|
477
|
-
this.bcsRegistry.set(type.getNormalizedSignature(), bcsType);
|
|
478
|
-
}
|
|
479
|
-
async decodeBCS(type, data, encoding) {
|
|
480
|
-
await this.registerBCSTypes(type);
|
|
481
|
-
if (typeof data == "string") {
|
|
482
|
-
const buf = Buffer.from(data, encoding);
|
|
483
|
-
data = new Uint8Array(buf, buf.byteOffset, buf.byteLength);
|
|
484
|
-
}
|
|
485
|
-
const bcsType = this.bcsRegistry.get(type.getNormalizedSignature());
|
|
486
|
-
return bcsType?.parse(data);
|
|
487
|
-
}
|
|
488
|
-
async decodeDevInspectResult(inspectRes) {
|
|
489
|
-
const returnValues = [];
|
|
490
|
-
if (inspectRes.results != null) {
|
|
491
|
-
for (const r of inspectRes.results) {
|
|
492
|
-
if (r.returnValues) {
|
|
493
|
-
for (const returnValue of r.returnValues) {
|
|
494
|
-
const type = parseMoveType(returnValue[1]);
|
|
495
|
-
const bcsDecoded = await this.decodeBCS(type, new Uint8Array(returnValue[0]));
|
|
496
|
-
const decoded = await this.decodeType(bcsDecoded, type);
|
|
497
|
-
returnValues.push(decoded);
|
|
498
|
-
}
|
|
499
|
-
} else {
|
|
500
|
-
returnValues.push(null);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
return { ...inspectRes, results_decoded: returnValues };
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
var DEFAULT_ENDPOINT = "https://api.mainnet.iota.cafe/";
|
|
508
|
-
var CODER_MAP = /* @__PURE__ */ new Map();
|
|
509
|
-
function defaultMoveCoder(endpoint = DEFAULT_ENDPOINT) {
|
|
510
|
-
let coder = CODER_MAP.get(endpoint);
|
|
511
|
-
if (!coder) {
|
|
512
|
-
coder = new MoveCoder(new IotaClient({ url: endpoint }));
|
|
513
|
-
CODER_MAP.set(endpoint, coder);
|
|
514
|
-
}
|
|
515
|
-
return coder;
|
|
516
|
-
}
|
|
517
|
-
__name(defaultMoveCoder, "defaultMoveCoder");
|
|
518
|
-
var PROVIDER_CODER_MAP = /* @__PURE__ */ new Map();
|
|
519
|
-
var DEFAULT_CHAIN_ID;
|
|
520
|
-
async function getMoveCoder(client) {
|
|
521
|
-
let coder = PROVIDER_CODER_MAP.get(client);
|
|
522
|
-
if (!coder) {
|
|
523
|
-
coder = new MoveCoder(client);
|
|
524
|
-
const id = await client.getChainIdentifier();
|
|
525
|
-
const defaultCoder = defaultMoveCoder();
|
|
526
|
-
if (!DEFAULT_CHAIN_ID) {
|
|
527
|
-
DEFAULT_CHAIN_ID = await defaultCoder.adapter.getChainId();
|
|
528
|
-
}
|
|
529
|
-
if (id === DEFAULT_CHAIN_ID) {
|
|
530
|
-
coder = defaultCoder;
|
|
531
|
-
}
|
|
532
|
-
PROVIDER_CODER_MAP.set(client, coder);
|
|
533
|
-
}
|
|
534
|
-
return coder;
|
|
535
|
-
}
|
|
536
|
-
__name(getMoveCoder, "getMoveCoder");
|
|
537
|
-
|
|
538
|
-
// src/iota/move-coder.ts
|
|
539
|
-
var CODERS = /* @__PURE__ */ new Map();
|
|
540
|
-
function defaultMoveCoder2(network = IotaNetwork.MAIN_NET) {
|
|
541
|
-
let coder = CODERS.get(network);
|
|
542
|
-
if (!coder) {
|
|
543
|
-
coder = new MoveCoder(getClient(network));
|
|
544
|
-
CODERS.set(network, coder);
|
|
545
|
-
}
|
|
546
|
-
return coder;
|
|
547
|
-
}
|
|
548
|
-
__name(defaultMoveCoder2, "defaultMoveCoder");
|
|
549
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
550
|
-
|
|
551
|
-
// src/iota/context.ts
|
|
552
|
-
var IotaContext = class extends MoveContext {
|
|
553
|
-
static {
|
|
554
|
-
__name(this, "IotaContext");
|
|
555
|
-
}
|
|
556
|
-
moduleName;
|
|
557
|
-
timestamp;
|
|
558
|
-
checkpoint;
|
|
559
|
-
transaction;
|
|
560
|
-
eventIndex;
|
|
561
|
-
coder;
|
|
562
|
-
constructor(moduleName, network, address, timestamp, checkpoint, transaction, eventIndex, baseLabels) {
|
|
563
|
-
super(baseLabels);
|
|
564
|
-
this.address = address.toLowerCase();
|
|
565
|
-
this.network = network;
|
|
566
|
-
this.moduleName = moduleName;
|
|
567
|
-
this.timestamp = timestamp;
|
|
568
|
-
this.checkpoint = checkpoint;
|
|
569
|
-
this.eventIndex = eventIndex;
|
|
570
|
-
this.coder = defaultMoveCoder2(network);
|
|
571
|
-
if (transaction) {
|
|
572
|
-
this.transaction = transaction;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
getChainId() {
|
|
576
|
-
return this.network;
|
|
577
|
-
}
|
|
578
|
-
getTimestamp() {
|
|
579
|
-
return this.timestamp.getDate();
|
|
580
|
-
}
|
|
581
|
-
getMetaDataInternal(name, labels) {
|
|
582
|
-
return {
|
|
583
|
-
address: this.address,
|
|
584
|
-
contractName: this.moduleName,
|
|
585
|
-
blockNumber: this.checkpoint,
|
|
586
|
-
transactionIndex: 0,
|
|
587
|
-
transactionHash: this.transaction?.digest || "",
|
|
588
|
-
// TODO
|
|
589
|
-
logIndex: this.eventIndex,
|
|
590
|
-
chainId: this.getChainId(),
|
|
591
|
-
name,
|
|
592
|
-
labels: normalizeLabels(labels)
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
get client() {
|
|
596
|
-
return getClient(this.network);
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
var IotaObjectChangeContext = class extends MoveContext {
|
|
600
|
-
static {
|
|
601
|
-
__name(this, "IotaObjectChangeContext");
|
|
602
|
-
}
|
|
603
|
-
timestamp;
|
|
604
|
-
checkpoint;
|
|
605
|
-
coder;
|
|
606
|
-
txDigest;
|
|
607
|
-
constructor(network, address, timestamp, checkpoint, txDigest, baseLabels) {
|
|
608
|
-
super(baseLabels);
|
|
609
|
-
this.address = address;
|
|
610
|
-
this.network = network;
|
|
611
|
-
this.timestamp = timestamp;
|
|
612
|
-
this.checkpoint = checkpoint;
|
|
613
|
-
this.txDigest = txDigest;
|
|
614
|
-
this.coder = defaultMoveCoder2(network);
|
|
615
|
-
}
|
|
616
|
-
getChainId() {
|
|
617
|
-
return this.network;
|
|
618
|
-
}
|
|
619
|
-
getTimestamp() {
|
|
620
|
-
return this.timestamp.getDate();
|
|
621
|
-
}
|
|
622
|
-
getMetaDataInternal(name, labels) {
|
|
623
|
-
return {
|
|
624
|
-
address: this.address,
|
|
625
|
-
contractName: "*",
|
|
626
|
-
blockNumber: this.checkpoint,
|
|
627
|
-
transactionIndex: -1,
|
|
628
|
-
transactionHash: this.txDigest,
|
|
629
|
-
logIndex: 0,
|
|
630
|
-
chainId: this.getChainId(),
|
|
631
|
-
name,
|
|
632
|
-
labels: normalizeLabels(labels)
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
get client() {
|
|
636
|
-
return getClient(this.network);
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
var IotaAddressContext = class extends MoveAccountContext {
|
|
640
|
-
static {
|
|
641
|
-
__name(this, "IotaAddressContext");
|
|
642
|
-
}
|
|
643
|
-
address;
|
|
644
|
-
network;
|
|
645
|
-
checkpoint;
|
|
646
|
-
timestamp;
|
|
647
|
-
coder;
|
|
648
|
-
contractName = "address";
|
|
649
|
-
constructor(network, address, checkpoint, timestamp, baseLabels) {
|
|
650
|
-
super(baseLabels);
|
|
651
|
-
this.address = address;
|
|
652
|
-
this.network = network;
|
|
653
|
-
this.checkpoint = checkpoint;
|
|
654
|
-
this.timestamp = timestamp;
|
|
655
|
-
this.coder = defaultMoveCoder2(network);
|
|
656
|
-
}
|
|
657
|
-
getChainId() {
|
|
658
|
-
return this.network;
|
|
659
|
-
}
|
|
660
|
-
getMetaDataInternal(name, labels) {
|
|
661
|
-
return {
|
|
662
|
-
address: this.address,
|
|
663
|
-
contractName: this.contractName,
|
|
664
|
-
blockNumber: this.checkpoint,
|
|
665
|
-
transactionIndex: 0,
|
|
666
|
-
transactionHash: "",
|
|
667
|
-
logIndex: 0,
|
|
668
|
-
chainId: this.getChainId(),
|
|
669
|
-
name,
|
|
670
|
-
labels: normalizeLabels(labels)
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
get client() {
|
|
674
|
-
return getClient(this.network);
|
|
675
|
-
}
|
|
676
|
-
getTimestamp() {
|
|
677
|
-
return this.timestamp.getDate();
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
var IotaObjectContext = class extends IotaAddressContext {
|
|
681
|
-
static {
|
|
682
|
-
__name(this, "IotaObjectContext");
|
|
683
|
-
}
|
|
684
|
-
contractName = "object";
|
|
685
|
-
objectId;
|
|
686
|
-
objectVersion;
|
|
687
|
-
constructor(network, objectId, objectVersion, checkpoint, timestamp, baseLabels) {
|
|
688
|
-
super(network, objectId, checkpoint, timestamp, baseLabels);
|
|
689
|
-
this.objectId = objectId;
|
|
690
|
-
this.objectVersion = objectVersion;
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
694
|
-
|
|
695
|
-
// src/iota/utils.ts
|
|
696
|
-
function getMoveCalls(txBlock) {
|
|
697
|
-
const txKind = txBlock.transaction?.data.transaction;
|
|
698
|
-
if (!txKind) {
|
|
699
|
-
return [];
|
|
700
|
-
}
|
|
701
|
-
const programmableTx = txKind.kind === "ProgrammableTransaction" ? txKind : void 0;
|
|
702
|
-
if (!programmableTx) {
|
|
703
|
-
return [];
|
|
704
|
-
}
|
|
705
|
-
return programmableTx.transactions.flatMap((tx) => {
|
|
706
|
-
if ("MoveCall" in tx) {
|
|
707
|
-
const call = tx.MoveCall;
|
|
708
|
-
call.package = accountTypeString(call.package);
|
|
709
|
-
return [call];
|
|
710
|
-
}
|
|
711
|
-
return [];
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
__name(getMoveCalls, "getMoveCalls");
|
|
715
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
716
|
-
|
|
717
|
-
// src/iota/iota-processor.ts
|
|
718
|
-
var DEFAULT_FETCH_CONFIG = {
|
|
719
|
-
resourceChanges: false,
|
|
720
|
-
allEvents: true,
|
|
721
|
-
inputs: true
|
|
722
|
-
};
|
|
723
|
-
function configure(options) {
|
|
724
|
-
return {
|
|
725
|
-
startCheckpoint: options.startCheckpoint || 0n,
|
|
726
|
-
endCheckpoint: options.endCheckpoint,
|
|
727
|
-
address: options.address === ALL_ADDRESS ? ALL_ADDRESS : accountAddressString(options.address),
|
|
728
|
-
network: options.network || IotaNetwork.MAIN_NET,
|
|
729
|
-
baseLabels: options.baseLabels
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
__name(configure, "configure");
|
|
733
|
-
var IotaProcessorState = class _IotaProcessorState extends ListStateStorage {
|
|
734
|
-
static {
|
|
735
|
-
__name(this, "IotaProcessorState");
|
|
736
|
-
}
|
|
737
|
-
static INSTANCE = new _IotaProcessorState();
|
|
738
|
-
};
|
|
739
|
-
var IotaBaseProcessor = class {
|
|
740
|
-
static {
|
|
741
|
-
__name(this, "IotaBaseProcessor");
|
|
742
|
-
}
|
|
743
|
-
moduleName;
|
|
744
|
-
config;
|
|
745
|
-
eventHandlers = [];
|
|
746
|
-
callHandlers = [];
|
|
747
|
-
objectChangeHandlers = [];
|
|
748
|
-
coder;
|
|
749
|
-
constructor(name, options) {
|
|
750
|
-
this.moduleName = name;
|
|
751
|
-
this.config = configure(options);
|
|
752
|
-
IotaProcessorState.INSTANCE.addValue(this);
|
|
753
|
-
this.coder = defaultMoveCoder2(this.config.network);
|
|
754
|
-
return proxyProcessor(this);
|
|
755
|
-
}
|
|
756
|
-
getChainId() {
|
|
757
|
-
return this.config.network;
|
|
758
|
-
}
|
|
759
|
-
onMoveEvent(handler, filter, handlerOptions) {
|
|
760
|
-
let _filters = [];
|
|
761
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions });
|
|
762
|
-
if (Array.isArray(filter)) {
|
|
763
|
-
_filters = filter;
|
|
764
|
-
} else {
|
|
765
|
-
_filters.push(filter);
|
|
766
|
-
}
|
|
767
|
-
const processor = this;
|
|
768
|
-
this.eventHandlers.push({
|
|
769
|
-
handlerName: getHandlerName(),
|
|
770
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
771
|
-
if (!data.rawTransaction) {
|
|
772
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "event is null");
|
|
773
|
-
}
|
|
774
|
-
const txn = JSON.parse(data.rawTransaction);
|
|
775
|
-
if (txn.events == null) {
|
|
776
|
-
txn.events = [];
|
|
777
|
-
}
|
|
778
|
-
const evt = JSON.parse(data.rawEvent);
|
|
779
|
-
const idx = Number(evt.id.eventSeq) || 0;
|
|
780
|
-
const ctx = new IotaContext(
|
|
781
|
-
processor.moduleName,
|
|
782
|
-
processor.config.network,
|
|
783
|
-
processor.config.address,
|
|
784
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
785
|
-
data.slot,
|
|
786
|
-
txn,
|
|
787
|
-
idx,
|
|
788
|
-
processor.config.baseLabels
|
|
789
|
-
);
|
|
790
|
-
const decoded = await processor.coder.decodeEvent(evt);
|
|
791
|
-
await handler(decoded || evt, ctx);
|
|
792
|
-
return ctx.stopAndGetResult();
|
|
793
|
-
}, "handler"),
|
|
794
|
-
filters: _filters,
|
|
795
|
-
fetchConfig: _fetchConfig,
|
|
796
|
-
partitionHandler: /* @__PURE__ */ __name(async (data) => {
|
|
797
|
-
const p = handlerOptions?.partitionKey;
|
|
798
|
-
if (!p) return void 0;
|
|
799
|
-
if (typeof p === "function") {
|
|
800
|
-
const evt = JSON.parse(data.rawEvent);
|
|
801
|
-
const decoded = await processor.coder.decodeEvent(evt);
|
|
802
|
-
return p(decoded || evt);
|
|
803
|
-
}
|
|
804
|
-
return p;
|
|
805
|
-
}, "partitionHandler")
|
|
806
|
-
});
|
|
807
|
-
return this;
|
|
808
|
-
}
|
|
809
|
-
onEntryFunctionCall(handler, filter, handlerOptions) {
|
|
810
|
-
let _filters = [];
|
|
811
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions });
|
|
812
|
-
if (Array.isArray(filter)) {
|
|
813
|
-
_filters = filter;
|
|
814
|
-
} else {
|
|
815
|
-
_filters.push(filter);
|
|
816
|
-
}
|
|
817
|
-
const processor = this;
|
|
818
|
-
const allFunctionType = new Set(_filters.map((f) => f.function));
|
|
819
|
-
this.callHandlers.push({
|
|
820
|
-
handlerName: getHandlerName(),
|
|
821
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
822
|
-
if (!data.rawTransaction) {
|
|
823
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "call is null");
|
|
824
|
-
}
|
|
825
|
-
const tx = JSON.parse(data.rawTransaction);
|
|
826
|
-
const ctx = new IotaContext(
|
|
827
|
-
processor.moduleName,
|
|
828
|
-
processor.config.network,
|
|
829
|
-
processor.config.address,
|
|
830
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
831
|
-
data.slot,
|
|
832
|
-
tx,
|
|
833
|
-
0,
|
|
834
|
-
processor.config.baseLabels
|
|
835
|
-
);
|
|
836
|
-
if (tx) {
|
|
837
|
-
const calls = getMoveCalls(tx);
|
|
838
|
-
const txKind = tx.transaction?.data?.transaction;
|
|
839
|
-
if (!txKind) {
|
|
840
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Unexpected getTransactionKind get empty");
|
|
841
|
-
}
|
|
842
|
-
const programmableTx = txKind.kind === "ProgrammableTransaction" ? txKind : void 0;
|
|
843
|
-
for (const call of calls) {
|
|
844
|
-
const functionType = [call.module, call.function].join(SPLITTER);
|
|
845
|
-
if (!allFunctionType.has(functionType)) {
|
|
846
|
-
continue;
|
|
847
|
-
}
|
|
848
|
-
const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || []);
|
|
849
|
-
await handler(decoded, ctx);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
return ctx.stopAndGetResult();
|
|
853
|
-
}, "handler"),
|
|
854
|
-
filters: _filters,
|
|
855
|
-
fetchConfig: _fetchConfig,
|
|
856
|
-
partitionHandler: /* @__PURE__ */ __name(async (data) => {
|
|
857
|
-
const p = handlerOptions?.partitionKey;
|
|
858
|
-
if (!p) return void 0;
|
|
859
|
-
if (typeof p === "function") {
|
|
860
|
-
const tx = JSON.parse(data.rawTransaction);
|
|
861
|
-
const calls = getMoveCalls(tx);
|
|
862
|
-
if (calls.length > 0) {
|
|
863
|
-
return p(calls[0]);
|
|
864
|
-
}
|
|
865
|
-
return void 0;
|
|
866
|
-
}
|
|
867
|
-
return p;
|
|
868
|
-
}, "partitionHandler")
|
|
869
|
-
});
|
|
870
|
-
return this;
|
|
871
|
-
}
|
|
872
|
-
onEvent(handler, handlerOptions) {
|
|
873
|
-
this.onMoveEvent(handler, { type: "" }, handlerOptions);
|
|
874
|
-
return this;
|
|
875
|
-
}
|
|
876
|
-
onTransactionBlock(handler, filter, handlerOptions) {
|
|
877
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions });
|
|
878
|
-
const processor = this;
|
|
879
|
-
this.callHandlers.push({
|
|
880
|
-
handlerName: getHandlerName(),
|
|
881
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
882
|
-
if (!data.rawTransaction) {
|
|
883
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "transaction is null");
|
|
884
|
-
}
|
|
885
|
-
const tx = JSON.parse(data.rawTransaction);
|
|
886
|
-
const ctx = new IotaContext(
|
|
887
|
-
processor.moduleName,
|
|
888
|
-
processor.config.network,
|
|
889
|
-
processor.config.address,
|
|
890
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
891
|
-
data.slot,
|
|
892
|
-
tx,
|
|
893
|
-
0,
|
|
894
|
-
processor.config.baseLabels
|
|
895
|
-
);
|
|
896
|
-
if (tx) {
|
|
897
|
-
await handler(tx, ctx);
|
|
898
|
-
}
|
|
899
|
-
return ctx.stopAndGetResult();
|
|
900
|
-
}, "handler"),
|
|
901
|
-
filters: [{ ...filter, function: "" }],
|
|
902
|
-
fetchConfig: _fetchConfig,
|
|
903
|
-
partitionHandler: /* @__PURE__ */ __name(async (data) => {
|
|
904
|
-
const p = handlerOptions?.partitionKey;
|
|
905
|
-
if (!p) return void 0;
|
|
906
|
-
if (typeof p === "function") {
|
|
907
|
-
const tx = JSON.parse(data.rawTransaction);
|
|
908
|
-
return p(tx);
|
|
909
|
-
}
|
|
910
|
-
return p;
|
|
911
|
-
}, "partitionHandler")
|
|
912
|
-
});
|
|
913
|
-
return this;
|
|
914
|
-
}
|
|
915
|
-
onObjectChange(handler, type) {
|
|
916
|
-
if (this.config.network === IotaNetwork.TEST_NET) {
|
|
917
|
-
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "object change not supported in testnet");
|
|
918
|
-
}
|
|
919
|
-
const processor = this;
|
|
920
|
-
this.objectChangeHandlers.push({
|
|
921
|
-
handlerName: getHandlerName(),
|
|
922
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
923
|
-
const ctx = new IotaObjectChangeContext(
|
|
924
|
-
processor.config.network,
|
|
925
|
-
processor.config.address,
|
|
926
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
927
|
-
data.slot,
|
|
928
|
-
data.txDigest,
|
|
929
|
-
processor.config.baseLabels
|
|
930
|
-
);
|
|
931
|
-
await handler(data.rawChanges.map((r) => JSON.parse(r)), ctx);
|
|
932
|
-
return ctx.stopAndGetResult();
|
|
933
|
-
}, "handler"),
|
|
934
|
-
type
|
|
935
|
-
});
|
|
936
|
-
return this;
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
var IotaModulesProcessor = class _IotaModulesProcessor extends IotaBaseProcessor {
|
|
940
|
-
static {
|
|
941
|
-
__name(this, "IotaModulesProcessor");
|
|
942
|
-
}
|
|
943
|
-
static bind(options) {
|
|
944
|
-
return new _IotaModulesProcessor(ALL_ADDRESS, options);
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
var IotaGlobalProcessor = class _IotaGlobalProcessor extends IotaBaseProcessor {
|
|
948
|
-
static {
|
|
949
|
-
__name(this, "IotaGlobalProcessor");
|
|
950
|
-
}
|
|
951
|
-
static bind(options) {
|
|
952
|
-
return new _IotaGlobalProcessor(ALL_ADDRESS, { ...options, address: ALL_ADDRESS });
|
|
953
|
-
}
|
|
954
|
-
onTransactionBlock(handler, filter, fetchConfig) {
|
|
955
|
-
return super.onTransactionBlock(handler, filter, fetchConfig);
|
|
956
|
-
}
|
|
957
|
-
// deprecated,, use object type processor
|
|
958
|
-
onObjectChange(handler, type) {
|
|
959
|
-
return super.onObjectChange(handler, type);
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
963
|
-
|
|
964
|
-
// src/iota/iota-object-processor.ts
|
|
965
|
-
import { ListStateStorage as ListStateStorage2 } from "@sentio/runtime";
|
|
966
|
-
var import_nice_grpc2 = __toESM(require_lib(), 1);
|
|
967
|
-
var DEFAULT_ACCOUNT_FETCH_CONFIG = {
|
|
968
|
-
owned: false
|
|
969
|
-
};
|
|
970
|
-
var IotaAccountProcessorState = class _IotaAccountProcessorState extends ListStateStorage2 {
|
|
971
|
-
static {
|
|
972
|
-
__name(this, "IotaAccountProcessorState");
|
|
973
|
-
}
|
|
974
|
-
static INSTANCE = new _IotaAccountProcessorState();
|
|
975
|
-
};
|
|
976
|
-
var IotaBaseObjectOrAddressProcessor = class {
|
|
977
|
-
static {
|
|
978
|
-
__name(this, "IotaBaseObjectOrAddressProcessor");
|
|
979
|
-
}
|
|
980
|
-
config;
|
|
981
|
-
ownerType;
|
|
982
|
-
templateId;
|
|
983
|
-
objectHandlers = [];
|
|
984
|
-
objectChangeHandlers = [];
|
|
985
|
-
// static bind(options: IotaObjectsBindOptions): IotaBaseObjectsProcessor<any> {
|
|
986
|
-
// return new IotaBaseObjectsProcessor(options)
|
|
987
|
-
// }
|
|
988
|
-
constructor(options) {
|
|
989
|
-
if (options.ownerType === MoveOwnerType.TYPE) {
|
|
990
|
-
this.config = {
|
|
991
|
-
startCheckpoint: options.startCheckpoint || 0n,
|
|
992
|
-
endCheckpoint: options.endCheckpoint,
|
|
993
|
-
address: options.address === "*" ? "*" : accountTypeString(options.address),
|
|
994
|
-
network: options.network || IotaNetwork.MAIN_NET,
|
|
995
|
-
baseLabels: options.baseLabels
|
|
996
|
-
};
|
|
997
|
-
} else {
|
|
998
|
-
this.config = configure(options);
|
|
999
|
-
}
|
|
1000
|
-
this.ownerType = options.ownerType;
|
|
1001
|
-
IotaAccountProcessorState.INSTANCE.addValue(this);
|
|
1002
|
-
return proxyProcessor(this);
|
|
1003
|
-
}
|
|
1004
|
-
getChainId() {
|
|
1005
|
-
return this.config.network;
|
|
1006
|
-
}
|
|
1007
|
-
onInterval(handler, timeInterval, checkpointInterval, type, fetchConfig, handlerName = getHandlerName()) {
|
|
1008
|
-
const processor = this;
|
|
1009
|
-
this.objectHandlers.push({
|
|
1010
|
-
handlerName,
|
|
1011
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
1012
|
-
const ctx = new IotaObjectContext(
|
|
1013
|
-
processor.config.network,
|
|
1014
|
-
data.objectId,
|
|
1015
|
-
data.objectVersion,
|
|
1016
|
-
data.slot,
|
|
1017
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
1018
|
-
processor.config.baseLabels
|
|
1019
|
-
);
|
|
1020
|
-
await processor.doHandle(handler, data, ctx);
|
|
1021
|
-
return ctx.stopAndGetResult();
|
|
1022
|
-
}, "handler"),
|
|
1023
|
-
timeIntervalInMinutes: timeInterval,
|
|
1024
|
-
checkPointInterval: checkpointInterval,
|
|
1025
|
-
type,
|
|
1026
|
-
fetchConfig: { ...DEFAULT_ACCOUNT_FETCH_CONFIG, ...fetchConfig }
|
|
1027
|
-
});
|
|
1028
|
-
return this;
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
var IotaBaseObjectOrAddressProcessorInternal = class extends IotaBaseObjectOrAddressProcessor {
|
|
1032
|
-
static {
|
|
1033
|
-
__name(this, "IotaBaseObjectOrAddressProcessorInternal");
|
|
1034
|
-
}
|
|
1035
|
-
onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type, fetchConfig) {
|
|
1036
|
-
return this.onInterval(
|
|
1037
|
-
handler,
|
|
1038
|
-
{
|
|
1039
|
-
recentInterval: timeIntervalInMinutes,
|
|
1040
|
-
backfillInterval: backfillTimeIntervalInMinutes
|
|
1041
|
-
},
|
|
1042
|
-
void 0,
|
|
1043
|
-
type,
|
|
1044
|
-
fetchConfig
|
|
1045
|
-
);
|
|
1046
|
-
}
|
|
1047
|
-
onCheckpointInterval(handler, checkpointInterval = 1e5, backfillCheckpointInterval = 4e5, type, fetchConfig) {
|
|
1048
|
-
return this.onInterval(
|
|
1049
|
-
handler,
|
|
1050
|
-
void 0,
|
|
1051
|
-
{ recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
|
|
1052
|
-
type,
|
|
1053
|
-
fetchConfig
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
var IotaAddressProcessor = class _IotaAddressProcessor extends IotaBaseObjectOrAddressProcessorInternal {
|
|
1058
|
-
static {
|
|
1059
|
-
__name(this, "IotaAddressProcessor");
|
|
1060
|
-
}
|
|
1061
|
-
callHandlers = [];
|
|
1062
|
-
static bind(options) {
|
|
1063
|
-
return new _IotaAddressProcessor({ ...options, ownerType: MoveOwnerType.ADDRESS });
|
|
1064
|
-
}
|
|
1065
|
-
async doHandle(handler, data, ctx) {
|
|
1066
|
-
return handler(data.rawObjects.map((o) => JSON.parse(o)), ctx);
|
|
1067
|
-
}
|
|
1068
|
-
onTransactionBlock(handler, filter, fetchConfig) {
|
|
1069
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig });
|
|
1070
|
-
const _filter = {
|
|
1071
|
-
fromAndToAddress: {
|
|
1072
|
-
from: "",
|
|
1073
|
-
to: this.config.address
|
|
1074
|
-
},
|
|
1075
|
-
...filter
|
|
1076
|
-
};
|
|
1077
|
-
const processor = this;
|
|
1078
|
-
this.callHandlers.push({
|
|
1079
|
-
handlerName: getHandlerName(),
|
|
1080
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
1081
|
-
if (!data.rawTransaction) {
|
|
1082
|
-
throw new import_nice_grpc2.ServerError(import_nice_grpc2.Status.INVALID_ARGUMENT, "transaction is null");
|
|
1083
|
-
}
|
|
1084
|
-
const tx = JSON.parse(data.rawTransaction);
|
|
1085
|
-
const ctx = new IotaContext(
|
|
1086
|
-
"object",
|
|
1087
|
-
processor.config.network,
|
|
1088
|
-
processor.config.address,
|
|
1089
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
1090
|
-
data.slot,
|
|
1091
|
-
tx,
|
|
1092
|
-
0,
|
|
1093
|
-
processor.config.baseLabels
|
|
1094
|
-
);
|
|
1095
|
-
if (tx) {
|
|
1096
|
-
await handler(tx, ctx);
|
|
1097
|
-
}
|
|
1098
|
-
return ctx.stopAndGetResult();
|
|
1099
|
-
}, "handler"),
|
|
1100
|
-
filters: [{ ..._filter, function: "" }],
|
|
1101
|
-
fetchConfig: _fetchConfig
|
|
1102
|
-
});
|
|
1103
|
-
return this;
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
var IotaObjectProcessor = class _IotaObjectProcessor extends IotaBaseObjectOrAddressProcessorInternal {
|
|
1107
|
-
static {
|
|
1108
|
-
__name(this, "IotaObjectProcessor");
|
|
1109
|
-
}
|
|
1110
|
-
static bind(options) {
|
|
1111
|
-
return new _IotaObjectProcessor({
|
|
1112
|
-
address: options.objectId,
|
|
1113
|
-
network: options.network,
|
|
1114
|
-
startCheckpoint: options.startCheckpoint,
|
|
1115
|
-
endCheckpoint: options.endCheckpoint,
|
|
1116
|
-
ownerType: MoveOwnerType.OBJECT,
|
|
1117
|
-
baseLabels: options.baseLabels
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
async doHandle(handler, data, ctx) {
|
|
1121
|
-
if (!data.rawSelf) {
|
|
1122
|
-
console.log(`Iota object not existed in ${ctx.checkpoint}, please specific a start time`);
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
return handler(
|
|
1126
|
-
JSON.parse(data.rawSelf),
|
|
1127
|
-
data.rawObjects.map((o) => JSON.parse(o)),
|
|
1128
|
-
ctx
|
|
1129
|
-
);
|
|
1130
|
-
}
|
|
1131
|
-
};
|
|
1132
|
-
var IotaObjectTypeProcessor = class _IotaObjectTypeProcessor extends IotaBaseObjectOrAddressProcessor {
|
|
1133
|
-
static {
|
|
1134
|
-
__name(this, "IotaObjectTypeProcessor");
|
|
1135
|
-
}
|
|
1136
|
-
objectType;
|
|
1137
|
-
static bind(options) {
|
|
1138
|
-
const processor = new _IotaObjectTypeProcessor({
|
|
1139
|
-
address: ALL_ADDRESS,
|
|
1140
|
-
// current only support on all address
|
|
1141
|
-
network: options.network,
|
|
1142
|
-
startCheckpoint: options.startCheckpoint,
|
|
1143
|
-
endCheckpoint: options.endCheckpoint,
|
|
1144
|
-
ownerType: MoveOwnerType.TYPE,
|
|
1145
|
-
baseLabels: options.baseLabels
|
|
1146
|
-
});
|
|
1147
|
-
processor.objectType = options.objectType;
|
|
1148
|
-
return processor;
|
|
1149
|
-
}
|
|
1150
|
-
async doHandle(handler, data, ctx) {
|
|
1151
|
-
if (!data.rawSelf) {
|
|
1152
|
-
console.log(`Iota object not existed in ${ctx.checkpoint}, please specific a start time`);
|
|
1153
|
-
return;
|
|
1154
|
-
}
|
|
1155
|
-
const object = await ctx.coder.filterAndDecodeObjects(this.objectType, [JSON.parse(data.rawSelf)]);
|
|
1156
|
-
return handler(object[0], data.rawObjects.map((o) => JSON.parse(o)), ctx);
|
|
1157
|
-
}
|
|
1158
|
-
onObjectChange(handler) {
|
|
1159
|
-
if (this.config.network === IotaNetwork.TEST_NET) {
|
|
1160
|
-
throw new import_nice_grpc2.ServerError(import_nice_grpc2.Status.INVALID_ARGUMENT, "object change not supported in testnet");
|
|
1161
|
-
}
|
|
1162
|
-
const processor = this;
|
|
1163
|
-
this.objectChangeHandlers.push({
|
|
1164
|
-
handlerName: getHandlerName(),
|
|
1165
|
-
handler: /* @__PURE__ */ __name(async function(data) {
|
|
1166
|
-
const ctx = new IotaObjectChangeContext(
|
|
1167
|
-
processor.config.network,
|
|
1168
|
-
processor.config.address,
|
|
1169
|
-
data.timestamp || /* @__PURE__ */ new Date(0),
|
|
1170
|
-
data.slot,
|
|
1171
|
-
data.txDigest,
|
|
1172
|
-
processor.config.baseLabels
|
|
1173
|
-
);
|
|
1174
|
-
await handler(data.rawChanges.map((r) => JSON.parse(r)), ctx);
|
|
1175
|
-
return ctx.stopAndGetResult();
|
|
1176
|
-
}, "handler"),
|
|
1177
|
-
type: this.objectType.getSignature()
|
|
1178
|
-
});
|
|
1179
|
-
return this;
|
|
1180
|
-
}
|
|
1181
|
-
onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, fetchConfig) {
|
|
1182
|
-
return this.onInterval(
|
|
1183
|
-
handler,
|
|
1184
|
-
{
|
|
1185
|
-
recentInterval: timeIntervalInMinutes,
|
|
1186
|
-
backfillInterval: backfillTimeIntervalInMinutes
|
|
1187
|
-
},
|
|
1188
|
-
void 0,
|
|
1189
|
-
this.objectType.getSignature(),
|
|
1190
|
-
fetchConfig
|
|
1191
|
-
);
|
|
1192
|
-
}
|
|
1193
|
-
onCheckpointInterval(handler, checkpointInterval = 1e5, backfillCheckpointInterval = 4e5, fetchConfig) {
|
|
1194
|
-
return this.onInterval(
|
|
1195
|
-
handler,
|
|
1196
|
-
void 0,
|
|
1197
|
-
{ recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
|
|
1198
|
-
this.objectType.qname,
|
|
1199
|
-
fetchConfig
|
|
1200
|
-
);
|
|
1201
|
-
}
|
|
1202
|
-
};
|
|
1203
|
-
var IotaWrappedObjectProcessor = class _IotaWrappedObjectProcessor extends IotaBaseObjectOrAddressProcessorInternal {
|
|
1204
|
-
static {
|
|
1205
|
-
__name(this, "IotaWrappedObjectProcessor");
|
|
1206
|
-
}
|
|
1207
|
-
static bind(options) {
|
|
1208
|
-
return new _IotaWrappedObjectProcessor({
|
|
1209
|
-
address: options.objectId,
|
|
1210
|
-
network: options.network,
|
|
1211
|
-
startCheckpoint: options.startCheckpoint,
|
|
1212
|
-
endCheckpoint: options.endCheckpoint,
|
|
1213
|
-
ownerType: MoveOwnerType.WRAPPED_OBJECT,
|
|
1214
|
-
baseLabels: options.baseLabels
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
async doHandle(handler, data, ctx) {
|
|
1218
|
-
return handler(data.rawObjects.map((o) => JSON.parse(o)), ctx);
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
1222
|
-
|
|
1223
|
-
// src/iota/iota-object-processor-template.ts
|
|
1224
|
-
import { ListStateStorage as ListStateStorage3 } from "@sentio/runtime";
|
|
1225
|
-
var import_nice_grpc3 = __toESM(require_lib(), 1);
|
|
1226
|
-
var IotaAccountProcessorTemplateState = class _IotaAccountProcessorTemplateState extends ListStateStorage3 {
|
|
1227
|
-
static {
|
|
1228
|
-
__name(this, "IotaAccountProcessorTemplateState");
|
|
1229
|
-
}
|
|
1230
|
-
static INSTANCE = new _IotaAccountProcessorTemplateState();
|
|
1231
|
-
};
|
|
1232
|
-
var IotaObjectOrAddressProcessorTemplate = class {
|
|
1233
|
-
static {
|
|
1234
|
-
__name(this, "IotaObjectOrAddressProcessorTemplate");
|
|
1235
|
-
}
|
|
1236
|
-
id;
|
|
1237
|
-
objectHandlers = [];
|
|
1238
|
-
binds = /* @__PURE__ */ new Set();
|
|
1239
|
-
constructor() {
|
|
1240
|
-
this.id = IotaAccountProcessorTemplateState.INSTANCE.getValues().length;
|
|
1241
|
-
IotaAccountProcessorTemplateState.INSTANCE.addValue(this);
|
|
1242
|
-
return proxyProcessor(this);
|
|
1243
|
-
}
|
|
1244
|
-
bind(options, ctx) {
|
|
1245
|
-
options.network = options.network || ctx.network;
|
|
1246
|
-
options.startCheckpoint = options.startCheckpoint || ctx.checkpoint;
|
|
1247
|
-
let id = options.objectId || options.address;
|
|
1248
|
-
if (id === "*") {
|
|
1249
|
-
throw new import_nice_grpc3.ServerError(import_nice_grpc3.Status.INVALID_ARGUMENT, "can't bind template instance with *");
|
|
1250
|
-
}
|
|
1251
|
-
id = accountAddressString(id);
|
|
1252
|
-
const sig = [options.network, id].join("_");
|
|
1253
|
-
if (this.binds.has(sig)) {
|
|
1254
|
-
console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`);
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
this.binds.add(sig);
|
|
1258
|
-
const processor = this.createProcessor(options);
|
|
1259
|
-
for (const h of this.objectHandlers) {
|
|
1260
|
-
processor.onInterval(
|
|
1261
|
-
h.handler,
|
|
1262
|
-
h.timeIntervalInMinutes,
|
|
1263
|
-
h.checkpointInterval,
|
|
1264
|
-
h.type,
|
|
1265
|
-
h.fetchConfig,
|
|
1266
|
-
h.handlerName
|
|
1267
|
-
);
|
|
1268
|
-
}
|
|
1269
|
-
const config = processor.config;
|
|
1270
|
-
ctx.update({
|
|
1271
|
-
states: {
|
|
1272
|
-
configUpdated: true
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
TemplateInstanceState.INSTANCE.addValue({
|
|
1276
|
-
templateId: this.id,
|
|
1277
|
-
contract: {
|
|
1278
|
-
name: "",
|
|
1279
|
-
chainId: config.network,
|
|
1280
|
-
address: config.address,
|
|
1281
|
-
abi: ""
|
|
1282
|
-
},
|
|
1283
|
-
startBlock: config.startCheckpoint,
|
|
1284
|
-
endBlock: config.endCheckpoint || 0n,
|
|
1285
|
-
baseLabels: config.baseLabels
|
|
1286
|
-
});
|
|
1287
|
-
console.log(`successfully bind template ${sig}`);
|
|
1288
|
-
}
|
|
1289
|
-
unbind(options, ctx) {
|
|
1290
|
-
options.network = options.network || ctx.network;
|
|
1291
|
-
options.startCheckpoint = options.startCheckpoint || ctx.checkpoint;
|
|
1292
|
-
let id = options.objectId || options.address;
|
|
1293
|
-
if (id === "*") {
|
|
1294
|
-
throw new import_nice_grpc3.ServerError(import_nice_grpc3.Status.INVALID_ARGUMENT, "can't delete template instance bind with *");
|
|
1295
|
-
}
|
|
1296
|
-
id = accountAddressString(id);
|
|
1297
|
-
const sig = [options.network, id].join("_");
|
|
1298
|
-
if (!this.binds.has(sig)) {
|
|
1299
|
-
console.log(`the template instance ${sig} not existed or already unbind`);
|
|
1300
|
-
return;
|
|
1301
|
-
}
|
|
1302
|
-
this.binds.delete(sig);
|
|
1303
|
-
let deleted = 0;
|
|
1304
|
-
const oldTemplateInstances = TemplateInstanceState.INSTANCE.unregister();
|
|
1305
|
-
for (const templateInstance of oldTemplateInstances) {
|
|
1306
|
-
if (templateInstance.contract?.chainId === options.network && templateInstance.contract.address == id) {
|
|
1307
|
-
deleted++;
|
|
1308
|
-
continue;
|
|
1309
|
-
}
|
|
1310
|
-
TemplateInstanceState.INSTANCE.addValue(templateInstance);
|
|
1311
|
-
}
|
|
1312
|
-
if (deleted !== 1) {
|
|
1313
|
-
throw new import_nice_grpc3.ServerError(
|
|
1314
|
-
import_nice_grpc3.Status.INVALID_ARGUMENT,
|
|
1315
|
-
`Failed to delete template instance ${sig}, deleted ${deleted} times`
|
|
1316
|
-
);
|
|
1317
|
-
}
|
|
1318
|
-
const oldProcessors = IotaAccountProcessorState.INSTANCE.unregister();
|
|
1319
|
-
deleted = 0;
|
|
1320
|
-
for (const processor of oldProcessors) {
|
|
1321
|
-
if (processor.templateId === this.id) {
|
|
1322
|
-
if (processor.config.network == options.network && processor.config.address === id) {
|
|
1323
|
-
deleted++;
|
|
1324
|
-
continue;
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
IotaAccountProcessorState.INSTANCE.addValue(processor);
|
|
1328
|
-
}
|
|
1329
|
-
if (deleted !== 1) {
|
|
1330
|
-
throw new import_nice_grpc3.ServerError(
|
|
1331
|
-
import_nice_grpc3.Status.INVALID_ARGUMENT,
|
|
1332
|
-
`Failed to delete processor for template ${this.id}, ${sig}. deleted ${deleted} times`
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
console.log(`successfully unbind template ${sig}`);
|
|
1336
|
-
ctx.update({
|
|
1337
|
-
states: {
|
|
1338
|
-
configUpdated: true
|
|
1339
|
-
}
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
onInterval(handler, timeInterval, checkpointInterval, type, fetchConfig) {
|
|
1343
|
-
this.objectHandlers.push({
|
|
1344
|
-
handlerName: getHandlerName(),
|
|
1345
|
-
handler,
|
|
1346
|
-
timeIntervalInMinutes: timeInterval,
|
|
1347
|
-
checkpointInterval,
|
|
1348
|
-
type,
|
|
1349
|
-
fetchConfig: { ...DEFAULT_ACCOUNT_FETCH_CONFIG, ...fetchConfig }
|
|
1350
|
-
});
|
|
1351
|
-
return this;
|
|
1352
|
-
}
|
|
1353
|
-
onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type, fetchConfig) {
|
|
1354
|
-
return this.onInterval(
|
|
1355
|
-
handler,
|
|
1356
|
-
{
|
|
1357
|
-
recentInterval: timeIntervalInMinutes,
|
|
1358
|
-
backfillInterval: backfillTimeIntervalInMinutes
|
|
1359
|
-
},
|
|
1360
|
-
void 0,
|
|
1361
|
-
type,
|
|
1362
|
-
fetchConfig
|
|
1363
|
-
);
|
|
1364
|
-
}
|
|
1365
|
-
onCheckpointInterval(handler, checkpointInterval = 1e5, backfillCheckpointInterval = 4e5, type, fetchConfig) {
|
|
1366
|
-
return this.onInterval(
|
|
1367
|
-
handler,
|
|
1368
|
-
void 0,
|
|
1369
|
-
{ recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
|
|
1370
|
-
type,
|
|
1371
|
-
fetchConfig
|
|
1372
|
-
);
|
|
1373
|
-
}
|
|
1374
|
-
};
|
|
1375
|
-
var IotaAddressProcessorTemplate = class extends IotaObjectOrAddressProcessorTemplate {
|
|
1376
|
-
static {
|
|
1377
|
-
__name(this, "IotaAddressProcessorTemplate");
|
|
1378
|
-
}
|
|
1379
|
-
handlers = [];
|
|
1380
|
-
createProcessor(options) {
|
|
1381
|
-
const p = IotaAddressProcessor.bind(options);
|
|
1382
|
-
for (const handler of this.handlers) {
|
|
1383
|
-
p.onTransactionBlock(handler.handler, handler.filter, handler.fetchConfig);
|
|
1384
|
-
}
|
|
1385
|
-
p.templateId = this.id;
|
|
1386
|
-
return p;
|
|
1387
|
-
}
|
|
1388
|
-
onTransactionBlock(handler, filter, fetchConfig) {
|
|
1389
|
-
this.handlers.push({
|
|
1390
|
-
handler,
|
|
1391
|
-
filter,
|
|
1392
|
-
fetchConfig
|
|
1393
|
-
});
|
|
1394
|
-
return this;
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
var IotaObjectProcessorTemplate = class extends IotaObjectOrAddressProcessorTemplate {
|
|
1398
|
-
static {
|
|
1399
|
-
__name(this, "IotaObjectProcessorTemplate");
|
|
1400
|
-
}
|
|
1401
|
-
createProcessor(options) {
|
|
1402
|
-
const p = IotaObjectProcessor.bind(options);
|
|
1403
|
-
p.templateId = this.id;
|
|
1404
|
-
return p;
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
var IotaWrappedObjectProcessorTemplate = class extends IotaObjectOrAddressProcessorTemplate {
|
|
1408
|
-
static {
|
|
1409
|
-
__name(this, "IotaWrappedObjectProcessorTemplate");
|
|
1410
|
-
}
|
|
1411
|
-
createProcessor(options) {
|
|
1412
|
-
const p = IotaWrappedObjectProcessor.bind(options);
|
|
1413
|
-
p.templateId = this.id;
|
|
1414
|
-
return p;
|
|
1415
|
-
}
|
|
1416
|
-
};
|
|
1417
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
1418
|
-
|
|
1419
|
-
// src/iota/models.ts
|
|
1420
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
1421
|
-
|
|
1422
|
-
// src/iota/iota-plugin.ts
|
|
1423
|
-
var IotaPlugin = class {
|
|
1424
|
-
static {
|
|
1425
|
-
__name(this, "IotaPlugin");
|
|
1426
|
-
}
|
|
1427
|
-
};
|
|
1428
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
1429
|
-
|
|
1430
|
-
// src/iota/index.ts
|
|
1431
|
-
import("node:process").then((p) => p.stdout.write(""));
|
|
1432
|
-
|
|
1433
|
-
export {
|
|
1434
|
-
ZERO_ADDRESS,
|
|
1435
|
-
transactionArgumentOrObject,
|
|
1436
|
-
transactionArgumentOrPure,
|
|
1437
|
-
transactionArgumentOrPureAddress,
|
|
1438
|
-
transactionArgumentOrPureU8,
|
|
1439
|
-
transactionArgumentOrPureU16,
|
|
1440
|
-
transactionArgumentOrPureU32,
|
|
1441
|
-
transactionArgumentOrPureU64,
|
|
1442
|
-
transactionArgumentOrPureU128,
|
|
1443
|
-
transactionArgumentOrPureU256,
|
|
1444
|
-
transactionArgumentOrPureBool,
|
|
1445
|
-
transactionArgumentOrVec,
|
|
1446
|
-
MoveCoder,
|
|
1447
|
-
getMoveCoder,
|
|
1448
|
-
defaultMoveCoder2 as defaultMoveCoder,
|
|
1449
|
-
IotaContext,
|
|
1450
|
-
IotaObjectChangeContext,
|
|
1451
|
-
IotaAddressContext,
|
|
1452
|
-
IotaObjectContext,
|
|
1453
|
-
getMoveCalls,
|
|
1454
|
-
IotaProcessorState,
|
|
1455
|
-
IotaBaseProcessor,
|
|
1456
|
-
IotaModulesProcessor,
|
|
1457
|
-
IotaGlobalProcessor,
|
|
1458
|
-
IotaAccountProcessorState,
|
|
1459
|
-
IotaAddressProcessor,
|
|
1460
|
-
IotaObjectProcessor,
|
|
1461
|
-
IotaObjectTypeProcessor,
|
|
1462
|
-
IotaWrappedObjectProcessor,
|
|
1463
|
-
IotaAccountProcessorTemplateState,
|
|
1464
|
-
IotaAddressProcessorTemplate,
|
|
1465
|
-
IotaObjectProcessorTemplate,
|
|
1466
|
-
IotaWrappedObjectProcessorTemplate,
|
|
1467
|
-
IotaPlugin
|
|
1468
|
-
};
|
|
1469
|
-
//# sourceMappingURL=chunk-XEXUSO2Q.js.map
|