@typeberry/lib 0.0.1-6b496a1 → 0.0.1-7996e00

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.
@@ -0,0 +1,74 @@
1
+ export declare const configs: {
2
+ default: {
3
+ $schema: string;
4
+ version: number;
5
+ flavor: string;
6
+ authorship: {
7
+ omit_seal_verification: boolean;
8
+ };
9
+ chain_spec: {
10
+ id: string;
11
+ bootnodes: string[];
12
+ genesis_header: string;
13
+ genesis_state: {
14
+ "01000000000000000000000000000000000000000000000000000000000000": string;
15
+ "02000000000000000000000000000000000000000000000000000000000000": string;
16
+ "03000000000000000000000000000000000000000000000000000000000000": string;
17
+ "04000000000000000000000000000000000000000000000000000000000000": string;
18
+ "05000000000000000000000000000000000000000000000000000000000000": string;
19
+ "06000000000000000000000000000000000000000000000000000000000000": string;
20
+ "07000000000000000000000000000000000000000000000000000000000000": string;
21
+ "08000000000000000000000000000000000000000000000000000000000000": string;
22
+ "09000000000000000000000000000000000000000000000000000000000000": string;
23
+ "0a000000000000000000000000000000000000000000000000000000000000": string;
24
+ "0b000000000000000000000000000000000000000000000000000000000000": string;
25
+ "0c000000000000000000000000000000000000000000000000000000000000": string;
26
+ "0d000000000000000000000000000000000000000000000000000000000000": string;
27
+ "0e000000000000000000000000000000000000000000000000000000000000": string;
28
+ "0f000000000000000000000000000000000000000000000000000000000000": string;
29
+ ff000000000000000000000000000000000000000000000000000000000000: string;
30
+ "00fe00ff00ff00ff6326432b5b3213dfd1609495e13c6b276cb474d6796453": string;
31
+ "00fe00ff00ff00fff8485e3a88e86182e63280720d5ec9892578f0e577fb1b": string;
32
+ "0023000000000000478648cd19b4f812f897a26976ecf312eac28508b4368d": string;
33
+ "004b000400000000f324d112c31c3778a072940b55dd35f3a4b77e72d2d2db": string;
34
+ };
35
+ };
36
+ database_base_path: string;
37
+ };
38
+ dev: {
39
+ $schema: string;
40
+ version: number;
41
+ flavor: string;
42
+ authorship: {
43
+ omit_seal_verification: boolean;
44
+ };
45
+ chain_spec: {
46
+ id: string;
47
+ bootnodes: string[];
48
+ genesis_header: string;
49
+ genesis_state: {
50
+ "01000000000000000000000000000000000000000000000000000000000000": string;
51
+ "02000000000000000000000000000000000000000000000000000000000000": string;
52
+ "03000000000000000000000000000000000000000000000000000000000000": string;
53
+ "04000000000000000000000000000000000000000000000000000000000000": string;
54
+ "05000000000000000000000000000000000000000000000000000000000000": string;
55
+ "06000000000000000000000000000000000000000000000000000000000000": string;
56
+ "07000000000000000000000000000000000000000000000000000000000000": string;
57
+ "08000000000000000000000000000000000000000000000000000000000000": string;
58
+ "09000000000000000000000000000000000000000000000000000000000000": string;
59
+ "0a000000000000000000000000000000000000000000000000000000000000": string;
60
+ "0b000000000000000000000000000000000000000000000000000000000000": string;
61
+ "0c000000000000000000000000000000000000000000000000000000000000": string;
62
+ "0d000000000000000000000000000000000000000000000000000000000000": string;
63
+ "0e000000000000000000000000000000000000000000000000000000000000": string;
64
+ "0f000000000000000000000000000000000000000000000000000000000000": string;
65
+ ff000000000000000000000000000000000000000000000000000000000000: string;
66
+ "00fe00ff00ff00ff6326432b5b3213dfd1609495e13c6b276cb474d6796453": string;
67
+ "00fe00ff00ff00fff8485e3a88e86182e63280720d5ec9892578f0e577fb1b": string;
68
+ "0023000000000000478648cd19b4f812f897a26976ecf312eac28508b4368d": string;
69
+ "004b000400000000f324d112c31c3778a072940b55dd35f3a4b77e72d2d2db": string;
70
+ };
71
+ };
72
+ database_base_path: string;
73
+ };
74
+ };
package/index.d.ts CHANGED
@@ -160,6 +160,10 @@ declare class Compatibility {
160
160
  }
161
161
  }
162
162
 
163
+ declare function isBrowser() {
164
+ return typeof process === "undefined" || typeof process.abort === "undefined";
165
+ }
166
+
163
167
  /**
164
168
  * A function to perform runtime assertions.
165
169
  *
@@ -278,20 +282,19 @@ declare function inspect<T>(val: T): string {
278
282
  }
279
283
 
280
284
  /** Utility function to measure time taken for some operation [ms]. */
