@fleet-sdk/blockchain-providers 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @fleet-sdk/blockchain-providers
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [eeb2f66]
8
+ - Updated dependencies [eeb2f66]
9
+ - Updated dependencies [a33850a]
10
+ - @fleet-sdk/core@0.9.0
11
+
12
+ ## 0.8.5
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [07bafd5]
17
+ - @fleet-sdk/common@0.8.5
18
+ - @fleet-sdk/core@0.8.5
19
+
3
20
  ## 0.8.3
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -483,6 +483,33 @@ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
483
483
  IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
484
484
  );
485
485
 
486
+ // Should never happen
487
+
488
+ /**
489
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
490
+
491
+ @example
492
+ ```
493
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
494
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
495
+ //=> 'VALID'
496
+
497
+ // When `T` is `any` => Returns `IfAny` branch
498
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
499
+ //=> 'IS_ANY'
500
+
501
+ // When `T` is `never` => Returns `IfNever` branch
502
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
503
+ //=> 'IS_NEVER'
504
+ ```
505
+ */
506
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> =
507
+ IsAny<T> extends true
508
+ ? IfAny
509
+ : IsNever<T> extends true
510
+ ? IfNever
511
+ : IfNotAnyOrNever;
512
+
486
513
  /**
487
514
  Merges user specified options with default options.
488
515
 
@@ -683,6 +710,16 @@ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
683
710
  type RequireAtLeastOne<
684
711
  ObjectType,
685
712
  KeysType extends keyof ObjectType = keyof ObjectType,
713
+ > =
714
+ IfNotAnyOrNever<ObjectType,
715
+ IfNever<KeysType,
716
+ never,
717
+ _RequireAtLeastOne<ObjectType, IfAny<KeysType, keyof ObjectType, KeysType>>
718
+ >>;
719
+
720
+ type _RequireAtLeastOne<
721
+ ObjectType,
722
+ KeysType extends keyof ObjectType,
686
723
  > = {
687
724
  // For each `Key` in `KeysType` make a mapped type:
688
725
  [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & // 1. Make `Key`'s type required
package/dist/index.d.ts CHANGED
@@ -483,6 +483,33 @@ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
483
483
  IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
484
484
  );
485
485
 
486
+ // Should never happen
487
+
488
+ /**
489
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
490
+
491
+ @example
492
+ ```
493
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
494
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
495
+ //=> 'VALID'
496
+
497
+ // When `T` is `any` => Returns `IfAny` branch
498
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
499
+ //=> 'IS_ANY'
500
+
501
+ // When `T` is `never` => Returns `IfNever` branch
502
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
503
+ //=> 'IS_NEVER'
504
+ ```
505
+ */
506
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> =
507
+ IsAny<T> extends true
508
+ ? IfAny
509
+ : IsNever<T> extends true
510
+ ? IfNever
511
+ : IfNotAnyOrNever;
512
+
486
513
  /**
487
514
  Merges user specified options with default options.
488
515
 
@@ -683,6 +710,16 @@ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
683
710
  type RequireAtLeastOne<
684
711
  ObjectType,
685
712
  KeysType extends keyof ObjectType = keyof ObjectType,
713
+ > =
714
+ IfNotAnyOrNever<ObjectType,
715
+ IfNever<KeysType,
716
+ never,
717
+ _RequireAtLeastOne<ObjectType, IfAny<KeysType, keyof ObjectType, KeysType>>
718
+ >>;
719
+
720
+ type _RequireAtLeastOne<
721
+ ObjectType,
722
+ KeysType extends keyof ObjectType,
686
723
  > = {
687
724
  // For each `Key` in `KeysType` make a mapped type:
688
725
  [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & // 1. Make `Key`'s type required
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ 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.2/node_modules/@noble/hashes/esm/_assert.js
8
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
9
9
  function isBytes(a) {
10
10
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
11
11
  }
@@ -28,21 +28,20 @@ function aoutput(out, instance) {
28
28
  throw new Error("digestInto() expects output buffer of length at least " + min);
29
29
  }
30
30
  }
31
-
32
- // ../../node_modules/.pnpm/@noble+hashes@1.7.2/node_modules/@noble/hashes/esm/utils.js
31
+ function clean(...arrays) {
32
+ for (let i = 0; i < arrays.length; i++) {
33
+ arrays[i].fill(0);
34
+ }
35
+ }
33
36
  function createView(arr) {
34
37
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
35
38
  }
36
39
  function rotr(word, shift) {
37
40
  return word << 32 - shift | word >>> shift;
38
41
  }
39
- (
40
- // @ts-ignore
41
- typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
42
- );
43
42
  function utf8ToBytes(str) {
44
43
  if (typeof str !== "string")
45
- throw new Error("utf8ToBytes expected string, got " + typeof str);
44
+ throw new Error("string expected");
46
45
  return new Uint8Array(new TextEncoder().encode(str));
47
46
  }
48
47
  function toBytes(data) {
@@ -52,12 +51,8 @@ function toBytes(data) {
52
51
  return data;
53
52
  }
54
53
  var Hash = class {
55
- // Safe version that clones internal state
56
- clone() {
57
- return this._cloneInto();
58
- }
59
54
  };
60
- function wrapConstructor(hashCons) {
55
+ function createHasher(hashCons) {
61
56
  const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
62
57
  const tmp = hashCons();
63
58
  hashC.outputLen = tmp.outputLen;
@@ -66,7 +61,7 @@ function wrapConstructor(hashCons) {
66
61
  return hashC;
67
62
  }
68
63
 
69
- // ../../node_modules/.pnpm/@noble+hashes@1.7.2/node_modules/@noble/hashes/esm/_md.js
64
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
70
65
  function setBigUint64(view, byteOffset, value, isLE) {
71
66
  if (typeof view.setBigUint64 === "function")
72
67
  return view.setBigUint64(byteOffset, value, isLE);
@@ -101,8 +96,9 @@ var HashMD = class extends Hash {
101
96
  }
102
97
  update(data) {
103
98
  aexists(this);
104
- const { view, buffer, blockLen } = this;
105
99
  data = toBytes(data);
100
+ abytes(data);
101
+ const { view, buffer, blockLen } = this;
106
102
  const len = data.length;
107
103
  for (let pos = 0; pos < len; ) {
108
104
  const take = Math.min(blockLen - this.pos, len - pos);
@@ -131,7 +127,7 @@ var HashMD = class extends Hash {
131
127
  const { buffer, view, blockLen, isLE } = this;
132
128
  let { pos } = this;
133
129
  buffer[pos++] = 128;
134
- this.buffer.subarray(pos).fill(0);
130
+ clean(this.buffer.subarray(pos));
135
131
  if (this.padOffset > blockLen - pos) {
136
132
  this.process(view, 0);
137
133
  pos = 0;
@@ -162,18 +158,31 @@ var HashMD = class extends Hash {
162
158
  to || (to = new this.constructor());
163
159
  to.set(...this.get());
164
160
  const { blockLen, buffer, length, finished, destroyed, pos } = this;
161
+ to.destroyed = destroyed;
162
+ to.finished = finished;
165
163
  to.length = length;
166
164
  to.pos = pos;
167
- to.finished = finished;
168
- to.destroyed = destroyed;
169
165
  if (length % blockLen)
170
166
  to.buffer.set(buffer);
171
167
  return to;
172
168
  }
169
+ clone() {
170
+ return this._cloneInto();
171
+ }
173
172
  };
173
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
174
+ 1779033703,
175
+ 3144134277,
176
+ 1013904242,
177
+ 2773480762,
178
+ 1359893119,
179
+ 2600822924,
180
+ 528734635,
181
+ 1541459225
182
+ ]);
174
183
 
175
- // ../../node_modules/.pnpm/@noble+hashes@1.7.2/node_modules/@noble/hashes/esm/sha256.js
176
- var SHA256_K = /* @__PURE__ */ new Uint32Array([
184
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
185
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
177
186
  1116352408,
178
187
  1899447441,
179
188
  3049323471,
@@ -239,16 +248,6 @@ var SHA256_K = /* @__PURE__ */ new Uint32Array([
239
248
  3204031479,
240
249
  3329325298
241
250
  ]);
242
- var SHA256_IV = /* @__PURE__ */ new Uint32Array([
243
- 1779033703,
244
- 3144134277,
245
- 1013904242,
246
- 2773480762,
247
- 1359893119,
248
- 2600822924,
249
- 528734635,
250
- 1541459225
251
- ]);
252
251
  var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
253
252
  var SHA256 = class extends HashMD {
254
253
  constructor(outputLen = 32) {
@@ -313,16 +312,19 @@ var SHA256 = class extends HashMD {
313
312
  this.set(A, B2, C, D, E, F, G, H);
314
313
  }
315
314
  roundClean() {
316
- SHA256_W.fill(0);
315
+ clean(SHA256_W);
317
316
  }
318
317
  destroy() {
319
318
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
320
- this.buffer.fill(0);
319
+ clean(this.buffer);
321
320
  }
322
321
  };
323
- var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
322
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
324
323
 
325
- // ../../node_modules/.pnpm/@scure+base@1.2.4/node_modules/@scure/base/lib/esm/index.js
324
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
325
+ var sha2562 = sha256;
326
+
327
+ // ../../node_modules/.pnpm/@scure+base@1.2.5/node_modules/@scure/base/lib/esm/index.js
326
328
  function isBytes2(a) {
327
329
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
328
330
  }
@@ -504,7 +506,7 @@ function checksum(len, fn) {
504
506
  }
505
507
  var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
506
508
  var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
507
- var createBase58check = (sha2563) => /* @__PURE__ */ chain(checksum(4, (data) => sha2563(sha2563(data))), base58);
509
+ var createBase58check = (sha2564) => /* @__PURE__ */ chain(checksum(4, (data) => sha2564(sha2564(data))), base58);
508
510
  var base58check = createBase58check;
509
511
  var HEXES = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
510
512
  var HexChar = {
@@ -551,12 +553,12 @@ var hex2 = {
551
553
  encode: bytesToHex,
552
554
  decode: hexToBytes
553
555
  };
554
- base58check(sha2562);
556
+ base58check(sha2563);
555
557
  function ensureBytes(input) {
556
558
  return typeof input === "string" ? hex2.decode(input) : input;
557
559
  }
558
- function sha2562(message) {
559
- return sha256(ensureBytes(message));
560
+ function sha2563(message) {
561
+ return sha2562(ensureBytes(message));
560
562
  }
561
563
  var RETRY_STATUS_CODES = /* @__PURE__ */ new Set([
562
564
  408,
@@ -794,9 +796,7 @@ var ErgoGraphQLProvider = class {
794
796
  while (keepFetching) {
795
797
  const response = await this.#getConfirmedTransactions(query2);
796
798
  if (common.some(response.data?.transactions)) {
797
- yield response.data.transactions.map(
798
- (t) => mapConfirmedTransaction(t, this.#biMapper)
799
- );
799
+ yield response.data.transactions.map((t) => mapConfirmedTransaction(t, this.#biMapper));
800
800
  }
801
801
  keepFetching = response.data?.transactions?.length === pageSize;
802
802
  if (keepFetching) query2.skip += pageSize;