@vleap/warps-adapter-fastset 0.1.0-alpha.32 → 0.1.0-alpha.33

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
@@ -1,8 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __export = (target, all) => {
4
- for (var name2 in all)
5
- __defProp(target, name2, { get: all[name2], enumerable: true });
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
8
 
@@ -217,14 +217,16 @@ function toHex(bytes) {
217
217
 
218
218
  // ../../node_modules/@mysten/bcs/dist/esm/uleb.js
219
219
  function ulebEncode(num) {
220
+ let bigNum = BigInt(num);
220
221
  const arr = [];
221
222
  let len = 0;
222
- if (num === 0) {
223
+ if (bigNum === 0n) {
223
224
  return [0];
224
225
  }
225
- while (num > 0) {
226
- arr[len] = num & 127;
227
- if (num >>= 7) {
226
+ while (bigNum > 0) {
227
+ arr[len] = Number(bigNum & 0x7fn);
228
+ bigNum >>= 7n;
229
+ if (bigNum > 0n) {
228
230
  arr[len] |= 128;
229
231
  }
230
232
  len += 1;
@@ -232,20 +234,26 @@ function ulebEncode(num) {
232
234
  return arr;
233
235
  }
234
236
  function ulebDecode(arr) {
235
- let total = 0;
236
- let shift = 0;
237
+ let total = 0n;
238
+ let shift = 0n;
237
239
  let len = 0;
238
240
  while (true) {
241
+ if (len >= arr.length) {
242
+ throw new Error("ULEB decode error: buffer overflow");
243
+ }
239
244
  const byte = arr[len];
240
245
  len += 1;
241
- total |= (byte & 127) << shift;
246
+ total += BigInt(byte & 127) << shift;
242
247
  if ((byte & 128) === 0) {
243
248
  break;
244
249
  }
245
- shift += 7;
250
+ shift += 7n;
251
+ }
252
+ if (total > BigInt(Number.MAX_SAFE_INTEGER)) {
253
+ throw new Error("ULEB decode error: value exceeds MAX_SAFE_INTEGER");
246
254
  }
247
255
  return {
248
- value: total,
256
+ value: Number(total),
249
257
  length: len
250
258
  };
251
259
  }
@@ -393,7 +401,10 @@ var BcsWriter = class {
393
401
  ensureSizeOrGrow(bytes) {
394
402
  const requiredSize = this.bytePosition + bytes;
395
403
  if (requiredSize > this.size) {
396
- const nextSize = Math.min(this.maxSize, this.size + this.allocateSize);
404
+ const nextSize = Math.min(
405
+ this.maxSize,
406
+ Math.max(this.size + requiredSize, this.size + this.allocateSize)
407
+ );
397
408
  if (requiredSize > nextSize) {
398
409
  throw new Error(
399
410
  `Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${requiredSize}`
@@ -425,6 +436,18 @@ var BcsWriter = class {
425
436
  this.dataView.setUint8(this.bytePosition, Number(value));
426
437
  return this.shift(1);
427
438
  }
439
+ /**
440
+ * Write a U8 value into a buffer and shift cursor position by 1.
441
+ * @param {Number} value Value to write.
442
+ * @returns {this}
443
+ */
444
+ writeBytes(bytes) {
445
+ this.ensureSizeOrGrow(bytes.length);
446
+ for (let i = 0; i < bytes.length; i++) {
447
+ this.dataView.setUint8(this.bytePosition + i, bytes[i]);
448
+ }
449
+ return this.shift(bytes.length);
450
+ }
428
451
  /**
429
452
  * Write a U16 value into a buffer and shift cursor position by 2.
430
453
  * @param {Number} value Value to write.
@@ -501,6 +524,7 @@ var BcsWriter = class {
501
524
  * Adds support for iterations over the object.
502
525
  * @returns {Uint8Array}
503
526
  */
527
+ // oxlint-disable-next-line require-yields
504
528
  *[Symbol.iterator]() {
505
529
  for (let i = 0; i < this.bytePosition; i++) {
506
530
  yield this.dataView.getUint8(i);
@@ -586,13 +610,13 @@ var _BcsType = class _BcsType2 {
586
610
  return this.parse(fromBase64(b64));
587
611
  }
588
612
  transform({
589
- name: name2,
613
+ name,
590
614
  input,
591
615
  output,
592
616
  validate
593
617
  }) {
594
618
  return new _BcsType2({
595
- name: name2 ?? this.name,
619
+ name: name ?? this.name,
596
620
  read: (reader) => output ? output(this.read(reader)) : this.read(reader),
597
621
  write: (value, writer) => __privateGet(this, _write).call(this, input ? input(value) : value, writer),
598
622
  serializedSize: (value) => this.serializedSize(input ? input(value) : value),
@@ -702,7 +726,7 @@ function dynamicSizeBcsType({
702
726
  return type;
703
727
  }
704
728
  function stringLikeBcsType({
705
- toBytes: toBytes2,
729
+ toBytes,
706
730
  fromBytes,
707
731
  ...options
708
732
  }) {
@@ -714,14 +738,14 @@ function stringLikeBcsType({
714
738
  return fromBytes(bytes);
715
739
  },
716
740
  write: (hex, writer) => {
717
- const bytes = toBytes2(hex);
741
+ const bytes = toBytes(hex);
718
742
  writer.writeULEB(bytes.length);
719
743
  for (let i = 0; i < bytes.length; i++) {
720
744
  writer.write8(bytes[i]);
721
745
  }
722
746
  },
723
747
  serialize: (value) => {
724
- const bytes = toBytes2(value);
748
+ const bytes = toBytes(value);
725
749
  const size = ulebEncode(bytes.length);
726
750
  const result = new Uint8Array(size.length + bytes.length);
727
751
  result.set(size, 0);
@@ -753,10 +777,10 @@ function lazyBcsType(cb) {
753
777
  });
754
778
  }
755
779
  var BcsStruct = class extends BcsType {
756
- constructor({ name: name2, fields, ...options }) {
780
+ constructor({ name, fields, ...options }) {
757
781
  const canonicalOrder = Object.entries(fields);
758
782
  super({
759
- name: name2,
783
+ name,
760
784
  serializedSize: (values) => {
761
785
  let total = 0;
762
786
  for (const [field, type] of canonicalOrder) {
@@ -798,7 +822,7 @@ var BcsEnum = class extends BcsType {
798
822
  const index = reader.readULEB();
799
823
  const enumEntry = canonicalOrder[index];
800
824
  if (!enumEntry) {
801
- throw new TypeError(`Unknown value ${index} for enum ${name}`);
825
+ throw new TypeError(`Unknown value ${index} for enum ${options.name}`);
802
826
  }
803
827
  const [kind, type] = enumEntry;
804
828
  return {
@@ -807,12 +831,12 @@ var BcsEnum = class extends BcsType {
807
831
  };
808
832
  },
809
833
  write: (value, writer) => {
810
- const [name2, val] = Object.entries(value).filter(
811
- ([name3]) => Object.hasOwn(fields, name3)
834
+ const [name, val] = Object.entries(value).filter(
835
+ ([name2]) => Object.hasOwn(fields, name2)
812
836
  )[0];
813
837
  for (let i = 0; i < canonicalOrder.length; i++) {
814
838
  const [optionName, optionType] = canonicalOrder[i];
815
- if (optionName === name2) {
839
+ if (optionName === name) {
816
840
  writer.writeULEB(i);
817
841
  optionType?.write(val, writer);
818
842
  return;
@@ -830,7 +854,7 @@ var BcsEnum = class extends BcsType {
830
854
  );
831
855
  if (keys.length !== 1) {
832
856
  throw new TypeError(
833
- `Expected object with one key, but found ${keys.length} for type ${name}}`
857
+ `Expected object with one key, but found ${keys.length} for type ${options.name}}`
834
858
  );
835
859
  }
836
860
  const [variant] = keys;
@@ -842,9 +866,9 @@ var BcsEnum = class extends BcsType {
842
866
  }
843
867
  };
844
868
  var BcsTuple = class extends BcsType {
845
- constructor({ fields, name: name2, ...options }) {
869
+ constructor({ fields, name, ...options }) {
846
870
  super({
847
- name: name2 ?? `(${fields.map((t) => t.name).join(", ")})`,
871
+ name: name ?? `(${fields.map((t) => t.name).join(", ")})`,
848
872
  serializedSize: (values) => {
849
873
  let total = 0;
850
874
  for (let i = 0; i < fields.length; i++) {
@@ -1107,10 +1131,7 @@ var bcs = {
1107
1131
  size,
1108
1132
  read: (reader) => reader.readBytes(size),
1109
1133
  write: (value, writer) => {
1110
- const array = new Uint8Array(value);
1111
- for (let i = 0; i < size; i++) {
1112
- writer.write8(array[i] ?? 0);
1113
- }
1134
+ writer.writeBytes(new Uint8Array(value));
1114
1135
  },
1115
1136
  ...options,
1116
1137
  name: options?.name ?? `bytes[${size}]`,
@@ -1140,9 +1161,7 @@ var bcs = {
1140
1161
  write: (value, writer) => {
1141
1162
  const array = new Uint8Array(value);
1142
1163
  writer.writeULEB(array.length);
1143
- for (let i = 0; i < array.length; i++) {
1144
- writer.write8(array[i] ?? 0);
1145
- }
1164
+ writer.writeBytes(array);
1146
1165
  },
1147
1166
  ...options,
1148
1167
  name: options?.name ?? "vector<u8>",
@@ -1221,9 +1240,9 @@ var bcs = {
1221
1240
  * })
1222
1241
  * struct.serialize({ a: 1, b: 'a' }).toBytes() // Uint8Array [ 1, 1, 97 ]
1223
1242
  */
1224
- struct(name2, fields, options) {
1243
+ struct(name, fields, options) {
1225
1244
  return new BcsStruct({
1226
- name: name2,
1245
+ name,
1227
1246
  fields,
1228
1247
  ...options
1229
1248
  });
@@ -1244,9 +1263,9 @@ var bcs = {
1244
1263
  * enum.serialize({ B: 'a' }).toBytes() // Uint8Array [ 1, 1, 97 ]
1245
1264
  * enum.serialize({ C: true }).toBytes() // Uint8Array [ 2 ]
1246
1265
  */
1247
- enum(name2, fields, options) {
1266
+ enum(name, fields, options) {
1248
1267
  return new BcsEnum({
1249
- name: name2,
1268
+ name,
1250
1269
  fields,
1251
1270
  ...options
1252
1271
  });
@@ -2017,10 +2036,10 @@ var invert = (num, md) => {
2017
2036
  }
2018
2037
  return b === 1n ? M(x, md) : err("no inverse");
2019
2038
  };
2020
- var callHash = (name2) => {
2021
- const fn = hashes[name2];
2039
+ var callHash = (name) => {
2040
+ const fn = hashes[name];
2022
2041
  if (typeof fn !== "function")
2023
- err("hashes." + name2 + " not set");
2042
+ err("hashes." + name + " not set");
2024
2043
  return fn;
2025
2044
  };
2026
2045
  var hash = (msg) => callHash("sha512")(msg);
@@ -2435,15 +2454,21 @@ var wNAF = (n) => {
2435
2454
  return { p, f };
2436
2455
  };
2437
2456
 
2438
- // ../../node_modules/@noble/hashes/esm/utils.js
2457
+ // node_modules/@noble/hashes/utils.js
2439
2458
  function isBytes3(a) {
2440
2459
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
2441
2460
  }
2442
- function abytes2(b, ...lengths) {
2443
- if (!isBytes3(b))
2444
- throw new Error("Uint8Array expected");
2445
- if (lengths.length > 0 && !lengths.includes(b.length))
2446
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
2461
+ function abytes2(value, length, title = "") {
2462
+ const bytes = isBytes3(value);
2463
+ const len = value?.length;
2464
+ const needsLen = length !== void 0;
2465
+ if (!bytes || needsLen && len !== length) {
2466
+ const prefix = title && `"${title}" `;
2467
+ const ofLen = needsLen ? ` of length ${length}` : "";
2468
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
2469
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
2470
+ }
2471
+ return value;
2447
2472
  }
2448
2473
  function aexists(instance, checkFinished = true) {
2449
2474
  if (instance.destroyed)
@@ -2452,10 +2477,10 @@ function aexists(instance, checkFinished = true) {
2452
2477
  throw new Error("Hash#digest() has already been called");
2453
2478
  }
2454
2479
  function aoutput(out, instance) {
2455
- abytes2(out);
2480
+ abytes2(out, void 0, "digestInto() output");
2456
2481
  const min = instance.outputLen;
2457
2482
  if (out.length < min) {
2458
- throw new Error("digestInto() expects output buffer of length at least " + min);
2483
+ throw new Error('"digestInto() output" expected to be of length >=' + min);
2459
2484
  }
2460
2485
  }
2461
2486
  function clean(...arrays) {
@@ -2466,48 +2491,33 @@ function clean(...arrays) {
2466
2491
  function createView(arr) {
2467
2492
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2468
2493
  }
2469
- function utf8ToBytes(str) {
2470
- if (typeof str !== "string")
2471
- throw new Error("string expected");
2472
- return new Uint8Array(new TextEncoder().encode(str));
2473
- }
2474
- function toBytes(data) {
2475
- if (typeof data === "string")
2476
- data = utf8ToBytes(data);
2477
- abytes2(data);
2478
- return data;
2479
- }
2480
- var Hash = class {
2481
- };
2482
- function createHasher(hashCons) {
2483
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
2484
- const tmp = hashCons();
2494
+ function createHasher(hashCons, info = {}) {
2495
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
2496
+ const tmp = hashCons(void 0);
2485
2497
  hashC.outputLen = tmp.outputLen;
2486
2498
  hashC.blockLen = tmp.blockLen;
2487
- hashC.create = () => hashCons();
2488
- return hashC;
2499
+ hashC.create = (opts) => hashCons(opts);
2500
+ Object.assign(hashC, info);
2501
+ return Object.freeze(hashC);
2489
2502
  }
2503
+ var oidNist = (suffix) => ({
2504
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
2505
+ });
2490
2506
 
2491
- // ../../node_modules/@noble/hashes/esm/_md.js
2492
- function setBigUint64(view, byteOffset, value, isLE) {
2493
- if (typeof view.setBigUint64 === "function")
2494
- return view.setBigUint64(byteOffset, value, isLE);
2495
- const _32n2 = BigInt(32);
2496
- const _u32_max = BigInt(4294967295);
2497
- const wh = Number(value >> _32n2 & _u32_max);
2498
- const wl = Number(value & _u32_max);
2499
- const h2 = isLE ? 4 : 0;
2500
- const l = isLE ? 0 : 4;
2501
- view.setUint32(byteOffset + h2, wh, isLE);
2502
- view.setUint32(byteOffset + l, wl, isLE);
2503
- }
2504
- var HashMD = class extends Hash {
2507
+ // node_modules/@noble/hashes/_md.js
2508
+ var HashMD = class {
2505
2509
  constructor(blockLen, outputLen, padOffset, isLE) {
2506
- super();
2507
- this.finished = false;
2508
- this.length = 0;
2509
- this.pos = 0;
2510
- this.destroyed = false;
2510
+ __publicField(this, "blockLen");
2511
+ __publicField(this, "outputLen");
2512
+ __publicField(this, "padOffset");
2513
+ __publicField(this, "isLE");
2514
+ // For partial updates less than block size
2515
+ __publicField(this, "buffer");
2516
+ __publicField(this, "view");
2517
+ __publicField(this, "finished", false);
2518
+ __publicField(this, "length", 0);
2519
+ __publicField(this, "pos", 0);
2520
+ __publicField(this, "destroyed", false);
2511
2521
  this.blockLen = blockLen;
2512
2522
  this.outputLen = outputLen;
2513
2523
  this.padOffset = padOffset;
@@ -2517,7 +2527,6 @@ var HashMD = class extends Hash {
2517
2527
  }
2518
2528
  update(data) {
2519
2529
  aexists(this);
2520
- data = toBytes(data);
2521
2530
  abytes2(data);
2522
2531
  const { view, buffer, blockLen } = this;
2523
2532
  const len = data.length;
@@ -2555,12 +2564,12 @@ var HashMD = class extends Hash {
2555
2564
  }
2556
2565
  for (let i = pos; i < blockLen; i++)
2557
2566
  buffer[i] = 0;
2558
- setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
2567
+ view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
2559
2568
  this.process(view, 0);
2560
2569
  const oview = createView(out);
2561
2570
  const len = this.outputLen;
2562
2571
  if (len % 4)
2563
- throw new Error("_sha2: outputLen should be aligned to 32bit");
2572
+ throw new Error("_sha2: outputLen must be aligned to 32bit");
2564
2573
  const outLen = len / 4;
2565
2574
  const state = this.get();
2566
2575
  if (outLen > state.length)
@@ -2610,7 +2619,7 @@ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
2610
2619
  327033209
2611
2620
  ]);
2612
2621
 
2613
- // ../../node_modules/@noble/hashes/esm/_u64.js
2622
+ // node_modules/@noble/hashes/_u64.js
2614
2623
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2615
2624
  var _32n = /* @__PURE__ */ BigInt(32);
2616
2625
  function fromBig(n, le = false) {
@@ -2645,7 +2654,7 @@ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0
2645
2654
  var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
2646
2655
  var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
2647
2656
 
2648
- // ../../node_modules/@noble/hashes/esm/sha2.js
2657
+ // node_modules/@noble/hashes/sha2.js
2649
2658
  var K512 = /* @__PURE__ */ (() => split([
2650
2659
  "0x428a2f98d728ae22",
2651
2660
  "0x7137449123ef65cd",
@@ -2732,25 +2741,9 @@ var SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
2732
2741
  var SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
2733
2742
  var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
2734
2743
  var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
2735
- var SHA512 = class extends HashMD {
2736
- constructor(outputLen = 64) {
2744
+ var SHA2_64B = class extends HashMD {
2745
+ constructor(outputLen) {
2737
2746
  super(128, outputLen, 16, false);
2738
- this.Ah = SHA512_IV[0] | 0;
2739
- this.Al = SHA512_IV[1] | 0;
2740
- this.Bh = SHA512_IV[2] | 0;
2741
- this.Bl = SHA512_IV[3] | 0;
2742
- this.Ch = SHA512_IV[4] | 0;
2743
- this.Cl = SHA512_IV[5] | 0;
2744
- this.Dh = SHA512_IV[6] | 0;
2745
- this.Dl = SHA512_IV[7] | 0;
2746
- this.Eh = SHA512_IV[8] | 0;
2747
- this.El = SHA512_IV[9] | 0;
2748
- this.Fh = SHA512_IV[10] | 0;
2749
- this.Fl = SHA512_IV[11] | 0;
2750
- this.Gh = SHA512_IV[12] | 0;
2751
- this.Gl = SHA512_IV[13] | 0;
2752
- this.Hh = SHA512_IV[14] | 0;
2753
- this.Hl = SHA512_IV[15] | 0;
2754
2747
  }
2755
2748
  // prettier-ignore
2756
2749
  get() {
@@ -2843,13 +2836,34 @@ var SHA512 = class extends HashMD {
2843
2836
  this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2844
2837
  }
2845
2838
  };
2846
- var sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
2847
-
2848
- // ../../node_modules/@noble/hashes/esm/sha512.js
2849
- var sha5122 = sha512;
2839
+ var _SHA512 = class extends SHA2_64B {
2840
+ constructor() {
2841
+ super(64);
2842
+ __publicField(this, "Ah", SHA512_IV[0] | 0);
2843
+ __publicField(this, "Al", SHA512_IV[1] | 0);
2844
+ __publicField(this, "Bh", SHA512_IV[2] | 0);
2845
+ __publicField(this, "Bl", SHA512_IV[3] | 0);
2846
+ __publicField(this, "Ch", SHA512_IV[4] | 0);
2847
+ __publicField(this, "Cl", SHA512_IV[5] | 0);
2848
+ __publicField(this, "Dh", SHA512_IV[6] | 0);
2849
+ __publicField(this, "Dl", SHA512_IV[7] | 0);
2850
+ __publicField(this, "Eh", SHA512_IV[8] | 0);
2851
+ __publicField(this, "El", SHA512_IV[9] | 0);
2852
+ __publicField(this, "Fh", SHA512_IV[10] | 0);
2853
+ __publicField(this, "Fl", SHA512_IV[11] | 0);
2854
+ __publicField(this, "Gh", SHA512_IV[12] | 0);
2855
+ __publicField(this, "Gl", SHA512_IV[13] | 0);
2856
+ __publicField(this, "Hh", SHA512_IV[14] | 0);
2857
+ __publicField(this, "Hl", SHA512_IV[15] | 0);
2858
+ }
2859
+ };
2860
+ var sha512 = /* @__PURE__ */ createHasher(
2861
+ () => new _SHA512(),
2862
+ /* @__PURE__ */ oidNist(3)
2863
+ );
2850
2864
 
2851
2865
  // src/sdk/ed25519-setup.ts
2852
- hashes.sha512 = sha5122;
2866
+ hashes.sha512 = sha512;
2853
2867
 
2854
2868
  // src/WarpFastsetWallet.ts
2855
2869
  var WarpFastsetWallet = class {
@@ -2985,7 +2999,7 @@ export {
2985
2999
  @noble/ed25519/index.js:
2986
3000
  (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
2987
3001
 
2988
- @noble/hashes/esm/utils.js:
3002
+ @noble/hashes/utils.js:
2989
3003
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2990
3004
  */
2991
3005
  //# sourceMappingURL=index.mjs.map