281
- declare const measure =
282
- typeof process === "undefined"
283
- ? (id: string) => {
284
- const start = performance.now();
285
- return () => `${id} took ${performance.now() - start}ms`;
286
- }
287
- : (id: string) => {
288
- const start = process.hrtime.bigint();
289
- return () => {
290
- const tookNano = process.hrtime.bigint() - start;
291
- const tookMilli = Number(tookNano / 1_000_000n).toFixed(2);
292
- return `${id} took ${tookMilli}ms`;
293
- };
285
+ declare const measure = isBrowser()
286
+ ? (id: string) => {
287
+ const start = performance.now();
288
+ return () => `${id} took ${performance.now() - start}ms`;
289
+ }
290
+ : (id: string) => {
291
+ const start = process.hrtime.bigint();
292
+ return () => {
293
+ const tookNano = process.hrtime.bigint() - start;
294
+ const tookMilli = Number(tookNano / 1_000_000n).toFixed(2);
295
+ return `${id} took ${tookMilli}ms`;
294
296
  };
297
+ };
295
298
 
296
299
  /** A class that adds `toString` method that prints all properties of an object. */
297
300
  declare abstract class WithDebug {
@@ -778,6 +781,7 @@ declare const index$r_ensure: typeof ensure;
778
781
  declare const index$r_env: typeof env;
779
782
  declare const index$r_getAllKeysSorted: typeof getAllKeysSorted;
780
783
  declare const index$r_inspect: typeof inspect;
784
+ declare const index$r_isBrowser: typeof isBrowser;
781
785
  declare const index$r_isResult: typeof isResult;
782
786
  declare const index$r_isTaggedError: typeof isTaggedError;
783
787
  declare const index$r_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
@@ -788,7 +792,7 @@ declare const index$r_resultToString: typeof resultToString;
788
792
  declare const index$r_seeThrough: typeof seeThrough;
789
793
  declare const index$r_trimStack: typeof trimStack;
790
794
  declare namespace index$r {
791
- export { index$r_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$r_CURRENT_SUITE as CURRENT_SUITE, index$r_CURRENT_VERSION as CURRENT_VERSION, index$r_Compatibility as Compatibility, index$r_DEFAULT_SUITE as DEFAULT_SUITE, index$r_DEFAULT_VERSION as DEFAULT_VERSION, index$r_ErrorsCollector as ErrorsCollector, index$r_GpVersion as GpVersion, Result$2 as Result, index$r_RichTaggedError as RichTaggedError, index$r_TEST_COMPARE_USING as TEST_COMPARE_USING, index$r_TestSuite as TestSuite, index$r_WithDebug as WithDebug, index$r___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$r_asOpaqueType as asOpaqueType, index$r_assertEmpty as assertEmpty, index$r_assertNever as assertNever, index$r_callCompareFunction as callCompareFunction, index$r_cast as cast, index$r_check as check, index$r_deepEqual as deepEqual, index$r_ensure as ensure, index$r_env as env, index$r_getAllKeysSorted as getAllKeysSorted, index$r_inspect as inspect, index$r_isResult as isResult, index$r_isTaggedError as isTaggedError, index$r_maybeTaggedErrorToString as maybeTaggedErrorToString, index$r_measure as measure, index$r_parseCurrentSuite as parseCurrentSuite, index$r_parseCurrentVersion as parseCurrentVersion, index$r_resultToString as resultToString, index$r_seeThrough as seeThrough, index$r_trimStack as trimStack };
795
+ export { index$r_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$r_CURRENT_SUITE as CURRENT_SUITE, index$r_CURRENT_VERSION as CURRENT_VERSION, index$r_Compatibility as Compatibility, index$r_DEFAULT_SUITE as DEFAULT_SUITE, index$r_DEFAULT_VERSION as DEFAULT_VERSION, index$r_ErrorsCollector as ErrorsCollector, index$r_GpVersion as GpVersion, Result$2 as Result, index$r_RichTaggedError as RichTaggedError, index$r_TEST_COMPARE_USING as TEST_COMPARE_USING, index$r_TestSuite as TestSuite, index$r_WithDebug as WithDebug, index$r___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$r_asOpaqueType as asOpaqueType, index$r_assertEmpty as assertEmpty, index$r_assertNever as assertNever, index$r_callCompareFunction as callCompareFunction, index$r_cast as cast, index$r_check as check, index$r_deepEqual as deepEqual, index$r_ensure as ensure, index$r_env as env, index$r_getAllKeysSorted as getAllKeysSorted, index$r_inspect as inspect, index$r_isBrowser as isBrowser, index$r_isResult as isResult, index$r_isTaggedError as isTaggedError, index$r_maybeTaggedErrorToString as maybeTaggedErrorToString, index$r_measure as measure, index$r_parseCurrentSuite as parseCurrentSuite, index$r_parseCurrentVersion as parseCurrentVersion, index$r_resultToString as resultToString, index$r_seeThrough as seeThrough, index$r_trimStack as trimStack };
792
796
  export type { index$r_DeepEqualOptions as DeepEqualOptions, index$r_EnumMapping as EnumMapping, index$r_ErrorResult as ErrorResult, index$r_OK as OK, index$r_OkResult as OkResult, index$r_Opaque as Opaque, index$r_StringLiteral as StringLiteral, index$r_TaggedError as TaggedError, index$r_TokenOf as TokenOf, index$r_Uninstantiable as Uninstantiable, index$r_WithOpaque as WithOpaque };
793
797
  }
794
798
 
@@ -4456,6 +4460,84 @@ declare namespace index$m {
4456
4460
  export type { index$m_HashWithZeroedBit as HashWithZeroedBit, index$m_ImmutableHashDictionary as ImmutableHashDictionary, index$m_ImmutableHashSet as ImmutableHashSet, index$m_ImmutableSortedArray as ImmutableSortedArray, index$m_ImmutableSortedSet as ImmutableSortedSet, index$m_KeyMapper as KeyMapper, index$m_KeyMappers as KeyMappers, index$m_KnownSize as KnownSize, index$m_KnownSizeArray as KnownSizeArray, index$m_KnownSizeId as KnownSizeId, index$m_NestedMaps as NestedMaps };
4457
4461
  }
4458
4462
 
4463
+ declare namespace bandersnatch_d_exports {
4464
+ export { batch_verify_tickets, __wbg_init$2 as default, derive_public_key, initSync$2 as initSync, ring_commitment, verify_seal };
4465
+ export type { InitInput$2 as InitInput, InitOutput$2 as InitOutput, SyncInitInput$2 as SyncInitInput };
4466
+ }
4467
+ /* tslint:disable */
4468
+ /* eslint-disable */
4469
+ /**
4470
+ * @param {Uint8Array} keys
4471
+ * @returns {Uint8Array}
4472
+ */
4473
+ declare function ring_commitment(keys: Uint8Array): Uint8Array;
4474
+ /**
4475
+ * Derive Private and Public Key from Seed
4476
+ *
4477
+ * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
4478
+ * @param {Uint8Array} seed
4479
+ * @returns {Uint8Array}
4480
+ */
4481
+ declare function derive_public_key(seed: Uint8Array): Uint8Array;
4482
+ /**
4483
+ * Seal verification as defined in:
4484
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
4485
+ * or
4486
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
4487
+ * @param {Uint8Array} keys
4488
+ * @param {number} signer_key_index
4489
+ * @param {Uint8Array} seal_data
4490
+ * @param {Uint8Array} payload
4491
+ * @param {Uint8Array} aux_data
4492
+ * @returns {Uint8Array}
4493
+ */
4494
+ declare function verify_seal(keys: Uint8Array, signer_key_index: number, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
4495
+ /**
4496
+ * Verify multiple tickets at once as defined in:
4497
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
4498
+ *
4499
+ * NOTE: the aux_data of VRF function is empty!
4500
+ * @param {Uint8Array} keys
4501
+ * @param {Uint8Array} tickets_data
4502
+ * @param {number} vrf_input_data_len
4503
+ * @returns {Uint8Array}
4504
+ */
4505
+ declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
4506
+ type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
4507
+ interface InitOutput$2 {
4508
+ readonly memory: WebAssembly.Memory;
4509
+ readonly ring_commitment: (a: number, b: number, c: number) => void;
4510
+ readonly derive_public_key: (a: number, b: number, c: number) => void;
4511
+ readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
4512
+ readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
4513
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
4514
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
4515
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
4516
+ }
4517
+ type SyncInitInput$2 = BufferSource | WebAssembly.Module;
4518
+ /**
4519
+ * Instantiates the given `module`, which can either be bytes or
4520
+ * a precompiled `WebAssembly.Module`.
4521
+ *
4522
+ * @param {SyncInitInput} module
4523
+ *
4524
+ * @returns {InitOutput}
4525
+ */
4526
+ declare function initSync$2(module: SyncInitInput$2): InitOutput$2;
4527
+
4528
+ /**
4529
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
4530
+ * for everything else, calls `WebAssembly.instantiate` directly.
4531
+ *
4532
+ * @param {InitInput | Promise<InitInput>} module_or_path
4533
+ *
4534
+ * @returns {Promise<InitOutput>}
4535
+ */
4536
+ declare function __wbg_init$2(module_or_path?: InitInput$2 | Promise<InitInput$2>): Promise<InitOutput$2>;
4537
+ //#endregion
4538
+ //#region native/index.d.ts
4539
+ declare function initAll(): Promise<void>;
4540
+
4459
4541
  /** ED25519 private key size. */
4460
4542
  declare const ED25519_PRIV_KEY_BYTES = 32;
4461
4543
  type ED25519_PRIV_KEY_BYTES = typeof ED25519_PRIV_KEY_BYTES;
@@ -4548,7 +4630,7 @@ declare async function verify<T extends BytesBlob>(input: Input<T>[]): Promise<b
4548
4630
  offset += messageLength;
4549
4631
  }
4550
4632
 
4551
- const result = Array.from(verify_ed25519(data)).map((x) => x === 1);
4633
+ const result = Array.from(ed25519.verify_ed25519(data)).map((x) => x === 1);
4552
4634
  return Promise.resolve(result);
4553
4635
  }
4554
4636
 
@@ -4570,7 +4652,7 @@ declare async function verifyBatch<T extends BytesBlob>(input: Input<T>[]): Prom
4570
4652
 
4571
4653
  const data = BytesBlob.blobFromParts(first, ...rest).raw;
4572
4654
 
4573
- return Promise.resolve(verify_ed25519_batch(data));
4655
+ return Promise.resolve(ed25519.verify_ed25519_batch(data));
4574
4656
  }
