@midnight-ntwrk/wallet-sdk-capabilities 4.0.0-beta.2 → 4.0.0-beta.4

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.
Files changed (68) hide show
  1. package/README.md +27 -3
  2. package/dist/chainVersion/chainVersionProbe.d.ts +95 -0
  3. package/dist/chainVersion/chainVersionProbe.js +83 -0
  4. package/dist/chainVersion/index.d.ts +1 -0
  5. package/dist/chainVersion/index.js +13 -0
  6. package/dist/codecs/index.d.ts +1 -0
  7. package/dist/codecs/index.js +13 -0
  8. package/dist/codecs/ledgerParameters.d.ts +81 -0
  9. package/dist/codecs/ledgerParameters.js +63 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.js +3 -0
  12. package/dist/pendingTransactions/pendingTransactions.d.ts +113 -9
  13. package/dist/pendingTransactions/pendingTransactions.js +147 -30
  14. package/dist/pendingTransactions/pendingTransactionsService.d.ts +25 -9
  15. package/dist/pendingTransactions/pendingTransactionsService.js +33 -21
  16. package/dist/proving/index.d.ts +2 -0
  17. package/dist/proving/index.js +2 -0
  18. package/dist/proving/provingService.d.ts +184 -15
  19. package/dist/proving/provingService.js +114 -12
  20. package/dist/proving/v8ProvingService.d.ts +53 -0
  21. package/dist/proving/v8ProvingService.js +71 -0
  22. package/dist/proving/versionedProving.d.ts +42 -0
  23. package/dist/proving/versionedProving.js +103 -0
  24. package/dist/signatures/index.d.ts +2 -0
  25. package/dist/signatures/index.js +14 -0
  26. package/dist/signatures/signing.d.ts +37 -0
  27. package/dist/signatures/signing.js +13 -0
  28. package/dist/signatures/v8Signatures.d.ts +54 -0
  29. package/dist/signatures/v8Signatures.js +62 -0
  30. package/dist/simulation/ForkSimulator.d.ts +114 -0
  31. package/dist/simulation/ForkSimulator.js +209 -0
  32. package/dist/simulation/LedgerTranslation.d.ts +53 -0
  33. package/dist/simulation/LedgerTranslation.js +56 -0
  34. package/dist/simulation/core/VersionTimeline.d.ts +54 -0
  35. package/dist/simulation/core/VersionTimeline.js +56 -0
  36. package/dist/simulation/core/blocks.d.ts +38 -0
  37. package/dist/simulation/core/blocks.js +52 -0
  38. package/dist/simulation/core/index.d.ts +13 -0
  39. package/dist/simulation/core/index.js +25 -0
  40. package/dist/simulation/core/strictness.d.ts +29 -0
  41. package/dist/simulation/core/strictness.js +39 -0
  42. package/dist/simulation/index.d.ts +22 -2
  43. package/dist/simulation/index.js +25 -14
  44. package/dist/simulation/v8/Simulator.d.ts +231 -0
  45. package/dist/simulation/v8/Simulator.js +503 -0
  46. package/dist/simulation/{SimulatorState.d.ts → v8/SimulatorState.d.ts} +31 -44
  47. package/dist/simulation/v8/SimulatorState.js +290 -0
  48. package/dist/simulation/v8/index.d.ts +2 -0
  49. package/dist/simulation/v8/index.js +26 -0
  50. package/dist/simulation/{Simulator.d.ts → v9/Simulator.d.ts} +57 -6
  51. package/dist/simulation/{Simulator.js → v9/Simulator.js} +68 -18
  52. package/dist/simulation/v9/SimulatorState.d.ts +336 -0
  53. package/dist/simulation/{SimulatorState.js → v9/SimulatorState.js} +34 -67
  54. package/dist/simulation/v9/index.d.ts +2 -0
  55. package/dist/simulation/v9/index.js +26 -0
  56. package/dist/submission/submissionService.d.ts +2 -1
  57. package/dist/submission/submissionService.js +1 -1
  58. package/dist/validation/blockData.d.ts +42 -2
  59. package/dist/validation/blockData.js +55 -8
  60. package/dist/validation/index.d.ts +2 -0
  61. package/dist/validation/index.js +2 -0
  62. package/dist/validation/v8ValidationService.d.ts +29 -0
  63. package/dist/validation/v8ValidationService.js +48 -0
  64. package/dist/validation/validationService.d.ts +132 -17
  65. package/dist/validation/validationService.js +88 -42
  66. package/dist/validation/versionedValidation.d.ts +46 -0
  67. package/dist/validation/versionedValidation.js +55 -0
  68. package/package.json +28 -14
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Translating a ledger-v8 state into a ledger-v9 one.
3
+ *
4
+ * The translation itself is a ledger-side tool reached across a WASM boundary, so this module only describes the seam,
5
+ * never the mechanism: serialized bytes in, serialized bytes out, as an `Effect`. Bytes because that is the only thing
6
+ * that crosses the boundary — neither ledger's state objects exist in the other's WASM module. An `Effect` because the
7
+ * tool has to be loaded and then run to completion (it translates incrementally, under a cost budget per step), and
8
+ * both are the translator's business rather than the caller's.
9
+ */
10
+ import { Effect } from 'effect';
11
+ declare const LedgerTranslationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
12
+ readonly _tag: "LedgerTranslationError";
13
+ } & Readonly<A>;
14
+ /** Thrown when a ledger-v8 state cannot be translated into a ledger-v9 one. */
15
+ export declare class LedgerTranslationError extends LedgerTranslationError_base<{
16
+ message: string;
17
+ cause?: unknown;
18
+ }> {
19
+ }
20
+ /**
21
+ * Translates a serialized ledger-v8 state into a serialized ledger-v9 one.
22
+ *
23
+ * Implementations own loading whatever performs the translation and running it to completion. Deserializing the result
24
+ * is the caller's, so bytes that are not valid ledger-v9 state are reported as a translation failure.
25
+ */
26
+ export type LedgerStateTranslator = (v8State: Uint8Array) => Effect.Effect<Uint8Array, LedgerTranslationError>;
27
+ /**
28
+ * Build a translator from an async function, turning anything it throws or rejects with into a
29
+ * {@link LedgerTranslationError}.
30
+ *
31
+ * This is how the WASM tool is meant to be plugged in: its call is asynchronous and it signals failure by throwing, so
32
+ * this is the whole adapter.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const translator = translatorFromAsync(async (bytes) => {
37
+ * const tool = await loadStateTranslation();
38
+ * return tool.translate(bytes);
39
+ * });
40
+ * ```;
41
+ *
42
+ * @param translate - Async translation of serialized ledger-v8 state into serialized ledger-v9 state
43
+ * @returns A translator over that function
44
+ */
45
+ export declare const translatorFromAsync: (translate: (v8State: Uint8Array) => Promise<Uint8Array>) => LedgerStateTranslator;
46
+ /**
47
+ * A translator that always fails, standing in for the real tool until it exists.
48
+ *
49
+ * Useful as an explicit default: a fork configured with it fails loudly at the boundary, rather than silently crossing
50
+ * it with state that was never translated.
51
+ */
52
+ export declare const unavailableTranslator: LedgerStateTranslator;
53
+ export {};
@@ -0,0 +1,56 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * Translating a ledger-v8 state into a ledger-v9 one.
15
+ *
16
+ * The translation itself is a ledger-side tool reached across a WASM boundary, so this module only describes the seam,
17
+ * never the mechanism: serialized bytes in, serialized bytes out, as an `Effect`. Bytes because that is the only thing
18
+ * that crosses the boundary — neither ledger's state objects exist in the other's WASM module. An `Effect` because the
19
+ * tool has to be loaded and then run to completion (it translates incrementally, under a cost budget per step), and
20
+ * both are the translator's business rather than the caller's.
21
+ */
22
+ import { Data, Effect } from 'effect';
23
+ /** Thrown when a ledger-v8 state cannot be translated into a ledger-v9 one. */
24
+ export class LedgerTranslationError extends Data.TaggedError('LedgerTranslationError') {
25
+ }
26
+ /**
27
+ * Build a translator from an async function, turning anything it throws or rejects with into a
28
+ * {@link LedgerTranslationError}.
29
+ *
30
+ * This is how the WASM tool is meant to be plugged in: its call is asynchronous and it signals failure by throwing, so
31
+ * this is the whole adapter.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const translator = translatorFromAsync(async (bytes) => {
36
+ * const tool = await loadStateTranslation();
37
+ * return tool.translate(bytes);
38
+ * });
39
+ * ```;
40
+ *
41
+ * @param translate - Async translation of serialized ledger-v8 state into serialized ledger-v9 state
42
+ * @returns A translator over that function
43
+ */
44
+ export const translatorFromAsync = (translate) => (v8State) => Effect.tryPromise({
45
+ try: () => translate(v8State),
46
+ catch: (cause) => new LedgerTranslationError({ message: 'Ledger state translation failed', cause }),
47
+ });
48
+ /**
49
+ * A translator that always fails, standing in for the real tool until it exists.
50
+ *
51
+ * Useful as an explicit default: a fork configured with it fails loudly at the boundary, rather than silently crossing
52
+ * it with state that was never translated.
53
+ */
54
+ export const unavailableTranslator = () => Effect.fail(new LedgerTranslationError({
55
+ message: 'A v8-to-v9 ledger state translation is not yet available; supply a translator explicitly',
56
+ }));
@@ -0,0 +1,54 @@
1
+ import { type ProtocolVersion } from '@midnight-ntwrk/wallet-sdk-abstractions';
2
+ /**
3
+ * A protocol version scheduled to activate at a block height — a fork on the simulated chain.
4
+ *
5
+ * The version itself is always supplied by the caller: the protocol version of the real fork is not final, so nothing
6
+ * in the simulator may assume a particular value.
7
+ */
8
+ export type ScheduledFork = Readonly<{
9
+ /** Height of the first block produced under {@link version}. */
10
+ atBlock: bigint;
11
+ /** Version that activates at {@link atBlock}. */
12
+ version: ProtocolVersion.ProtocolVersion;
13
+ }>;
14
+ /**
15
+ * The version-timeline part of a simulator state — the current version plus any scheduled activations.
16
+ *
17
+ * Every simulator state satisfies this structurally, so the functions below apply to all of them without knowing which
18
+ * ledger the state's other fields belong to.
19
+ */
20
+ export type VersionTimeline = Readonly<{
21
+ protocolVersion: ProtocolVersion.ProtocolVersion;
22
+ scheduledForks: readonly ScheduledFork[];
23
+ }>;
24
+ /** Get the protocol version the chain is currently on. */
25
+ export declare const getProtocolVersion: (timeline: VersionTimeline) => ProtocolVersion.ProtocolVersion;
26
+ /**
27
+ * Resolve the protocol version a block of the given height is produced under: the highest scheduled version whose
28
+ * activation height has been reached, or the chain's current version when no schedule applies.
29
+ *
30
+ * Scheduling a version at a height the chain has already passed therefore activates it on the next block rather than
31
+ * rewriting history — produced blocks keep the version they were produced under.
32
+ *
33
+ * @param timeline - Current version timeline
34
+ * @param blockNumber - Height of the block being produced
35
+ */
36
+ export declare const protocolVersionAt: {
37
+ (blockNumber: bigint): (timeline: VersionTimeline) => ProtocolVersion.ProtocolVersion;
38
+ (timeline: VersionTimeline, blockNumber: bigint): ProtocolVersion.ProtocolVersion;
39
+ };
40
+ /**
41
+ * Set the protocol version blocks produced from now on are stamped with. Already-produced blocks are untouched.
42
+ *
43
+ * @param state - Current simulator state
44
+ * @param version - Version to switch the chain to
45
+ */
46
+ export declare const setProtocolVersion: <TState extends VersionTimeline>(state: TState, version: ProtocolVersion.ProtocolVersion) => TState;
47
+ /**
48
+ * Schedule a protocol version to activate at a block height — a fork on the simulated chain.
49
+ *
50
+ * @param state - Current simulator state
51
+ * @param atBlock - Height of the first block produced under `version`
52
+ * @param version - Version that activates at `atBlock`
53
+ */
54
+ export declare const scheduleFork: <TState extends VersionTimeline>(state: TState, atBlock: bigint, version: ProtocolVersion.ProtocolVersion) => TState;
@@ -0,0 +1,56 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * A simulated chain's protocol-version timeline.
15
+ *
16
+ * Which protocol version a chain is on, and when it changes, is the same question whichever ledger the chain runs — so
17
+ * it is answered once here and shared by every simulator, rather than duplicated per ledger version.
18
+ *
19
+ * Nothing in this module refers to a ledger type. Functions are stated over the smallest structure they need
20
+ * ({@link VersionTimeline}), which every simulator state satisfies.
21
+ */
22
+ import { Function as EFunction } from 'effect';
23
+ /** Get the protocol version the chain is currently on. */
24
+ export const getProtocolVersion = (timeline) => timeline.protocolVersion;
25
+ /**
26
+ * Resolve the protocol version a block of the given height is produced under: the highest scheduled version whose
27
+ * activation height has been reached, or the chain's current version when no schedule applies.
28
+ *
29
+ * Scheduling a version at a height the chain has already passed therefore activates it on the next block rather than
30
+ * rewriting history — produced blocks keep the version they were produced under.
31
+ *
32
+ * @param timeline - Current version timeline
33
+ * @param blockNumber - Height of the block being produced
34
+ */
35
+ export const protocolVersionAt = EFunction.dual(2, (timeline, blockNumber) => timeline.scheduledForks.reduce((version, fork) => (fork.atBlock <= blockNumber && fork.version > version ? fork.version : version), timeline.protocolVersion));
36
+ /**
37
+ * Set the protocol version blocks produced from now on are stamped with. Already-produced blocks are untouched.
38
+ *
39
+ * @param state - Current simulator state
40
+ * @param version - Version to switch the chain to
41
+ */
42
+ export const setProtocolVersion = (state, version) => ({
43
+ ...state,
44
+ protocolVersion: version,
45
+ });
46
+ /**
47
+ * Schedule a protocol version to activate at a block height — a fork on the simulated chain.
48
+ *
49
+ * @param state - Current simulator state
50
+ * @param atBlock - Height of the first block produced under `version`
51
+ * @param version - Version that activates at `atBlock`
52
+ */
53
+ export const scheduleFork = (state, atBlock, version) => ({
54
+ ...state,
55
+ scheduledForks: [...state.scheduledForks, { atBlock, version }],
56
+ });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The context a block is executed against.
3
+ *
4
+ * Structurally the ledger's own `BlockContext`, which is a plain record and is defined identically by ledger-v8 and
5
+ * ledger-v9 — so it is stated once here and a value of this type is accepted by either ledger.
6
+ */
7
+ export type BlockContext = Readonly<{
8
+ /** Hash of the parent block */
9
+ parentBlockHash: string;
10
+ /** Seconds elapsed since the UNIX epoch */
11
+ secondsSinceEpoch: bigint;
12
+ /** Maximum expected error on {@link secondsSinceEpoch}, as a positive number of seconds */
13
+ secondsSinceEpochErr: number;
14
+ /** Seconds since the previous block */
15
+ lastBlockTime: bigint;
16
+ }>;
17
+ /** The part of a produced block that block timing needs — its height and when it was produced. */
18
+ export type PreviousBlock = Readonly<{
19
+ number: bigint;
20
+ timestamp: Date;
21
+ }>;
22
+ /**
23
+ * Compute block hash from block number. Uses a deterministic hash based on block number for easy recomputation.
24
+ *
25
+ * @param blockNumber - The block number to compute hash for
26
+ * @returns A deterministic 64-character hex hash
27
+ */
28
+ export declare const blockHash: (blockNumber: bigint) => Promise<string>;
29
+ /**
30
+ * Create the next block context from the previous block.
31
+ *
32
+ * @param previousBlock - The previous block (or undefined for genesis)
33
+ * @param blockTime - The timestamp for the new block
34
+ * @param blockNumber - Height of the new block, overriding the height derived from `previousBlock`. Needed for a
35
+ * genesis block that continues an existing chain's numbering, as a ledger-v9 chain's does.
36
+ * @returns A BlockContext suitable for transaction processing
37
+ */
38
+ export declare const nextBlockContextFromBlock: (previousBlock: PreviousBlock | undefined, blockTime: Date, blockNumber?: bigint) => Promise<BlockContext>;
@@ -0,0 +1,52 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * Block identity and timing for a simulated chain — how a block is hashed and what context it is executed against.
15
+ *
16
+ * Neither depends on the ledger a chain runs, so both are shared by every simulator.
17
+ */
18
+ import { DateOps } from '@midnight-ntwrk/wallet-sdk-utilities';
19
+ /**
20
+ * Compute block hash from block number. Uses a deterministic hash based on block number for easy recomputation.
21
+ *
22
+ * @param blockNumber - The block number to compute hash for
23
+ * @returns A deterministic 64-character hex hash
24
+ */
25
+ export const blockHash = async (blockNumber) => {
26
+ const input = `block-${blockNumber.toString()}`;
27
+ const hashBuffer = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(input));
28
+ const { Encoding } = await import('effect');
29
+ return Encoding.encodeHex(new Uint8Array(hashBuffer));
30
+ };
31
+ /**
32
+ * Create the next block context from the previous block.
33
+ *
34
+ * @param previousBlock - The previous block (or undefined for genesis)
35
+ * @param blockTime - The timestamp for the new block
36
+ * @param blockNumber - Height of the new block, overriding the height derived from `previousBlock`. Needed for a
37
+ * genesis block that continues an existing chain's numbering, as a ledger-v9 chain's does.
38
+ * @returns A BlockContext suitable for transaction processing
39
+ */
40
+ export const nextBlockContextFromBlock = async (previousBlock, blockTime, blockNumber) => {
41
+ const nextBlockNumber = blockNumber ?? (previousBlock !== undefined ? previousBlock.number + 1n : 0n);
42
+ const hash = await blockHash(nextBlockNumber);
43
+ const blockSeconds = DateOps.dateToSeconds(blockTime);
44
+ const previousSeconds = previousBlock !== undefined ? DateOps.dateToSeconds(previousBlock.timestamp) : blockSeconds - 1n;
45
+ const timeSinceLastBlock = blockSeconds - previousSeconds;
46
+ return {
47
+ parentBlockHash: hash,
48
+ secondsSinceEpoch: blockSeconds,
49
+ secondsSinceEpochErr: 1, // Clock error tolerance in seconds (reasonable default for simulator)
50
+ lastBlockTime: timeSinceLastBlock > 0n ? timeSinceLastBlock : 1n,
51
+ };
52
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Simulator internals that are the same whichever ledger a simulated chain runs.
3
+ *
4
+ * The ledger-v8 and ledger-v9 simulators are otherwise twins, so anything here is written once instead of once per
5
+ * version. The rule for what belongs: it must not name a ledger type. Everything that constructs or applies ledger
6
+ * objects — the ledger state, transactions, strictness objects, genesis minting — stays in the per-version simulators,
7
+ * because that is what genuinely differs between them.
8
+ *
9
+ * Not a published entry point; re-exported through each version's barrel.
10
+ */
11
+ export { getProtocolVersion, protocolVersionAt, scheduleFork, setProtocolVersion, type ScheduledFork, type VersionTimeline, } from './VersionTimeline.js';
12
+ export { blockHash, nextBlockContextFromBlock, type BlockContext, type PreviousBlock } from './blocks.js';
13
+ export { defaultStrictness, genesisStrictness, type StrictnessConfig } from './strictness.js';
@@ -0,0 +1,25 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * Simulator internals that are the same whichever ledger a simulated chain runs.
15
+ *
16
+ * The ledger-v8 and ledger-v9 simulators are otherwise twins, so anything here is written once instead of once per
17
+ * version. The rule for what belongs: it must not name a ledger type. Everything that constructs or applies ledger
18
+ * objects — the ledger state, transactions, strictness objects, genesis minting — stays in the per-version simulators,
19
+ * because that is what genuinely differs between them.
20
+ *
21
+ * Not a published entry point; re-exported through each version's barrel.
22
+ */
23
+ export { getProtocolVersion, protocolVersionAt, scheduleFork, setProtocolVersion, } from './VersionTimeline.js';
24
+ export { blockHash, nextBlockContextFromBlock } from './blocks.js';
25
+ export { defaultStrictness, genesisStrictness } from './strictness.js';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Which well-formedness checks a simulated chain enforces, as plain configuration.
3
+ *
4
+ * The configuration and its presets say nothing about a ledger, so they are shared. Turning one into the ledger's
5
+ * `WellFormedStrictness` object is per-ledger and stays with each simulator (`createStrictness`).
6
+ */
7
+ /** Configuration for well-formedness strictness checks. All options default to false for testing flexibility. */
8
+ export type StrictnessConfig = Readonly<{
9
+ enforceBalancing?: boolean;
10
+ verifyNativeProofs?: boolean;
11
+ verifyContractProofs?: boolean;
12
+ enforceLimits?: boolean;
13
+ verifySignatures?: boolean;
14
+ }>;
15
+ /**
16
+ * Default strictness for post-genesis blocks.
17
+ *
18
+ * In a realistic simulation:
19
+ *
20
+ * - Signatures should be verified (verifySignatures: true)
21
+ * - Proofs cannot be verified because they're erased (verifyNativeProofs/verifyContractProofs: false)
22
+ * - Limits should be enforced (enforceLimits: true)
23
+ * - Balancing must be enforced (enforceBalancing: true) - transactions must pay fees
24
+ *
25
+ * Note: Genesis blocks typically disable all strictness to allow initial token distribution.
26
+ */
27
+ export declare const defaultStrictness: StrictnessConfig;
28
+ /** Strictness for genesis blocks - all checks disabled to allow initial token distribution. */
29
+ export declare const genesisStrictness: StrictnessConfig;
@@ -0,0 +1,39 @@
1
+ // This file is part of MIDNIGHT-WALLET-SDK.
2
+ // Copyright (C) Midnight Foundation
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // You may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * Default strictness for post-genesis blocks.
15
+ *
16
+ * In a realistic simulation:
17
+ *
18
+ * - Signatures should be verified (verifySignatures: true)
19
+ * - Proofs cannot be verified because they're erased (verifyNativeProofs/verifyContractProofs: false)
20
+ * - Limits should be enforced (enforceLimits: true)
21
+ * - Balancing must be enforced (enforceBalancing: true) - transactions must pay fees
22
+ *
23
+ * Note: Genesis blocks typically disable all strictness to allow initial token distribution.
24
+ */
25
+ export const defaultStrictness = {
26
+ enforceBalancing: true,
27
+ verifyNativeProofs: false,
28
+ verifyContractProofs: false,
29
+ enforceLimits: true,
30
+ verifySignatures: true,
31
+ };
32
+ /** Strictness for genesis blocks - all checks disabled to allow initial token distribution. */
33
+ export const genesisStrictness = {
34
+ enforceBalancing: false,
35
+ verifyNativeProofs: false,
36
+ verifyContractProofs: false,
37
+ enforceLimits: false,
38
+ verifySignatures: false,
39
+ };
@@ -1,2 +1,22 @@
1
- export { getLastBlock, getCurrentBlockNumber, getCurrentTime, getBlockByNumber, getLastBlockResults, getLastBlockEvents, getBlockEventsFrom, getBlockEventsSince, hasPendingTransactions, resolveFullness, allMempoolTransactions, blankState, addToMempool, removeFromMempool, advanceTime, updateLedger, appendBlock, applyTransaction, processTransaction, processTransactions, createBlock, createEmptyBlock, type TransactionProcessingResult, createStrictness, blockHash, assignStrictness, assignStrictnessToAll, defaultStrictness, genesisStrictness, type SimulatorState, type Block, type BlockTransaction, type BlockInfo, type PendingTransaction, type ReadyTransaction, type BlockProductionRequest, type BlockProducer, type FullnessSpec, type GenesisMint, type StrictnessConfig, } from './SimulatorState.js';
2
- export { Simulator, immediateBlockProducer, type SimulatorConfig } from './Simulator.js';
1
+ /**
2
+ * Simulated ledger environments for wallet testing.
3
+ *
4
+ * There is one simulator per ledger version, in `v8/` and `v9/`. They are twins: the same simulator over a different
5
+ * ledger, so a chain on either side of the hard fork is driven with the same API. Their shared, ledger-agnostic
6
+ * internals live in `core/`.
7
+ *
8
+ * - **{@link V9}** — the ledger-v9 line. Also re-exported unqualified below, so `Simulator` and friends mean the v9
9
+ * simulator; this is what existing code gets.
10
+ * - **{@link V8}** — the ledger-v8 line. Used to drive a chain before the v9 fork, standalone or via {@link ForkSimulator}.
11
+ * - **{@link ForkSimulator}** — the two composed into a single chain that crosses the fork.
12
+ *
13
+ * Both namespaces are needed at once only when working across the boundary; the qualified form is what keeps the two
14
+ * apart, since the twins export identical names over structurally distinct ledger types.
15
+ */
16
+ export * from './v9/index.js';
17
+ /** The ledger-v9 simulator. Same as the unqualified exports above, named for symmetry with {@link V8}. */
18
+ export * as V9 from './v9/index.js';
19
+ /** The ledger-v8 simulator. */
20
+ export * as V8 from './v8/index.js';
21
+ export { ForkSimulator, type ForkSimulatorConfig } from './ForkSimulator.js';
22
+ export { LedgerTranslationError, translatorFromAsync, unavailableTranslator, type LedgerStateTranslator, } from './LedgerTranslation.js';
@@ -10,17 +10,28 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- // Re-export everything from SimulatorState
14
- export {
15
- // State accessor functions (composable with simulator.query())
16
- getLastBlock, getCurrentBlockNumber, getCurrentTime, getBlockByNumber, getLastBlockResults, getLastBlockEvents, getBlockEventsFrom, getBlockEventsSince, hasPendingTransactions,
17
- // State transformation functions
18
- resolveFullness, allMempoolTransactions, blankState, addToMempool, removeFromMempool, advanceTime, updateLedger, appendBlock, applyTransaction,
19
- // Block production functions
20
- processTransaction, processTransactions, createBlock, createEmptyBlock,
21
- // Helper functions
22
- createStrictness, blockHash, assignStrictness, assignStrictnessToAll,
23
- // Strictness constants
24
- defaultStrictness, genesisStrictness, } from './SimulatorState.js';
25
- // Re-export from Simulator
26
- export { Simulator, immediateBlockProducer } from './Simulator.js';
13
+ /**
14
+ * Simulated ledger environments for wallet testing.
15
+ *
16
+ * There is one simulator per ledger version, in `v8/` and `v9/`. They are twins: the same simulator over a different
17
+ * ledger, so a chain on either side of the hard fork is driven with the same API. Their shared, ledger-agnostic
18
+ * internals live in `core/`.
19
+ *
20
+ * - **{@link V9}** — the ledger-v9 line. Also re-exported unqualified below, so `Simulator` and friends mean the v9
21
+ * simulator; this is what existing code gets.
22
+ * - **{@link V8}** — the ledger-v8 line. Used to drive a chain before the v9 fork, standalone or via {@link ForkSimulator}.
23
+ * - **{@link ForkSimulator}** — the two composed into a single chain that crosses the fork.
24
+ *
25
+ * Both namespaces are needed at once only when working across the boundary; the qualified form is what keeps the two
26
+ * apart, since the twins export identical names over structurally distinct ledger types.
27
+ */
28
+ // The ledger-v9 simulator, unqualified: the default for code that does not span a fork.
29
+ export * from './v9/index.js';
30
+ /** The ledger-v9 simulator. Same as the unqualified exports above, named for symmetry with {@link V8}. */
31
+ export * as V9 from './v9/index.js';
32
+ /** The ledger-v8 simulator. */
33
+ export * as V8 from './v8/index.js';
34
+ // A chain that crosses the fork, built from both twins.
35
+ export { ForkSimulator } from './ForkSimulator.js';
36
+ // Carrying ledger state across the fork.
37
+ export { LedgerTranslationError, translatorFromAsync, unavailableTranslator, } from './LedgerTranslation.js';