@fastxyz/cli 1.0.1 → 1.0.3
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/LICENSE +21 -0
- package/README.md +366 -6
- package/dist/_esm-PAFIJ3CY.js +0 -0
- package/dist/{app-IJ6QEQ2I.js → app-ZXKQBKVM.js} +1 -1
- package/dist/ccip-25L4RSNC.js +0 -0
- package/dist/chunk-5U55A5N6.js +0 -0
- package/dist/chunk-77HVPD4G.js +0 -0
- package/dist/chunk-DITXH2ZY.js +2476 -0
- package/dist/chunk-MWATGKBS.js +0 -0
- package/dist/chunk-T7HRTMD7.js +0 -0
- package/dist/{chunk-MIRQRJSD.js → chunk-UZZ2O26Y.js} +90 -51
- package/dist/chunk-VOHYNW3B.js +0 -0
- package/dist/database-NXA7GQKE.js +0 -0
- package/dist/main.js +616 -2466
- package/dist/{network-5PLYLKX3.js → network-GHRVPGMD.js} +2 -2
- package/dist/secp256k1-CWQX754O.js +0 -0
- package/package.json +20 -12
- package/dist/chunk-FLS2KI2D.js +0 -146
|
@@ -0,0 +1,2476 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
AppConfig
|
|
4
|
+
} from "./chunk-UZZ2O26Y.js";
|
|
5
|
+
import {
|
|
6
|
+
DatabaseService,
|
|
7
|
+
DefaultNetworkError,
|
|
8
|
+
FileIOError,
|
|
9
|
+
InvalidNetworkConfigError,
|
|
10
|
+
NetworkExistsError,
|
|
11
|
+
NetworkNotFoundError,
|
|
12
|
+
NoDefaultNetworkError,
|
|
13
|
+
ReservedNameError,
|
|
14
|
+
customNetworks,
|
|
15
|
+
metadata
|
|
16
|
+
} from "./chunk-T7HRTMD7.js";
|
|
17
|
+
|
|
18
|
+
// src/services/storage/network.ts
|
|
19
|
+
import { readFileSync } from "fs";
|
|
20
|
+
import { eq } from "drizzle-orm";
|
|
21
|
+
import { Effect, Schema as Schema20 } from "effect";
|
|
22
|
+
|
|
23
|
+
// src/schemas/networks.ts
|
|
24
|
+
import { Schema as Schema19 } from "effect";
|
|
25
|
+
|
|
26
|
+
// ../../packages/fast-schema/dist/index.js
|
|
27
|
+
import { Schema as Schema6 } from "effect";
|
|
28
|
+
import { bech32m } from "bech32";
|
|
29
|
+
import { ParseResult, Schema } from "effect";
|
|
30
|
+
import { Schema as Schema2 } from "effect";
|
|
31
|
+
import { Schema as Schema3, String as Str } from "effect";
|
|
32
|
+
import { Either, ParseResult as ParseResult2, Schema as Schema4 } from "effect";
|
|
33
|
+
import { Schema as Schema5 } from "effect";
|
|
34
|
+
import { Schema as Schema7 } from "effect";
|
|
35
|
+
import { Schema as Schema8 } from "effect";
|
|
36
|
+
import { Schema as Schema9 } from "effect";
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/uleb.mjs
|
|
39
|
+
function ulebEncode(num) {
|
|
40
|
+
let bigNum = BigInt(num);
|
|
41
|
+
const arr = [];
|
|
42
|
+
let len = 0;
|
|
43
|
+
if (bigNum === 0n) return [0];
|
|
44
|
+
while (bigNum > 0) {
|
|
45
|
+
arr[len] = Number(bigNum & 127n);
|
|
46
|
+
bigNum >>= 7n;
|
|
47
|
+
if (bigNum > 0n) arr[len] |= 128;
|
|
48
|
+
len += 1;
|
|
49
|
+
}
|
|
50
|
+
return arr;
|
|
51
|
+
}
|
|
52
|
+
function ulebDecode(arr) {
|
|
53
|
+
let total = 0n;
|
|
54
|
+
let shift = 0n;
|
|
55
|
+
let len = 0;
|
|
56
|
+
while (true) {
|
|
57
|
+
if (len >= arr.length) throw new Error("ULEB decode error: buffer overflow");
|
|
58
|
+
const byte = arr[len];
|
|
59
|
+
len += 1;
|
|
60
|
+
total += BigInt(byte & 127) << shift;
|
|
61
|
+
if ((byte & 128) === 0) break;
|
|
62
|
+
shift += 7n;
|
|
63
|
+
}
|
|
64
|
+
if (total > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("ULEB decode error: value exceeds MAX_SAFE_INTEGER");
|
|
65
|
+
return {
|
|
66
|
+
value: Number(total),
|
|
67
|
+
length: len
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/reader.mjs
|
|
72
|
+
var BcsReader = class {
|
|
73
|
+
/**
|
|
74
|
+
* @param {Uint8Array} data Data to use as a buffer.
|
|
75
|
+
*/
|
|
76
|
+
constructor(data) {
|
|
77
|
+
this.bytePosition = 0;
|
|
78
|
+
this.dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Shift current cursor position by `bytes`.
|
|
82
|
+
*
|
|
83
|
+
* @param {Number} bytes Number of bytes to
|
|
84
|
+
* @returns {this} Self for possible chaining.
|
|
85
|
+
*/
|
|
86
|
+
shift(bytes) {
|
|
87
|
+
this.bytePosition += bytes;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read U8 value from the buffer and shift cursor by 1.
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
read8() {
|
|
95
|
+
const value = this.dataView.getUint8(this.bytePosition);
|
|
96
|
+
this.shift(1);
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Read U16 value from the buffer and shift cursor by 2.
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
read16() {
|
|
104
|
+
const value = this.dataView.getUint16(this.bytePosition, true);
|
|
105
|
+
this.shift(2);
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Read U32 value from the buffer and shift cursor by 4.
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
read32() {
|
|
113
|
+
const value = this.dataView.getUint32(this.bytePosition, true);
|
|
114
|
+
this.shift(4);
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Read U64 value from the buffer and shift cursor by 8.
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
read64() {
|
|
122
|
+
const value1 = this.read32();
|
|
123
|
+
const result = this.read32().toString(16) + value1.toString(16).padStart(8, "0");
|
|
124
|
+
return BigInt("0x" + result).toString(10);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Read U128 value from the buffer and shift cursor by 16.
|
|
128
|
+
*/
|
|
129
|
+
read128() {
|
|
130
|
+
const value1 = BigInt(this.read64());
|
|
131
|
+
const result = BigInt(this.read64()).toString(16) + value1.toString(16).padStart(16, "0");
|
|
132
|
+
return BigInt("0x" + result).toString(10);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Read U128 value from the buffer and shift cursor by 32.
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
read256() {
|
|
139
|
+
const value1 = BigInt(this.read128());
|
|
140
|
+
const result = BigInt(this.read128()).toString(16) + value1.toString(16).padStart(32, "0");
|
|
141
|
+
return BigInt("0x" + result).toString(10);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Read `num` number of bytes from the buffer and shift cursor by `num`.
|
|
145
|
+
* @param num Number of bytes to read.
|
|
146
|
+
*/
|
|
147
|
+
readBytes(num) {
|
|
148
|
+
const start = this.bytePosition + this.dataView.byteOffset;
|
|
149
|
+
const value = new Uint8Array(this.dataView.buffer, start, num);
|
|
150
|
+
this.shift(num);
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Read ULEB value - an integer of varying size. Used for enum indexes and
|
|
155
|
+
* vector lengths.
|
|
156
|
+
* @returns {Number} The ULEB value.
|
|
157
|
+
*/
|
|
158
|
+
readULEB() {
|
|
159
|
+
const start = this.bytePosition + this.dataView.byteOffset;
|
|
160
|
+
const { value, length } = ulebDecode(new Uint8Array(this.dataView.buffer, start));
|
|
161
|
+
this.shift(length);
|
|
162
|
+
return value;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Read a BCS vector: read a length and then apply function `cb` X times
|
|
166
|
+
* where X is the length of the vector, defined as ULEB in BCS bytes.
|
|
167
|
+
* @param cb Callback to process elements of vector.
|
|
168
|
+
* @returns {Array<Any>} Array of the resulting values, returned by callback.
|
|
169
|
+
*/
|
|
170
|
+
readVec(cb) {
|
|
171
|
+
const length = this.readULEB();
|
|
172
|
+
const result = [];
|
|
173
|
+
for (let i = 0; i < length; i++) result.push(cb(this, i, length));
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// ../../node_modules/.pnpm/@scure+base@2.0.0/node_modules/@scure/base/index.js
|
|
179
|
+
function isBytes(a) {
|
|
180
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
181
|
+
}
|
|
182
|
+
function isArrayOf(isString, arr) {
|
|
183
|
+
if (!Array.isArray(arr))
|
|
184
|
+
return false;
|
|
185
|
+
if (arr.length === 0)
|
|
186
|
+
return true;
|
|
187
|
+
if (isString) {
|
|
188
|
+
return arr.every((item) => typeof item === "string");
|
|
189
|
+
} else {
|
|
190
|
+
return arr.every((item) => Number.isSafeInteger(item));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function astr(label, input) {
|
|
194
|
+
if (typeof input !== "string")
|
|
195
|
+
throw new Error(`${label}: string expected`);
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
function anumber(n) {
|
|
199
|
+
if (!Number.isSafeInteger(n))
|
|
200
|
+
throw new Error(`invalid integer: ${n}`);
|
|
201
|
+
}
|
|
202
|
+
function aArr(input) {
|
|
203
|
+
if (!Array.isArray(input))
|
|
204
|
+
throw new Error("array expected");
|
|
205
|
+
}
|
|
206
|
+
function astrArr(label, input) {
|
|
207
|
+
if (!isArrayOf(true, input))
|
|
208
|
+
throw new Error(`${label}: array of strings expected`);
|
|
209
|
+
}
|
|
210
|
+
function anumArr(label, input) {
|
|
211
|
+
if (!isArrayOf(false, input))
|
|
212
|
+
throw new Error(`${label}: array of numbers expected`);
|
|
213
|
+
}
|
|
214
|
+
// @__NO_SIDE_EFFECTS__
|
|
215
|
+
function chain(...args) {
|
|
216
|
+
const id = (a) => a;
|
|
217
|
+
const wrap = (a, b) => (c) => a(b(c));
|
|
218
|
+
const encode = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
219
|
+
const decode = args.map((x) => x.decode).reduce(wrap, id);
|
|
220
|
+
return { encode, decode };
|
|
221
|
+
}
|
|
222
|
+
// @__NO_SIDE_EFFECTS__
|
|
223
|
+
function alphabet(letters) {
|
|
224
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
225
|
+
const len = lettersA.length;
|
|
226
|
+
astrArr("alphabet", lettersA);
|
|
227
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
228
|
+
return {
|
|
229
|
+
encode: (digits) => {
|
|
230
|
+
aArr(digits);
|
|
231
|
+
return digits.map((i) => {
|
|
232
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len)
|
|
233
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
234
|
+
return lettersA[i];
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
decode: (input) => {
|
|
238
|
+
aArr(input);
|
|
239
|
+
return input.map((letter) => {
|
|
240
|
+
astr("alphabet.decode", letter);
|
|
241
|
+
const i = indexes.get(letter);
|
|
242
|
+
if (i === void 0)
|
|
243
|
+
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
244
|
+
return i;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// @__NO_SIDE_EFFECTS__
|
|
250
|
+
function join(separator = "") {
|
|
251
|
+
astr("join", separator);
|
|
252
|
+
return {
|
|
253
|
+
encode: (from) => {
|
|
254
|
+
astrArr("join.decode", from);
|
|
255
|
+
return from.join(separator);
|
|
256
|
+
},
|
|
257
|
+
decode: (to) => {
|
|
258
|
+
astr("join.decode", to);
|
|
259
|
+
return to.split(separator);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function convertRadix(data, from, to) {
|
|
264
|
+
if (from < 2)
|
|
265
|
+
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
|
266
|
+
if (to < 2)
|
|
267
|
+
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
268
|
+
aArr(data);
|
|
269
|
+
if (!data.length)
|
|
270
|
+
return [];
|
|
271
|
+
let pos = 0;
|
|
272
|
+
const res = [];
|
|
273
|
+
const digits = Array.from(data, (d) => {
|
|
274
|
+
anumber(d);
|
|
275
|
+
if (d < 0 || d >= from)
|
|
276
|
+
throw new Error(`invalid integer: ${d}`);
|
|
277
|
+
return d;
|
|
278
|
+
});
|
|
279
|
+
const dlen = digits.length;
|
|
280
|
+
while (true) {
|
|
281
|
+
let carry = 0;
|
|
282
|
+
let done = true;
|
|
283
|
+
for (let i = pos; i < dlen; i++) {
|
|
284
|
+
const digit = digits[i];
|
|
285
|
+
const fromCarry = from * carry;
|
|
286
|
+
const digitBase = fromCarry + digit;
|
|
287
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
|
|
288
|
+
throw new Error("convertRadix: carry overflow");
|
|
289
|
+
}
|
|
290
|
+
const div = digitBase / to;
|
|
291
|
+
carry = digitBase % to;
|
|
292
|
+
const rounded = Math.floor(div);
|
|
293
|
+
digits[i] = rounded;
|
|
294
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
|
295
|
+
throw new Error("convertRadix: carry overflow");
|
|
296
|
+
if (!done)
|
|
297
|
+
continue;
|
|
298
|
+
else if (!rounded)
|
|
299
|
+
pos = i;
|
|
300
|
+
else
|
|
301
|
+
done = false;
|
|
302
|
+
}
|
|
303
|
+
res.push(carry);
|
|
304
|
+
if (done)
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
|
|
308
|
+
res.push(0);
|
|
309
|
+
return res.reverse();
|
|
310
|
+
}
|
|
311
|
+
// @__NO_SIDE_EFFECTS__
|
|
312
|
+
function radix(num) {
|
|
313
|
+
anumber(num);
|
|
314
|
+
const _256 = 2 ** 8;
|
|
315
|
+
return {
|
|
316
|
+
encode: (bytes) => {
|
|
317
|
+
if (!isBytes(bytes))
|
|
318
|
+
throw new Error("radix.encode input should be Uint8Array");
|
|
319
|
+
return convertRadix(Array.from(bytes), _256, num);
|
|
320
|
+
},
|
|
321
|
+
decode: (digits) => {
|
|
322
|
+
anumArr("radix.decode", digits);
|
|
323
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
|
|
328
|
+
var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
329
|
+
|
|
330
|
+
// ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/b58.mjs
|
|
331
|
+
var toBase58 = (buffer) => base58.encode(buffer);
|
|
332
|
+
var fromBase58 = (str) => base58.decode(str);
|
|
333
|
+
|
|
334
|
+
// ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/b64.mjs
|
|
335
|
+
function fromBase64(base64String) {
|
|
336
|
+
return Uint8Array.from(atob(base64String), (char) => char.charCodeAt(0));
|
|
337
|
+
}
|
|
338
|
+
var CHUNK_SIZE = 8192;
|
|
339
|
+
function toBase64(bytes) {
|
|
340
|
+
if (bytes.length < CHUNK_SIZE) return btoa(String.fromCharCode(...bytes));
|
|
341
|
+
let output = "";
|
|
342
|
+
for (var i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
343
|
+
const chunk = bytes.slice(i, i + CHUNK_SIZE);
|
|
344
|
+
output += String.fromCharCode(...chunk);
|
|
345
|
+
}
|
|
346
|
+
return btoa(output);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/hex.mjs
|
|
350
|
+
function fromHex(hexStr) {
|
|
351
|
+
const normalized = hexStr.startsWith("0x") ? hexStr.slice(2) : hexStr;
|
|
352
|
+
const padded = normalized.length % 2 === 0 ? normalized : `0${normalized}`;
|
|
353
|
+
const intArr = padded.match(/[0-9a-fA-F]{2}/g)?.map((byte) => parseInt(byte, 16)) ?? [];
|
|
354
|
+
if (intArr.length !== padded.length / 2) throw new Error(`Invalid hex string ${hexStr}`);
|
|
355
|
+
return Uint8Array.from(intArr);
|
|
356
|
+
}
|
|
357
|
+
function toHex(bytes) {
|
|
358
|
+
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/utils.mjs
|
|
362
|
+
function encodeStr(data, encoding) {
|
|
363
|
+
switch (encoding) {
|
|
364
|
+
case "base58":
|
|
365
|
+
return toBase58(data);
|
|
366
|
+
case "base64":
|
|
367
|
+
return toBase64(data);
|
|
368
|
+
case "hex":
|
|
369
|
+
return toHex(data);
|
|
370
|
+
default:
|
|
371
|
+
throw new Error("Unsupported encoding, supported values are: base64, hex");
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/writer.mjs
|
|
376
|
+
var BcsWriter = class {
|
|
377
|
+
constructor({ initialSize = 1024, maxSize = Infinity, allocateSize = 1024 } = {}) {
|
|
378
|
+
this.bytePosition = 0;
|
|
379
|
+
this.size = initialSize;
|
|
380
|
+
this.maxSize = maxSize;
|
|
381
|
+
this.allocateSize = allocateSize;
|
|
382
|
+
this.dataView = new DataView(new ArrayBuffer(initialSize));
|
|
383
|
+
}
|
|
384
|
+
ensureSizeOrGrow(bytes) {
|
|
385
|
+
const requiredSize = this.bytePosition + bytes;
|
|
386
|
+
if (requiredSize > this.size) {
|
|
387
|
+
const nextSize = Math.min(this.maxSize, Math.max(this.size + requiredSize, this.size + this.allocateSize));
|
|
388
|
+
if (requiredSize > nextSize) throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${requiredSize}`);
|
|
389
|
+
this.size = nextSize;
|
|
390
|
+
const nextBuffer = new ArrayBuffer(this.size);
|
|
391
|
+
new Uint8Array(nextBuffer).set(new Uint8Array(this.dataView.buffer));
|
|
392
|
+
this.dataView = new DataView(nextBuffer);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Shift current cursor position by `bytes`.
|
|
397
|
+
*
|
|
398
|
+
* @param {Number} bytes Number of bytes to
|
|
399
|
+
* @returns {this} Self for possible chaining.
|
|
400
|
+
*/
|
|
401
|
+
shift(bytes) {
|
|
402
|
+
this.bytePosition += bytes;
|
|
403
|
+
return this;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Write a U8 value into a buffer and shift cursor position by 1.
|
|
407
|
+
* @param {Number} value Value to write.
|
|
408
|
+
* @returns {this}
|
|
409
|
+
*/
|
|
410
|
+
write8(value) {
|
|
411
|
+
this.ensureSizeOrGrow(1);
|
|
412
|
+
this.dataView.setUint8(this.bytePosition, Number(value));
|
|
413
|
+
return this.shift(1);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Write a U8 value into a buffer and shift cursor position by 1.
|
|
417
|
+
* @param {Number} value Value to write.
|
|
418
|
+
* @returns {this}
|
|
419
|
+
*/
|
|
420
|
+
writeBytes(bytes) {
|
|
421
|
+
this.ensureSizeOrGrow(bytes.length);
|
|
422
|
+
for (let i = 0; i < bytes.length; i++) this.dataView.setUint8(this.bytePosition + i, bytes[i]);
|
|
423
|
+
return this.shift(bytes.length);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Write a U16 value into a buffer and shift cursor position by 2.
|
|
427
|
+
* @param {Number} value Value to write.
|
|
428
|
+
* @returns {this}
|
|
429
|
+
*/
|
|
430
|
+
write16(value) {
|
|
431
|
+
this.ensureSizeOrGrow(2);
|
|
432
|
+
this.dataView.setUint16(this.bytePosition, Number(value), true);
|
|
433
|
+
return this.shift(2);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Write a U32 value into a buffer and shift cursor position by 4.
|
|
437
|
+
* @param {Number} value Value to write.
|
|
438
|
+
* @returns {this}
|
|
439
|
+
*/
|
|
440
|
+
write32(value) {
|
|
441
|
+
this.ensureSizeOrGrow(4);
|
|
442
|
+
this.dataView.setUint32(this.bytePosition, Number(value), true);
|
|
443
|
+
return this.shift(4);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Write a U64 value into a buffer and shift cursor position by 8.
|
|
447
|
+
* @param {bigint} value Value to write.
|
|
448
|
+
* @returns {this}
|
|
449
|
+
*/
|
|
450
|
+
write64(value) {
|
|
451
|
+
toLittleEndian(BigInt(value), 8).forEach((el) => this.write8(el));
|
|
452
|
+
return this;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Write a U128 value into a buffer and shift cursor position by 16.
|
|
456
|
+
*
|
|
457
|
+
* @param {bigint} value Value to write.
|
|
458
|
+
* @returns {this}
|
|
459
|
+
*/
|
|
460
|
+
write128(value) {
|
|
461
|
+
toLittleEndian(BigInt(value), 16).forEach((el) => this.write8(el));
|
|
462
|
+
return this;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Write a U256 value into a buffer and shift cursor position by 16.
|
|
466
|
+
*
|
|
467
|
+
* @param {bigint} value Value to write.
|
|
468
|
+
* @returns {this}
|
|
469
|
+
*/
|
|
470
|
+
write256(value) {
|
|
471
|
+
toLittleEndian(BigInt(value), 32).forEach((el) => this.write8(el));
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Write a ULEB value into a buffer and shift cursor position by number of bytes
|
|
476
|
+
* written.
|
|
477
|
+
* @param {Number} value Value to write.
|
|
478
|
+
* @returns {this}
|
|
479
|
+
*/
|
|
480
|
+
writeULEB(value) {
|
|
481
|
+
ulebEncode(value).forEach((el) => this.write8(el));
|
|
482
|
+
return this;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Write a vector into a buffer by first writing the vector length and then calling
|
|
486
|
+
* a callback on each passed value.
|
|
487
|
+
*
|
|
488
|
+
* @param {Array<Any>} vector Array of elements to write.
|
|
489
|
+
* @param {WriteVecCb} cb Callback to call on each element of the vector.
|
|
490
|
+
* @returns {this}
|
|
491
|
+
*/
|
|
492
|
+
writeVec(vector2, cb) {
|
|
493
|
+
this.writeULEB(vector2.length);
|
|
494
|
+
Array.from(vector2).forEach((el, i) => cb(this, el, i, vector2.length));
|
|
495
|
+
return this;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Adds support for iterations over the object.
|
|
499
|
+
* @returns {Uint8Array}
|
|
500
|
+
*/
|
|
501
|
+
*[Symbol.iterator]() {
|
|
502
|
+
for (let i = 0; i < this.bytePosition; i++) yield this.dataView.getUint8(i);
|
|
503
|
+
return this.toBytes();
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Get underlying buffer taking only value bytes (in case initial buffer size was bigger).
|
|
507
|
+
* @returns {Uint8Array} Resulting bcs.
|
|
508
|
+
*/
|
|
509
|
+
toBytes() {
|
|
510
|
+
return new Uint8Array(this.dataView.buffer.slice(0, this.bytePosition));
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Represent data as 'hex' or 'base64'
|
|
514
|
+
* @param encoding Encoding to use: 'base64' or 'hex'
|
|
515
|
+
*/
|
|
516
|
+
toString(encoding) {
|
|
517
|
+
return encodeStr(this.toBytes(), encoding);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
function toLittleEndian(bigint, size) {
|
|
521
|
+
const result = new Uint8Array(size);
|
|
522
|
+
let i = 0;
|
|
523
|
+
while (bigint > 0) {
|
|
524
|
+
result[i] = Number(bigint % BigInt(256));
|
|
525
|
+
bigint = bigint / BigInt(256);
|
|
526
|
+
i += 1;
|
|
527
|
+
}
|
|
528
|
+
return result;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/bcs-type.mjs
|
|
532
|
+
var BcsType = class BcsType2 {
|
|
533
|
+
#write;
|
|
534
|
+
#serialize;
|
|
535
|
+
constructor(options) {
|
|
536
|
+
this.name = options.name;
|
|
537
|
+
this.read = options.read;
|
|
538
|
+
this.serializedSize = options.serializedSize ?? (() => null);
|
|
539
|
+
this.#write = options.write;
|
|
540
|
+
this.#serialize = options.serialize ?? ((value, options$1) => {
|
|
541
|
+
const writer = new BcsWriter({
|
|
542
|
+
initialSize: this.serializedSize(value) ?? void 0,
|
|
543
|
+
...options$1
|
|
544
|
+
});
|
|
545
|
+
this.#write(value, writer);
|
|
546
|
+
return writer.toBytes();
|
|
547
|
+
});
|
|
548
|
+
this.validate = options.validate ?? (() => {
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
write(value, writer) {
|
|
552
|
+
this.validate(value);
|
|
553
|
+
this.#write(value, writer);
|
|
554
|
+
}
|
|
555
|
+
serialize(value, options) {
|
|
556
|
+
this.validate(value);
|
|
557
|
+
return new SerializedBcs(this, this.#serialize(value, options));
|
|
558
|
+
}
|
|
559
|
+
parse(bytes) {
|
|
560
|
+
const reader = new BcsReader(bytes);
|
|
561
|
+
return this.read(reader);
|
|
562
|
+
}
|
|
563
|
+
fromHex(hex) {
|
|
564
|
+
return this.parse(fromHex(hex));
|
|
565
|
+
}
|
|
566
|
+
fromBase58(b64) {
|
|
567
|
+
return this.parse(fromBase58(b64));
|
|
568
|
+
}
|
|
569
|
+
fromBase64(b64) {
|
|
570
|
+
return this.parse(fromBase64(b64));
|
|
571
|
+
}
|
|
572
|
+
transform({ name, input, output, validate }) {
|
|
573
|
+
return new BcsType2({
|
|
574
|
+
name: name ?? this.name,
|
|
575
|
+
read: (reader) => output ? output(this.read(reader)) : this.read(reader),
|
|
576
|
+
write: (value, writer) => this.#write(input ? input(value) : value, writer),
|
|
577
|
+
serializedSize: (value) => this.serializedSize(input ? input(value) : value),
|
|
578
|
+
serialize: (value, options) => this.#serialize(input ? input(value) : value, options),
|
|
579
|
+
validate: (value) => {
|
|
580
|
+
validate?.(value);
|
|
581
|
+
this.validate(input ? input(value) : value);
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
var SERIALIZED_BCS_BRAND = /* @__PURE__ */ Symbol.for("@mysten/serialized-bcs");
|
|
587
|
+
var SerializedBcs = class {
|
|
588
|
+
#schema;
|
|
589
|
+
#bytes;
|
|
590
|
+
get [SERIALIZED_BCS_BRAND]() {
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
constructor(schema, bytes) {
|
|
594
|
+
this.#schema = schema;
|
|
595
|
+
this.#bytes = bytes;
|
|
596
|
+
}
|
|
597
|
+
toBytes() {
|
|
598
|
+
return this.#bytes;
|
|
599
|
+
}
|
|
600
|
+
toHex() {
|
|
601
|
+
return toHex(this.#bytes);
|
|
602
|
+
}
|
|
603
|
+
toBase64() {
|
|
604
|
+
return toBase64(this.#bytes);
|
|
605
|
+
}
|
|
606
|
+
toBase58() {
|
|
607
|
+
return toBase58(this.#bytes);
|
|
608
|
+
}
|
|
609
|
+
parse() {
|
|
610
|
+
return this.#schema.parse(this.#bytes);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
function fixedSizeBcsType({ size, ...options }) {
|
|
614
|
+
return new BcsType({
|
|
615
|
+
...options,
|
|
616
|
+
serializedSize: () => size
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function uIntBcsType({ readMethod, writeMethod, ...options }) {
|
|
620
|
+
return fixedSizeBcsType({
|
|
621
|
+
...options,
|
|
622
|
+
read: (reader) => reader[readMethod](),
|
|
623
|
+
write: (value, writer) => writer[writeMethod](value),
|
|
624
|
+
validate: (value) => {
|
|
625
|
+
if (value < 0 || value > options.maxValue) throw new TypeError(`Invalid ${options.name} value: ${value}. Expected value in range 0-${options.maxValue}`);
|
|
626
|
+
options.validate?.(value);
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function bigUIntBcsType({ readMethod, writeMethod, ...options }) {
|
|
631
|
+
return fixedSizeBcsType({
|
|
632
|
+
...options,
|
|
633
|
+
read: (reader) => reader[readMethod](),
|
|
634
|
+
write: (value, writer) => writer[writeMethod](BigInt(value)),
|
|
635
|
+
validate: (val) => {
|
|
636
|
+
const value = BigInt(val);
|
|
637
|
+
if (value < 0 || value > options.maxValue) throw new TypeError(`Invalid ${options.name} value: ${value}. Expected value in range 0-${options.maxValue}`);
|
|
638
|
+
options.validate?.(value);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
function dynamicSizeBcsType({ serialize, ...options }) {
|
|
643
|
+
const type = new BcsType({
|
|
644
|
+
...options,
|
|
645
|
+
serialize,
|
|
646
|
+
write: (value, writer) => {
|
|
647
|
+
for (const byte of type.serialize(value).toBytes()) writer.write8(byte);
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return type;
|
|
651
|
+
}
|
|
652
|
+
function stringLikeBcsType({ toBytes, fromBytes, ...options }) {
|
|
653
|
+
return new BcsType({
|
|
654
|
+
...options,
|
|
655
|
+
read: (reader) => {
|
|
656
|
+
const length = reader.readULEB();
|
|
657
|
+
return fromBytes(reader.readBytes(length));
|
|
658
|
+
},
|
|
659
|
+
write: (hex, writer) => {
|
|
660
|
+
const bytes = toBytes(hex);
|
|
661
|
+
writer.writeULEB(bytes.length);
|
|
662
|
+
for (let i = 0; i < bytes.length; i++) writer.write8(bytes[i]);
|
|
663
|
+
},
|
|
664
|
+
serialize: (value) => {
|
|
665
|
+
const bytes = toBytes(value);
|
|
666
|
+
const size = ulebEncode(bytes.length);
|
|
667
|
+
const result = new Uint8Array(size.length + bytes.length);
|
|
668
|
+
result.set(size, 0);
|
|
669
|
+
result.set(bytes, size.length);
|
|
670
|
+
return result;
|
|
671
|
+
},
|
|
672
|
+
validate: (value) => {
|
|
673
|
+
if (typeof value !== "string") throw new TypeError(`Invalid ${options.name} value: ${value}. Expected string`);
|
|
674
|
+
options.validate?.(value);
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
function lazyBcsType(cb) {
|
|
679
|
+
let lazyType = null;
|
|
680
|
+
function getType() {
|
|
681
|
+
if (!lazyType) lazyType = cb();
|
|
682
|
+
return lazyType;
|
|
683
|
+
}
|
|
684
|
+
return new BcsType({
|
|
685
|
+
name: "lazy",
|
|
686
|
+
read: (data) => getType().read(data),
|
|
687
|
+
serializedSize: (value) => getType().serializedSize(value),
|
|
688
|
+
write: (value, writer) => getType().write(value, writer),
|
|
689
|
+
serialize: (value, options) => getType().serialize(value, options).toBytes()
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
var BcsStruct = class extends BcsType {
|
|
693
|
+
constructor({ name, fields, ...options }) {
|
|
694
|
+
const canonicalOrder = Object.entries(fields);
|
|
695
|
+
super({
|
|
696
|
+
name,
|
|
697
|
+
serializedSize: (values) => {
|
|
698
|
+
let total = 0;
|
|
699
|
+
for (const [field, type] of canonicalOrder) {
|
|
700
|
+
const size = type.serializedSize(values[field]);
|
|
701
|
+
if (size == null) return null;
|
|
702
|
+
total += size;
|
|
703
|
+
}
|
|
704
|
+
return total;
|
|
705
|
+
},
|
|
706
|
+
read: (reader) => {
|
|
707
|
+
const result = {};
|
|
708
|
+
for (const [field, type] of canonicalOrder) result[field] = type.read(reader);
|
|
709
|
+
return result;
|
|
710
|
+
},
|
|
711
|
+
write: (value, writer) => {
|
|
712
|
+
for (const [field, type] of canonicalOrder) type.write(value[field], writer);
|
|
713
|
+
},
|
|
714
|
+
...options,
|
|
715
|
+
validate: (value) => {
|
|
716
|
+
options?.validate?.(value);
|
|
717
|
+
if (typeof value !== "object" || value == null) throw new TypeError(`Expected object, found ${typeof value}`);
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
var BcsEnum = class extends BcsType {
|
|
723
|
+
constructor({ fields, ...options }) {
|
|
724
|
+
const canonicalOrder = Object.entries(fields);
|
|
725
|
+
super({
|
|
726
|
+
read: (reader) => {
|
|
727
|
+
const index = reader.readULEB();
|
|
728
|
+
const enumEntry = canonicalOrder[index];
|
|
729
|
+
if (!enumEntry) throw new TypeError(`Unknown value ${index} for enum ${options.name}`);
|
|
730
|
+
const [kind, type] = enumEntry;
|
|
731
|
+
return {
|
|
732
|
+
[kind]: type?.read(reader) ?? true,
|
|
733
|
+
$kind: kind
|
|
734
|
+
};
|
|
735
|
+
},
|
|
736
|
+
write: (value, writer) => {
|
|
737
|
+
const [name, val] = Object.entries(value).filter(([name$1]) => Object.hasOwn(fields, name$1))[0];
|
|
738
|
+
for (let i = 0; i < canonicalOrder.length; i++) {
|
|
739
|
+
const [optionName, optionType] = canonicalOrder[i];
|
|
740
|
+
if (optionName === name) {
|
|
741
|
+
writer.writeULEB(i);
|
|
742
|
+
optionType?.write(val, writer);
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
...options,
|
|
748
|
+
validate: (value) => {
|
|
749
|
+
options?.validate?.(value);
|
|
750
|
+
if (typeof value !== "object" || value == null) throw new TypeError(`Expected object, found ${typeof value}`);
|
|
751
|
+
const keys = Object.keys(value).filter((k) => value[k] !== void 0 && Object.hasOwn(fields, k));
|
|
752
|
+
if (keys.length !== 1) throw new TypeError(`Expected object with one key, but found ${keys.length} for type ${options.name}}`);
|
|
753
|
+
const [variant] = keys;
|
|
754
|
+
if (!Object.hasOwn(fields, variant)) throw new TypeError(`Invalid enum variant ${variant}`);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
var BcsTuple = class extends BcsType {
|
|
760
|
+
constructor({ fields, name, ...options }) {
|
|
761
|
+
super({
|
|
762
|
+
name: name ?? `(${fields.map((t) => t.name).join(", ")})`,
|
|
763
|
+
serializedSize: (values) => {
|
|
764
|
+
let total = 0;
|
|
765
|
+
for (let i = 0; i < fields.length; i++) {
|
|
766
|
+
const size = fields[i].serializedSize(values[i]);
|
|
767
|
+
if (size == null) return null;
|
|
768
|
+
total += size;
|
|
769
|
+
}
|
|
770
|
+
return total;
|
|
771
|
+
},
|
|
772
|
+
read: (reader) => {
|
|
773
|
+
const result = [];
|
|
774
|
+
for (const field of fields) result.push(field.read(reader));
|
|
775
|
+
return result;
|
|
776
|
+
},
|
|
777
|
+
write: (value, writer) => {
|
|
778
|
+
for (let i = 0; i < fields.length; i++) fields[i].write(value[i], writer);
|
|
779
|
+
},
|
|
780
|
+
...options,
|
|
781
|
+
validate: (value) => {
|
|
782
|
+
options?.validate?.(value);
|
|
783
|
+
if (!Array.isArray(value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
784
|
+
if (value.length !== fields.length) throw new TypeError(`Expected array of length ${fields.length}, found ${value.length}`);
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/bcs.mjs
|
|
791
|
+
function fixedArray(size, type, options) {
|
|
792
|
+
return new BcsType({
|
|
793
|
+
read: (reader) => {
|
|
794
|
+
const result = new Array(size);
|
|
795
|
+
for (let i = 0; i < size; i++) result[i] = type.read(reader);
|
|
796
|
+
return result;
|
|
797
|
+
},
|
|
798
|
+
write: (value, writer) => {
|
|
799
|
+
for (const item of value) type.write(item, writer);
|
|
800
|
+
},
|
|
801
|
+
...options,
|
|
802
|
+
name: options?.name ?? `${type.name}[${size}]`,
|
|
803
|
+
validate: (value) => {
|
|
804
|
+
options?.validate?.(value);
|
|
805
|
+
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
806
|
+
if (value.length !== size) throw new TypeError(`Expected array of length ${size}, found ${value.length}`);
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
function option(type) {
|
|
811
|
+
return bcs.enum(`Option<${type.name}>`, {
|
|
812
|
+
None: null,
|
|
813
|
+
Some: type
|
|
814
|
+
}).transform({
|
|
815
|
+
input: (value) => {
|
|
816
|
+
if (value == null) return { None: true };
|
|
817
|
+
return { Some: value };
|
|
818
|
+
},
|
|
819
|
+
output: (value) => {
|
|
820
|
+
if (value.$kind === "Some") return value.Some;
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function vector(type, options) {
|
|
826
|
+
return new BcsType({
|
|
827
|
+
read: (reader) => {
|
|
828
|
+
const length = reader.readULEB();
|
|
829
|
+
const result = new Array(length);
|
|
830
|
+
for (let i = 0; i < length; i++) result[i] = type.read(reader);
|
|
831
|
+
return result;
|
|
832
|
+
},
|
|
833
|
+
write: (value, writer) => {
|
|
834
|
+
writer.writeULEB(value.length);
|
|
835
|
+
for (const item of value) type.write(item, writer);
|
|
836
|
+
},
|
|
837
|
+
...options,
|
|
838
|
+
name: options?.name ?? `vector<${type.name}>`,
|
|
839
|
+
validate: (value) => {
|
|
840
|
+
options?.validate?.(value);
|
|
841
|
+
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
function compareBcsBytes(a, b) {
|
|
846
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++) if (a[i] !== b[i]) return a[i] - b[i];
|
|
847
|
+
return a.length - b.length;
|
|
848
|
+
}
|
|
849
|
+
function map(keyType, valueType) {
|
|
850
|
+
return new BcsType({
|
|
851
|
+
name: `Map<${keyType.name}, ${valueType.name}>`,
|
|
852
|
+
read: (reader) => {
|
|
853
|
+
const length = reader.readULEB();
|
|
854
|
+
const result = /* @__PURE__ */ new Map();
|
|
855
|
+
for (let i = 0; i < length; i++) result.set(keyType.read(reader), valueType.read(reader));
|
|
856
|
+
return result;
|
|
857
|
+
},
|
|
858
|
+
write: (value, writer) => {
|
|
859
|
+
const entries = [...value.entries()].map(([key, val]) => [keyType.serialize(key).toBytes(), val]);
|
|
860
|
+
entries.sort(([a], [b]) => compareBcsBytes(a, b));
|
|
861
|
+
writer.writeULEB(entries.length);
|
|
862
|
+
for (const [keyBytes, val] of entries) {
|
|
863
|
+
writer.writeBytes(keyBytes);
|
|
864
|
+
valueType.write(val, writer);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
var bcs = {
|
|
870
|
+
u8(options) {
|
|
871
|
+
return uIntBcsType({
|
|
872
|
+
readMethod: "read8",
|
|
873
|
+
writeMethod: "write8",
|
|
874
|
+
size: 1,
|
|
875
|
+
maxValue: 2 ** 8 - 1,
|
|
876
|
+
...options,
|
|
877
|
+
name: options?.name ?? "u8"
|
|
878
|
+
});
|
|
879
|
+
},
|
|
880
|
+
u16(options) {
|
|
881
|
+
return uIntBcsType({
|
|
882
|
+
readMethod: "read16",
|
|
883
|
+
writeMethod: "write16",
|
|
884
|
+
size: 2,
|
|
885
|
+
maxValue: 2 ** 16 - 1,
|
|
886
|
+
...options,
|
|
887
|
+
name: options?.name ?? "u16"
|
|
888
|
+
});
|
|
889
|
+
},
|
|
890
|
+
u32(options) {
|
|
891
|
+
return uIntBcsType({
|
|
892
|
+
readMethod: "read32",
|
|
893
|
+
writeMethod: "write32",
|
|
894
|
+
size: 4,
|
|
895
|
+
maxValue: 2 ** 32 - 1,
|
|
896
|
+
...options,
|
|
897
|
+
name: options?.name ?? "u32"
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
u64(options) {
|
|
901
|
+
return bigUIntBcsType({
|
|
902
|
+
readMethod: "read64",
|
|
903
|
+
writeMethod: "write64",
|
|
904
|
+
size: 8,
|
|
905
|
+
maxValue: 2n ** 64n - 1n,
|
|
906
|
+
...options,
|
|
907
|
+
name: options?.name ?? "u64"
|
|
908
|
+
});
|
|
909
|
+
},
|
|
910
|
+
u128(options) {
|
|
911
|
+
return bigUIntBcsType({
|
|
912
|
+
readMethod: "read128",
|
|
913
|
+
writeMethod: "write128",
|
|
914
|
+
size: 16,
|
|
915
|
+
maxValue: 2n ** 128n - 1n,
|
|
916
|
+
...options,
|
|
917
|
+
name: options?.name ?? "u128"
|
|
918
|
+
});
|
|
919
|
+
},
|
|
920
|
+
u256(options) {
|
|
921
|
+
return bigUIntBcsType({
|
|
922
|
+
readMethod: "read256",
|
|
923
|
+
writeMethod: "write256",
|
|
924
|
+
size: 32,
|
|
925
|
+
maxValue: 2n ** 256n - 1n,
|
|
926
|
+
...options,
|
|
927
|
+
name: options?.name ?? "u256"
|
|
928
|
+
});
|
|
929
|
+
},
|
|
930
|
+
bool(options) {
|
|
931
|
+
return fixedSizeBcsType({
|
|
932
|
+
size: 1,
|
|
933
|
+
read: (reader) => reader.read8() === 1,
|
|
934
|
+
write: (value, writer) => writer.write8(value ? 1 : 0),
|
|
935
|
+
...options,
|
|
936
|
+
name: options?.name ?? "bool",
|
|
937
|
+
validate: (value) => {
|
|
938
|
+
options?.validate?.(value);
|
|
939
|
+
if (typeof value !== "boolean") throw new TypeError(`Expected boolean, found ${typeof value}`);
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
},
|
|
943
|
+
uleb128(options) {
|
|
944
|
+
return dynamicSizeBcsType({
|
|
945
|
+
read: (reader) => reader.readULEB(),
|
|
946
|
+
serialize: (value) => {
|
|
947
|
+
return Uint8Array.from(ulebEncode(value));
|
|
948
|
+
},
|
|
949
|
+
...options,
|
|
950
|
+
name: options?.name ?? "uleb128"
|
|
951
|
+
});
|
|
952
|
+
},
|
|
953
|
+
bytes(size, options) {
|
|
954
|
+
return fixedSizeBcsType({
|
|
955
|
+
size,
|
|
956
|
+
read: (reader) => reader.readBytes(size),
|
|
957
|
+
write: (value, writer) => {
|
|
958
|
+
writer.writeBytes(new Uint8Array(value));
|
|
959
|
+
},
|
|
960
|
+
...options,
|
|
961
|
+
name: options?.name ?? `bytes[${size}]`,
|
|
962
|
+
validate: (value) => {
|
|
963
|
+
options?.validate?.(value);
|
|
964
|
+
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
965
|
+
if (value.length !== size) throw new TypeError(`Expected array of length ${size}, found ${value.length}`);
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
},
|
|
969
|
+
byteVector(options) {
|
|
970
|
+
return new BcsType({
|
|
971
|
+
read: (reader) => {
|
|
972
|
+
const length = reader.readULEB();
|
|
973
|
+
return reader.readBytes(length);
|
|
974
|
+
},
|
|
975
|
+
write: (value, writer) => {
|
|
976
|
+
const array = new Uint8Array(value);
|
|
977
|
+
writer.writeULEB(array.length);
|
|
978
|
+
writer.writeBytes(array);
|
|
979
|
+
},
|
|
980
|
+
...options,
|
|
981
|
+
name: options?.name ?? "vector<u8>",
|
|
982
|
+
serializedSize: (value) => {
|
|
983
|
+
const length = "length" in value ? value.length : null;
|
|
984
|
+
return length == null ? null : ulebEncode(length).length + length;
|
|
985
|
+
},
|
|
986
|
+
validate: (value) => {
|
|
987
|
+
options?.validate?.(value);
|
|
988
|
+
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
},
|
|
992
|
+
string(options) {
|
|
993
|
+
return stringLikeBcsType({
|
|
994
|
+
toBytes: (value) => new TextEncoder().encode(value),
|
|
995
|
+
fromBytes: (bytes) => new TextDecoder().decode(bytes),
|
|
996
|
+
...options,
|
|
997
|
+
name: options?.name ?? "string"
|
|
998
|
+
});
|
|
999
|
+
},
|
|
1000
|
+
fixedArray,
|
|
1001
|
+
option,
|
|
1002
|
+
vector,
|
|
1003
|
+
tuple(fields, options) {
|
|
1004
|
+
return new BcsTuple({
|
|
1005
|
+
fields,
|
|
1006
|
+
...options
|
|
1007
|
+
});
|
|
1008
|
+
},
|
|
1009
|
+
struct(name, fields, options) {
|
|
1010
|
+
return new BcsStruct({
|
|
1011
|
+
name,
|
|
1012
|
+
fields,
|
|
1013
|
+
...options
|
|
1014
|
+
});
|
|
1015
|
+
},
|
|
1016
|
+
enum(name, fields, options) {
|
|
1017
|
+
return new BcsEnum({
|
|
1018
|
+
name,
|
|
1019
|
+
fields,
|
|
1020
|
+
...options
|
|
1021
|
+
});
|
|
1022
|
+
},
|
|
1023
|
+
map,
|
|
1024
|
+
lazy(cb) {
|
|
1025
|
+
return lazyBcsType(cb);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
// ../../packages/fast-schema/dist/index.js
|
|
1030
|
+
import { Schema as Schema10 } from "effect";
|
|
1031
|
+
import { Schema as Schema13 } from "effect";
|
|
1032
|
+
import { Schema as Schema12 } from "effect";
|
|
1033
|
+
import { Schema as Schema11 } from "effect";
|
|
1034
|
+
import { Schema as Schema14 } from "effect";
|
|
1035
|
+
import { Schema as Schema15 } from "effect";
|
|
1036
|
+
import { Schema as Schema16 } from "effect";
|
|
1037
|
+
import { Schema as Schema17 } from "effect";
|
|
1038
|
+
import { Schema as Schema18 } from "effect";
|
|
1039
|
+
var __defProp = Object.defineProperty;
|
|
1040
|
+
var __export = (target, all) => {
|
|
1041
|
+
for (var name in all)
|
|
1042
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1043
|
+
};
|
|
1044
|
+
var Uint8ArrayFromNumberArray = Schema.transform(Schema.Array(Schema.Number), Schema.Uint8ArrayFromSelf, {
|
|
1045
|
+
strict: true,
|
|
1046
|
+
decode: (arr) => new Uint8Array(arr),
|
|
1047
|
+
encode: (buf) => Array.from(buf)
|
|
1048
|
+
});
|
|
1049
|
+
var Uint8ArrayFromBase64 = Schema.Uint8ArrayFromBase64;
|
|
1050
|
+
var Uint8ArrayFromHex = Schema.Uint8ArrayFromHex;
|
|
1051
|
+
var Strip0xHex = Schema.transform(Schema.String, Schema.String, {
|
|
1052
|
+
strict: true,
|
|
1053
|
+
decode: (s) => s.startsWith("0x") || s.startsWith("0X") ? s.slice(2) : s,
|
|
1054
|
+
encode: (s) => s
|
|
1055
|
+
});
|
|
1056
|
+
var Uint8ArrayFromHexOptional0x = Schema.compose(Strip0xHex, Uint8ArrayFromHex);
|
|
1057
|
+
var Uint8ArrayFromBech32m = (hrp) => Schema.transformOrFail(Schema.String, Schema.Uint8ArrayFromSelf, {
|
|
1058
|
+
strict: true,
|
|
1059
|
+
decode: (encoded, _options, ast) => {
|
|
1060
|
+
let result;
|
|
1061
|
+
try {
|
|
1062
|
+
result = bech32m.decode(encoded);
|
|
1063
|
+
} catch (e) {
|
|
1064
|
+
const error = e instanceof Error ? e.message : String(e);
|
|
1065
|
+
const message = `Failed to decode bech32m: ${error}`;
|
|
1066
|
+
const failure = new ParseResult.Type(ast, encoded, message);
|
|
1067
|
+
return ParseResult.fail(failure);
|
|
1068
|
+
}
|
|
1069
|
+
const prefix = result.prefix;
|
|
1070
|
+
const words = result.words;
|
|
1071
|
+
if (prefix !== hrp) {
|
|
1072
|
+
const message = `Expected bech32m prefix "${hrp}", got "${prefix}"`;
|
|
1073
|
+
const failure = new ParseResult.Type(ast, encoded, message);
|
|
1074
|
+
return ParseResult.fail(failure);
|
|
1075
|
+
}
|
|
1076
|
+
const array = new Uint8Array(bech32m.fromWords(words));
|
|
1077
|
+
return ParseResult.succeed(array);
|
|
1078
|
+
},
|
|
1079
|
+
encode: (data, _options, ast) => {
|
|
1080
|
+
let words;
|
|
1081
|
+
try {
|
|
1082
|
+
words = bech32m.toWords(data);
|
|
1083
|
+
} catch (e) {
|
|
1084
|
+
const error = e instanceof Error ? e.message : String(e);
|
|
1085
|
+
const message = `Failed to encode bech32m: ${error}`;
|
|
1086
|
+
const inner = new ParseResult.Type(ast, data, message);
|
|
1087
|
+
const failure = new ParseResult.Transformation(ast, data, "Transformation", inner);
|
|
1088
|
+
return ParseResult.fail(failure);
|
|
1089
|
+
}
|
|
1090
|
+
return ParseResult.succeed(bech32m.encode(hrp, words));
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
var FixedUint8Array = (n) => Schema.Uint8ArrayFromSelf.pipe(
|
|
1094
|
+
Schema.filter((a) => a.length === n, {
|
|
1095
|
+
message: () => `Expected exactly ${n} bytes`
|
|
1096
|
+
}),
|
|
1097
|
+
Schema.brand(`Uint8Array${n}`)
|
|
1098
|
+
);
|
|
1099
|
+
var FixedUint8ArrayFromNumberArray = (n) => Schema.compose(Uint8ArrayFromNumberArray, FixedUint8Array(n));
|
|
1100
|
+
var FixedUint8ArrayFromHex = (n) => Schema.compose(Uint8ArrayFromHex, FixedUint8Array(n));
|
|
1101
|
+
var FixedUint8ArrayFromHexOptional0x = (n) => Schema.compose(Uint8ArrayFromHexOptional0x, FixedUint8Array(n));
|
|
1102
|
+
var DecimalBigInt = Schema2.BigInt;
|
|
1103
|
+
var HexBigInt = Schema2.transform(Schema2.String, Schema2.BigIntFromSelf, {
|
|
1104
|
+
strict: true,
|
|
1105
|
+
decode: (s) => {
|
|
1106
|
+
const sign = s[0] === "-" ? -1n : 1n;
|
|
1107
|
+
const digits = s[0] === "-" ? s.slice(1) : s;
|
|
1108
|
+
if (digits.length === 0 || !/^[0-9a-fA-F]+$/.test(digits)) {
|
|
1109
|
+
throw new Error(`Invalid hex string: "${s}"`);
|
|
1110
|
+
}
|
|
1111
|
+
return sign * BigInt(`0x${digits}`);
|
|
1112
|
+
},
|
|
1113
|
+
encode: (n) => n.toString(16)
|
|
1114
|
+
});
|
|
1115
|
+
var DecimalNumber = Schema2.NumberFromString;
|
|
1116
|
+
var HexNumber = Schema2.transform(Schema2.String, Schema2.Number, {
|
|
1117
|
+
strict: true,
|
|
1118
|
+
decode: (s) => {
|
|
1119
|
+
if (s.length === 0 || !/^[0-9a-fA-F]+$/.test(s)) {
|
|
1120
|
+
throw new Error(`Invalid hex string: "${s}"`);
|
|
1121
|
+
}
|
|
1122
|
+
return Number(`0x${s}`);
|
|
1123
|
+
},
|
|
1124
|
+
encode: (n) => n.toString(16)
|
|
1125
|
+
});
|
|
1126
|
+
var BigIntFromNumberOrStringOrSelf = Schema2.transform(
|
|
1127
|
+
Schema2.Union(Schema2.Number, Schema2.BigIntFromSelf, Schema2.String),
|
|
1128
|
+
Schema2.BigIntFromSelf,
|
|
1129
|
+
{
|
|
1130
|
+
strict: true,
|
|
1131
|
+
decode: (n) => typeof n === "bigint" ? n : BigInt(n),
|
|
1132
|
+
encode: (n) => n
|
|
1133
|
+
}
|
|
1134
|
+
);
|
|
1135
|
+
var UintNumber = (bits) => Schema2.Number.pipe(Schema2.int(), Schema2.between(0, 2 ** bits - 1), Schema2.brand(`Uint${bits}`));
|
|
1136
|
+
var IntNumber = (bits) => Schema2.Number.pipe(Schema2.int(), Schema2.between(-(2 ** (bits - 1)), 2 ** (bits - 1) - 1), Schema2.brand(`Int${bits}`));
|
|
1137
|
+
var UintBigInt = (bits) => Schema2.BigIntFromSelf.pipe(Schema2.betweenBigInt(0n, 2n ** BigInt(bits) - 1n), Schema2.brand(`Uint${bits}`));
|
|
1138
|
+
var IntBigInt = (bits) => Schema2.BigIntFromSelf.pipe(Schema2.betweenBigInt(-(2n ** BigInt(bits - 1)), 2n ** BigInt(bits - 1) - 1n), Schema2.brand(`Int${bits}`));
|
|
1139
|
+
var HexUintBigInt = (bits) => Schema2.compose(HexBigInt, UintBigInt(bits));
|
|
1140
|
+
var HexIntBigInt = (bits) => Schema2.compose(HexBigInt, IntBigInt(bits));
|
|
1141
|
+
var DecimalUintBigInt = (bits) => Schema2.compose(DecimalBigInt, UintBigInt(bits));
|
|
1142
|
+
var DecimalIntBigInt = (bits) => Schema2.compose(DecimalBigInt, IntBigInt(bits));
|
|
1143
|
+
var UintBigIntFromNumberOrStringOrSelf = (bits) => Schema2.compose(BigIntFromNumberOrStringOrSelf, UintBigInt(bits));
|
|
1144
|
+
var IntBigIntFromNumberOrStringOrSelf = (bits) => Schema2.compose(BigIntFromNumberOrStringOrSelf, IntBigInt(bits));
|
|
1145
|
+
var Uint8Array32 = FixedUint8Array(32);
|
|
1146
|
+
var Uint8Array64 = FixedUint8Array(64);
|
|
1147
|
+
var Uint8Array32FromNumberArray = FixedUint8ArrayFromNumberArray(32);
|
|
1148
|
+
var Uint8Array32FromHex = FixedUint8ArrayFromHex(32);
|
|
1149
|
+
var Uint8Array32FromHex0x = FixedUint8ArrayFromHexOptional0x(32);
|
|
1150
|
+
var Uint8Array64FromNumberArray = FixedUint8ArrayFromNumberArray(64);
|
|
1151
|
+
var Uint8Array64FromHex0x = FixedUint8ArrayFromHexOptional0x(64);
|
|
1152
|
+
var Uint8Array64FromHex = FixedUint8ArrayFromHex(64);
|
|
1153
|
+
var Uint8 = UintNumber(8);
|
|
1154
|
+
var Uint16 = UintNumber(16);
|
|
1155
|
+
var Uint32 = UintNumber(32);
|
|
1156
|
+
var Int32 = IntNumber(32);
|
|
1157
|
+
var Uint64 = UintBigInt(64);
|
|
1158
|
+
var Int64 = IntBigInt(64);
|
|
1159
|
+
var Uint128 = UintBigInt(128);
|
|
1160
|
+
var Uint256 = UintBigInt(256);
|
|
1161
|
+
var Int320 = IntBigInt(320);
|
|
1162
|
+
var HexUint64 = HexUintBigInt(64);
|
|
1163
|
+
var HexUint256 = HexUintBigInt(256);
|
|
1164
|
+
var HexInt320 = HexIntBigInt(320);
|
|
1165
|
+
var DecimalUint64 = DecimalUintBigInt(64);
|
|
1166
|
+
var DecimalUint256 = DecimalUintBigInt(256);
|
|
1167
|
+
var DecimalInt320 = DecimalIntBigInt(320);
|
|
1168
|
+
var Uint64FromNumberOrStringOrSelf = UintBigIntFromNumberOrStringOrSelf(64);
|
|
1169
|
+
var Uint256FromNumberOrStringOrSelf = UintBigIntFromNumberOrStringOrSelf(256);
|
|
1170
|
+
var Int320FromNumberOrStringOrSelf = IntBigIntFromNumberOrStringOrSelf(320);
|
|
1171
|
+
var CamelCaseStruct = (fields) => {
|
|
1172
|
+
const structFields = {};
|
|
1173
|
+
for (const key of Object.keys(fields)) {
|
|
1174
|
+
const schema = fields[key];
|
|
1175
|
+
const camelKey = Str.snakeToCamel(key);
|
|
1176
|
+
if (camelKey !== key) {
|
|
1177
|
+
structFields[camelKey] = Schema3.propertySignature(schema).pipe(Schema3.fromKey(key));
|
|
1178
|
+
} else {
|
|
1179
|
+
structFields[camelKey] = schema;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
return Schema3.Struct(structFields);
|
|
1183
|
+
};
|
|
1184
|
+
var KeyedVariantSchema = Schema4.Union(
|
|
1185
|
+
Schema4.Record({ key: Schema4.String, value: Schema4.Unknown }),
|
|
1186
|
+
Schema4.String
|
|
1187
|
+
);
|
|
1188
|
+
var TypedVariantSchema = Schema4.Struct({
|
|
1189
|
+
type: Schema4.String,
|
|
1190
|
+
value: Schema4.optional(Schema4.Unknown)
|
|
1191
|
+
});
|
|
1192
|
+
var TypedVariant = (variants, options) => {
|
|
1193
|
+
const bcsMode = options?.unitEncoding === "bcs";
|
|
1194
|
+
const fail = (ast, actual, message) => ParseResult2.fail(new ParseResult2.Type(ast, actual, message));
|
|
1195
|
+
return Schema4.transformOrFail(KeyedVariantSchema, TypedVariantSchema, {
|
|
1196
|
+
strict: false,
|
|
1197
|
+
decode: (kv, _options, ast) => {
|
|
1198
|
+
if (typeof kv === "string") {
|
|
1199
|
+
if (!(kv in variants)) return fail(ast, kv, `Unknown variant "${kv}"`);
|
|
1200
|
+
if (variants[kv] !== null)
|
|
1201
|
+
return fail(ast, kv, `Variant "${kv}" expects data`);
|
|
1202
|
+
return ParseResult2.succeed({ type: kv });
|
|
1203
|
+
}
|
|
1204
|
+
const keys = Object.keys(kv);
|
|
1205
|
+
if (keys.length !== 1) {
|
|
1206
|
+
return fail(ast, kv, `Expected exactly one key, got ${keys.length}`);
|
|
1207
|
+
}
|
|
1208
|
+
const type = keys[0];
|
|
1209
|
+
if (!(type in variants))
|
|
1210
|
+
return fail(ast, kv, `Unknown variant "${type}"`);
|
|
1211
|
+
const schema = variants[type];
|
|
1212
|
+
if (schema === null || schema === void 0) {
|
|
1213
|
+
return ParseResult2.succeed({ type });
|
|
1214
|
+
}
|
|
1215
|
+
const decoded = ParseResult2.decodeUnknownEither(
|
|
1216
|
+
schema
|
|
1217
|
+
)(kv[type]);
|
|
1218
|
+
if (Either.isLeft(decoded)) return ParseResult2.fail(decoded.left);
|
|
1219
|
+
return ParseResult2.succeed({ type, value: decoded.right });
|
|
1220
|
+
},
|
|
1221
|
+
encode: (tv, _options, ast) => {
|
|
1222
|
+
const { type, value } = tv;
|
|
1223
|
+
if (!(type in variants))
|
|
1224
|
+
return fail(ast, tv, `Unknown variant "${type}"`);
|
|
1225
|
+
const schema = variants[type];
|
|
1226
|
+
if (schema === null || schema === void 0) {
|
|
1227
|
+
return ParseResult2.succeed(bcsMode ? { [type]: [] } : type);
|
|
1228
|
+
}
|
|
1229
|
+
const encoded = ParseResult2.encodeUnknownEither(
|
|
1230
|
+
schema
|
|
1231
|
+
)(value);
|
|
1232
|
+
if (Either.isLeft(encoded)) return ParseResult2.fail(encoded.left);
|
|
1233
|
+
return ParseResult2.succeed({ [type]: encoded.right });
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
};
|
|
1237
|
+
var Amount = Uint256.pipe(Schema5.brand("Amount"));
|
|
1238
|
+
var Balance = Int320.pipe(Schema5.brand("Balance"));
|
|
1239
|
+
var Nonce = Uint64.pipe(Schema5.brand("Nonce"));
|
|
1240
|
+
var Quorum = Uint64.pipe(Schema5.brand("Quorum"));
|
|
1241
|
+
var NetworkId = Schema5.Literal("fast:localnet", "fast:devnet", "fast:testnet", "fast:mainnet");
|
|
1242
|
+
var TransactionVersion = Schema5.Literal("Release20260319", "Release20260407");
|
|
1243
|
+
var SupportedTransactionVersions = TransactionVersion.literals;
|
|
1244
|
+
var LatestTransactionVersion = "Release20260407";
|
|
1245
|
+
var Address = Uint8Array32.pipe(Schema5.brand("Address"));
|
|
1246
|
+
var Signature = Uint8Array64.pipe(Schema5.brand("Signature"));
|
|
1247
|
+
var TokenId = Uint8Array32.pipe(Schema5.brand("TokenId"));
|
|
1248
|
+
var StateKey = Uint8Array32.pipe(Schema5.brand("StateKey"));
|
|
1249
|
+
var State = Uint8Array32.pipe(Schema5.brand("State"));
|
|
1250
|
+
var ClaimData = Schema5.Uint8ArrayFromSelf.pipe(Schema5.brand("ClaimData"));
|
|
1251
|
+
var UserData = Schema5.NullOr(Uint8Array32.pipe(Schema5.brand("UserData")));
|
|
1252
|
+
var AmountFromBcs = Uint256FromNumberOrStringOrSelf.pipe(Schema6.brand("Amount"));
|
|
1253
|
+
var BalanceFromBcs = Int320FromNumberOrStringOrSelf.pipe(Schema6.brand("Balance"));
|
|
1254
|
+
var NonceFromBcs = Uint64FromNumberOrStringOrSelf.pipe(Schema6.brand("Nonce"));
|
|
1255
|
+
var QuorumFromBcs = Uint64FromNumberOrStringOrSelf.pipe(Schema6.brand("Quorum"));
|
|
1256
|
+
var NetworkIdFromBcs = NetworkId;
|
|
1257
|
+
var AddressFromBcs = Uint8Array32FromNumberArray.pipe(Schema6.brand("Address"));
|
|
1258
|
+
var SignatureFromBcs = Uint8Array64FromNumberArray.pipe(Schema6.brand("Signature"));
|
|
1259
|
+
var TokenIdFromBcs = Uint8Array32FromNumberArray.pipe(Schema6.brand("TokenId"));
|
|
1260
|
+
var StateKeyFromBcs = Uint8Array32FromNumberArray.pipe(Schema6.brand("StateKey"));
|
|
1261
|
+
var StateFromBcs = Uint8Array32FromNumberArray.pipe(Schema6.brand("State"));
|
|
1262
|
+
var ClaimDataFromBcs = Uint8ArrayFromNumberArray.pipe(Schema6.brand("ClaimData"));
|
|
1263
|
+
var UserDataFromBcs = Schema6.NullOr(Uint8Array32FromNumberArray.pipe(Schema6.brand("UserData")));
|
|
1264
|
+
var AmountFromInput = Schema7.Union(
|
|
1265
|
+
Uint256FromNumberOrStringOrSelf,
|
|
1266
|
+
HexUint256,
|
|
1267
|
+
DecimalUint256
|
|
1268
|
+
).pipe(Schema7.brand("Amount"));
|
|
1269
|
+
var BalanceFromInput = Schema7.Union(
|
|
1270
|
+
Int320FromNumberOrStringOrSelf,
|
|
1271
|
+
HexInt320,
|
|
1272
|
+
DecimalInt320
|
|
1273
|
+
).pipe(Schema7.brand("Balance"));
|
|
1274
|
+
var NonceFromInput = Uint64FromNumberOrStringOrSelf.pipe(
|
|
1275
|
+
Schema7.brand("Nonce")
|
|
1276
|
+
);
|
|
1277
|
+
var QuorumFromInput = Uint64FromNumberOrStringOrSelf.pipe(
|
|
1278
|
+
Schema7.brand("Quorum")
|
|
1279
|
+
);
|
|
1280
|
+
var NetworkIdFromInput = NetworkId;
|
|
1281
|
+
var AddressFromInput = Schema7.Union(
|
|
1282
|
+
Uint8Array32,
|
|
1283
|
+
Uint8Array32FromNumberArray,
|
|
1284
|
+
Uint8Array32FromHex0x,
|
|
1285
|
+
Schema7.compose(Uint8ArrayFromBech32m("fast"), Uint8Array32)
|
|
1286
|
+
).pipe(Schema7.brand("Address"));
|
|
1287
|
+
var SignatureFromInput = Schema7.Union(
|
|
1288
|
+
Uint8Array64,
|
|
1289
|
+
Uint8Array64FromNumberArray,
|
|
1290
|
+
Uint8Array64FromHex0x
|
|
1291
|
+
).pipe(Schema7.brand("Signature"));
|
|
1292
|
+
var TokenIdFromInput = Schema7.Union(
|
|
1293
|
+
Uint8Array32,
|
|
1294
|
+
Uint8Array32FromNumberArray,
|
|
1295
|
+
Uint8Array32FromHex0x
|
|
1296
|
+
).pipe(Schema7.brand("TokenId"));
|
|
1297
|
+
var StateKeyFromInput = Schema7.Union(
|
|
1298
|
+
Uint8Array32,
|
|
1299
|
+
Uint8Array32FromNumberArray,
|
|
1300
|
+
Uint8Array32FromHex0x
|
|
1301
|
+
).pipe(Schema7.brand("StateKey"));
|
|
1302
|
+
var StateFromInput = Schema7.Union(
|
|
1303
|
+
Uint8Array32,
|
|
1304
|
+
Uint8Array32FromNumberArray,
|
|
1305
|
+
Uint8Array32FromHex0x
|
|
1306
|
+
).pipe(Schema7.brand("State"));
|
|
1307
|
+
var ClaimDataFromInput = Schema7.Union(
|
|
1308
|
+
Schema7.Uint8ArrayFromSelf,
|
|
1309
|
+
Uint8ArrayFromNumberArray,
|
|
1310
|
+
Uint8ArrayFromHexOptional0x
|
|
1311
|
+
).pipe(Schema7.brand("ClaimData"));
|
|
1312
|
+
var UserDataFromInput = Schema7.NullOr(
|
|
1313
|
+
Schema7.Union(
|
|
1314
|
+
Uint8Array32,
|
|
1315
|
+
Uint8Array32FromNumberArray,
|
|
1316
|
+
Uint8Array32FromHex0x
|
|
1317
|
+
).pipe(Schema7.brand("UserData"))
|
|
1318
|
+
);
|
|
1319
|
+
var AmountFromRest = DecimalUint256.pipe(Schema8.brand("Amount"));
|
|
1320
|
+
var BalanceFromRest = DecimalInt320.pipe(Schema8.brand("Balance"));
|
|
1321
|
+
var NonceFromRest = Uint64FromNumberOrStringOrSelf.pipe(Schema8.brand("Nonce"));
|
|
1322
|
+
var QuorumFromRest = Uint64FromNumberOrStringOrSelf.pipe(Schema8.brand("Quorum"));
|
|
1323
|
+
var NetworkIdFromRest = NetworkId;
|
|
1324
|
+
var AddressFromRest = Schema8.compose(Uint8ArrayFromBech32m("fast"), Uint8Array32).pipe(Schema8.brand("Address"));
|
|
1325
|
+
var SignatureFromRest = Uint8Array64FromHex.pipe(Schema8.brand("Signature"));
|
|
1326
|
+
var TokenIdFromRest = Uint8Array32FromHex.pipe(Schema8.brand("TokenId"));
|
|
1327
|
+
var StateKeyFromRest = Uint8Array32FromHex.pipe(Schema8.brand("StateKey"));
|
|
1328
|
+
var StateFromRest = Uint8Array32FromHex.pipe(Schema8.brand("State"));
|
|
1329
|
+
var ClaimDataFromRest = Schema8.Uint8ArrayFromHex.pipe(Schema8.brand("ClaimData"));
|
|
1330
|
+
var UserDataFromRest = Schema8.NullOr(Uint8Array32FromHex.pipe(Schema8.brand("UserData")));
|
|
1331
|
+
var AmountFromRpc = HexUint256.pipe(Schema9.brand("Amount"));
|
|
1332
|
+
var BalanceFromRpc = HexInt320.pipe(Schema9.brand("Balance"));
|
|
1333
|
+
var NonceFromRpc = Uint64FromNumberOrStringOrSelf.pipe(Schema9.brand("Nonce"));
|
|
1334
|
+
var QuorumFromRpc = Uint64FromNumberOrStringOrSelf.pipe(Schema9.brand("Quorum"));
|
|
1335
|
+
var NetworkIdFromRpc = NetworkId;
|
|
1336
|
+
var AddressFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("Address"));
|
|
1337
|
+
var SignatureFromRpc = Uint8Array64FromNumberArray.pipe(Schema9.brand("Signature"));
|
|
1338
|
+
var TokenIdFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("TokenId"));
|
|
1339
|
+
var StateKeyFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("StateKey"));
|
|
1340
|
+
var StateFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("State"));
|
|
1341
|
+
var ClaimDataFromRpc = Uint8ArrayFromNumberArray.pipe(Schema9.brand("ClaimData"));
|
|
1342
|
+
var UserDataFromRpc = Schema9.NullOr(Uint8Array32FromNumberArray.pipe(Schema9.brand("UserData")));
|
|
1343
|
+
var bcs_layout_exports = {};
|
|
1344
|
+
__export(bcs_layout_exports, {
|
|
1345
|
+
AddressChange: () => AddressChange,
|
|
1346
|
+
Amount: () => Amount2,
|
|
1347
|
+
Burn: () => Burn,
|
|
1348
|
+
ClaimData: () => ClaimData2,
|
|
1349
|
+
ClaimType: () => ClaimType,
|
|
1350
|
+
CommitteeChange: () => CommitteeChange,
|
|
1351
|
+
CommitteeConfig: () => CommitteeConfig,
|
|
1352
|
+
Escrow: () => Escrow,
|
|
1353
|
+
EscrowComplete: () => EscrowComplete,
|
|
1354
|
+
EscrowCreateConfig: () => EscrowCreateConfig,
|
|
1355
|
+
EscrowCreateJob: () => EscrowCreateJob,
|
|
1356
|
+
EscrowReject: () => EscrowReject,
|
|
1357
|
+
EscrowSubmit: () => EscrowSubmit,
|
|
1358
|
+
ExternalClaim: () => ExternalClaim,
|
|
1359
|
+
ExternalClaimBody: () => ExternalClaimBody,
|
|
1360
|
+
FixedAmountOrBps: () => FixedAmountOrBps,
|
|
1361
|
+
Mint: () => Mint,
|
|
1362
|
+
MultiSig: () => MultiSig,
|
|
1363
|
+
MultiSigConfig: () => MultiSigConfig,
|
|
1364
|
+
Nonce: () => Nonce2,
|
|
1365
|
+
Operation: () => Operation,
|
|
1366
|
+
PublicKeyBytes: () => PublicKeyBytes,
|
|
1367
|
+
Quorum: () => Quorum2,
|
|
1368
|
+
Signature: () => Signature2,
|
|
1369
|
+
SignatureOrMultiSig: () => SignatureOrMultiSig,
|
|
1370
|
+
State: () => State2,
|
|
1371
|
+
StateInitialization: () => StateInitialization,
|
|
1372
|
+
StateKey: () => StateKey2,
|
|
1373
|
+
StateReset: () => StateReset,
|
|
1374
|
+
StateUpdate: () => StateUpdate,
|
|
1375
|
+
TimestampNanos: () => TimestampNanos,
|
|
1376
|
+
TokenCreation: () => TokenCreation,
|
|
1377
|
+
TokenDecimals: () => TokenDecimals,
|
|
1378
|
+
TokenId: () => TokenId2,
|
|
1379
|
+
TokenManagement: () => TokenManagement,
|
|
1380
|
+
TokenName: () => TokenName,
|
|
1381
|
+
TokenTransfer: () => TokenTransfer,
|
|
1382
|
+
Transaction20260319: () => Transaction20260319,
|
|
1383
|
+
Transaction20260407: () => Transaction20260407,
|
|
1384
|
+
UserData: () => UserData2,
|
|
1385
|
+
ValidatorConfig: () => ValidatorConfig,
|
|
1386
|
+
VerifierSig: () => VerifierSig,
|
|
1387
|
+
VersionedTransaction: () => VersionedTransaction
|
|
1388
|
+
});
|
|
1389
|
+
var PublicKeyBytes = bcs.fixedArray(32, bcs.u8());
|
|
1390
|
+
var StateKey2 = bcs.fixedArray(32, bcs.u8());
|
|
1391
|
+
var Nonce2 = bcs.u64();
|
|
1392
|
+
var TimestampNanos = bcs.u128();
|
|
1393
|
+
var TokenId2 = bcs.fixedArray(32, bcs.u8());
|
|
1394
|
+
var TokenName = bcs.string();
|
|
1395
|
+
var TokenDecimals = bcs.u8();
|
|
1396
|
+
var Amount2 = bcs.u256();
|
|
1397
|
+
var UserData2 = bcs.option(bcs.fixedArray(32, bcs.u8()));
|
|
1398
|
+
var State2 = bcs.fixedArray(32, bcs.u8());
|
|
1399
|
+
var Quorum2 = bcs.u64();
|
|
1400
|
+
var ClaimData2 = bcs.vector(bcs.u8());
|
|
1401
|
+
var Signature2 = bcs.fixedArray(64, bcs.u8());
|
|
1402
|
+
var MultiSigConfig = bcs.struct("MultiSigConfig", {
|
|
1403
|
+
authorized_signers: bcs.vector(PublicKeyBytes),
|
|
1404
|
+
quorum: Quorum2,
|
|
1405
|
+
nonce: Nonce2
|
|
1406
|
+
});
|
|
1407
|
+
var MultiSig = bcs.struct("MultiSig", {
|
|
1408
|
+
config: MultiSigConfig,
|
|
1409
|
+
signatures: bcs.vector(bcs.tuple([PublicKeyBytes, Signature2]))
|
|
1410
|
+
});
|
|
1411
|
+
var SignatureOrMultiSig = bcs.enum("SignatureOrMultiSig", {
|
|
1412
|
+
Signature: Signature2,
|
|
1413
|
+
MultiSig
|
|
1414
|
+
});
|
|
1415
|
+
var AddressChange = bcs.enum("AddressChange", {
|
|
1416
|
+
Add: bcs.tuple([]),
|
|
1417
|
+
Remove: bcs.tuple([])
|
|
1418
|
+
});
|
|
1419
|
+
var TokenTransfer = bcs.struct("TokenTransfer", {
|
|
1420
|
+
token_id: TokenId2,
|
|
1421
|
+
recipient: PublicKeyBytes,
|
|
1422
|
+
amount: Amount2,
|
|
1423
|
+
user_data: UserData2
|
|
1424
|
+
});
|
|
1425
|
+
var TokenCreation = bcs.struct("TokenCreation", {
|
|
1426
|
+
token_name: TokenName,
|
|
1427
|
+
decimals: TokenDecimals,
|
|
1428
|
+
initial_amount: Amount2,
|
|
1429
|
+
mints: bcs.vector(PublicKeyBytes),
|
|
1430
|
+
user_data: UserData2
|
|
1431
|
+
});
|
|
1432
|
+
var TokenManagement = bcs.struct("TokenManagement", {
|
|
1433
|
+
token_id: TokenId2,
|
|
1434
|
+
update_id: Nonce2,
|
|
1435
|
+
new_admin: bcs.option(PublicKeyBytes),
|
|
1436
|
+
mints: bcs.vector(bcs.tuple([AddressChange, PublicKeyBytes])),
|
|
1437
|
+
user_data: UserData2
|
|
1438
|
+
});
|
|
1439
|
+
var Mint = bcs.struct("Mint", {
|
|
1440
|
+
token_id: TokenId2,
|
|
1441
|
+
recipient: PublicKeyBytes,
|
|
1442
|
+
amount: Amount2
|
|
1443
|
+
});
|
|
1444
|
+
var Burn = bcs.struct("Burn", {
|
|
1445
|
+
token_id: TokenId2,
|
|
1446
|
+
amount: Amount2
|
|
1447
|
+
});
|
|
1448
|
+
var StateInitialization = bcs.struct("StateInitialization", {
|
|
1449
|
+
key: StateKey2,
|
|
1450
|
+
initial_state: State2
|
|
1451
|
+
});
|
|
1452
|
+
var StateUpdate = bcs.struct("StateUpdate", {
|
|
1453
|
+
key: StateKey2,
|
|
1454
|
+
previous_state: State2,
|
|
1455
|
+
next_state: State2,
|
|
1456
|
+
compute_claim_tx_hash: bcs.fixedArray(32, bcs.u8()),
|
|
1457
|
+
compute_claim_tx_timestamp: TimestampNanos
|
|
1458
|
+
});
|
|
1459
|
+
var StateReset = bcs.struct("StateReset", {
|
|
1460
|
+
key: StateKey2,
|
|
1461
|
+
reset_state: State2
|
|
1462
|
+
});
|
|
1463
|
+
var ExternalClaimBody = bcs.struct("ExternalClaimBody", {
|
|
1464
|
+
verifier_committee: bcs.vector(PublicKeyBytes),
|
|
1465
|
+
verifier_quorum: Quorum2,
|
|
1466
|
+
claim_data: ClaimData2
|
|
1467
|
+
});
|
|
1468
|
+
var VerifierSig = bcs.struct("VerifierSig", {
|
|
1469
|
+
verifier_addr: PublicKeyBytes,
|
|
1470
|
+
sig: Signature2
|
|
1471
|
+
});
|
|
1472
|
+
var ExternalClaim = bcs.struct("ExternalClaim", {
|
|
1473
|
+
claim: ExternalClaimBody,
|
|
1474
|
+
signatures: bcs.vector(VerifierSig)
|
|
1475
|
+
});
|
|
1476
|
+
var ValidatorConfig = bcs.struct("ValidatorConfig", {
|
|
1477
|
+
address: PublicKeyBytes,
|
|
1478
|
+
host: bcs.string(),
|
|
1479
|
+
rpc_port: bcs.u32()
|
|
1480
|
+
});
|
|
1481
|
+
var CommitteeConfig = bcs.struct("CommitteeConfig", {
|
|
1482
|
+
validators: bcs.vector(ValidatorConfig)
|
|
1483
|
+
});
|
|
1484
|
+
var CommitteeChange = bcs.struct("CommitteeChange", {
|
|
1485
|
+
new_committee: CommitteeConfig,
|
|
1486
|
+
epoch: bcs.u32()
|
|
1487
|
+
});
|
|
1488
|
+
var FixedAmountOrBps = bcs.enum("FixedAmountOrBps", {
|
|
1489
|
+
Fixed: Amount2,
|
|
1490
|
+
Bps: bcs.u16()
|
|
1491
|
+
});
|
|
1492
|
+
var EscrowCreateConfig = bcs.struct("EscrowCreateConfig", {
|
|
1493
|
+
token_id: TokenId2,
|
|
1494
|
+
evaluator: PublicKeyBytes,
|
|
1495
|
+
evaluation_fee: FixedAmountOrBps,
|
|
1496
|
+
min_evaluator_fee: Amount2
|
|
1497
|
+
});
|
|
1498
|
+
var EscrowCreateJob = bcs.struct("EscrowCreateJob", {
|
|
1499
|
+
config_id: bcs.fixedArray(32, bcs.u8()),
|
|
1500
|
+
provider: PublicKeyBytes,
|
|
1501
|
+
provider_fee: Amount2,
|
|
1502
|
+
description: bcs.string()
|
|
1503
|
+
});
|
|
1504
|
+
var EscrowSubmit = bcs.struct("EscrowSubmit", {
|
|
1505
|
+
job_id: bcs.fixedArray(32, bcs.u8()),
|
|
1506
|
+
deliverable: bcs.fixedArray(32, bcs.u8())
|
|
1507
|
+
});
|
|
1508
|
+
var EscrowReject = bcs.struct("EscrowReject", {
|
|
1509
|
+
job_id: bcs.fixedArray(32, bcs.u8())
|
|
1510
|
+
});
|
|
1511
|
+
var EscrowComplete = bcs.struct("EscrowComplete", {
|
|
1512
|
+
job_id: bcs.fixedArray(32, bcs.u8())
|
|
1513
|
+
});
|
|
1514
|
+
var Escrow = bcs.enum("Escrow", {
|
|
1515
|
+
CreateConfig: EscrowCreateConfig,
|
|
1516
|
+
CreateJob: EscrowCreateJob,
|
|
1517
|
+
Submit: EscrowSubmit,
|
|
1518
|
+
Reject: EscrowReject,
|
|
1519
|
+
Complete: EscrowComplete
|
|
1520
|
+
});
|
|
1521
|
+
var Operation = bcs.enum("Operation", {
|
|
1522
|
+
TokenTransfer,
|
|
1523
|
+
TokenCreation,
|
|
1524
|
+
TokenManagement,
|
|
1525
|
+
Mint,
|
|
1526
|
+
Burn,
|
|
1527
|
+
StateInitialization,
|
|
1528
|
+
StateUpdate,
|
|
1529
|
+
ExternalClaim,
|
|
1530
|
+
StateReset,
|
|
1531
|
+
JoinCommittee: ValidatorConfig,
|
|
1532
|
+
LeaveCommittee: bcs.tuple([]),
|
|
1533
|
+
ChangeCommittee: CommitteeChange,
|
|
1534
|
+
Escrow
|
|
1535
|
+
});
|
|
1536
|
+
var ClaimType = bcs.enum("ClaimType", {
|
|
1537
|
+
TokenTransfer,
|
|
1538
|
+
TokenCreation,
|
|
1539
|
+
TokenManagement,
|
|
1540
|
+
Mint,
|
|
1541
|
+
Burn,
|
|
1542
|
+
StateInitialization,
|
|
1543
|
+
StateUpdate,
|
|
1544
|
+
ExternalClaim,
|
|
1545
|
+
StateReset,
|
|
1546
|
+
JoinCommittee: ValidatorConfig,
|
|
1547
|
+
LeaveCommittee: bcs.tuple([]),
|
|
1548
|
+
ChangeCommittee: CommitteeChange,
|
|
1549
|
+
Escrow,
|
|
1550
|
+
Batch: bcs.vector(Operation)
|
|
1551
|
+
});
|
|
1552
|
+
var Transaction20260319 = bcs.struct("Transaction", {
|
|
1553
|
+
network_id: bcs.string(),
|
|
1554
|
+
sender: PublicKeyBytes,
|
|
1555
|
+
nonce: Nonce2,
|
|
1556
|
+
timestamp_nanos: TimestampNanos,
|
|
1557
|
+
claim: ClaimType,
|
|
1558
|
+
archival: bcs.bool(),
|
|
1559
|
+
fee_token: bcs.option(TokenId2)
|
|
1560
|
+
});
|
|
1561
|
+
var Transaction20260407 = bcs.struct("Transaction20260407", {
|
|
1562
|
+
network_id: bcs.string(),
|
|
1563
|
+
sender: PublicKeyBytes,
|
|
1564
|
+
nonce: Nonce2,
|
|
1565
|
+
timestamp_nanos: TimestampNanos,
|
|
1566
|
+
claims: bcs.vector(Operation),
|
|
1567
|
+
archival: bcs.bool(),
|
|
1568
|
+
fee_token: bcs.option(TokenId2)
|
|
1569
|
+
});
|
|
1570
|
+
var VersionedTransaction = bcs.enum("VersionedTransaction", {
|
|
1571
|
+
Release20260319: Transaction20260319,
|
|
1572
|
+
Release20260407: Transaction20260407
|
|
1573
|
+
});
|
|
1574
|
+
var FastSetErrorData = TypedVariant({
|
|
1575
|
+
UnexpectedNonce: CamelCaseStruct({
|
|
1576
|
+
expected_nonce: BigIntFromNumberOrStringOrSelf
|
|
1577
|
+
}),
|
|
1578
|
+
InsufficientFunding: CamelCaseStruct({
|
|
1579
|
+
current_balance: BigIntFromNumberOrStringOrSelf
|
|
1580
|
+
}),
|
|
1581
|
+
PreviousTransactionMustBeConfirmedFirst: CamelCaseStruct({
|
|
1582
|
+
pending_confirmation: Schema10.Unknown
|
|
1583
|
+
}),
|
|
1584
|
+
InvalidSignature: Schema10.Struct({
|
|
1585
|
+
error: Schema10.String
|
|
1586
|
+
}),
|
|
1587
|
+
MissingEarlierConfirmations: CamelCaseStruct({
|
|
1588
|
+
current_nonce: BigIntFromNumberOrStringOrSelf
|
|
1589
|
+
}),
|
|
1590
|
+
CertificateTooYoung: CamelCaseStruct({
|
|
1591
|
+
resend_after_nanos: BigIntFromNumberOrStringOrSelf
|
|
1592
|
+
}),
|
|
1593
|
+
NonSubmittableOperation: Schema10.Struct({
|
|
1594
|
+
reason: Schema10.String
|
|
1595
|
+
})
|
|
1596
|
+
});
|
|
1597
|
+
var JsonRpcError = TypedVariant({
|
|
1598
|
+
FastSet: FastSetErrorData,
|
|
1599
|
+
Generic: Schema10.String
|
|
1600
|
+
});
|
|
1601
|
+
var ProxyErrorData = TypedVariant({
|
|
1602
|
+
GeneralError: Schema10.String,
|
|
1603
|
+
FaucetDisabled: null,
|
|
1604
|
+
RpcError: JsonRpcError,
|
|
1605
|
+
FaucetThrottled: Schema10.Unknown,
|
|
1606
|
+
FaucetTxnFailed: Schema10.Unknown,
|
|
1607
|
+
FaucetThresholdExceeded: Schema10.Unknown,
|
|
1608
|
+
VerifierSigsInvalid: Schema10.Unknown,
|
|
1609
|
+
DatabaseError: Schema10.String,
|
|
1610
|
+
TooManyCertificatesRequested: null,
|
|
1611
|
+
UnexpectedNonce: CamelCaseStruct({
|
|
1612
|
+
tx_nonce: BigIntFromNumberOrStringOrSelf,
|
|
1613
|
+
expected_nonce: BigIntFromNumberOrStringOrSelf
|
|
1614
|
+
}),
|
|
1615
|
+
InvalidRequest: Schema10.String
|
|
1616
|
+
});
|
|
1617
|
+
var makeAddressChange = (options) => TypedVariant({ Add: null, Remove: null }, options);
|
|
1618
|
+
var AddressChange2 = makeAddressChange();
|
|
1619
|
+
var makeTokenTransfer = (p4) => CamelCaseStruct({
|
|
1620
|
+
token_id: p4.TokenId,
|
|
1621
|
+
recipient: p4.Address,
|
|
1622
|
+
amount: p4.Amount,
|
|
1623
|
+
user_data: p4.UserData
|
|
1624
|
+
});
|
|
1625
|
+
var makeTokenCreation = (p4) => CamelCaseStruct({
|
|
1626
|
+
token_name: Schema11.String,
|
|
1627
|
+
decimals: Schema11.Number,
|
|
1628
|
+
initial_amount: p4.Amount,
|
|
1629
|
+
mints: Schema11.Array(p4.Address),
|
|
1630
|
+
user_data: p4.UserData
|
|
1631
|
+
});
|
|
1632
|
+
var makeTokenManagement = (p4, options) => CamelCaseStruct({
|
|
1633
|
+
token_id: p4.TokenId,
|
|
1634
|
+
update_id: p4.Nonce,
|
|
1635
|
+
new_admin: Schema11.NullOr(p4.Address),
|
|
1636
|
+
mints: Schema11.Array(Schema11.Tuple(makeAddressChange(options), p4.Address)),
|
|
1637
|
+
user_data: p4.UserData
|
|
1638
|
+
});
|
|
1639
|
+
var makeMint = (p4) => CamelCaseStruct({
|
|
1640
|
+
token_id: p4.TokenId,
|
|
1641
|
+
recipient: p4.Address,
|
|
1642
|
+
amount: p4.Amount
|
|
1643
|
+
});
|
|
1644
|
+
var makeBurn = (p4) => CamelCaseStruct({ token_id: p4.TokenId, amount: p4.Amount });
|
|
1645
|
+
var makeStateInitialization = (p4) => CamelCaseStruct({ key: p4.StateKey, initial_state: p4.State });
|
|
1646
|
+
var makeStateUpdate = (p4) => CamelCaseStruct({
|
|
1647
|
+
key: p4.StateKey,
|
|
1648
|
+
previous_state: p4.State,
|
|
1649
|
+
next_state: p4.State,
|
|
1650
|
+
compute_claim_tx_hash: p4.StateKey,
|
|
1651
|
+
compute_claim_tx_timestamp: p4.BigInt
|
|
1652
|
+
});
|
|
1653
|
+
var makeStateReset = (p4) => CamelCaseStruct({ key: p4.StateKey, reset_state: p4.State });
|
|
1654
|
+
var makeExternalClaimBody = (p4) => CamelCaseStruct({
|
|
1655
|
+
verifier_committee: Schema11.Array(p4.Address),
|
|
1656
|
+
verifier_quorum: p4.Quorum,
|
|
1657
|
+
claim_data: p4.ClaimData
|
|
1658
|
+
});
|
|
1659
|
+
var makeVerifierSig = (p4) => CamelCaseStruct({ verifier_addr: p4.Address, sig: p4.Signature });
|
|
1660
|
+
var makeExternalClaim = (p4) => Schema11.Struct({
|
|
1661
|
+
claim: makeExternalClaimBody(p4),
|
|
1662
|
+
signatures: Schema11.Array(makeVerifierSig(p4))
|
|
1663
|
+
});
|
|
1664
|
+
var makeValidatorConfig = (p4) => CamelCaseStruct({
|
|
1665
|
+
address: p4.Address,
|
|
1666
|
+
host: Schema11.String,
|
|
1667
|
+
rpc_port: Schema11.Number
|
|
1668
|
+
});
|
|
1669
|
+
var makeCommitteeConfig = (p4) => Schema11.Struct({ validators: Schema11.Array(makeValidatorConfig(p4)) });
|
|
1670
|
+
var makeCommitteeChange = (p4) => CamelCaseStruct({
|
|
1671
|
+
new_committee: makeCommitteeConfig(p4),
|
|
1672
|
+
epoch: Schema11.Number
|
|
1673
|
+
});
|
|
1674
|
+
var makeFixedAmountOrBps = (p4, options) => TypedVariant({ Fixed: p4.Amount, Bps: Schema11.Number }, options);
|
|
1675
|
+
var makeEscrowCreateConfig = (p4, options) => CamelCaseStruct({
|
|
1676
|
+
token_id: p4.TokenId,
|
|
1677
|
+
evaluator: p4.Address,
|
|
1678
|
+
evaluation_fee: makeFixedAmountOrBps(p4, options),
|
|
1679
|
+
min_evaluator_fee: p4.Amount
|
|
1680
|
+
});
|
|
1681
|
+
var makeEscrowCreateJob = (p4) => CamelCaseStruct({
|
|
1682
|
+
config_id: p4.TokenId,
|
|
1683
|
+
provider: p4.Address,
|
|
1684
|
+
provider_fee: p4.Amount,
|
|
1685
|
+
description: Schema11.String
|
|
1686
|
+
});
|
|
1687
|
+
var makeEscrowSubmit = (p4) => CamelCaseStruct({ job_id: p4.TokenId, deliverable: p4.TokenId });
|
|
1688
|
+
var makeEscrowReject = (p4) => CamelCaseStruct({ job_id: p4.TokenId });
|
|
1689
|
+
var makeEscrowComplete = (p4) => CamelCaseStruct({ job_id: p4.TokenId });
|
|
1690
|
+
var makeEscrow = (p4, options) => TypedVariant(
|
|
1691
|
+
{
|
|
1692
|
+
CreateConfig: makeEscrowCreateConfig(p4, options),
|
|
1693
|
+
CreateJob: makeEscrowCreateJob(p4),
|
|
1694
|
+
Submit: makeEscrowSubmit(p4),
|
|
1695
|
+
Reject: makeEscrowReject(p4),
|
|
1696
|
+
Complete: makeEscrowComplete(p4)
|
|
1697
|
+
},
|
|
1698
|
+
options
|
|
1699
|
+
);
|
|
1700
|
+
var makeOperation = (p4, options) => TypedVariant(
|
|
1701
|
+
{
|
|
1702
|
+
TokenTransfer: makeTokenTransfer(p4),
|
|
1703
|
+
TokenCreation: makeTokenCreation(p4),
|
|
1704
|
+
TokenManagement: makeTokenManagement(p4, options),
|
|
1705
|
+
Mint: makeMint(p4),
|
|
1706
|
+
Burn: makeBurn(p4),
|
|
1707
|
+
StateInitialization: makeStateInitialization(p4),
|
|
1708
|
+
StateUpdate: makeStateUpdate(p4),
|
|
1709
|
+
StateReset: makeStateReset(p4),
|
|
1710
|
+
ExternalClaim: makeExternalClaim(p4),
|
|
1711
|
+
JoinCommittee: makeValidatorConfig(p4),
|
|
1712
|
+
LeaveCommittee: null,
|
|
1713
|
+
ChangeCommittee: makeCommitteeChange(p4),
|
|
1714
|
+
Escrow: makeEscrow(p4, options)
|
|
1715
|
+
},
|
|
1716
|
+
options
|
|
1717
|
+
);
|
|
1718
|
+
var makeClaimType = (p4, options) => TypedVariant(
|
|
1719
|
+
{
|
|
1720
|
+
TokenTransfer: makeTokenTransfer(p4),
|
|
1721
|
+
TokenCreation: makeTokenCreation(p4),
|
|
1722
|
+
TokenManagement: makeTokenManagement(p4, options),
|
|
1723
|
+
Mint: makeMint(p4),
|
|
1724
|
+
Burn: makeBurn(p4),
|
|
1725
|
+
StateInitialization: makeStateInitialization(p4),
|
|
1726
|
+
StateUpdate: makeStateUpdate(p4),
|
|
1727
|
+
StateReset: makeStateReset(p4),
|
|
1728
|
+
ExternalClaim: makeExternalClaim(p4),
|
|
1729
|
+
JoinCommittee: makeValidatorConfig(p4),
|
|
1730
|
+
LeaveCommittee: null,
|
|
1731
|
+
ChangeCommittee: makeCommitteeChange(p4),
|
|
1732
|
+
Escrow: makeEscrow(p4, options),
|
|
1733
|
+
Batch: Schema11.Array(makeOperation(p4, options))
|
|
1734
|
+
},
|
|
1735
|
+
options
|
|
1736
|
+
);
|
|
1737
|
+
var makeTransactionRelease20260319 = (p4, options) => CamelCaseStruct({
|
|
1738
|
+
network_id: p4.NetworkId,
|
|
1739
|
+
sender: p4.Address,
|
|
1740
|
+
nonce: p4.Nonce,
|
|
1741
|
+
timestamp_nanos: p4.BigInt,
|
|
1742
|
+
claim: makeClaimType(p4, options),
|
|
1743
|
+
archival: Schema12.Boolean,
|
|
1744
|
+
fee_token: Schema12.NullOr(p4.TokenId)
|
|
1745
|
+
});
|
|
1746
|
+
var makeTransactionRelease20260407 = (p4, options) => CamelCaseStruct({
|
|
1747
|
+
network_id: p4.NetworkId,
|
|
1748
|
+
sender: p4.Address,
|
|
1749
|
+
nonce: p4.Nonce,
|
|
1750
|
+
timestamp_nanos: p4.BigInt,
|
|
1751
|
+
claims: Schema12.Array(makeOperation(p4, options)),
|
|
1752
|
+
archival: Schema12.Boolean,
|
|
1753
|
+
fee_token: Schema12.NullOr(p4.TokenId)
|
|
1754
|
+
});
|
|
1755
|
+
var makeTransaction = makeTransactionRelease20260407;
|
|
1756
|
+
var makeVersionedTransaction = (p4, options) => TypedVariant({
|
|
1757
|
+
Release20260319: makeTransactionRelease20260319(p4, options),
|
|
1758
|
+
Release20260407: makeTransactionRelease20260407(p4, options)
|
|
1759
|
+
});
|
|
1760
|
+
var makeMultiSigConfig = (p4) => CamelCaseStruct({ authorized_signers: Schema13.Array(p4.Address), quorum: p4.Quorum, nonce: p4.Nonce });
|
|
1761
|
+
var makeMultiSig = (p4) => Schema13.Struct({
|
|
1762
|
+
config: makeMultiSigConfig(p4),
|
|
1763
|
+
signatures: Schema13.Array(Schema13.Tuple(p4.Address, p4.Signature))
|
|
1764
|
+
});
|
|
1765
|
+
var makeSignatureOrMultiSig = (p4) => TypedVariant({
|
|
1766
|
+
Signature: p4.Signature,
|
|
1767
|
+
MultiSig: makeMultiSig(p4)
|
|
1768
|
+
});
|
|
1769
|
+
var makeTransactionEnvelope = (p4) => Schema13.Struct({
|
|
1770
|
+
transaction: makeVersionedTransaction(p4),
|
|
1771
|
+
signature: makeSignatureOrMultiSig(p4)
|
|
1772
|
+
});
|
|
1773
|
+
var makeValidatedTransaction = (p4) => Schema13.Struct({
|
|
1774
|
+
value: makeTransactionEnvelope(p4),
|
|
1775
|
+
validator: p4.Address,
|
|
1776
|
+
signature: p4.Signature
|
|
1777
|
+
});
|
|
1778
|
+
var makeTransactionCertificate = (p4) => Schema13.Struct({
|
|
1779
|
+
envelope: makeTransactionEnvelope(p4),
|
|
1780
|
+
signatures: Schema13.Array(Schema13.Tuple(p4.Address, p4.Signature))
|
|
1781
|
+
});
|
|
1782
|
+
var makeNonceRange = (p4) => Schema14.Struct({ start: p4.Nonce, limit: Schema14.Number });
|
|
1783
|
+
var makePageRequest = (p4) => Schema14.Struct({ limit: Schema14.Number, token: Schema14.optional(p4.BigInt) });
|
|
1784
|
+
var makeTokenMetadata = (p4) => CamelCaseStruct({
|
|
1785
|
+
update_id: p4.Nonce,
|
|
1786
|
+
admin: p4.Address,
|
|
1787
|
+
token_name: Schema14.String,
|
|
1788
|
+
decimals: Schema14.Number,
|
|
1789
|
+
total_supply: p4.Amount,
|
|
1790
|
+
mints: Schema14.Array(p4.Address)
|
|
1791
|
+
});
|
|
1792
|
+
var makeAccountInfoResponse = (p4) => CamelCaseStruct({
|
|
1793
|
+
sender: p4.Address,
|
|
1794
|
+
balance: p4.Balance,
|
|
1795
|
+
next_nonce: p4.Nonce,
|
|
1796
|
+
pending_confirmation: Schema14.NullOr(makeValidatedTransaction(p4)),
|
|
1797
|
+
requested_state: Schema14.Array(Schema14.Tuple(p4.StateKey, p4.State)),
|
|
1798
|
+
requested_certificates: Schema14.NullOr(Schema14.Array(makeTransactionCertificate(p4))),
|
|
1799
|
+
requested_validated_transaction: Schema14.NullOr(makeValidatedTransaction(p4)),
|
|
1800
|
+
token_balance: Schema14.Array(Schema14.Tuple(p4.TokenId, p4.Balance))
|
|
1801
|
+
});
|
|
1802
|
+
var makeTokenInfoResponse = (p4) => CamelCaseStruct({
|
|
1803
|
+
requested_token_metadata: Schema14.Array(Schema14.Tuple(p4.TokenId, Schema14.NullOr(makeTokenMetadata(p4))))
|
|
1804
|
+
});
|
|
1805
|
+
var makeSubmitTransactionResponse = (p4) => CamelCaseStruct({ validator: p4.Address, signature: p4.Signature, next_nonce: p4.Nonce, transaction_hash: p4.ClaimData });
|
|
1806
|
+
var makeConfirmTransactionResponse = (p4) => CamelCaseStruct({ token_ids: Schema14.Array(p4.TokenId) });
|
|
1807
|
+
var makeProxySubmitTransactionResult = (p4) => TypedVariant({
|
|
1808
|
+
Success: makeTransactionCertificate(p4),
|
|
1809
|
+
IncompleteVerifierSigs: null,
|
|
1810
|
+
IncompleteMultiSig: null
|
|
1811
|
+
});
|
|
1812
|
+
var makeEscrowJobRecord = (p4) => CamelCaseStruct({
|
|
1813
|
+
job_id: p4.TokenId,
|
|
1814
|
+
config_id: p4.TokenId,
|
|
1815
|
+
client: p4.Address,
|
|
1816
|
+
provider: p4.Address,
|
|
1817
|
+
evaluator: p4.Address,
|
|
1818
|
+
token_id: p4.TokenId,
|
|
1819
|
+
provider_fee: p4.Amount,
|
|
1820
|
+
evaluator_fee: p4.Amount,
|
|
1821
|
+
description: Schema14.String,
|
|
1822
|
+
deliverable: Schema14.NullOr(p4.TokenId),
|
|
1823
|
+
status: Schema14.String
|
|
1824
|
+
});
|
|
1825
|
+
var makeEscrowJobWithCerts = (p4) => Schema14.Struct({
|
|
1826
|
+
job: makeEscrowJobRecord(p4),
|
|
1827
|
+
certificates: Schema14.Array(makeTransactionCertificate(p4))
|
|
1828
|
+
});
|
|
1829
|
+
var makeSubmitTransactionParams = (p4) => makeTransactionEnvelope(p4);
|
|
1830
|
+
var makeFaucetDripParams = (p4) => CamelCaseStruct({
|
|
1831
|
+
recipient: p4.Address,
|
|
1832
|
+
amount: p4.Amount,
|
|
1833
|
+
token_id: Schema15.NullOr(p4.TokenId)
|
|
1834
|
+
});
|
|
1835
|
+
var makeGetAccountInfoParams = (p4) => CamelCaseStruct({
|
|
1836
|
+
address: p4.Address,
|
|
1837
|
+
token_balances_filter: Schema15.NullOr(Schema15.Array(p4.TokenId)),
|
|
1838
|
+
state_key_filter: Schema15.NullOr(Schema15.Array(p4.StateKey)),
|
|
1839
|
+
certificate_by_nonce: Schema15.NullOr(Schema15.Struct({ start: p4.Nonce, limit: Schema15.Number }))
|
|
1840
|
+
});
|
|
1841
|
+
var makeGetPendingMultisigParams = (p4) => Schema15.Struct({ address: p4.Address });
|
|
1842
|
+
var makeGetTokenInfoParams = (p4) => CamelCaseStruct({ token_ids: Schema15.Array(p4.TokenId) });
|
|
1843
|
+
var makeGetTransactionCertificatesParams = (p4) => CamelCaseStruct({
|
|
1844
|
+
address: p4.Address,
|
|
1845
|
+
from_nonce: p4.Nonce,
|
|
1846
|
+
limit: Schema15.Number
|
|
1847
|
+
});
|
|
1848
|
+
var FaucetDripInput = Schema15.Struct({
|
|
1849
|
+
recipient: AddressFromInput,
|
|
1850
|
+
amount: AmountFromInput,
|
|
1851
|
+
tokenId: Schema15.NullOr(TokenIdFromInput)
|
|
1852
|
+
});
|
|
1853
|
+
var GetAccountInfoInput = Schema15.Struct({
|
|
1854
|
+
address: AddressFromInput,
|
|
1855
|
+
tokenBalancesFilter: Schema15.optionalWith(Schema15.NullOr(Schema15.Array(TokenIdFromInput)), { default: () => null }),
|
|
1856
|
+
stateKeyFilter: Schema15.optionalWith(Schema15.NullOr(Schema15.Array(StateKeyFromInput)), { default: () => null }),
|
|
1857
|
+
certificateByNonce: Schema15.optionalWith(
|
|
1858
|
+
Schema15.NullOr(
|
|
1859
|
+
Schema15.Struct({
|
|
1860
|
+
start: NonceFromInput,
|
|
1861
|
+
limit: Schema15.Number
|
|
1862
|
+
})
|
|
1863
|
+
),
|
|
1864
|
+
{ default: () => null }
|
|
1865
|
+
)
|
|
1866
|
+
});
|
|
1867
|
+
var GetPendingMultisigInput = Schema15.Struct({
|
|
1868
|
+
address: AddressFromInput
|
|
1869
|
+
});
|
|
1870
|
+
var GetTokenInfoInput = Schema15.Struct({
|
|
1871
|
+
tokenIds: Schema15.Array(TokenIdFromInput)
|
|
1872
|
+
});
|
|
1873
|
+
var GetTransactionCertificatesInput = Schema15.Struct({
|
|
1874
|
+
address: AddressFromInput,
|
|
1875
|
+
fromNonce: NonceFromInput,
|
|
1876
|
+
limit: Schema15.Number
|
|
1877
|
+
});
|
|
1878
|
+
var GetEscrowJobInput = Schema15.Struct({
|
|
1879
|
+
jobId: TokenIdFromInput,
|
|
1880
|
+
certs: Schema15.optionalWith(Schema15.Boolean, { default: () => false })
|
|
1881
|
+
});
|
|
1882
|
+
var GetEscrowJobsInput = Schema15.Struct({
|
|
1883
|
+
client: Schema15.optional(AddressFromInput),
|
|
1884
|
+
provider: Schema15.optional(AddressFromInput),
|
|
1885
|
+
evaluator: Schema15.optional(AddressFromInput),
|
|
1886
|
+
status: Schema15.optional(Schema15.String),
|
|
1887
|
+
certs: Schema15.optionalWith(Schema15.Boolean, { default: () => false })
|
|
1888
|
+
});
|
|
1889
|
+
var PrivateKeyFromInput = Schema16.Union(Uint8Array32, Uint8Array32FromHex0x, Uint8Array32FromNumberArray).pipe(Schema16.brand("PrivateKey"));
|
|
1890
|
+
var TokenTransferInput = Schema17.Struct({
|
|
1891
|
+
tokenId: TokenIdFromInput,
|
|
1892
|
+
recipient: AddressFromInput,
|
|
1893
|
+
amount: AmountFromInput,
|
|
1894
|
+
userData: UserDataFromInput
|
|
1895
|
+
});
|
|
1896
|
+
var TokenCreationInput = Schema17.Struct({
|
|
1897
|
+
tokenName: Schema17.String,
|
|
1898
|
+
decimals: Schema17.Number,
|
|
1899
|
+
initialAmount: AmountFromInput,
|
|
1900
|
+
mints: Schema17.Array(AddressFromInput),
|
|
1901
|
+
userData: UserDataFromInput
|
|
1902
|
+
});
|
|
1903
|
+
var TokenManagementInput = Schema17.Struct({
|
|
1904
|
+
tokenId: TokenIdFromInput,
|
|
1905
|
+
updateId: NonceFromInput,
|
|
1906
|
+
newAdmin: Schema17.NullOr(AddressFromInput),
|
|
1907
|
+
mints: Schema17.Array(
|
|
1908
|
+
Schema17.Tuple(Schema17.Union(Schema17.Struct({ type: Schema17.Literal("Add") }), Schema17.Struct({ type: Schema17.Literal("Remove") })), AddressFromInput)
|
|
1909
|
+
),
|
|
1910
|
+
userData: UserDataFromInput
|
|
1911
|
+
});
|
|
1912
|
+
var MintInput = Schema17.Struct({
|
|
1913
|
+
tokenId: TokenIdFromInput,
|
|
1914
|
+
recipient: AddressFromInput,
|
|
1915
|
+
amount: AmountFromInput
|
|
1916
|
+
});
|
|
1917
|
+
var BurnInput = Schema17.Struct({
|
|
1918
|
+
tokenId: TokenIdFromInput,
|
|
1919
|
+
amount: AmountFromInput
|
|
1920
|
+
});
|
|
1921
|
+
var StateInitializationInput = Schema17.Struct({
|
|
1922
|
+
key: StateKeyFromInput,
|
|
1923
|
+
initialState: StateFromInput
|
|
1924
|
+
});
|
|
1925
|
+
var StateUpdateInput = Schema17.Struct({
|
|
1926
|
+
key: StateKeyFromInput,
|
|
1927
|
+
previousState: StateFromInput,
|
|
1928
|
+
nextState: StateFromInput,
|
|
1929
|
+
computeClaimTxHash: StateKeyFromInput,
|
|
1930
|
+
computeClaimTxTimestamp: BigIntFromNumberOrStringOrSelf
|
|
1931
|
+
});
|
|
1932
|
+
var StateResetInput = Schema17.Struct({
|
|
1933
|
+
key: StateKeyFromInput,
|
|
1934
|
+
resetState: StateFromInput
|
|
1935
|
+
});
|
|
1936
|
+
var ExternalClaimInput = Schema17.Struct({
|
|
1937
|
+
claim: Schema17.Struct({
|
|
1938
|
+
verifierCommittee: Schema17.Array(AddressFromInput),
|
|
1939
|
+
verifierQuorum: QuorumFromInput,
|
|
1940
|
+
claimData: ClaimDataFromInput
|
|
1941
|
+
}),
|
|
1942
|
+
signatures: Schema17.Array(
|
|
1943
|
+
Schema17.Struct({
|
|
1944
|
+
verifierAddr: AddressFromInput,
|
|
1945
|
+
sig: SignatureFromInput
|
|
1946
|
+
})
|
|
1947
|
+
)
|
|
1948
|
+
});
|
|
1949
|
+
var ValidatorConfigInput = Schema17.Struct({
|
|
1950
|
+
address: AddressFromInput,
|
|
1951
|
+
host: Schema17.String,
|
|
1952
|
+
rpcPort: Schema17.Number
|
|
1953
|
+
});
|
|
1954
|
+
var CommitteeChangeInput = Schema17.Struct({
|
|
1955
|
+
newCommittee: Schema17.Struct({
|
|
1956
|
+
validators: Schema17.Array(ValidatorConfigInput)
|
|
1957
|
+
}),
|
|
1958
|
+
epoch: Schema17.Number
|
|
1959
|
+
});
|
|
1960
|
+
var FixedAmountOrBpsInput = Schema17.Union(
|
|
1961
|
+
Schema17.Struct({ type: Schema17.Literal("Fixed"), value: AmountFromInput }),
|
|
1962
|
+
Schema17.Struct({ type: Schema17.Literal("Bps"), value: Schema17.Number })
|
|
1963
|
+
);
|
|
1964
|
+
var EscrowCreateConfigInput = Schema17.Struct({
|
|
1965
|
+
tokenId: TokenIdFromInput,
|
|
1966
|
+
evaluator: AddressFromInput,
|
|
1967
|
+
evaluationFee: FixedAmountOrBpsInput,
|
|
1968
|
+
minEvaluatorFee: AmountFromInput
|
|
1969
|
+
});
|
|
1970
|
+
var EscrowCreateJobInput = Schema17.Struct({
|
|
1971
|
+
configId: TokenIdFromInput,
|
|
1972
|
+
provider: AddressFromInput,
|
|
1973
|
+
providerFee: AmountFromInput,
|
|
1974
|
+
description: Schema17.String
|
|
1975
|
+
});
|
|
1976
|
+
var EscrowSubmitInput = Schema17.Struct({
|
|
1977
|
+
jobId: TokenIdFromInput,
|
|
1978
|
+
deliverable: TokenIdFromInput
|
|
1979
|
+
});
|
|
1980
|
+
var EscrowRejectInput = Schema17.Struct({
|
|
1981
|
+
jobId: TokenIdFromInput
|
|
1982
|
+
});
|
|
1983
|
+
var EscrowCompleteInput = Schema17.Struct({
|
|
1984
|
+
jobId: TokenIdFromInput
|
|
1985
|
+
});
|
|
1986
|
+
var EscrowInput = Schema17.Union(
|
|
1987
|
+
Schema17.Struct({ type: Schema17.Literal("CreateConfig"), value: EscrowCreateConfigInput }),
|
|
1988
|
+
Schema17.Struct({ type: Schema17.Literal("CreateJob"), value: EscrowCreateJobInput }),
|
|
1989
|
+
Schema17.Struct({ type: Schema17.Literal("Submit"), value: EscrowSubmitInput }),
|
|
1990
|
+
Schema17.Struct({ type: Schema17.Literal("Reject"), value: EscrowRejectInput }),
|
|
1991
|
+
Schema17.Struct({ type: Schema17.Literal("Complete"), value: EscrowCompleteInput })
|
|
1992
|
+
);
|
|
1993
|
+
var OperationInput = Schema17.Union(
|
|
1994
|
+
Schema17.Struct({
|
|
1995
|
+
type: Schema17.Literal("TokenTransfer"),
|
|
1996
|
+
value: TokenTransferInput
|
|
1997
|
+
}),
|
|
1998
|
+
Schema17.Struct({
|
|
1999
|
+
type: Schema17.Literal("TokenCreation"),
|
|
2000
|
+
value: TokenCreationInput
|
|
2001
|
+
}),
|
|
2002
|
+
Schema17.Struct({
|
|
2003
|
+
type: Schema17.Literal("TokenManagement"),
|
|
2004
|
+
value: TokenManagementInput
|
|
2005
|
+
}),
|
|
2006
|
+
Schema17.Struct({ type: Schema17.Literal("Mint"), value: MintInput }),
|
|
2007
|
+
Schema17.Struct({ type: Schema17.Literal("Burn"), value: BurnInput }),
|
|
2008
|
+
Schema17.Struct({
|
|
2009
|
+
type: Schema17.Literal("StateInitialization"),
|
|
2010
|
+
value: StateInitializationInput
|
|
2011
|
+
}),
|
|
2012
|
+
Schema17.Struct({
|
|
2013
|
+
type: Schema17.Literal("StateUpdate"),
|
|
2014
|
+
value: StateUpdateInput
|
|
2015
|
+
}),
|
|
2016
|
+
Schema17.Struct({ type: Schema17.Literal("StateReset"), value: StateResetInput }),
|
|
2017
|
+
Schema17.Struct({
|
|
2018
|
+
type: Schema17.Literal("ExternalClaim"),
|
|
2019
|
+
value: ExternalClaimInput
|
|
2020
|
+
}),
|
|
2021
|
+
Schema17.Struct({
|
|
2022
|
+
type: Schema17.Literal("JoinCommittee"),
|
|
2023
|
+
value: ValidatorConfigInput
|
|
2024
|
+
}),
|
|
2025
|
+
Schema17.Struct({ type: Schema17.Literal("LeaveCommittee") }),
|
|
2026
|
+
Schema17.Struct({
|
|
2027
|
+
type: Schema17.Literal("ChangeCommittee"),
|
|
2028
|
+
value: CommitteeChangeInput
|
|
2029
|
+
}),
|
|
2030
|
+
Schema17.Struct({
|
|
2031
|
+
type: Schema17.Literal("Escrow"),
|
|
2032
|
+
value: EscrowInput
|
|
2033
|
+
})
|
|
2034
|
+
);
|
|
2035
|
+
var ClaimTypeInput = Schema17.Union(
|
|
2036
|
+
...OperationInput.members,
|
|
2037
|
+
Schema17.Struct({
|
|
2038
|
+
type: Schema17.Literal("Batch"),
|
|
2039
|
+
value: Schema17.Array(OperationInput)
|
|
2040
|
+
})
|
|
2041
|
+
);
|
|
2042
|
+
var TransactionRelease20260319Input = Schema17.Struct({
|
|
2043
|
+
networkId: NetworkIdFromInput,
|
|
2044
|
+
sender: AddressFromInput,
|
|
2045
|
+
nonce: NonceFromInput,
|
|
2046
|
+
timestampNanos: BigIntFromNumberOrStringOrSelf,
|
|
2047
|
+
claim: ClaimTypeInput,
|
|
2048
|
+
archival: Schema17.Boolean,
|
|
2049
|
+
feeToken: Schema17.NullOr(TokenIdFromInput)
|
|
2050
|
+
});
|
|
2051
|
+
var TransactionRelease20260407Input = Schema17.Struct({
|
|
2052
|
+
networkId: NetworkIdFromInput,
|
|
2053
|
+
sender: AddressFromInput,
|
|
2054
|
+
nonce: NonceFromInput,
|
|
2055
|
+
timestampNanos: BigIntFromNumberOrStringOrSelf,
|
|
2056
|
+
claims: Schema17.Array(OperationInput),
|
|
2057
|
+
archival: Schema17.Boolean,
|
|
2058
|
+
feeToken: Schema17.NullOr(TokenIdFromInput)
|
|
2059
|
+
});
|
|
2060
|
+
var TransactionVersionRegistry = {
|
|
2061
|
+
Release20260319: {
|
|
2062
|
+
wrapOperations(ops) {
|
|
2063
|
+
if (ops.length === 0) {
|
|
2064
|
+
throw new Error("Release20260319 transactions require at least one operation");
|
|
2065
|
+
}
|
|
2066
|
+
const claim = ops.length === 1 ? ops[0] : { type: "Batch", value: ops };
|
|
2067
|
+
return { claim };
|
|
2068
|
+
},
|
|
2069
|
+
extractOperations(decoded) {
|
|
2070
|
+
const claim = decoded.claim;
|
|
2071
|
+
if (claim == null) return [];
|
|
2072
|
+
if (typeof claim === "object" && !Array.isArray(claim)) {
|
|
2073
|
+
const rec = claim;
|
|
2074
|
+
if ("Batch" in rec && Array.isArray(rec.Batch)) {
|
|
2075
|
+
return rec.Batch;
|
|
2076
|
+
}
|
|
2077
|
+
if (rec.type === "Batch" && Array.isArray(rec.value)) {
|
|
2078
|
+
return rec.value;
|
|
2079
|
+
}
|
|
2080
|
+
return [claim];
|
|
2081
|
+
}
|
|
2082
|
+
return [];
|
|
2083
|
+
},
|
|
2084
|
+
inputSchema: TransactionRelease20260319Input
|
|
2085
|
+
},
|
|
2086
|
+
Release20260407: {
|
|
2087
|
+
wrapOperations(ops) {
|
|
2088
|
+
return { claims: ops };
|
|
2089
|
+
},
|
|
2090
|
+
extractOperations(decoded) {
|
|
2091
|
+
return Array.isArray(decoded.claims) ? decoded.claims : [];
|
|
2092
|
+
},
|
|
2093
|
+
inputSchema: TransactionRelease20260407Input
|
|
2094
|
+
}
|
|
2095
|
+
};
|
|
2096
|
+
function getTransactionVersionConfig(version) {
|
|
2097
|
+
if (!(version in TransactionVersionRegistry)) {
|
|
2098
|
+
throw new Error(`Unknown transaction version: ${version}`);
|
|
2099
|
+
}
|
|
2100
|
+
return TransactionVersionRegistry[version];
|
|
2101
|
+
}
|
|
2102
|
+
var RpcPalette = {
|
|
2103
|
+
Amount: AmountFromRpc,
|
|
2104
|
+
Balance: BalanceFromRpc,
|
|
2105
|
+
Nonce: NonceFromRpc,
|
|
2106
|
+
Quorum: QuorumFromRpc,
|
|
2107
|
+
NetworkId: NetworkIdFromRpc,
|
|
2108
|
+
Address: AddressFromRpc,
|
|
2109
|
+
Signature: SignatureFromRpc,
|
|
2110
|
+
TokenId: TokenIdFromRpc,
|
|
2111
|
+
StateKey: StateKeyFromRpc,
|
|
2112
|
+
State: StateFromRpc,
|
|
2113
|
+
ClaimData: ClaimDataFromRpc,
|
|
2114
|
+
UserData: UserDataFromRpc,
|
|
2115
|
+
BigInt: BigIntFromNumberOrStringOrSelf
|
|
2116
|
+
};
|
|
2117
|
+
var RestPalette = {
|
|
2118
|
+
Amount: AmountFromRest,
|
|
2119
|
+
Balance: BalanceFromRest,
|
|
2120
|
+
Nonce: NonceFromRest,
|
|
2121
|
+
Quorum: QuorumFromRest,
|
|
2122
|
+
NetworkId: NetworkIdFromRest,
|
|
2123
|
+
Address: AddressFromRest,
|
|
2124
|
+
Signature: SignatureFromRest,
|
|
2125
|
+
TokenId: TokenIdFromRest,
|
|
2126
|
+
StateKey: StateKeyFromRest,
|
|
2127
|
+
State: StateFromRest,
|
|
2128
|
+
ClaimData: ClaimDataFromRest,
|
|
2129
|
+
UserData: UserDataFromRest,
|
|
2130
|
+
BigInt: BigIntFromNumberOrStringOrSelf
|
|
2131
|
+
};
|
|
2132
|
+
var BcsPalette = {
|
|
2133
|
+
Amount: AmountFromBcs,
|
|
2134
|
+
Balance: BalanceFromBcs,
|
|
2135
|
+
Nonce: NonceFromBcs,
|
|
2136
|
+
Quorum: QuorumFromBcs,
|
|
2137
|
+
NetworkId: NetworkIdFromBcs,
|
|
2138
|
+
Address: AddressFromBcs,
|
|
2139
|
+
Signature: SignatureFromBcs,
|
|
2140
|
+
TokenId: TokenIdFromBcs,
|
|
2141
|
+
StateKey: StateKeyFromBcs,
|
|
2142
|
+
State: StateFromBcs,
|
|
2143
|
+
ClaimData: ClaimDataFromBcs,
|
|
2144
|
+
UserData: UserDataFromBcs,
|
|
2145
|
+
BigInt: BigIntFromNumberOrStringOrSelf
|
|
2146
|
+
};
|
|
2147
|
+
var p = BcsPalette;
|
|
2148
|
+
var TokenTransferFromBcs = makeTokenTransfer(p);
|
|
2149
|
+
var TokenCreationFromBcs = makeTokenCreation(p);
|
|
2150
|
+
var TokenManagementFromBcs = makeTokenManagement(p);
|
|
2151
|
+
var MintFromBcs = makeMint(p);
|
|
2152
|
+
var BurnFromBcs = makeBurn(p);
|
|
2153
|
+
var StateInitializationFromBcs = makeStateInitialization(p);
|
|
2154
|
+
var StateUpdateFromBcs = makeStateUpdate(p);
|
|
2155
|
+
var StateResetFromBcs = makeStateReset(p);
|
|
2156
|
+
var ExternalClaimBodyFromBcs = makeExternalClaimBody(p);
|
|
2157
|
+
var VerifierSigFromBcs = makeVerifierSig(p);
|
|
2158
|
+
var ExternalClaimFromBcs = makeExternalClaim(p);
|
|
2159
|
+
var ValidatorConfigFromBcs = makeValidatorConfig(p);
|
|
2160
|
+
var CommitteeConfigFromBcs = makeCommitteeConfig(p);
|
|
2161
|
+
var CommitteeChangeFromBcs = makeCommitteeChange(p);
|
|
2162
|
+
var bcsOpts = { unitEncoding: "bcs" };
|
|
2163
|
+
var FixedAmountOrBpsFromBcs = makeFixedAmountOrBps(p, bcsOpts);
|
|
2164
|
+
var EscrowCreateConfigFromBcs = makeEscrowCreateConfig(p, bcsOpts);
|
|
2165
|
+
var EscrowCreateJobFromBcs = makeEscrowCreateJob(p);
|
|
2166
|
+
var EscrowSubmitFromBcs = makeEscrowSubmit(p);
|
|
2167
|
+
var EscrowRejectFromBcs = makeEscrowReject(p);
|
|
2168
|
+
var EscrowCompleteFromBcs = makeEscrowComplete(p);
|
|
2169
|
+
var EscrowFromBcs = makeEscrow(p, bcsOpts);
|
|
2170
|
+
var OperationFromBcs = makeOperation(p, bcsOpts);
|
|
2171
|
+
var ClaimTypeFromBcs = makeClaimType(p, bcsOpts);
|
|
2172
|
+
var TransactionRelease20260319FromBcs = makeTransactionRelease20260319(
|
|
2173
|
+
p,
|
|
2174
|
+
bcsOpts
|
|
2175
|
+
);
|
|
2176
|
+
var TransactionRelease20260407FromBcs = makeTransactionRelease20260407(
|
|
2177
|
+
p,
|
|
2178
|
+
bcsOpts
|
|
2179
|
+
);
|
|
2180
|
+
var TransactionFromBcs = makeTransaction(p, bcsOpts);
|
|
2181
|
+
var VersionedTransactionFromBcs = makeVersionedTransaction(p, bcsOpts);
|
|
2182
|
+
var MultiSigConfigFromBcs = makeMultiSigConfig(p);
|
|
2183
|
+
var MultiSigFromBcs = makeMultiSig(p);
|
|
2184
|
+
var SignatureOrMultiSigFromBcs = makeSignatureOrMultiSig(p);
|
|
2185
|
+
var TransactionEnvelopeFromBcs = makeTransactionEnvelope(p);
|
|
2186
|
+
var ValidatedTransactionFromBcs = makeValidatedTransaction(p);
|
|
2187
|
+
var TransactionCertificateFromBcs = makeTransactionCertificate(p);
|
|
2188
|
+
var NonceRangeFromBcs = makeNonceRange(p);
|
|
2189
|
+
var PageRequestFromBcs = makePageRequest(p);
|
|
2190
|
+
var TokenMetadataFromBcs = makeTokenMetadata(p);
|
|
2191
|
+
var AccountInfoResponseFromBcs = makeAccountInfoResponse(p);
|
|
2192
|
+
var TokenInfoResponseFromBcs = makeTokenInfoResponse(p);
|
|
2193
|
+
var SubmitTransactionResponseFromBcs = makeSubmitTransactionResponse(p);
|
|
2194
|
+
var ConfirmTransactionResponseFromBcs = makeConfirmTransactionResponse(p);
|
|
2195
|
+
var ProxySubmitTransactionResultFromBcs = makeProxySubmitTransactionResult(p);
|
|
2196
|
+
var EscrowJobRecordFromBcs = makeEscrowJobRecord(p);
|
|
2197
|
+
var EscrowJobWithCertsFromBcs = makeEscrowJobWithCerts(p);
|
|
2198
|
+
var p2 = RestPalette;
|
|
2199
|
+
var TokenTransferFromRest = makeTokenTransfer(p2);
|
|
2200
|
+
var TokenCreationFromRest = makeTokenCreation(p2);
|
|
2201
|
+
var TokenManagementFromRest = makeTokenManagement(p2);
|
|
2202
|
+
var MintFromRest = makeMint(p2);
|
|
2203
|
+
var BurnFromRest = makeBurn(p2);
|
|
2204
|
+
var StateInitializationFromRest = makeStateInitialization(p2);
|
|
2205
|
+
var StateUpdateFromRest = makeStateUpdate(p2);
|
|
2206
|
+
var StateResetFromRest = makeStateReset(p2);
|
|
2207
|
+
var ExternalClaimBodyFromRest = makeExternalClaimBody(p2);
|
|
2208
|
+
var VerifierSigFromRest = makeVerifierSig(p2);
|
|
2209
|
+
var ExternalClaimFromRest = makeExternalClaim(p2);
|
|
2210
|
+
var ValidatorConfigFromRest = makeValidatorConfig(p2);
|
|
2211
|
+
var CommitteeConfigFromRest = makeCommitteeConfig(p2);
|
|
2212
|
+
var CommitteeChangeFromRest = makeCommitteeChange(p2);
|
|
2213
|
+
var FixedAmountOrBpsFromRest = makeFixedAmountOrBps(p2);
|
|
2214
|
+
var EscrowCreateConfigFromRest = makeEscrowCreateConfig(p2);
|
|
2215
|
+
var EscrowCreateJobFromRest = makeEscrowCreateJob(p2);
|
|
2216
|
+
var EscrowSubmitFromRest = makeEscrowSubmit(p2);
|
|
2217
|
+
var EscrowRejectFromRest = makeEscrowReject(p2);
|
|
2218
|
+
var EscrowCompleteFromRest = makeEscrowComplete(p2);
|
|
2219
|
+
var EscrowFromRest = makeEscrow(p2);
|
|
2220
|
+
var OperationFromRest = makeOperation(p2);
|
|
2221
|
+
var ClaimTypeFromRest = makeClaimType(p2);
|
|
2222
|
+
var TransactionRelease20260319FromRest = makeTransactionRelease20260319(p2);
|
|
2223
|
+
var TransactionRelease20260407FromRest = makeTransactionRelease20260407(p2);
|
|
2224
|
+
var TransactionFromRest = makeTransaction(p2);
|
|
2225
|
+
var VersionedTransactionFromRest = makeVersionedTransaction(p2);
|
|
2226
|
+
var MultiSigConfigFromRest = makeMultiSigConfig(p2);
|
|
2227
|
+
var MultiSigFromRest = makeMultiSig(p2);
|
|
2228
|
+
var SignatureOrMultiSigFromRest = makeSignatureOrMultiSig(p2);
|
|
2229
|
+
var TransactionEnvelopeFromRest = makeTransactionEnvelope(p2);
|
|
2230
|
+
var ValidatedTransactionFromRest = makeValidatedTransaction(p2);
|
|
2231
|
+
var TransactionCertificateFromRest = makeTransactionCertificate(p2);
|
|
2232
|
+
var NonceRangeFromRest = makeNonceRange(p2);
|
|
2233
|
+
var PageRequestFromRest = makePageRequest(p2);
|
|
2234
|
+
var TokenMetadataFromRest = makeTokenMetadata(p2);
|
|
2235
|
+
var AccountInfoResponseFromRest = makeAccountInfoResponse(p2);
|
|
2236
|
+
var TokenInfoResponseFromRest = makeTokenInfoResponse(p2);
|
|
2237
|
+
var SubmitTransactionResponseFromRest = makeSubmitTransactionResponse(p2);
|
|
2238
|
+
var ConfirmTransactionResponseFromRest = makeConfirmTransactionResponse(p2);
|
|
2239
|
+
var ProxySubmitTransactionResultFromRest = makeProxySubmitTransactionResult(p2);
|
|
2240
|
+
var EscrowJobRecordFromRest = makeEscrowJobRecord(p2);
|
|
2241
|
+
var EscrowJobWithCertsFromRest = makeEscrowJobWithCerts(p2);
|
|
2242
|
+
var p3 = RpcPalette;
|
|
2243
|
+
var TokenTransferFromRpc = makeTokenTransfer(p3);
|
|
2244
|
+
var TokenCreationFromRpc = makeTokenCreation(p3);
|
|
2245
|
+
var TokenManagementFromRpc = makeTokenManagement(p3);
|
|
2246
|
+
var MintFromRpc = makeMint(p3);
|
|
2247
|
+
var BurnFromRpc = makeBurn(p3);
|
|
2248
|
+
var StateInitializationFromRpc = makeStateInitialization(p3);
|
|
2249
|
+
var StateUpdateFromRpc = makeStateUpdate(p3);
|
|
2250
|
+
var StateResetFromRpc = makeStateReset(p3);
|
|
2251
|
+
var ExternalClaimBodyFromRpc = makeExternalClaimBody(p3);
|
|
2252
|
+
var VerifierSigFromRpc = makeVerifierSig(p3);
|
|
2253
|
+
var ExternalClaimFromRpc = makeExternalClaim(p3);
|
|
2254
|
+
var ValidatorConfigFromRpc = makeValidatorConfig(p3);
|
|
2255
|
+
var CommitteeConfigFromRpc = makeCommitteeConfig(p3);
|
|
2256
|
+
var CommitteeChangeFromRpc = makeCommitteeChange(p3);
|
|
2257
|
+
var FixedAmountOrBpsFromRpc = makeFixedAmountOrBps(p3);
|
|
2258
|
+
var EscrowCreateConfigFromRpc = makeEscrowCreateConfig(p3);
|
|
2259
|
+
var EscrowCreateJobFromRpc = makeEscrowCreateJob(p3);
|
|
2260
|
+
var EscrowSubmitFromRpc = makeEscrowSubmit(p3);
|
|
2261
|
+
var EscrowRejectFromRpc = makeEscrowReject(p3);
|
|
2262
|
+
var EscrowCompleteFromRpc = makeEscrowComplete(p3);
|
|
2263
|
+
var EscrowFromRpc = makeEscrow(p3);
|
|
2264
|
+
var OperationFromRpc = makeOperation(p3);
|
|
2265
|
+
var ClaimTypeFromRpc = makeClaimType(p3);
|
|
2266
|
+
var TransactionRelease20260319FromRpc = makeTransactionRelease20260319(p3);
|
|
2267
|
+
var TransactionRelease20260407FromRpc = makeTransactionRelease20260407(p3);
|
|
2268
|
+
var TransactionFromRpc = makeTransaction(p3);
|
|
2269
|
+
var VersionedTransactionFromRpc = makeVersionedTransaction(p3);
|
|
2270
|
+
var MultiSigConfigFromRpc = makeMultiSigConfig(p3);
|
|
2271
|
+
var MultiSigFromRpc = makeMultiSig(p3);
|
|
2272
|
+
var SignatureOrMultiSigFromRpc = makeSignatureOrMultiSig(p3);
|
|
2273
|
+
var TransactionEnvelopeFromRpc = makeTransactionEnvelope(p3);
|
|
2274
|
+
var ValidatedTransactionFromRpc = makeValidatedTransaction(p3);
|
|
2275
|
+
var TransactionCertificateFromRpc = makeTransactionCertificate(p3);
|
|
2276
|
+
var NonceRangeFromRpc = makeNonceRange(p3);
|
|
2277
|
+
var PageRequestFromRpc = makePageRequest(p3);
|
|
2278
|
+
var TokenMetadataFromRpc = makeTokenMetadata(p3);
|
|
2279
|
+
var AccountInfoResponseFromRpc = makeAccountInfoResponse(p3);
|
|
2280
|
+
var TokenInfoResponseFromRpc = makeTokenInfoResponse(p3);
|
|
2281
|
+
var SubmitTransactionResponseFromRpc = makeSubmitTransactionResponse(p3);
|
|
2282
|
+
var ConfirmTransactionResponseFromRpc = makeConfirmTransactionResponse(p3);
|
|
2283
|
+
var ProxySubmitTransactionResultFromRpc = makeProxySubmitTransactionResult(p3);
|
|
2284
|
+
var EscrowJobRecordFromRpc = makeEscrowJobRecord(p3);
|
|
2285
|
+
var EscrowJobWithCertsFromRpc = makeEscrowJobWithCerts(p3);
|
|
2286
|
+
var SubmitTransactionParamsFromRpc = makeSubmitTransactionParams(p3);
|
|
2287
|
+
var FaucetDripParamsFromRpc = makeFaucetDripParams(p3);
|
|
2288
|
+
var GetAccountInfoParamsFromRpc = makeGetAccountInfoParams(p3);
|
|
2289
|
+
var GetPendingMultisigParamsFromRpc = makeGetPendingMultisigParams(p3);
|
|
2290
|
+
var GetTokenInfoParamsFromRpc = makeGetTokenInfoParams(p3);
|
|
2291
|
+
var GetTransactionCertificatesParamsFromRpc = makeGetTransactionCertificatesParams(p3);
|
|
2292
|
+
|
|
2293
|
+
// src/schemas/networks.ts
|
|
2294
|
+
var AllSetChainTokenSchema = Schema19.Struct({
|
|
2295
|
+
evmAddress: Schema19.String,
|
|
2296
|
+
fastTokenId: Schema19.String,
|
|
2297
|
+
decimals: Schema19.Number
|
|
2298
|
+
});
|
|
2299
|
+
var AllSetChainSchema = Schema19.Struct({
|
|
2300
|
+
chainId: Schema19.Number,
|
|
2301
|
+
bridgeContract: Schema19.String,
|
|
2302
|
+
fastBridgeAddress: Schema19.String,
|
|
2303
|
+
relayerUrl: Schema19.String,
|
|
2304
|
+
evmRpcUrl: Schema19.String,
|
|
2305
|
+
evmExplorerUrl: Schema19.String,
|
|
2306
|
+
tokens: Schema19.Record({ key: Schema19.String, value: AllSetChainTokenSchema })
|
|
2307
|
+
});
|
|
2308
|
+
var AllSetConfigSchema = Schema19.Struct({
|
|
2309
|
+
crossSignUrl: Schema19.String,
|
|
2310
|
+
portalApiUrl: Schema19.String,
|
|
2311
|
+
chains: Schema19.Record({ key: Schema19.String, value: AllSetChainSchema })
|
|
2312
|
+
});
|
|
2313
|
+
var NetworkConfigSchema = Schema19.Struct({
|
|
2314
|
+
url: Schema19.String,
|
|
2315
|
+
explorerUrl: Schema19.String,
|
|
2316
|
+
networkId: NetworkId,
|
|
2317
|
+
allSet: Schema19.optional(AllSetConfigSchema)
|
|
2318
|
+
});
|
|
2319
|
+
var BundledNetworksSchema = Schema19.Record({
|
|
2320
|
+
key: Schema19.String,
|
|
2321
|
+
value: NetworkConfigSchema
|
|
2322
|
+
});
|
|
2323
|
+
|
|
2324
|
+
// src/services/storage/network.ts
|
|
2325
|
+
var getDefaultNetwork = (db) => db.select().from(metadata).where(eq(metadata.key, "default_network")).get();
|
|
2326
|
+
var listCustomNetworks = (db) => db.select({ name: customNetworks.name }).from(customNetworks).all();
|
|
2327
|
+
var getCustomNetwork = (db, name) => db.select().from(customNetworks).where(eq(customNetworks.name, name)).get();
|
|
2328
|
+
var setDefaultNetwork = (db, name) => db.insert(metadata).values({ key: "default_network", value: name }).onConflictDoUpdate({ target: metadata.key, set: { value: name } }).run();
|
|
2329
|
+
var deleteCustomNetwork = (db, name) => db.delete(customNetworks).where(eq(customNetworks.name, name)).run();
|
|
2330
|
+
var getDefault = (handle) => Effect.flatMap(
|
|
2331
|
+
handle.query(
|
|
2332
|
+
(db) => getDefaultNetwork(db),
|
|
2333
|
+
"Failed to get default network"
|
|
2334
|
+
),
|
|
2335
|
+
(row) => row?.value !== void 0 ? Effect.succeed(row.value) : Effect.fail(new NoDefaultNetworkError())
|
|
2336
|
+
);
|
|
2337
|
+
var resolve = (context, name) => Effect.gen(function* () {
|
|
2338
|
+
const bundled = context.config.getBundledNetwork(name);
|
|
2339
|
+
if (bundled) return bundled;
|
|
2340
|
+
const row = yield* context.handle.query(
|
|
2341
|
+
(db) => getCustomNetwork(db, name),
|
|
2342
|
+
"Failed to get network config"
|
|
2343
|
+
);
|
|
2344
|
+
if (!row) {
|
|
2345
|
+
return yield* Effect.fail(new NetworkNotFoundError({ name }));
|
|
2346
|
+
}
|
|
2347
|
+
const json = JSON.parse(row.config);
|
|
2348
|
+
return yield* Schema20.decodeUnknown(NetworkConfigSchema)(json).pipe(
|
|
2349
|
+
Effect.mapError(() => new InvalidNetworkConfigError({ name }))
|
|
2350
|
+
);
|
|
2351
|
+
});
|
|
2352
|
+
var list = (context) => Effect.gen(function* () {
|
|
2353
|
+
const defaultName = yield* getDefault(context.handle);
|
|
2354
|
+
const customRows = yield* context.handle.query(
|
|
2355
|
+
(db) => listCustomNetworks(db),
|
|
2356
|
+
"Failed to list networks"
|
|
2357
|
+
);
|
|
2358
|
+
const names = [
|
|
2359
|
+
...Object.keys(context.config.bundledNetworks),
|
|
2360
|
+
...customRows.map((r) => r.name)
|
|
2361
|
+
];
|
|
2362
|
+
return names.map((name) => {
|
|
2363
|
+
const type = context.config.isBundledNetwork(name) ? "bundled" : "custom";
|
|
2364
|
+
const isDefault = name === defaultName;
|
|
2365
|
+
return { name, type, isDefault };
|
|
2366
|
+
});
|
|
2367
|
+
});
|
|
2368
|
+
var setDefault = (context, name) => Effect.gen(function* () {
|
|
2369
|
+
if (!context.config.isBundledNetwork(name)) {
|
|
2370
|
+
const row = yield* context.handle.query(
|
|
2371
|
+
(db) => getCustomNetwork(db, name),
|
|
2372
|
+
"Failed to get network config"
|
|
2373
|
+
);
|
|
2374
|
+
if (!row) return yield* Effect.fail(new NetworkNotFoundError({ name }));
|
|
2375
|
+
}
|
|
2376
|
+
yield* context.handle.query(
|
|
2377
|
+
(db) => setDefaultNetwork(db, name),
|
|
2378
|
+
"Failed to set default network"
|
|
2379
|
+
);
|
|
2380
|
+
});
|
|
2381
|
+
var add = (context, name, configPath) => Effect.gen(function* () {
|
|
2382
|
+
if (context.config.isBundledNetwork(name)) {
|
|
2383
|
+
return yield* Effect.fail(new ReservedNameError({ name }));
|
|
2384
|
+
}
|
|
2385
|
+
const existing = yield* context.handle.query(
|
|
2386
|
+
(db) => getCustomNetwork(db, name),
|
|
2387
|
+
"Failed to check existing networks"
|
|
2388
|
+
);
|
|
2389
|
+
if (existing) {
|
|
2390
|
+
return yield* Effect.fail(new NetworkExistsError({ name }));
|
|
2391
|
+
}
|
|
2392
|
+
const raw = yield* Effect.try({
|
|
2393
|
+
try: () => readFileSync(configPath, "utf-8"),
|
|
2394
|
+
catch: (cause) => new FileIOError({
|
|
2395
|
+
message: `Failed to read network config file at "${configPath}"`,
|
|
2396
|
+
cause
|
|
2397
|
+
})
|
|
2398
|
+
});
|
|
2399
|
+
yield* Schema20.decodeUnknown(NetworkConfigSchema)(JSON.parse(raw)).pipe(
|
|
2400
|
+
Effect.mapError(() => new InvalidNetworkConfigError({ name }))
|
|
2401
|
+
);
|
|
2402
|
+
yield* context.handle.query(
|
|
2403
|
+
(db) => db.insert(customNetworks).values({ name, config: raw }).run(),
|
|
2404
|
+
"Failed to save network config"
|
|
2405
|
+
);
|
|
2406
|
+
});
|
|
2407
|
+
var remove = (context, name) => Effect.gen(function* () {
|
|
2408
|
+
if (context.config.isBundledNetwork(name)) {
|
|
2409
|
+
return yield* Effect.fail(new ReservedNameError({ name }));
|
|
2410
|
+
}
|
|
2411
|
+
const row = yield* context.handle.query(
|
|
2412
|
+
(db) => getCustomNetwork(db, name),
|
|
2413
|
+
"Failed to check network exists"
|
|
2414
|
+
);
|
|
2415
|
+
if (!row) {
|
|
2416
|
+
return yield* Effect.fail(new NetworkNotFoundError({ name }));
|
|
2417
|
+
}
|
|
2418
|
+
const defaultName = yield* getDefault(context.handle);
|
|
2419
|
+
if (defaultName === name) {
|
|
2420
|
+
return yield* Effect.fail(new DefaultNetworkError({ name }));
|
|
2421
|
+
}
|
|
2422
|
+
yield* context.handle.query(
|
|
2423
|
+
(db) => deleteCustomNetwork(db, name),
|
|
2424
|
+
"Failed to remove network"
|
|
2425
|
+
);
|
|
2426
|
+
});
|
|
2427
|
+
var ServiceEffect = Effect.gen(function* () {
|
|
2428
|
+
const handle = yield* DatabaseService;
|
|
2429
|
+
const config = yield* AppConfig;
|
|
2430
|
+
const context = { handle, config };
|
|
2431
|
+
return {
|
|
2432
|
+
resolve: (name) => resolve(context, name),
|
|
2433
|
+
list: () => list(context),
|
|
2434
|
+
setDefault: (name) => setDefault(context, name),
|
|
2435
|
+
add: (name, configPath) => add(context, name, configPath),
|
|
2436
|
+
remove: (name) => remove(context, name),
|
|
2437
|
+
getDefault: () => getDefault(context.handle)
|
|
2438
|
+
};
|
|
2439
|
+
});
|
|
2440
|
+
var NetworkConfigService = class extends Effect.Service()(
|
|
2441
|
+
"NetworkConfigService",
|
|
2442
|
+
{ effect: ServiceEffect }
|
|
2443
|
+
) {
|
|
2444
|
+
};
|
|
2445
|
+
|
|
2446
|
+
export {
|
|
2447
|
+
LatestTransactionVersion,
|
|
2448
|
+
SignatureFromInput,
|
|
2449
|
+
AddressFromRest,
|
|
2450
|
+
TokenIdFromRest,
|
|
2451
|
+
bcs_layout_exports,
|
|
2452
|
+
GetAccountInfoInput,
|
|
2453
|
+
GetPendingMultisigInput,
|
|
2454
|
+
GetTokenInfoInput,
|
|
2455
|
+
GetTransactionCertificatesInput,
|
|
2456
|
+
GetEscrowJobInput,
|
|
2457
|
+
GetEscrowJobsInput,
|
|
2458
|
+
PrivateKeyFromInput,
|
|
2459
|
+
getTransactionVersionConfig,
|
|
2460
|
+
VersionedTransactionFromBcs,
|
|
2461
|
+
SignatureOrMultiSigFromBcs,
|
|
2462
|
+
TransactionEnvelopeFromRest,
|
|
2463
|
+
TransactionCertificateFromRest,
|
|
2464
|
+
AccountInfoResponseFromRest,
|
|
2465
|
+
TokenInfoResponseFromRest,
|
|
2466
|
+
ProxySubmitTransactionResultFromRest,
|
|
2467
|
+
EscrowJobRecordFromRest,
|
|
2468
|
+
EscrowJobWithCertsFromRest,
|
|
2469
|
+
TransactionCertificateFromRpc,
|
|
2470
|
+
NetworkConfigService
|
|
2471
|
+
};
|
|
2472
|
+
/*! Bundled license information:
|
|
2473
|
+
|
|
2474
|
+
@scure/base/index.js:
|
|
2475
|
+
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2476
|
+
*/
|