4575
4657
 
4576
4658
  type ed25519_ED25519_KEY_BYTES = ED25519_KEY_BYTES;
@@ -4590,59 +4672,6 @@ declare namespace ed25519 {
4590
4672
  export type { ed25519_ED25519_KEY_BYTES as ED25519_KEY_BYTES, ed25519_ED25519_PRIV_KEY_BYTES as ED25519_PRIV_KEY_BYTES, ed25519_ED25519_SIGNATURE_BYTES as ED25519_SIGNATURE_BYTES, ed25519_Ed25519Key as Ed25519Key, ed25519_Ed25519Signature as Ed25519Signature, ed25519_Input as Input };
4591
4673
  }
4592
4674
 
4593
- /* tslint:disable */
4594
- /* eslint-disable */
4595
- /**
4596
- * @param {Uint8Array} keys
4597
- * @returns {Uint8Array}
4598
- */
4599
- declare function ring_commitment(keys: Uint8Array): Uint8Array;
4600
- /**
4601
- * Derive Private and Public Key from Seed
4602
- *
4603
- * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
4604
- * @param {Uint8Array} seed
4605
- * @returns {Uint8Array}
4606
- */
4607
- declare function derive_public_key(seed: Uint8Array): Uint8Array;
4608
- /**
4609
- * Seal verification as defined in:
4610
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
4611
- * or
4612
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
4613
- * @param {Uint8Array} keys
4614
- * @param {number} signer_key_index
4615
- * @param {Uint8Array} seal_data
4616
- * @param {Uint8Array} payload
4617
- * @param {Uint8Array} aux_data
4618
- * @returns {Uint8Array}
4619
- */
4620
- declare function verify_seal(keys: Uint8Array, signer_key_index: number, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
4621
- /**
4622
- * Verify multiple tickets at once as defined in:
4623
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
4624
- *
4625
- * NOTE: the aux_data of VRF function is empty!
4626
- * @param {Uint8Array} keys
4627
- * @param {Uint8Array} tickets_data
4628
- * @param {number} vrf_input_data_len
4629
- * @returns {Uint8Array}
4630
- */
4631
- declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
4632
-
4633
- declare const bandersnatch_d_batch_verify_tickets: typeof batch_verify_tickets;
4634
- declare const bandersnatch_d_derive_public_key: typeof derive_public_key;
4635
- declare const bandersnatch_d_ring_commitment: typeof ring_commitment;
4636
- declare const bandersnatch_d_verify_seal: typeof verify_seal;
4637
- declare namespace bandersnatch_d {
4638
- export {
4639
- bandersnatch_d_batch_verify_tickets as batch_verify_tickets,
4640
- bandersnatch_d_derive_public_key as derive_public_key,
4641
- bandersnatch_d_ring_commitment as ring_commitment,
4642
- bandersnatch_d_verify_seal as verify_seal,
4643
- };
4644
- }
4645
-
4646
4675
  /** Bandersnatch public key size. */
4647
4676
  declare const BANDERSNATCH_KEY_BYTES = 32;
4648
4677
  type BANDERSNATCH_KEY_BYTES = typeof BANDERSNATCH_KEY_BYTES;
@@ -4700,7 +4729,7 @@ type BlsKey = Opaque<Bytes<BLS_KEY_BYTES>, "BlsKey">;
4700
4729
 
4701
4730
  /** Derive a Bandersnatch public key from a seed. */
4702
4731
  declare function publicKey(seed: Uint8Array): BandersnatchKey {
4703
- const key = derive_public_key(seed);
4732
+ const key = bandersnatch.derive_public_key(seed);
4704
4733
 
4705
4734
  check(key[0] === 0, "Invalid Bandersnatch public key derived from seed");
4706
4735
 
@@ -4826,7 +4855,7 @@ declare const index$l_bandersnatch: typeof bandersnatch;
4826
4855
  declare const index$l_ed25519: typeof ed25519;
4827
4856
  declare const index$l_keyDerivation: typeof keyDerivation;
4828
4857
  declare namespace index$l {
4829
- export { index$l_Ed25519Pair as Ed25519Pair, index$l_bandersnatch as bandersnatch, bandersnatch_d as bandersnatchWasm, index$l_ed25519 as ed25519, index$l_keyDerivation as keyDerivation };
4858
+ export { index$l_Ed25519Pair as Ed25519Pair, index$l_bandersnatch as bandersnatch, bandersnatch_d_exports as bandersnatchWasm, index$l_ed25519 as ed25519, initAll as initWasm, index$l_keyDerivation as keyDerivation };
4830
4859
  export type { index$l_BANDERSNATCH_KEY_BYTES as BANDERSNATCH_KEY_BYTES, index$l_BANDERSNATCH_PROOF_BYTES as BANDERSNATCH_PROOF_BYTES, index$l_BANDERSNATCH_RING_ROOT_BYTES as BANDERSNATCH_RING_ROOT_BYTES, index$l_BANDERSNATCH_VRF_SIGNATURE_BYTES as BANDERSNATCH_VRF_SIGNATURE_BYTES, index$l_BLS_KEY_BYTES as BLS_KEY_BYTES, index$l_BandersnatchKey as BandersnatchKey, index$l_BandersnatchProof as BandersnatchProof, index$l_BandersnatchRingRoot as BandersnatchRingRoot, index$l_BandersnatchSecretSeed as BandersnatchSecretSeed, index$l_BandersnatchVrfSignature as BandersnatchVrfSignature, index$l_BlsKey as BlsKey, index$l_ED25519_KEY_BYTES as ED25519_KEY_BYTES, index$l_ED25519_PRIV_KEY_BYTES as ED25519_PRIV_KEY_BYTES, index$l_ED25519_SIGNATURE_BYTES as ED25519_SIGNATURE_BYTES, index$l_Ed25519Key as Ed25519Key, index$l_Ed25519SecretSeed as Ed25519SecretSeed, index$l_Ed25519Signature as Ed25519Signature, KeySeed as PublicKeySeed, index$l_SEED_SIZE as SEED_SIZE };
4831
4860
  }
4832
4861
 
@@ -7820,7 +7849,7 @@ declare const DEV_CONFIG = "dev";
7820
7849
  declare const DEFAULT_CONFIG = "default";
7821
7850
 
7822
7851
  declare const NODE_DEFAULTS = {
7823
- name: os.hostname(),
7852
+ name: isBrowser() ? "browser" : os.hostname(),
7824
7853
  config: DEFAULT_CONFIG,
7825
7854
  };
7826
7855
 
@@ -7875,11 +7904,11 @@ declare class NodeConfiguration {
7875
7904
 
7876
7905
  declare function loadConfig(configPath: string): NodeConfiguration {
7877
7906
  if (configPath === DEFAULT_CONFIG) {
7878
- return parseFromJson(defaultConfigJson, NodeConfiguration.fromJson);
7907
+ return parseFromJson(configs.default, NodeConfiguration.fromJson);
7879
7908
  }
7880
7909
 
7881
7910
  if (configPath === DEV_CONFIG) {
7882
- return parseFromJson(devConfigJson, NodeConfiguration.fromJson);
7911
+ return parseFromJson(configs.dev, NodeConfiguration.fromJson);
7883
7912
  }
7884
7913
 
7885
7914
  try {
@@ -12245,8 +12274,8 @@ declare function encodePoints(input: Bytes<PIECE_SIZE>): FixedSizeArray<Bytes<PO
12245
12274
  }
12246
12275
 
12247
12276
  // encode and add redundancy shards
12248
- const points = new ShardsCollection(POINT_ALIGNMENT, data);
12249
- const encodedResult = encode(N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12277
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data);
12278
+ const encodedResult = reedSolomon.encode(N_CHUNKS_REDUNDANCY, points);
12250
12279
  const encodedData = encodedResult.take_data();
12251
12280
 
12252
12281
  for (let i = 0; i < N_CHUNKS_REDUNDANCY; i++) {
@@ -12288,9 +12317,9 @@ declare function decodePiece(
12288
12317
  result.raw.set(points.raw, pointStartInResult);
12289
12318
  }
12290
12319
  }
12291
- const points = new ShardsCollection(POINT_ALIGNMENT, data, indices);
12320
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data, indices);
12292
12321
 
12293
- const decodingResult = decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12322
+ const decodingResult = reedSolomon.decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, points);
12294
12323
  const resultIndices = decodingResult.take_indices(); // it has to be called before take_data
12295
12324
  const resultData = decodingResult.take_data(); // it destroys the result object in rust
12296
12325
 
@@ -12527,6 +12556,10 @@ declare function chunksToShards(
12527
12556
  return tryAsPerValidator(result, spec);
12528
12557
  }
12529
12558
 
12559
+ declare const initEc = async () => {
12560
+ await init.reedSolomon();
12561
+ };
12562
+
12530
12563
  declare const index$a_HALF_POINT_SIZE: typeof HALF_POINT_SIZE;
12531
12564
  declare const index$a_N_CHUNKS_REDUNDANCY: typeof N_CHUNKS_REDUNDANCY;
12532
12565
  type index$a_N_CHUNKS_REQUIRED = N_CHUNKS_REQUIRED;
@@ -12540,6 +12573,7 @@ declare const index$a_decodeData: typeof decodeData;
12540
12573
  declare const index$a_decodeDataAndTrim: typeof decodeDataAndTrim;
12541
12574
  declare const index$a_decodePiece: typeof decodePiece;
12542
12575
  declare const index$a_encodePoints: typeof encodePoints;
12576
+ declare const index$a_initEc: typeof initEc;
12543
12577
  declare const index$a_join: typeof join;
12544
12578
  declare const index$a_lace: typeof lace;
12545
12579
  declare const index$a_padAndEncodeData: typeof padAndEncodeData;
@@ -12548,7 +12582,7 @@ declare const index$a_split: typeof split;
12548
12582
  declare const index$a_transpose: typeof transpose;
12549
12583
  declare const index$a_unzip: typeof unzip;
12550
12584
  declare namespace index$a {
12551
- export { index$a_HALF_POINT_SIZE as HALF_POINT_SIZE, index$a_N_CHUNKS_REDUNDANCY as N_CHUNKS_REDUNDANCY, index$a_POINT_ALIGNMENT as POINT_ALIGNMENT, index$a_chunkingFunction as chunkingFunction, index$a_chunksToShards as chunksToShards, index$a_decodeData as decodeData, index$a_decodeDataAndTrim as decodeDataAndTrim, index$a_decodePiece as decodePiece, index$a_encodePoints as encodePoints, index$a_join as join, index$a_lace as lace, index$a_padAndEncodeData as padAndEncodeData, index$a_shardsToChunks as shardsToChunks, index$a_split as split, index$a_transpose as transpose, index$a_unzip as unzip };
12585
+ export { index$a_HALF_POINT_SIZE as HALF_POINT_SIZE, index$a_N_CHUNKS_REDUNDANCY as N_CHUNKS_REDUNDANCY, index$a_POINT_ALIGNMENT as POINT_ALIGNMENT, index$a_chunkingFunction as chunkingFunction, index$a_chunksToShards as chunksToShards, index$a_decodeData as decodeData, index$a_decodeDataAndTrim as decodeDataAndTrim, index$a_decodePiece as decodePiece, index$a_encodePoints as encodePoints, index$a_initEc as initEc, index$a_join as join, index$a_lace as lace, index$a_padAndEncodeData as padAndEncodeData, index$a_shardsToChunks as shardsToChunks, index$a_split as split, index$a_transpose as transpose, index$a_unzip as unzip };
12552
12586
  export type { index$a_N_CHUNKS_REQUIRED as N_CHUNKS_REQUIRED, index$a_N_CHUNKS_TOTAL as N_CHUNKS_TOTAL, index$a_PIECE_SIZE as PIECE_SIZE, index$a_POINT_LENGTH as POINT_LENGTH };
12553
12587
  }
12554
12588
 
@@ -13839,13 +13873,14 @@ declare abstract class MemoryPage {
13839
13873
  * And then a new version of TypeScript is released.
13840
13874
  */
13841
13875
  declare global {
13842
- interface ArrayBufferConstructor {
13843
- new (length: number, options?: { maxByteLength: number }): ArrayBuffer;
13844
- }
13845
-
13846
- interface ArrayBuffer {
13847
- resize(length: number): void;
13848
- }
13876
+ interface ArrayBufferConstructor {
13877
+ new (length: number, options?: {
13878
+ maxByteLength: number;
13879
+ }): ArrayBuffer;
13880
+ }
13881
+ interface ArrayBuffer {
13882
+ resize(length: number): void;
13883
+ }
13849
13884
  }
13850
13885
 
13851
13886
  type InitialMemoryState = {
@@ -16320,12 +16355,6 @@ declare class Interpreter {
16320
16355
  }
16321
16356
 
16322
16357
  if (this.instructionResult.status !== null) {
16323
- // All abnormal terminations should be interpreted as TRAP and we should subtract the gas. In case of FAULT we have to do it manually at the very end.
16324
- if (this.instructionResult.status === Result.FAULT || this.instructionResult.status === Result.FAULT_ACCESS) {
16325
- // TODO [ToDr] underflow?
16326
- this.gas.sub(instructionGasMap[Instruction.TRAP]);
16327
- }
16328
-
16329
16358
  switch (this.instructionResult.status) {
16330
16359
  case Result.FAULT:
16331
16360
  this.status = Status.FAULT;
@@ -16684,7 +16713,7 @@ declare class HostCalls {
16684
16713
  this.hostCalls.traceHostCall("Invoking", index, hostCall, regs, gasBefore);
16685
16714
  const result = await hostCall.execute(gas, regs, memory);
16686
16715
  this.hostCalls.traceHostCall(
16687
- result === undefined ? "Result" : `Status(${result})`,
16716
+ result === undefined ? "Result" : `Status(${PvmExecution[result]})`,
16688
16717
  index,
16689
16718
  hostCall,
16690
16719
  regs,
@@ -18036,6 +18065,7 @@ declare const index$3_getServiceId: typeof getServiceId;
18036
18065
  declare const index$3_getServiceIdOrCurrent: typeof getServiceIdOrCurrent;
18037
18066
  declare const index$3_inspect: typeof inspect;
18038
18067
  declare const index$3_instructionArgumentTypeMap: typeof instructionArgumentTypeMap;
18068
+ declare const index$3_isBrowser: typeof isBrowser;
18039
18069
  declare const index$3_isTaggedError: typeof isTaggedError;
18040
18070
  declare const index$3_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
18041
18071
  declare const index$3_measure: typeof measure;
@@ -18048,7 +18078,7 @@ declare const index$3_tryAsMachineId: typeof tryAsMachineId;
18048
18078
  declare const index$3_tryAsProgramCounter: typeof tryAsProgramCounter;
18049
18079
  declare const index$3_writeServiceIdAsLeBytes: typeof writeServiceIdAsLeBytes;
18050
18080
  declare namespace index$3 {
18051
- export { index$3_AccumulationStateUpdate as AccumulationStateUpdate, index$3_ArgsDecoder as ArgsDecoder, index$3_ArgumentType as ArgumentType, index$3_BasicBlocks as BasicBlocks, index$3_CURRENT_SERVICE_ID as CURRENT_SERVICE_ID, index$3_EjectError as EjectError, index$3_ExtendedWitdthImmediateDecoder as ExtendedWitdthImmediateDecoder, index$3_ForgetPreimageError as ForgetPreimageError, index$3_HostCallMemory as HostCallMemory, index$3_HostCallRegisters as HostCallRegisters, index$3_HostCallResult as HostCallResult, index$3_ImmediateDecoder as ImmediateDecoder, index$3_MAX_U32 as MAX_U32, index$3_MAX_U32_BIG_INT as MAX_U32_BIG_INT, index$3_MachineInstance as MachineInstance, index$3_Mask as Mask, index$3_MemoryOperation as MemoryOperation, index$3_MemorySegment as MemorySegment, NO_OF_REGISTERS$1 as NO_OF_REGISTERS, index$3_NewServiceError as NewServiceError, index$3_NibblesDecoder as NibblesDecoder, index$3_PagesError as PagesError, index$3_PartiallyUpdatedState as PartiallyUpdatedState, index$3_PeekPokeError as PeekPokeError, index$3_PendingTransfer as PendingTransfer, index$3_PreimageStatusKind as PreimageStatusKind, index$3_Program as Program, index$3_ProgramDecoder as ProgramDecoder, index$3_ProvidePreimageError as ProvidePreimageError, DebuggerAdapter as Pvm, index$3_Registers as Registers, index$3_RequestPreimageError as RequestPreimageError, Result$2 as Result, index$3_RichTaggedError as RichTaggedError, index$3_SERVICE_ID_BYTES as SERVICE_ID_BYTES, index$3_SpiMemory as SpiMemory, index$3_SpiProgram as SpiProgram, index$3_TransferError as TransferError, index$3_UpdatePrivilegesError as UpdatePrivilegesError, index$3_WithDebug as WithDebug, index$3_ZeroVoidError as ZeroVoidError, index$3___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$3_asOpaqueType as asOpaqueType, index$3_assertEmpty as assertEmpty, index$3_assertNever as assertNever, index$j as block, index$q as bytes, index$3_cast as cast, index$3_check as check, index$3_clampU64ToU32 as clampU64ToU32, index$3_createResults as createResults, index$3_decodeStandardProgram as decodeStandardProgram, index$3_ensure as ensure, index$3_extractCodeAndMetadata as extractCodeAndMetadata, index$3_getServiceId as getServiceId, index$3_getServiceIdOrCurrent as getServiceIdOrCurrent, index$n as hash, index$3_inspect as inspect, index$3_instructionArgumentTypeMap as instructionArgumentTypeMap, index$8 as interpreter, index$3_isTaggedError as isTaggedError, index$3_maybeTaggedErrorToString as maybeTaggedErrorToString, index$3_measure as measure, index$p as numbers, index$3_preimageLenAsU32 as preimageLenAsU32, index$3_resultToString as resultToString, index$3_seeThrough as seeThrough, index$3_slotsToPreimageStatus as slotsToPreimageStatus, index$3_toMemoryOperation as toMemoryOperation, index$3_tryAsMachineId as tryAsMachineId, index$3_tryAsProgramCounter as tryAsProgramCounter, index$3_writeServiceIdAsLeBytes as writeServiceIdAsLeBytes };
18081
+ export { index$3_AccumulationStateUpdate as AccumulationStateUpdate, index$3_ArgsDecoder as ArgsDecoder, index$3_ArgumentType as ArgumentType, index$3_BasicBlocks as BasicBlocks, index$3_CURRENT_SERVICE_ID as CURRENT_SERVICE_ID, index$3_EjectError as EjectError, index$3_ExtendedWitdthImmediateDecoder as ExtendedWitdthImmediateDecoder, index$3_ForgetPreimageError as ForgetPreimageError, index$3_HostCallMemory as HostCallMemory, index$3_HostCallRegisters as HostCallRegisters, index$3_HostCallResult as HostCallResult, index$3_ImmediateDecoder as ImmediateDecoder, index$3_MAX_U32 as MAX_U32, index$3_MAX_U32_BIG_INT as MAX_U32_BIG_INT, index$3_MachineInstance as MachineInstance, index$3_Mask as Mask, index$3_MemoryOperation as MemoryOperation, index$3_MemorySegment as MemorySegment, NO_OF_REGISTERS$1 as NO_OF_REGISTERS, index$3_NewServiceError as NewServiceError, index$3_NibblesDecoder as NibblesDecoder, index$3_PagesError as PagesError, index$3_PartiallyUpdatedState as PartiallyUpdatedState, index$3_PeekPokeError as PeekPokeError, index$3_PendingTransfer as PendingTransfer, index$3_PreimageStatusKind as PreimageStatusKind, index$3_Program as Program, index$3_ProgramDecoder as ProgramDecoder, index$3_ProvidePreimageError as ProvidePreimageError, DebuggerAdapter as Pvm, index$3_Registers as Registers, index$3_RequestPreimageError as RequestPreimageError, Result$2 as Result, index$3_RichTaggedError as RichTaggedError, index$3_SERVICE_ID_BYTES as SERVICE_ID_BYTES, index$3_SpiMemory as SpiMemory, index$3_SpiProgram as SpiProgram, index$3_TransferError as TransferError, index$3_UpdatePrivilegesError as UpdatePrivilegesError, index$3_WithDebug as WithDebug, index$3_ZeroVoidError as ZeroVoidError, index$3___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$3_asOpaqueType as asOpaqueType, index$3_assertEmpty as assertEmpty, index$3_assertNever as assertNever, index$j as block, index$q as bytes, index$3_cast as cast, index$3_check as check, index$3_clampU64ToU32 as clampU64ToU32, index$3_createResults as createResults, index$3_decodeStandardProgram as decodeStandardProgram, index$3_ensure as ensure, index$3_extractCodeAndMetadata as extractCodeAndMetadata, index$3_getServiceId as getServiceId, index$3_getServiceIdOrCurrent as getServiceIdOrCurrent, index$n as hash, index$3_inspect as inspect, index$3_instructionArgumentTypeMap as instructionArgumentTypeMap, index$8 as interpreter, index$3_isBrowser as isBrowser, index$3_isTaggedError as isTaggedError, index$3_maybeTaggedErrorToString as maybeTaggedErrorToString, index$3_measure as measure, index$p as numbers, index$3_preimageLenAsU32 as preimageLenAsU32, index$3_resultToString as resultToString, index$3_seeThrough as seeThrough, index$3_slotsToPreimageStatus as slotsToPreimageStatus, index$3_toMemoryOperation as toMemoryOperation, index$3_tryAsMachineId as tryAsMachineId, index$3_tryAsProgramCounter as tryAsProgramCounter, index$3_writeServiceIdAsLeBytes as writeServiceIdAsLeBytes };
18052
18082
  export type { index$3_Args as Args, index$3_EnumMapping as EnumMapping, index$3_ErrorResult as ErrorResult, index$3_IHostCallMemory as IHostCallMemory, index$3_IHostCallRegisters as IHostCallRegisters, index$3_InsufficientFundsError as InsufficientFundsError, index$3_MachineId as MachineId, index$3_MachineResult as MachineResult, index$3_MachineStatus as MachineStatus, index$3_NoMachineError as NoMachineError, index$3_OK as OK, index$3_OkResult as OkResult, index$3_Opaque as Opaque, index$3_PartialState as PartialState, index$3_PreimageStatus as PreimageStatus, index$3_ProgramCounter as ProgramCounter, index$3_RefineExternalities as RefineExternalities, index$3_SegmentExportError as SegmentExportError, index$3_ServiceStateUpdate as ServiceStateUpdate, index$3_StateSlice as StateSlice, index$3_StringLiteral as StringLiteral, index$3_TRANSFER_MEMO_BYTES as TRANSFER_MEMO_BYTES, index$3_TaggedError as TaggedError, index$3_TokenOf as TokenOf, index$3_Uninstantiable as Uninstantiable, index$3_UnprivilegedError as UnprivilegedError, index$3_WithOpaque as WithOpaque };
18053
18083
  }
18054
18084