@fleet-sdk/blockchain-providers 0.8.2 → 0.8.5

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/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { ErgoAddress } from '@fleet-sdk/core';
3
3
 
4
4
  // src/ergo-graphql/ergoGraphQLProvider.ts
5
5
 
6
- // ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/_assert.js
6
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
7
7
  function isBytes(a) {
8
8
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
9
9
  }
@@ -26,8 +26,11 @@ function aoutput(out, instance) {
26
26
  throw new Error("digestInto() expects output buffer of length at least " + min);
27
27
  }
28
28
  }
29
-
30
- // ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/utils.js
29
+ function clean(...arrays) {
30
+ for (let i = 0; i < arrays.length; i++) {
31
+ arrays[i].fill(0);
32
+ }
33
+ }
31
34
  function createView(arr) {
32
35
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
33
36
  }
@@ -36,7 +39,7 @@ function rotr(word, shift) {
36
39
  }
37
40
  function utf8ToBytes(str) {
38
41
  if (typeof str !== "string")
39
- throw new Error("utf8ToBytes expected string, got " + typeof str);
42
+ throw new Error("string expected");
40
43
  return new Uint8Array(new TextEncoder().encode(str));
41
44
  }
42
45
  function toBytes(data) {
@@ -46,12 +49,8 @@ function toBytes(data) {
46
49
  return data;
47
50
  }
48
51
  var Hash = class {
49
- // Safe version that clones internal state
50
- clone() {
51
- return this._cloneInto();
52
- }
53
52
  };
54
- function wrapConstructor(hashCons) {
53
+ function createHasher(hashCons) {
55
54
  const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
56
55
  const tmp = hashCons();
57
56
  hashC.outputLen = tmp.outputLen;
@@ -60,7 +59,7 @@ function wrapConstructor(hashCons) {
60
59
  return hashC;
61
60
  }
62
61
 
63
- // ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/_md.js
62
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
64
63
  function setBigUint64(view, byteOffset, value, isLE) {
65
64
  if (typeof view.setBigUint64 === "function")
66
65
  return view.setBigUint64(byteOffset, value, isLE);
@@ -82,21 +81,22 @@ function Maj(a, b, c) {
82
81
  var HashMD = class extends Hash {
83
82
  constructor(blockLen, outputLen, padOffset, isLE) {
84
83
  super();
85
- this.blockLen = blockLen;
86
- this.outputLen = outputLen;
87
- this.padOffset = padOffset;
88
- this.isLE = isLE;
89
84
  this.finished = false;
90
85
  this.length = 0;
91
86
  this.pos = 0;
92
87
  this.destroyed = false;
88
+ this.blockLen = blockLen;
89
+ this.outputLen = outputLen;
90
+ this.padOffset = padOffset;
91
+ this.isLE = isLE;
93
92
  this.buffer = new Uint8Array(blockLen);
94
93
  this.view = createView(this.buffer);
95
94
  }
96
95
  update(data) {
97
96
  aexists(this);
98
- const { view, buffer, blockLen } = this;
99
97
  data = toBytes(data);
98
+ abytes(data);
99
+ const { view, buffer, blockLen } = this;
100
100
  const len = data.length;
101
101
  for (let pos = 0; pos < len; ) {
102
102
  const take = Math.min(blockLen - this.pos, len - pos);
@@ -125,7 +125,7 @@ var HashMD = class extends Hash {
125
125
  const { buffer, view, blockLen, isLE } = this;
126
126
  let { pos } = this;
127
127
  buffer[pos++] = 128;
128
- this.buffer.subarray(pos).fill(0);
128
+ clean(this.buffer.subarray(pos));
129
129
  if (this.padOffset > blockLen - pos) {
130
130
  this.process(view, 0);
131
131
  pos = 0;
@@ -156,18 +156,31 @@ var HashMD = class extends Hash {
156
156
  to || (to = new this.constructor());
157
157
  to.set(...this.get());
158
158
  const { blockLen, buffer, length, finished, destroyed, pos } = this;
159
+ to.destroyed = destroyed;
160
+ to.finished = finished;
159
161
  to.length = length;
160
162
  to.pos = pos;
161
- to.finished = finished;
162
- to.destroyed = destroyed;
163
163
  if (length % blockLen)
164
164
  to.buffer.set(buffer);
165
165
  return to;
166
166
  }
167
+ clone() {
168
+ return this._cloneInto();
169
+ }
167
170
  };
171
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
172
+ 1779033703,
173
+ 3144134277,
174
+ 1013904242,
175
+ 2773480762,
176
+ 1359893119,
177
+ 2600822924,
178
+ 528734635,
179
+ 1541459225
180
+ ]);
168
181
 
169
- // ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/sha256.js
170
- var SHA256_K = /* @__PURE__ */ new Uint32Array([
182
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
183
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
171
184
  1116352408,
172
185
  1899447441,
173
186
  3049323471,
@@ -233,20 +246,10 @@ var SHA256_K = /* @__PURE__ */ new Uint32Array([
233
246
  3204031479,
234
247
  3329325298
235
248
  ]);
236
- var SHA256_IV = /* @__PURE__ */ new Uint32Array([
237
- 1779033703,
238
- 3144134277,
239
- 1013904242,
240
- 2773480762,
241
- 1359893119,
242
- 2600822924,
243
- 528734635,
244
- 1541459225
245
- ]);
246
249
  var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
247
250
  var SHA256 = class extends HashMD {
248
- constructor() {
249
- super(64, 32, 8, false);
251
+ constructor(outputLen = 32) {
252
+ super(64, outputLen, 8, false);
250
253
  this.A = SHA256_IV[0] | 0;
251
254
  this.B = SHA256_IV[1] | 0;
252
255
  this.C = SHA256_IV[2] | 0;
@@ -307,16 +310,19 @@ var SHA256 = class extends HashMD {
307
310
  this.set(A, B2, C, D, E, F, G, H);
308
311
  }
309
312
  roundClean() {
310
- SHA256_W.fill(0);
313
+ clean(SHA256_W);
311
314
  }
312
315
  destroy() {
313
316
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
314
- this.buffer.fill(0);
317
+ clean(this.buffer);
315
318
  }
316
319
  };
317
- var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
320
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
321
+
322
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
323
+ var sha2562 = sha256;
318
324
 
319
- // ../../node_modules/.pnpm/@scure+base@1.2.4/node_modules/@scure/base/lib/esm/index.js
325
+ // ../../node_modules/.pnpm/@scure+base@1.2.5/node_modules/@scure/base/lib/esm/index.js
320
326
  function isBytes2(a) {
321
327
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
322
328
  }
@@ -385,7 +391,7 @@ function alphabet(letters) {
385
391
  return input.map((letter) => {
386
392
  astr("alphabet.decode", letter);
387
393
  const i = indexes.get(letter);
388
- if (i === undefined)
394
+ if (i === void 0)
389
395
  throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
390
396
  return i;
391
397
  });
@@ -498,7 +504,7 @@ function checksum(len, fn) {
498
504
  }
499
505
  var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
500
506
  var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
501
- var createBase58check = (sha2563) => /* @__PURE__ */ chain(checksum(4, (data) => sha2563(sha2563(data))), base58);
507
+ var createBase58check = (sha2564) => /* @__PURE__ */ chain(checksum(4, (data) => sha2564(sha2564(data))), base58);
502
508
  var base58check = createBase58check;
503
509
  var HEXES = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
504
510
  var HexChar = {
@@ -545,12 +551,12 @@ var hex2 = {
545
551
  encode: bytesToHex,
546
552
  decode: hexToBytes
547
553
  };
548
- base58check(sha2562);
554
+ base58check(sha2563);
549
555
  function ensureBytes(input) {
550
556
  return typeof input === "string" ? hex2.decode(input) : input;
551
557
  }
552
- function sha2562(message) {
553
- return sha256(ensureBytes(message));
558
+ function sha2563(message) {
559
+ return sha2562(ensureBytes(message));
554
560
  }
555
561
  var RETRY_STATUS_CODES = /* @__PURE__ */ new Set([
556
562
  408,
@@ -629,7 +635,7 @@ function createGqlOperation(query, options) {
629
635
  body: (options?.parser ?? JSON).stringify({
630
636
  operationName: getOpName(query),
631
637
  query,
632
- variables: variables ? clearUndefined(variables) : undefined
638
+ variables: variables ? clearUndefined(variables) : void 0
633
639
  })
634
640
  }
635
641
  });
@@ -850,7 +856,7 @@ function buildGqlBoxQueries(query) {
850
856
  );
851
857
  const baseQuery = {
852
858
  spent: false,
853
- boxIds: query.where.boxId ? [query.where.boxId] : undefined,
859
+ boxIds: query.where.boxId ? [query.where.boxId] : void 0,
854
860
  ergoTreeTemplateHash: query.where.templateHash,
855
861
  tokenId: query.where.tokenId,
856
862
  skip: query.skip ?? 0,
@@ -870,7 +876,7 @@ function buildGqlUnconfirmedTxQueries(query) {
870
876
  ].flat()
871
877
  );
872
878
  const baseQuery = {
873
- transactionIds: query.where.transactionId ? [query.where.transactionId] : undefined,
879
+ transactionIds: query.where.transactionId ? [query.where.transactionId] : void 0,
874
880
  skip: query.skip ?? 0,
875
881
  take: query.take ?? PAGE_SIZE
876
882
  };
@@ -962,7 +968,7 @@ function mapConfirmedTransaction(tx, mapper) {
962
968
  };
963
969
  }
964
970
  function isRequestParam(obj) {
965
- return typeof obj === "object" && obj.url !== undefined;
971
+ return typeof obj === "object" && obj.url !== void 0;
966
972
  }
967
973
  /*! Bundled license information:
968
974