@midnight-ntwrk/wallet-sdk-capabilities 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/balancer/Balancer.d.ts +2 -2
- package/dist/balancer/CounterOffer.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pendingTransactions/pendingTransactions.d.ts +1 -1
- package/dist/pendingTransactions/pendingTransactionsService.d.ts +3 -3
- package/dist/proving/provingService.d.ts +2 -2
- package/dist/proving/provingService.js +1 -1
- package/dist/simulation/Simulator.d.ts +180 -0
- package/dist/simulation/Simulator.js +453 -0
- package/dist/simulation/SimulatorState.d.ts +349 -0
- package/dist/simulation/SimulatorState.js +323 -0
- package/dist/simulation/index.d.ts +2 -0
- package/dist/simulation/index.js +26 -0
- package/dist/submission/submissionService.d.ts +4 -5
- package/dist/submission/submissionService.js +11 -5
- package/package.json +18 -14
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
// 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';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { SubmissionEvent as SubmissionEventImported } from '@midnight-ntwrk/wallet-sdk-node-client/effect';
|
|
3
3
|
import { type FinalizedTransaction } from '@midnight-ntwrk/ledger-v8';
|
|
4
|
+
import { type SimulatorState } from '../simulation/Simulator.js';
|
|
4
5
|
export declare const SubmissionEvent: typeof SubmissionEventImported;
|
|
5
6
|
export type SubmissionEvent = SubmissionEventImported.SubmissionEvent;
|
|
6
7
|
export declare namespace SubmissionEventCases {
|
|
@@ -8,7 +9,7 @@ export declare namespace SubmissionEventCases {
|
|
|
8
9
|
type Submitted = SubmissionEventImported.Cases.Submitted;
|
|
9
10
|
type InBlock = SubmissionEventImported.Cases.InBlock;
|
|
10
11
|
}
|
|
11
|
-
declare const SubmissionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
12
|
+
declare const SubmissionError_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
13
|
readonly _tag: "SubmissionError";
|
|
13
14
|
} & Readonly<A>;
|
|
14
15
|
export declare class SubmissionError extends SubmissionError_base<{
|
|
@@ -49,10 +50,8 @@ export declare const makeDefaultSubmissionService: <TTransaction extends {
|
|
|
49
50
|
} = FinalizedTransaction>(config: DefaultSubmissionConfiguration) => SubmissionService<TTransaction>;
|
|
50
51
|
export type SimulatorSubmissionConfiguration<TTransaction> = {
|
|
51
52
|
simulator: {
|
|
52
|
-
submitTransaction: (transaction: TTransaction) => Effect.Effect<
|
|
53
|
-
|
|
54
|
-
blockHash: string;
|
|
55
|
-
}, Error>;
|
|
53
|
+
submitTransaction: (transaction: TTransaction) => Effect.Effect<void, Error>;
|
|
54
|
+
getLatestState: () => Effect.Effect<SimulatorState>;
|
|
56
55
|
};
|
|
57
56
|
};
|
|
58
57
|
export declare const makeSimulatorSubmissionService: <TTransaction extends {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { Data, Deferred, Effect, Encoding, Exit, pipe, Scope } from 'effect';
|
|
14
14
|
import { NodeClient, PolkadotNodeClient, SubmissionEvent as SubmissionEventImported, } from '@midnight-ntwrk/wallet-sdk-node-client/effect';
|
|
15
15
|
import { SerializedTransaction } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
16
|
+
import { getLastBlock } from '../simulation/Simulator.js';
|
|
16
17
|
export const SubmissionEvent = SubmissionEventImported;
|
|
17
18
|
export class SubmissionError extends Data.TaggedError('SubmissionError') {
|
|
18
19
|
}
|
|
@@ -46,7 +47,12 @@ export const makeDefaultSubmissionService = (config) => {
|
|
|
46
47
|
};
|
|
47
48
|
export const makeSimulatorSubmissionService = (waitForStatus = 'InBlock') => (config) => {
|
|
48
49
|
const submit = (transaction) => {
|
|
49
|
-
return config.simulator.submitTransaction(transaction)
|
|
50
|
+
return pipe(config.simulator.submitTransaction(transaction),
|
|
51
|
+
// Wait for stream-based block production
|
|
52
|
+
Effect.andThen(Effect.sleep('100 millis')), Effect.andThen(config.simulator.getLatestState())).pipe(Effect.map((state) => {
|
|
53
|
+
const lastBlock = getLastBlock(state);
|
|
54
|
+
const blockNumber = lastBlock?.number ?? 0n;
|
|
55
|
+
const blockHash = lastBlock?.hash ?? '';
|
|
50
56
|
const serializedTransaction = SerializedTransaction.from(transaction);
|
|
51
57
|
const fakeTxHash = Encoding.encodeHex(serializedTransaction).slice(0, 64);
|
|
52
58
|
// Let's mimic node's client behavior here
|
|
@@ -59,15 +65,15 @@ export const makeSimulatorSubmissionService = (waitForStatus = 'InBlock') => (co
|
|
|
59
65
|
case 'InBlock':
|
|
60
66
|
return SubmissionEvent.InBlock({
|
|
61
67
|
tx: serializedTransaction,
|
|
62
|
-
blockHash
|
|
63
|
-
blockHeight:
|
|
68
|
+
blockHash,
|
|
69
|
+
blockHeight: blockNumber,
|
|
64
70
|
txHash: fakeTxHash,
|
|
65
71
|
});
|
|
66
72
|
case 'Finalized':
|
|
67
73
|
return SubmissionEvent.Finalized({
|
|
68
74
|
tx: serializedTransaction,
|
|
69
|
-
blockHash
|
|
70
|
-
blockHeight:
|
|
75
|
+
blockHash,
|
|
76
|
+
blockHeight: blockNumber,
|
|
71
77
|
txHash: fakeTxHash,
|
|
72
78
|
});
|
|
73
79
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/wallet-sdk-capabilities",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -37,27 +37,31 @@
|
|
|
37
37
|
"./proving": {
|
|
38
38
|
"types": "./dist/proving/index.d.ts",
|
|
39
39
|
"import": "./dist/proving/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./simulation": {
|
|
42
|
+
"types": "./dist/simulation/index.d.ts",
|
|
43
|
+
"import": "./dist/simulation/index.js"
|
|
40
44
|
}
|
|
41
45
|
},
|
|
42
46
|
"dependencies": {
|
|
43
|
-
"@midnight-ntwrk/ledger-v8": "^8.0.
|
|
44
|
-
"@midnight-ntwrk/wallet-sdk-abstractions": "^2.
|
|
45
|
-
"@midnight-ntwrk/wallet-sdk-indexer-client": "^1.2.
|
|
46
|
-
"@midnight-ntwrk/wallet-sdk-node-client": "^1.1.
|
|
47
|
-
"@midnight-ntwrk/wallet-sdk-prover-client": "^1.2.
|
|
48
|
-
"@midnight-ntwrk/wallet-sdk-utilities": "^1.1.
|
|
47
|
+
"@midnight-ntwrk/ledger-v8": "^8.0.3",
|
|
48
|
+
"@midnight-ntwrk/wallet-sdk-abstractions": "^2.1.0",
|
|
49
|
+
"@midnight-ntwrk/wallet-sdk-indexer-client": "^1.2.1",
|
|
50
|
+
"@midnight-ntwrk/wallet-sdk-node-client": "^1.1.1",
|
|
51
|
+
"@midnight-ntwrk/wallet-sdk-prover-client": "^1.2.1",
|
|
52
|
+
"@midnight-ntwrk/wallet-sdk-utilities": "^1.1.1",
|
|
49
53
|
"@midnight-ntwrk/zkir-v2": "^2.1.0",
|
|
50
54
|
"effect": "^3.19.19",
|
|
51
55
|
"rxjs": "^7.8.2"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
|
-
"@effect/cluster": "^0.
|
|
55
|
-
"@effect/experimental": "^0.
|
|
56
|
-
"@effect/platform": "^0.
|
|
57
|
-
"@effect/platform-node": "^0.
|
|
58
|
-
"@effect/rpc": "^0.
|
|
59
|
-
"@effect/sql": "^0.
|
|
60
|
-
"@effect/workflow": "^0.
|
|
58
|
+
"@effect/cluster": "^0.58.0",
|
|
59
|
+
"@effect/experimental": "^0.60.0",
|
|
60
|
+
"@effect/platform": "^0.96.0",
|
|
61
|
+
"@effect/platform-node": "^0.106.0",
|
|
62
|
+
"@effect/rpc": "^0.75.0",
|
|
63
|
+
"@effect/sql": "^0.51.0",
|
|
64
|
+
"@effect/workflow": "^0.18.0"
|
|
61
65
|
},
|
|
62
66
|
"scripts": {
|
|
63
67
|
"typecheck": "tsc -b ./tsconfig.json --noEmit --force",
|