@fleet-sdk/blockchain-providers 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +516 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +516 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
@@ -35,8 +35,8 @@ type Includes<Value extends readonly any[], Item> =
|
|
35
35
|
@category Utilities
|
36
36
|
*/
|
37
37
|
type IsEqual<A, B> =
|
38
|
-
(<G>() => G extends A ? 1 : 2) extends
|
39
|
-
(<G>() => G extends B ? 1 : 2)
|
38
|
+
(<G>() => G extends A & G | G ? 1 : 2) extends
|
39
|
+
(<G>() => G extends B & G | G ? 1 : 2)
|
40
40
|
? true
|
41
41
|
: false;
|
42
42
|
|
@@ -109,6 +109,26 @@ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
109
109
|
|
110
110
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
111
111
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
112
|
+
|
113
|
+
// The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
|
114
|
+
|
115
|
+
// Consider the following example:
|
116
|
+
|
117
|
+
type UserData = {
|
118
|
+
[metadata: string]: string;
|
119
|
+
email: string;
|
120
|
+
name: string;
|
121
|
+
role: 'admin' | 'user';
|
122
|
+
};
|
123
|
+
|
124
|
+
// `Omit` clearly doesn't behave as expected in this case:
|
125
|
+
type PostPayload = Omit<UserData, 'email'>;
|
126
|
+
//=> type PostPayload = { [x: string]: string; [x: number]: string; }
|
127
|
+
|
128
|
+
// In situations like this, `Except` works better.
|
129
|
+
// It simply removes the `email` key while preserving all the other keys.
|
130
|
+
type PostPayload = Except<UserData, 'email'>;
|
131
|
+
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
112
132
|
```
|
113
133
|
|
114
134
|
@category Object
|
package/dist/index.d.ts
CHANGED
@@ -35,8 +35,8 @@ type Includes<Value extends readonly any[], Item> =
|
|
35
35
|
@category Utilities
|
36
36
|
*/
|
37
37
|
type IsEqual<A, B> =
|
38
|
-
(<G>() => G extends A ? 1 : 2) extends
|
39
|
-
(<G>() => G extends B ? 1 : 2)
|
38
|
+
(<G>() => G extends A & G | G ? 1 : 2) extends
|
39
|
+
(<G>() => G extends B & G | G ? 1 : 2)
|
40
40
|
? true
|
41
41
|
: false;
|
42
42
|
|
@@ -109,6 +109,26 @@ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
109
109
|
|
110
110
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
111
111
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
112
|
+
|
113
|
+
// The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
|
114
|
+
|
115
|
+
// Consider the following example:
|
116
|
+
|
117
|
+
type UserData = {
|
118
|
+
[metadata: string]: string;
|
119
|
+
email: string;
|
120
|
+
name: string;
|
121
|
+
role: 'admin' | 'user';
|
122
|
+
};
|
123
|
+
|
124
|
+
// `Omit` clearly doesn't behave as expected in this case:
|
125
|
+
type PostPayload = Omit<UserData, 'email'>;
|
126
|
+
//=> type PostPayload = { [x: string]: string; [x: number]: string; }
|
127
|
+
|
128
|
+
// In situations like this, `Except` works better.
|
129
|
+
// It simply removes the `email` key while preserving all the other keys.
|
130
|
+
type PostPayload = Except<UserData, 'email'>;
|
131
|
+
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
112
132
|
```
|
113
133
|
|
114
134
|
@category Object
|
package/dist/index.js
CHANGED
@@ -4,7 +4,504 @@ var common = require('@fleet-sdk/common');
|
|
4
4
|
var core = require('@fleet-sdk/core');
|
5
5
|
|
6
6
|
// src/ergo-graphql/ergoGraphQLProvider.ts
|
7
|
-
|
7
|
+
|
8
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/_assert.js
|
9
|
+
function isBytes(a) {
|
10
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
11
|
+
}
|
12
|
+
function abytes(b, ...lengths) {
|
13
|
+
if (!isBytes(b))
|
14
|
+
throw new Error("Uint8Array expected");
|
15
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
16
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
17
|
+
}
|
18
|
+
function aexists(instance, checkFinished = true) {
|
19
|
+
if (instance.destroyed)
|
20
|
+
throw new Error("Hash instance has been destroyed");
|
21
|
+
if (checkFinished && instance.finished)
|
22
|
+
throw new Error("Hash#digest() has already been called");
|
23
|
+
}
|
24
|
+
function aoutput(out, instance) {
|
25
|
+
abytes(out);
|
26
|
+
const min = instance.outputLen;
|
27
|
+
if (out.length < min) {
|
28
|
+
throw new Error("digestInto() expects output buffer of length at least " + min);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/utils.js
|
33
|
+
function createView(arr) {
|
34
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
35
|
+
}
|
36
|
+
function rotr(word, shift) {
|
37
|
+
return word << 32 - shift | word >>> shift;
|
38
|
+
}
|
39
|
+
function utf8ToBytes(str) {
|
40
|
+
if (typeof str !== "string")
|
41
|
+
throw new Error("utf8ToBytes expected string, got " + typeof str);
|
42
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
43
|
+
}
|
44
|
+
function toBytes(data) {
|
45
|
+
if (typeof data === "string")
|
46
|
+
data = utf8ToBytes(data);
|
47
|
+
abytes(data);
|
48
|
+
return data;
|
49
|
+
}
|
50
|
+
var Hash = class {
|
51
|
+
// Safe version that clones internal state
|
52
|
+
clone() {
|
53
|
+
return this._cloneInto();
|
54
|
+
}
|
55
|
+
};
|
56
|
+
function wrapConstructor(hashCons) {
|
57
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
58
|
+
const tmp = hashCons();
|
59
|
+
hashC.outputLen = tmp.outputLen;
|
60
|
+
hashC.blockLen = tmp.blockLen;
|
61
|
+
hashC.create = () => hashCons();
|
62
|
+
return hashC;
|
63
|
+
}
|
64
|
+
|
65
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/_md.js
|
66
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
67
|
+
if (typeof view.setBigUint64 === "function")
|
68
|
+
return view.setBigUint64(byteOffset, value, isLE);
|
69
|
+
const _32n = BigInt(32);
|
70
|
+
const _u32_max = BigInt(4294967295);
|
71
|
+
const wh = Number(value >> _32n & _u32_max);
|
72
|
+
const wl = Number(value & _u32_max);
|
73
|
+
const h = isLE ? 4 : 0;
|
74
|
+
const l = isLE ? 0 : 4;
|
75
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
76
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
77
|
+
}
|
78
|
+
function Chi(a, b, c) {
|
79
|
+
return a & b ^ ~a & c;
|
80
|
+
}
|
81
|
+
function Maj(a, b, c) {
|
82
|
+
return a & b ^ a & c ^ b & c;
|
83
|
+
}
|
84
|
+
var HashMD = class extends Hash {
|
85
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
86
|
+
super();
|
87
|
+
this.blockLen = blockLen;
|
88
|
+
this.outputLen = outputLen;
|
89
|
+
this.padOffset = padOffset;
|
90
|
+
this.isLE = isLE;
|
91
|
+
this.finished = false;
|
92
|
+
this.length = 0;
|
93
|
+
this.pos = 0;
|
94
|
+
this.destroyed = false;
|
95
|
+
this.buffer = new Uint8Array(blockLen);
|
96
|
+
this.view = createView(this.buffer);
|
97
|
+
}
|
98
|
+
update(data) {
|
99
|
+
aexists(this);
|
100
|
+
const { view, buffer, blockLen } = this;
|
101
|
+
data = toBytes(data);
|
102
|
+
const len = data.length;
|
103
|
+
for (let pos = 0; pos < len; ) {
|
104
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
105
|
+
if (take === blockLen) {
|
106
|
+
const dataView = createView(data);
|
107
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
108
|
+
this.process(dataView, pos);
|
109
|
+
continue;
|
110
|
+
}
|
111
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
112
|
+
this.pos += take;
|
113
|
+
pos += take;
|
114
|
+
if (this.pos === blockLen) {
|
115
|
+
this.process(view, 0);
|
116
|
+
this.pos = 0;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
this.length += data.length;
|
120
|
+
this.roundClean();
|
121
|
+
return this;
|
122
|
+
}
|
123
|
+
digestInto(out) {
|
124
|
+
aexists(this);
|
125
|
+
aoutput(out, this);
|
126
|
+
this.finished = true;
|
127
|
+
const { buffer, view, blockLen, isLE } = this;
|
128
|
+
let { pos } = this;
|
129
|
+
buffer[pos++] = 128;
|
130
|
+
this.buffer.subarray(pos).fill(0);
|
131
|
+
if (this.padOffset > blockLen - pos) {
|
132
|
+
this.process(view, 0);
|
133
|
+
pos = 0;
|
134
|
+
}
|
135
|
+
for (let i = pos; i < blockLen; i++)
|
136
|
+
buffer[i] = 0;
|
137
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
138
|
+
this.process(view, 0);
|
139
|
+
const oview = createView(out);
|
140
|
+
const len = this.outputLen;
|
141
|
+
if (len % 4)
|
142
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
143
|
+
const outLen = len / 4;
|
144
|
+
const state = this.get();
|
145
|
+
if (outLen > state.length)
|
146
|
+
throw new Error("_sha2: outputLen bigger than state");
|
147
|
+
for (let i = 0; i < outLen; i++)
|
148
|
+
oview.setUint32(4 * i, state[i], isLE);
|
149
|
+
}
|
150
|
+
digest() {
|
151
|
+
const { buffer, outputLen } = this;
|
152
|
+
this.digestInto(buffer);
|
153
|
+
const res = buffer.slice(0, outputLen);
|
154
|
+
this.destroy();
|
155
|
+
return res;
|
156
|
+
}
|
157
|
+
_cloneInto(to) {
|
158
|
+
to || (to = new this.constructor());
|
159
|
+
to.set(...this.get());
|
160
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
161
|
+
to.length = length;
|
162
|
+
to.pos = pos;
|
163
|
+
to.finished = finished;
|
164
|
+
to.destroyed = destroyed;
|
165
|
+
if (length % blockLen)
|
166
|
+
to.buffer.set(buffer);
|
167
|
+
return to;
|
168
|
+
}
|
169
|
+
};
|
170
|
+
|
171
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/sha256.js
|
172
|
+
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
173
|
+
1116352408,
|
174
|
+
1899447441,
|
175
|
+
3049323471,
|
176
|
+
3921009573,
|
177
|
+
961987163,
|
178
|
+
1508970993,
|
179
|
+
2453635748,
|
180
|
+
2870763221,
|
181
|
+
3624381080,
|
182
|
+
310598401,
|
183
|
+
607225278,
|
184
|
+
1426881987,
|
185
|
+
1925078388,
|
186
|
+
2162078206,
|
187
|
+
2614888103,
|
188
|
+
3248222580,
|
189
|
+
3835390401,
|
190
|
+
4022224774,
|
191
|
+
264347078,
|
192
|
+
604807628,
|
193
|
+
770255983,
|
194
|
+
1249150122,
|
195
|
+
1555081692,
|
196
|
+
1996064986,
|
197
|
+
2554220882,
|
198
|
+
2821834349,
|
199
|
+
2952996808,
|
200
|
+
3210313671,
|
201
|
+
3336571891,
|
202
|
+
3584528711,
|
203
|
+
113926993,
|
204
|
+
338241895,
|
205
|
+
666307205,
|
206
|
+
773529912,
|
207
|
+
1294757372,
|
208
|
+
1396182291,
|
209
|
+
1695183700,
|
210
|
+
1986661051,
|
211
|
+
2177026350,
|
212
|
+
2456956037,
|
213
|
+
2730485921,
|
214
|
+
2820302411,
|
215
|
+
3259730800,
|
216
|
+
3345764771,
|
217
|
+
3516065817,
|
218
|
+
3600352804,
|
219
|
+
4094571909,
|
220
|
+
275423344,
|
221
|
+
430227734,
|
222
|
+
506948616,
|
223
|
+
659060556,
|
224
|
+
883997877,
|
225
|
+
958139571,
|
226
|
+
1322822218,
|
227
|
+
1537002063,
|
228
|
+
1747873779,
|
229
|
+
1955562222,
|
230
|
+
2024104815,
|
231
|
+
2227730452,
|
232
|
+
2361852424,
|
233
|
+
2428436474,
|
234
|
+
2756734187,
|
235
|
+
3204031479,
|
236
|
+
3329325298
|
237
|
+
]);
|
238
|
+
var SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
239
|
+
1779033703,
|
240
|
+
3144134277,
|
241
|
+
1013904242,
|
242
|
+
2773480762,
|
243
|
+
1359893119,
|
244
|
+
2600822924,
|
245
|
+
528734635,
|
246
|
+
1541459225
|
247
|
+
]);
|
248
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
249
|
+
var SHA256 = class extends HashMD {
|
250
|
+
constructor() {
|
251
|
+
super(64, 32, 8, false);
|
252
|
+
this.A = SHA256_IV[0] | 0;
|
253
|
+
this.B = SHA256_IV[1] | 0;
|
254
|
+
this.C = SHA256_IV[2] | 0;
|
255
|
+
this.D = SHA256_IV[3] | 0;
|
256
|
+
this.E = SHA256_IV[4] | 0;
|
257
|
+
this.F = SHA256_IV[5] | 0;
|
258
|
+
this.G = SHA256_IV[6] | 0;
|
259
|
+
this.H = SHA256_IV[7] | 0;
|
260
|
+
}
|
261
|
+
get() {
|
262
|
+
const { A, B: B2, C, D, E, F, G, H } = this;
|
263
|
+
return [A, B2, C, D, E, F, G, H];
|
264
|
+
}
|
265
|
+
// prettier-ignore
|
266
|
+
set(A, B2, C, D, E, F, G, H) {
|
267
|
+
this.A = A | 0;
|
268
|
+
this.B = B2 | 0;
|
269
|
+
this.C = C | 0;
|
270
|
+
this.D = D | 0;
|
271
|
+
this.E = E | 0;
|
272
|
+
this.F = F | 0;
|
273
|
+
this.G = G | 0;
|
274
|
+
this.H = H | 0;
|
275
|
+
}
|
276
|
+
process(view, offset) {
|
277
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
278
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
279
|
+
for (let i = 16; i < 64; i++) {
|
280
|
+
const W15 = SHA256_W[i - 15];
|
281
|
+
const W2 = SHA256_W[i - 2];
|
282
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
283
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
284
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
285
|
+
}
|
286
|
+
let { A, B: B2, C, D, E, F, G, H } = this;
|
287
|
+
for (let i = 0; i < 64; i++) {
|
288
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
289
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
290
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
291
|
+
const T2 = sigma0 + Maj(A, B2, C) | 0;
|
292
|
+
H = G;
|
293
|
+
G = F;
|
294
|
+
F = E;
|
295
|
+
E = D + T1 | 0;
|
296
|
+
D = C;
|
297
|
+
C = B2;
|
298
|
+
B2 = A;
|
299
|
+
A = T1 + T2 | 0;
|
300
|
+
}
|
301
|
+
A = A + this.A | 0;
|
302
|
+
B2 = B2 + this.B | 0;
|
303
|
+
C = C + this.C | 0;
|
304
|
+
D = D + this.D | 0;
|
305
|
+
E = E + this.E | 0;
|
306
|
+
F = F + this.F | 0;
|
307
|
+
G = G + this.G | 0;
|
308
|
+
H = H + this.H | 0;
|
309
|
+
this.set(A, B2, C, D, E, F, G, H);
|
310
|
+
}
|
311
|
+
roundClean() {
|
312
|
+
SHA256_W.fill(0);
|
313
|
+
}
|
314
|
+
destroy() {
|
315
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
316
|
+
this.buffer.fill(0);
|
317
|
+
}
|
318
|
+
};
|
319
|
+
var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
320
|
+
|
321
|
+
// ../../node_modules/.pnpm/@scure+base@1.2.4/node_modules/@scure/base/lib/esm/index.js
|
322
|
+
function isBytes2(a) {
|
323
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
324
|
+
}
|
325
|
+
function isArrayOf(isString, arr) {
|
326
|
+
if (!Array.isArray(arr))
|
327
|
+
return false;
|
328
|
+
if (arr.length === 0)
|
329
|
+
return true;
|
330
|
+
if (isString) {
|
331
|
+
return arr.every((item) => typeof item === "string");
|
332
|
+
} else {
|
333
|
+
return arr.every((item) => Number.isSafeInteger(item));
|
334
|
+
}
|
335
|
+
}
|
336
|
+
function afn(input) {
|
337
|
+
if (typeof input !== "function")
|
338
|
+
throw new Error("function expected");
|
339
|
+
return true;
|
340
|
+
}
|
341
|
+
function astr(label, input) {
|
342
|
+
if (typeof input !== "string")
|
343
|
+
throw new Error(`${label}: string expected`);
|
344
|
+
return true;
|
345
|
+
}
|
346
|
+
function anumber(n) {
|
347
|
+
if (!Number.isSafeInteger(n))
|
348
|
+
throw new Error(`invalid integer: ${n}`);
|
349
|
+
}
|
350
|
+
function aArr(input) {
|
351
|
+
if (!Array.isArray(input))
|
352
|
+
throw new Error("array expected");
|
353
|
+
}
|
354
|
+
function astrArr(label, input) {
|
355
|
+
if (!isArrayOf(true, input))
|
356
|
+
throw new Error(`${label}: array of strings expected`);
|
357
|
+
}
|
358
|
+
function anumArr(label, input) {
|
359
|
+
if (!isArrayOf(false, input))
|
360
|
+
throw new Error(`${label}: array of numbers expected`);
|
361
|
+
}
|
362
|
+
// @__NO_SIDE_EFFECTS__
|
363
|
+
function chain(...args) {
|
364
|
+
const id = (a) => a;
|
365
|
+
const wrap = (a, b) => (c) => a(b(c));
|
366
|
+
const encode = args.map((x) => x.encode).reduceRight(wrap, id);
|
367
|
+
const decode = args.map((x) => x.decode).reduce(wrap, id);
|
368
|
+
return { encode, decode };
|
369
|
+
}
|
370
|
+
// @__NO_SIDE_EFFECTS__
|
371
|
+
function alphabet(letters) {
|
372
|
+
const lettersA = letters.split("") ;
|
373
|
+
const len = lettersA.length;
|
374
|
+
astrArr("alphabet", lettersA);
|
375
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
376
|
+
return {
|
377
|
+
encode: (digits) => {
|
378
|
+
aArr(digits);
|
379
|
+
return digits.map((i) => {
|
380
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len)
|
381
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
382
|
+
return lettersA[i];
|
383
|
+
});
|
384
|
+
},
|
385
|
+
decode: (input) => {
|
386
|
+
aArr(input);
|
387
|
+
return input.map((letter) => {
|
388
|
+
astr("alphabet.decode", letter);
|
389
|
+
const i = indexes.get(letter);
|
390
|
+
if (i === undefined)
|
391
|
+
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
392
|
+
return i;
|
393
|
+
});
|
394
|
+
}
|
395
|
+
};
|
396
|
+
}
|
397
|
+
// @__NO_SIDE_EFFECTS__
|
398
|
+
function join(separator = "") {
|
399
|
+
astr("join", separator);
|
400
|
+
return {
|
401
|
+
encode: (from) => {
|
402
|
+
astrArr("join.decode", from);
|
403
|
+
return from.join(separator);
|
404
|
+
},
|
405
|
+
decode: (to) => {
|
406
|
+
astr("join.decode", to);
|
407
|
+
return to.split(separator);
|
408
|
+
}
|
409
|
+
};
|
410
|
+
}
|
411
|
+
function convertRadix(data, from, to) {
|
412
|
+
if (from < 2)
|
413
|
+
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
414
|
+
if (to < 2)
|
415
|
+
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
416
|
+
aArr(data);
|
417
|
+
if (!data.length)
|
418
|
+
return [];
|
419
|
+
let pos = 0;
|
420
|
+
const res = [];
|
421
|
+
const digits = Array.from(data, (d) => {
|
422
|
+
anumber(d);
|
423
|
+
if (d < 0 || d >= from)
|
424
|
+
throw new Error(`invalid integer: ${d}`);
|
425
|
+
return d;
|
426
|
+
});
|
427
|
+
const dlen = digits.length;
|
428
|
+
while (true) {
|
429
|
+
let carry = 0;
|
430
|
+
let done = true;
|
431
|
+
for (let i = pos; i < dlen; i++) {
|
432
|
+
const digit = digits[i];
|
433
|
+
const fromCarry = from * carry;
|
434
|
+
const digitBase = fromCarry + digit;
|
435
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
|
436
|
+
throw new Error("convertRadix: carry overflow");
|
437
|
+
}
|
438
|
+
const div = digitBase / to;
|
439
|
+
carry = digitBase % to;
|
440
|
+
const rounded = Math.floor(div);
|
441
|
+
digits[i] = rounded;
|
442
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
443
|
+
throw new Error("convertRadix: carry overflow");
|
444
|
+
if (!done)
|
445
|
+
continue;
|
446
|
+
else if (!rounded)
|
447
|
+
pos = i;
|
448
|
+
else
|
449
|
+
done = false;
|
450
|
+
}
|
451
|
+
res.push(carry);
|
452
|
+
if (done)
|
453
|
+
break;
|
454
|
+
}
|
455
|
+
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
|
456
|
+
res.push(0);
|
457
|
+
return res.reverse();
|
458
|
+
}
|
459
|
+
// @__NO_SIDE_EFFECTS__
|
460
|
+
function radix(num) {
|
461
|
+
anumber(num);
|
462
|
+
const _256 = 2 ** 8;
|
463
|
+
return {
|
464
|
+
encode: (bytes) => {
|
465
|
+
if (!isBytes2(bytes))
|
466
|
+
throw new Error("radix.encode input should be Uint8Array");
|
467
|
+
return convertRadix(Array.from(bytes), _256, num);
|
468
|
+
},
|
469
|
+
decode: (digits) => {
|
470
|
+
anumArr("radix.decode", digits);
|
471
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
472
|
+
}
|
473
|
+
};
|
474
|
+
}
|
475
|
+
function checksum(len, fn) {
|
476
|
+
anumber(len);
|
477
|
+
afn(fn);
|
478
|
+
return {
|
479
|
+
encode(data) {
|
480
|
+
if (!isBytes2(data))
|
481
|
+
throw new Error("checksum.encode: input should be Uint8Array");
|
482
|
+
const sum = fn(data).slice(0, len);
|
483
|
+
const res = new Uint8Array(data.length + len);
|
484
|
+
res.set(data);
|
485
|
+
res.set(sum, data.length);
|
486
|
+
return res;
|
487
|
+
},
|
488
|
+
decode(data) {
|
489
|
+
if (!isBytes2(data))
|
490
|
+
throw new Error("checksum.decode: input should be Uint8Array");
|
491
|
+
const payload = data.slice(0, -4);
|
492
|
+
const oldChecksum = data.slice(-4);
|
493
|
+
const newChecksum = fn(payload).slice(0, len);
|
494
|
+
for (let i = 0; i < len; i++)
|
495
|
+
if (newChecksum[i] !== oldChecksum[i])
|
496
|
+
throw new Error("Invalid checksum");
|
497
|
+
return payload;
|
498
|
+
}
|
499
|
+
};
|
500
|
+
}
|
501
|
+
var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
|
502
|
+
var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
503
|
+
var createBase58check = (sha2563) => /* @__PURE__ */ chain(checksum(4, (data) => sha2563(sha2563(data))), base58);
|
504
|
+
var base58check = createBase58check;
|
8
505
|
var HEXES = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
9
506
|
var HexChar = {
|
10
507
|
ZERO: 48,
|
@@ -20,11 +517,11 @@ var HexChar = {
|
|
20
517
|
F_LO: 102
|
21
518
|
// f
|
22
519
|
};
|
23
|
-
function bytesToHex(
|
24
|
-
common.assertInstanceOf(
|
520
|
+
function bytesToHex(bytes) {
|
521
|
+
common.assertInstanceOf(bytes, Uint8Array);
|
25
522
|
let hex3 = "";
|
26
|
-
for (let i = 0, len =
|
27
|
-
hex3 += HEXES[
|
523
|
+
for (let i = 0, len = bytes.length; i < len; i++) {
|
524
|
+
hex3 += HEXES[bytes[i]];
|
28
525
|
}
|
29
526
|
return hex3;
|
30
527
|
}
|
@@ -32,13 +529,13 @@ function hexToBytes(hex3) {
|
|
32
529
|
common.assertTypeOf(hex3, "string");
|
33
530
|
common.assert(hex3.length % 2 === 0, "Invalid hex padding.");
|
34
531
|
const len = hex3.length / 2;
|
35
|
-
const
|
532
|
+
const bytes = new Uint8Array(len);
|
36
533
|
for (let i = 0, j = 0; i < len; i++) {
|
37
534
|
const n1 = charCodeToBase16(hex3.charCodeAt(j++));
|
38
535
|
const n2 = charCodeToBase16(hex3.charCodeAt(j++));
|
39
|
-
|
536
|
+
bytes[i] = n1 * 16 + n2;
|
40
537
|
}
|
41
|
-
return
|
538
|
+
return bytes;
|
42
539
|
}
|
43
540
|
function charCodeToBase16(char) {
|
44
541
|
if (char >= HexChar.ZERO && char <= HexChar.NINE) return char - HexChar.ZERO;
|
@@ -50,6 +547,13 @@ var hex2 = {
|
|
50
547
|
encode: bytesToHex,
|
51
548
|
decode: hexToBytes
|
52
549
|
};
|
550
|
+
base58check(sha2562);
|
551
|
+
function ensureBytes(input) {
|
552
|
+
return typeof input === "string" ? hex2.decode(input) : input;
|
553
|
+
}
|
554
|
+
function sha2562(message) {
|
555
|
+
return sha256(ensureBytes(message));
|
556
|
+
}
|
53
557
|
var RETRY_STATUS_CODES = /* @__PURE__ */ new Set([
|
54
558
|
408,
|
55
559
|
// Request Timeout
|
@@ -127,7 +631,7 @@ function createGqlOperation(query, options) {
|
|
127
631
|
body: (options?.parser ?? JSON).stringify({
|
128
632
|
operationName: getOpName(query),
|
129
633
|
query,
|
130
|
-
variables: variables ? common.clearUndefined(variables) :
|
634
|
+
variables: variables ? common.clearUndefined(variables) : undefined
|
131
635
|
})
|
132
636
|
}
|
133
637
|
});
|
@@ -348,7 +852,7 @@ function buildGqlBoxQueries(query) {
|
|
348
852
|
);
|
349
853
|
const baseQuery = {
|
350
854
|
spent: false,
|
351
|
-
boxIds: query.where.boxId ? [query.where.boxId] :
|
855
|
+
boxIds: query.where.boxId ? [query.where.boxId] : undefined,
|
352
856
|
ergoTreeTemplateHash: query.where.templateHash,
|
353
857
|
tokenId: query.where.tokenId,
|
354
858
|
skip: query.skip ?? 0,
|
@@ -368,7 +872,7 @@ function buildGqlUnconfirmedTxQueries(query) {
|
|
368
872
|
].flat()
|
369
873
|
);
|
370
874
|
const baseQuery = {
|
371
|
-
transactionIds: query.where.transactionId ? [query.where.transactionId] :
|
875
|
+
transactionIds: query.where.transactionId ? [query.where.transactionId] : undefined,
|
372
876
|
skip: query.skip ?? 0,
|
373
877
|
take: query.take ?? PAGE_SIZE
|
374
878
|
};
|
@@ -460,7 +964,7 @@ function mapConfirmedTransaction(tx, mapper) {
|
|
460
964
|
};
|
461
965
|
}
|
462
966
|
function isRequestParam(obj) {
|
463
|
-
return typeof obj === "object" && obj.url !==
|
967
|
+
return typeof obj === "object" && obj.url !== undefined;
|
464
968
|
}
|
465
969
|
/*! Bundled license information:
|
466
970
|
|