@midnight-ntwrk/wallet-sdk-shielded 2.0.0-rc.0 → 2.0.0-rc.2
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/README.md +0 -7
- package/dist/ShieldedWallet.d.ts +3 -4
- package/dist/ShieldedWallet.js +1 -8
- package/dist/v1/CoreWallet.d.ts +5 -6
- package/dist/v1/CoreWallet.js +6 -7
- package/dist/v1/RunningV1Variant.d.ts +0 -3
- package/dist/v1/RunningV1Variant.js +0 -5
- package/dist/v1/TransactionHistory.d.ts +0 -7
- package/dist/v1/TransactionHistory.js +0 -24
- package/dist/v1/V1Builder.d.ts +2 -8
- package/dist/v1/V1Builder.js +1 -15
- package/dist/v1/WalletError.d.ts +1 -10
- package/dist/v1/WalletError.js +0 -8
- package/dist/v1/index.d.ts +0 -2
- package/dist/v1/index.js +0 -2
- package/package.json +7 -9
- package/dist/v1/Proving.d.ts +0 -21
- package/dist/v1/Proving.js +0 -46
- package/dist/v1/SyncProgress.d.ts +0 -22
- package/dist/v1/SyncProgress.js +0 -25
package/README.md
CHANGED
|
@@ -89,13 +89,6 @@ const tx = await wallet.transferTransaction(shieldedSecretKeys, [
|
|
|
89
89
|
const balancingTx = await wallet.balanceTransaction(shieldedSecretKeys, transactionToBalance);
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
### Finalizing Transactions
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
// Generates ZK proofs and finalizes the transaction
|
|
96
|
-
const finalizedTx = await wallet.finalizeTransaction(unprovenTx);
|
|
97
|
-
```
|
|
98
|
-
|
|
99
92
|
### Creating Swap Offers
|
|
100
93
|
|
|
101
94
|
```typescript
|
package/dist/ShieldedWallet.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type ProtocolState, ProtocolVersion } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
1
|
+
import { type ProtocolState, ProtocolVersion, SyncProgress } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
2
2
|
import { type BaseV1Configuration, type DefaultV1Configuration, type V1Variant, CoreWallet } from './v1/index.js';
|
|
3
3
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
4
4
|
import * as rx from 'rxjs';
|
|
5
5
|
import { type BalancingResult } from './v1/Transacting.js';
|
|
6
6
|
import { type SerializationCapability } from './v1/Serialization.js';
|
|
7
|
-
import { type
|
|
7
|
+
import { type TransactionHistoryCapability } from './v1/TransactionHistory.js';
|
|
8
8
|
import { type AvailableCoin, type CoinsAndBalancesCapability, type PendingCoin } from './v1/CoinsAndBalances.js';
|
|
9
9
|
import { type KeysCapability } from './v1/Keys.js';
|
|
10
10
|
import { type ShieldedAddress, type ShieldedCoinPublicKey, type ShieldedEncryptionPublicKey } from '@midnight-ntwrk/wallet-sdk-address-format';
|
|
@@ -30,7 +30,7 @@ export declare class ShieldedWalletState<TSerialized = string, TTransaction = le
|
|
|
30
30
|
get coinPublicKey(): ShieldedCoinPublicKey;
|
|
31
31
|
get encryptionPublicKey(): ShieldedEncryptionPublicKey;
|
|
32
32
|
get address(): ShieldedAddress;
|
|
33
|
-
get progress():
|
|
33
|
+
get progress(): SyncProgress.SyncProgress;
|
|
34
34
|
/**
|
|
35
35
|
* Transaction history for the wallet.
|
|
36
36
|
* @throws Error - Not yet implemented
|
|
@@ -47,7 +47,6 @@ export type ShieldedWalletAPI<TStartAux = ledger.ZswapSecretKeys, TTransaction =
|
|
|
47
47
|
balanceTransaction(secretKeys: ledger.ZswapSecretKeys, tx: ledger.Transaction<ledger.Signaturish, ledger.Proofish, ledger.Bindingish>): Promise<BalancingResult>;
|
|
48
48
|
transferTransaction(secretKeys: ledger.ZswapSecretKeys, outputs: readonly TokenTransfer[]): Promise<ledger.UnprovenTransaction>;
|
|
49
49
|
initSwap(secretKeys: ledger.ZswapSecretKeys, desiredInputs: Record<ledger.RawTokenType, bigint>, desiredOutputs: readonly TokenTransfer[]): Promise<ledger.UnprovenTransaction>;
|
|
50
|
-
finalizeTransaction(transaction: ledger.UnprovenTransaction): Promise<TTransaction>;
|
|
51
50
|
serializeState(): Promise<TSerialized>;
|
|
52
51
|
waitForSyncedState(allowedGap?: bigint): Promise<ShieldedWalletState<TSerialized, TTransaction>>;
|
|
53
52
|
getAddress(): Promise<ShieldedAddress>;
|
package/dist/ShieldedWallet.js
CHANGED
|
@@ -45,7 +45,7 @@ export class ShieldedWalletState {
|
|
|
45
45
|
return this.capabilities.keys.getAddress(this.state);
|
|
46
46
|
}
|
|
47
47
|
get progress() {
|
|
48
|
-
return this.
|
|
48
|
+
return this.state.progress;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Transaction history for the wallet.
|
|
@@ -111,13 +111,6 @@ export function CustomShieldedWallet(configuration, builder) {
|
|
|
111
111
|
.dispatch({ [V1Tag]: (v1) => v1.initSwap(secretKeys, desiredInputs, desiredOutputs) })
|
|
112
112
|
.pipe(Effect.runPromise);
|
|
113
113
|
}
|
|
114
|
-
finalizeTransaction(transaction) {
|
|
115
|
-
return this.runtime
|
|
116
|
-
.dispatch({
|
|
117
|
-
[V1Tag]: (v1) => v1.finalizeTransaction(transaction),
|
|
118
|
-
})
|
|
119
|
-
.pipe(Effect.runPromise);
|
|
120
|
-
}
|
|
121
114
|
revertTransaction(transaction) {
|
|
122
115
|
return this.runtime
|
|
123
116
|
.dispatch({
|
package/dist/v1/CoreWallet.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
2
|
-
import { ProtocolVersion } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
2
|
+
import { ProtocolVersion, SyncProgress } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
3
3
|
import { Either } from 'effect';
|
|
4
|
-
import { SyncProgress, SyncProgressData } from './SyncProgress.js';
|
|
5
4
|
import { WalletError } from './WalletError.js';
|
|
6
5
|
export type PublicKeys = {
|
|
7
6
|
coinPublicKey: ledger.CoinPublicKey;
|
|
@@ -26,20 +25,20 @@ export type CoreWallet = Readonly<{
|
|
|
26
25
|
state: ledger.ZswapLocalState;
|
|
27
26
|
publicKeys: PublicKeys;
|
|
28
27
|
protocolVersion: ProtocolVersion.ProtocolVersion;
|
|
29
|
-
progress: SyncProgress;
|
|
28
|
+
progress: SyncProgress.SyncProgress;
|
|
30
29
|
networkId: string;
|
|
31
30
|
coinHashes: CoinHashesMap;
|
|
32
31
|
}>;
|
|
33
32
|
export declare const CoreWallet: {
|
|
34
33
|
init(localState: ledger.ZswapLocalState, secretKeys: ledger.ZswapSecretKeys, networkId: string): CoreWallet;
|
|
35
34
|
empty(publicKeys: PublicKeys, networkId: string): CoreWallet;
|
|
36
|
-
restore(localState: ledger.ZswapLocalState, secretKeys: ledger.ZswapSecretKeys, syncProgress: Omit<SyncProgressData, "isConnected">, protocolVersion: bigint, networkId: string): CoreWallet;
|
|
37
|
-
restoreWithCoinHashes(publicKeys: PublicKeys, localState: ledger.ZswapLocalState, coinHashes: CoinHashesMap, syncProgress: SyncProgressData, protocolVersion: bigint, networkId: string): Either.Either<CoreWallet, WalletError>;
|
|
35
|
+
restore(localState: ledger.ZswapLocalState, secretKeys: ledger.ZswapSecretKeys, syncProgress: Omit<SyncProgress.SyncProgressData, "isConnected">, protocolVersion: bigint, networkId: string): CoreWallet;
|
|
36
|
+
restoreWithCoinHashes(publicKeys: PublicKeys, localState: ledger.ZswapLocalState, coinHashes: CoinHashesMap, syncProgress: SyncProgress.SyncProgressData, protocolVersion: bigint, networkId: string): Either.Either<CoreWallet, WalletError>;
|
|
38
37
|
initEmpty(keys: ledger.ZswapSecretKeys, networkId: string): CoreWallet;
|
|
39
38
|
applyCollapsedUpdate(wallet: CoreWallet, collapsed: ledger.MerkleTreeCollapsedUpdate): CoreWallet;
|
|
40
39
|
apply<TOffer extends ledger.ZswapOffer<ledger.Proofish>>(wallet: CoreWallet, secretKeys: ledger.ZswapSecretKeys, offer: TOffer): CoreWallet;
|
|
41
40
|
replayEvents(wallet: CoreWallet, secretKeys: ledger.ZswapSecretKeys, events: ledger.Event[]): CoreWallet;
|
|
42
|
-
updateProgress(wallet: CoreWallet, { appliedIndex, highestRelevantWalletIndex, highestIndex, highestRelevantIndex, isConnected, }: Partial<SyncProgressData>): CoreWallet;
|
|
41
|
+
updateProgress(wallet: CoreWallet, { appliedIndex, highestRelevantWalletIndex, highestIndex, highestRelevantIndex, isConnected, }: Partial<SyncProgress.SyncProgressData>): CoreWallet;
|
|
43
42
|
addTransaction(wallet: CoreWallet, _tx: ledger.FinalizedTransaction): CoreWallet;
|
|
44
43
|
revertTransaction<TTx extends ledger.Transaction<ledger.Signaturish, ledger.Proofish, ledger.Bindingish>>(wallet: CoreWallet, _tx: TTx): CoreWallet;
|
|
45
44
|
updateTxHistory(wallet: CoreWallet, _newTxs: readonly ledger.FinalizedTransaction[]): CoreWallet;
|
package/dist/v1/CoreWallet.js
CHANGED
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
14
|
-
import { ProtocolVersion } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
14
|
+
import { ProtocolVersion, SyncProgress } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
15
15
|
import { Either, Iterable, pipe, Record, Array as Arr } from 'effect';
|
|
16
|
-
import { createSyncProgress } from './SyncProgress.js';
|
|
17
16
|
import { InvalidCoinHashesError } from './WalletError.js';
|
|
18
17
|
export const PublicKeys = {
|
|
19
18
|
fromSecretKeys: (secretKeys) => {
|
|
@@ -56,7 +55,7 @@ export const CoreWallet = {
|
|
|
56
55
|
init(localState, secretKeys, networkId) {
|
|
57
56
|
const publicKeys = PublicKeys.fromSecretKeys(secretKeys);
|
|
58
57
|
const coinHashes = CoinHashesMap.init(secretKeys, CoinHashesMap.pickAllCoins(localState));
|
|
59
|
-
const progress = createSyncProgress();
|
|
58
|
+
const progress = SyncProgress.createSyncProgress();
|
|
60
59
|
const protocolVersion = ProtocolVersion.MinSupportedVersion;
|
|
61
60
|
return { state: localState, publicKeys, networkId, coinHashes, progress, protocolVersion };
|
|
62
61
|
},
|
|
@@ -66,7 +65,7 @@ export const CoreWallet = {
|
|
|
66
65
|
publicKeys,
|
|
67
66
|
networkId,
|
|
68
67
|
coinHashes: CoinHashesMap.empty,
|
|
69
|
-
progress: createSyncProgress(),
|
|
68
|
+
progress: SyncProgress.createSyncProgress(),
|
|
70
69
|
protocolVersion: ProtocolVersion.MinSupportedVersion,
|
|
71
70
|
};
|
|
72
71
|
},
|
|
@@ -78,7 +77,7 @@ export const CoreWallet = {
|
|
|
78
77
|
publicKeys,
|
|
79
78
|
networkId,
|
|
80
79
|
coinHashes,
|
|
81
|
-
progress: createSyncProgress(syncProgress),
|
|
80
|
+
progress: SyncProgress.createSyncProgress(syncProgress),
|
|
82
81
|
protocolVersion: ProtocolVersion.ProtocolVersion(protocolVersion),
|
|
83
82
|
};
|
|
84
83
|
},
|
|
@@ -90,7 +89,7 @@ export const CoreWallet = {
|
|
|
90
89
|
publicKeys,
|
|
91
90
|
networkId,
|
|
92
91
|
coinHashes,
|
|
93
|
-
progress: createSyncProgress(syncProgress),
|
|
92
|
+
progress: SyncProgress.createSyncProgress(syncProgress),
|
|
94
93
|
protocolVersion: ProtocolVersion.ProtocolVersion(protocolVersion),
|
|
95
94
|
}),
|
|
96
95
|
}));
|
|
@@ -113,7 +112,7 @@ export const CoreWallet = {
|
|
|
113
112
|
return { ...wallet, state: newState, coinHashes: newCoinHashes };
|
|
114
113
|
},
|
|
115
114
|
updateProgress(wallet, { appliedIndex, highestRelevantWalletIndex, highestIndex, highestRelevantIndex, isConnected, }) {
|
|
116
|
-
const updatedProgress = createSyncProgress({
|
|
115
|
+
const updatedProgress = SyncProgress.createSyncProgress({
|
|
117
116
|
appliedIndex: appliedIndex ?? wallet.progress.appliedIndex,
|
|
118
117
|
highestRelevantWalletIndex: highestRelevantWalletIndex ?? wallet.progress.highestRelevantWalletIndex,
|
|
119
118
|
highestIndex: highestIndex ?? wallet.progress.highestIndex,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
2
2
|
import { Effect, Scope, Stream } from 'effect';
|
|
3
3
|
import { type WalletRuntimeError, type Variant, StateChange } from '@midnight-ntwrk/wallet-sdk-runtime/abstractions';
|
|
4
|
-
import { type ProvingService } from './Proving.js';
|
|
5
4
|
import { type SerializationCapability } from './Serialization.js';
|
|
6
5
|
import { type EventsSyncUpdate, type SyncCapability, type SyncService } from './Sync.js';
|
|
7
6
|
import { type TransactingCapability, type TokenTransfer, type BalancingResult } from './Transacting.js';
|
|
@@ -17,7 +16,6 @@ export declare namespace RunningV1Variant {
|
|
|
17
16
|
syncService: SyncService<CoreWallet, TStartAux, TSyncUpdate>;
|
|
18
17
|
syncCapability: SyncCapability<CoreWallet, TSyncUpdate>;
|
|
19
18
|
transactingCapability: TransactingCapability<ledger.ZswapSecretKeys, CoreWallet, TTransaction>;
|
|
20
|
-
provingService: ProvingService<TTransaction>;
|
|
21
19
|
coinsAndBalancesCapability: CoinsAndBalancesCapability<CoreWallet>;
|
|
22
20
|
keysCapability: KeysCapability<CoreWallet>;
|
|
23
21
|
coinSelection: CoinSelection<ledger.QualifiedShieldedCoinInfo>;
|
|
@@ -37,7 +35,6 @@ export declare class RunningV1Variant<TSerialized, TSyncUpdate, TTransaction, TS
|
|
|
37
35
|
balanceTransaction(secretKeys: ledger.ZswapSecretKeys, tx: ledger.Transaction<ledger.Signaturish, ledger.Proofish, ledger.Bindingish>): Effect.Effect<BalancingResult, WalletError>;
|
|
38
36
|
transferTransaction(secretKeys: ledger.ZswapSecretKeys, outputs: ReadonlyArray<TokenTransfer>): Effect.Effect<ledger.UnprovenTransaction, WalletError>;
|
|
39
37
|
initSwap(secretKeys: ledger.ZswapSecretKeys, desiredInputs: Record<ledger.RawTokenType, bigint>, desiredOutputs: ReadonlyArray<TokenTransfer>): Effect.Effect<ledger.UnprovenTransaction, WalletError>;
|
|
40
|
-
finalizeTransaction(transaction: ledger.UnprovenTransaction): Effect.Effect<TTransaction, WalletError>;
|
|
41
38
|
revertTransaction(transaction: ledger.Transaction<ledger.Signaturish, ledger.Proofish, ledger.Bindingish>): Effect.Effect<void, WalletError>;
|
|
42
39
|
serializeState(state: CoreWallet): TSerialized;
|
|
43
40
|
}
|
|
@@ -79,11 +79,6 @@ export class RunningV1Variant {
|
|
|
79
79
|
return pipe(this.#v1Context.transactingCapability.initSwap(secretKeys, state, desiredInputs, desiredOutputs), EitherOps.toEffect);
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
finalizeTransaction(transaction) {
|
|
83
|
-
return this.#v1Context.provingService
|
|
84
|
-
.prove(transaction)
|
|
85
|
-
.pipe(Effect.tapError(() => SubscriptionRef.updateEffect(this.#context.stateRef, (state) => EitherOps.toEffect(this.#v1Context.transactingCapability.revertTransaction(state, transaction)))));
|
|
86
|
-
}
|
|
87
82
|
revertTransaction(transaction) {
|
|
88
83
|
return SubscriptionRef.updateEffect(this.#context.stateRef, (state) => {
|
|
89
84
|
return pipe(this.#v1Context.transactingCapability.revertTransaction(state, transaction), EitherOps.toEffect);
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
2
2
|
import { CoreWallet } from './CoreWallet.js';
|
|
3
|
-
export type ProgressUpdate = {
|
|
4
|
-
appliedIndex: bigint | undefined;
|
|
5
|
-
highestRelevantWalletIndex: bigint | undefined;
|
|
6
|
-
highestIndex: bigint | undefined;
|
|
7
|
-
highestRelevantIndex: bigint | undefined;
|
|
8
|
-
};
|
|
9
3
|
export type TransactionHistoryCapability<TState, TTransaction> = {
|
|
10
4
|
updateTxHistory(state: TState, newTxs: TTransaction[]): TState;
|
|
11
5
|
transactionHistory(state: TState): readonly TTransaction[];
|
|
12
|
-
progress(state: TState): ProgressUpdate;
|
|
13
6
|
};
|
|
14
7
|
export declare const makeDefaultTransactionHistoryCapability: () => TransactionHistoryCapability<CoreWallet, ledger.FinalizedTransaction>;
|
|
15
8
|
export declare const makeSimulatorTransactionHistoryCapability: () => TransactionHistoryCapability<CoreWallet, ledger.ProofErasedTransaction>;
|
|
@@ -7,14 +7,6 @@ export const makeDefaultTransactionHistoryCapability = () => {
|
|
|
7
7
|
transactionHistory: (_state) => {
|
|
8
8
|
return [];
|
|
9
9
|
},
|
|
10
|
-
progress: (state) => {
|
|
11
|
-
return {
|
|
12
|
-
appliedIndex: state.progress.appliedIndex,
|
|
13
|
-
highestRelevantWalletIndex: state.progress.highestRelevantWalletIndex,
|
|
14
|
-
highestIndex: state.progress.highestIndex,
|
|
15
|
-
highestRelevantIndex: state.progress.highestRelevantIndex,
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
10
|
};
|
|
19
11
|
};
|
|
20
12
|
export const makeSimulatorTransactionHistoryCapability = () => {
|
|
@@ -25,14 +17,6 @@ export const makeSimulatorTransactionHistoryCapability = () => {
|
|
|
25
17
|
transactionHistory: (_state) => {
|
|
26
18
|
return [];
|
|
27
19
|
},
|
|
28
|
-
progress: (state) => {
|
|
29
|
-
return {
|
|
30
|
-
appliedIndex: state.progress.appliedIndex,
|
|
31
|
-
highestRelevantWalletIndex: state.progress.highestRelevantWalletIndex,
|
|
32
|
-
highestIndex: state.progress.highestIndex,
|
|
33
|
-
highestRelevantIndex: state.progress.highestRelevantIndex,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
20
|
};
|
|
37
21
|
};
|
|
38
22
|
export const makeDiscardTransactionHistoryCapability = () => {
|
|
@@ -43,13 +27,5 @@ export const makeDiscardTransactionHistoryCapability = () => {
|
|
|
43
27
|
transactionHistory: (_state) => {
|
|
44
28
|
return [];
|
|
45
29
|
},
|
|
46
|
-
progress: (state) => {
|
|
47
|
-
return {
|
|
48
|
-
appliedIndex: state.progress.appliedIndex,
|
|
49
|
-
highestRelevantWalletIndex: state.progress.highestRelevantWalletIndex,
|
|
50
|
-
highestIndex: state.progress.highestIndex,
|
|
51
|
-
highestRelevantIndex: state.progress.highestRelevantIndex,
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
30
|
};
|
|
55
31
|
};
|
package/dist/v1/V1Builder.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
|
2
2
|
import { type Either, type Types } from 'effect';
|
|
3
3
|
import { type NetworkId } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
4
4
|
import { type Variant, type VariantBuilder } from '@midnight-ntwrk/wallet-sdk-runtime/abstractions';
|
|
5
|
-
import { type DefaultProvingConfiguration, type ProvingService } from './Proving.js';
|
|
6
5
|
import { RunningV1Variant, V1Tag } from './RunningV1Variant.js';
|
|
7
6
|
import { type SerializationCapability } from './Serialization.js';
|
|
8
7
|
import { type DefaultSyncContext, type DefaultSyncConfiguration, type SyncCapability, type SyncService, type WalletSyncUpdate } from './Sync.js';
|
|
@@ -16,7 +15,7 @@ import { type TransactionHistoryCapability } from './TransactionHistory.js';
|
|
|
16
15
|
export type BaseV1Configuration = {
|
|
17
16
|
networkId: NetworkId.NetworkId;
|
|
18
17
|
};
|
|
19
|
-
export type DefaultV1Configuration = BaseV1Configuration & DefaultSyncConfiguration &
|
|
18
|
+
export type DefaultV1Configuration = BaseV1Configuration & DefaultSyncConfiguration & DefaultTransactingConfiguration;
|
|
20
19
|
declare const V1BuilderSymbol: {
|
|
21
20
|
readonly typeId: unique symbol;
|
|
22
21
|
};
|
|
@@ -47,8 +46,6 @@ export declare class V1Builder<TConfig extends BaseV1Configuration = BaseV1Confi
|
|
|
47
46
|
withTransacting<TTransactingConfig, TTransactingContext extends Partial<RunningV1Variant.AnyContext>>(transactingCapability: (config: TTransactingConfig, getContext: () => TTransactingContext) => TransactingCapability<ledger.ZswapSecretKeys, CoreWallet, TTransaction>): V1Builder<TConfig & TTransactingConfig, TContext & TTransactingContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
48
47
|
withCoinSelection<TCoinSelectionConfig, TCoinSelectionContext extends Partial<RunningV1Variant.AnyContext>>(coinSelection: (config: TCoinSelectionConfig, getContext: () => TCoinSelectionContext) => CoinSelection<ledger.QualifiedShieldedCoinInfo>): V1Builder<TConfig & TCoinSelectionConfig, TContext & TCoinSelectionContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
49
48
|
withCoinSelectionDefaults(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
50
|
-
withProving<TProvingConfig, TProvingContext extends Partial<RunningV1Variant.AnyContext>>(provingService: (config: TProvingConfig, getContext: () => TProvingContext) => ProvingService<TTransaction>): V1Builder<TConfig & TProvingConfig, TContext & TProvingContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
51
|
-
withProvingDefaults(this: V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>): V1Builder<TConfig & DefaultProvingConfiguration, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
52
49
|
withCoinsAndBalancesDefaults(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
53
50
|
withCoinsAndBalances<TBalancesConfig, TBalancesContext extends Partial<RunningV1Variant.AnyContext>>(coinsAndBalancesCapability: (configuration: TBalancesConfig, getContext: () => TBalancesContext) => CoinsAndBalancesCapability<CoreWallet>): V1Builder<TConfig & TBalancesConfig, TContext & TBalancesContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
54
51
|
withTransactionHistoryDefaults(this: V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
@@ -72,9 +69,6 @@ declare namespace V1Builder {
|
|
|
72
69
|
type HasSerialization<TConfig, TContext, TSerialized> = {
|
|
73
70
|
readonly serializationCapability: (configuration: TConfig, getContext: () => TContext) => SerializationCapability<CoreWallet, null, TSerialized>;
|
|
74
71
|
};
|
|
75
|
-
type HasProving<TConfig, TContext, TTransaction> = {
|
|
76
|
-
readonly provingService: (configuration: TConfig, getContext: () => TContext) => ProvingService<TTransaction>;
|
|
77
|
-
};
|
|
78
72
|
type HasCoinsAndBalances<TConfig, TContext> = {
|
|
79
73
|
readonly coinsAndBalancesCapability: (configuration: TConfig, getContext: () => TContext) => CoinsAndBalancesCapability<CoreWallet>;
|
|
80
74
|
};
|
|
@@ -87,7 +81,7 @@ declare namespace V1Builder {
|
|
|
87
81
|
/**
|
|
88
82
|
* The internal build state of {@link V1Builder}.
|
|
89
83
|
*/
|
|
90
|
-
type FullBuildState<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux> = Types.Simplify<HasSync<TConfig, TContext, TSyncUpdate, TStartAux> & HasSerialization<TConfig, TContext, TSerialized> & HasTransacting<TConfig, TContext, TTransaction> & HasCoinSelection<TConfig, TContext> &
|
|
84
|
+
type FullBuildState<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux> = Types.Simplify<HasSync<TConfig, TContext, TSyncUpdate, TStartAux> & HasSerialization<TConfig, TContext, TSerialized> & HasTransacting<TConfig, TContext, TTransaction> & HasCoinSelection<TConfig, TContext> & HasCoinsAndBalances<TConfig, TContext> & HasKeys<TConfig, TContext> & HasTransactionHistory<TConfig, TContext, TTransaction>>;
|
|
91
85
|
type PartialBuildState<TConfig = object, TContext = object, TSerialized = never, TSyncUpdate = never, TTransaction = never, TStartAux = object> = {
|
|
92
86
|
[K in keyof FullBuildState<never, never, never, never, never, never>]?: FullBuildState<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>[K] | undefined;
|
|
93
87
|
};
|
package/dist/v1/V1Builder.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
14
14
|
import { Effect, Scope } from 'effect';
|
|
15
15
|
import { WalletSeed } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
16
|
-
import { makeDefaultProvingService } from './Proving.js';
|
|
17
16
|
import { RunningV1Variant, V1Tag } from './RunningV1Variant.js';
|
|
18
17
|
import { makeDefaultV1SerializationCapability } from './Serialization.js';
|
|
19
18
|
import { makeEventsSyncService, makeEventsSyncCapability, } from './Sync.js';
|
|
@@ -39,13 +38,11 @@ export class V1Builder {
|
|
|
39
38
|
.withCoinsAndBalancesDefaults()
|
|
40
39
|
.withTransactionHistoryDefaults()
|
|
41
40
|
.withKeysDefaults()
|
|
42
|
-
.withProvingDefaults()
|
|
43
41
|
.withCoinSelectionDefaults();
|
|
44
42
|
}
|
|
45
43
|
withTransactionType() {
|
|
46
44
|
return new V1Builder({
|
|
47
45
|
...this.#buildState,
|
|
48
|
-
provingService: undefined,
|
|
49
46
|
transactingCapability: undefined,
|
|
50
47
|
transactionHistoryCapability: undefined,
|
|
51
48
|
});
|
|
@@ -90,15 +87,6 @@ export class V1Builder {
|
|
|
90
87
|
withCoinSelectionDefaults() {
|
|
91
88
|
return this.withCoinSelection(() => chooseCoin);
|
|
92
89
|
}
|
|
93
|
-
withProving(provingService) {
|
|
94
|
-
return new V1Builder({
|
|
95
|
-
...this.#buildState,
|
|
96
|
-
provingService,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
withProvingDefaults() {
|
|
100
|
-
return this.withProving(makeDefaultProvingService);
|
|
101
|
-
}
|
|
102
90
|
withCoinsAndBalancesDefaults() {
|
|
103
91
|
return this.withCoinsAndBalances(makeDefaultCoinsAndBalancesCapability);
|
|
104
92
|
}
|
|
@@ -154,7 +142,7 @@ export class V1Builder {
|
|
|
154
142
|
if (!isBuildStateFull(this.#buildState)) {
|
|
155
143
|
throw new Error('Not all components are configured in V1 Builder');
|
|
156
144
|
}
|
|
157
|
-
const { syncCapability, syncService, transactingCapability, serializationCapability,
|
|
145
|
+
const { syncCapability, syncService, transactingCapability, serializationCapability, coinSelection, coinsAndBalancesCapability, keysCapability, transactionHistoryCapability, } = this.#buildState;
|
|
158
146
|
const getContext = () => context;
|
|
159
147
|
const context = {
|
|
160
148
|
serializationCapability: serializationCapability(configuration, getContext),
|
|
@@ -163,7 +151,6 @@ export class V1Builder {
|
|
|
163
151
|
transactingCapability: transactingCapability(configuration, getContext),
|
|
164
152
|
coinsAndBalancesCapability: coinsAndBalancesCapability(configuration, getContext),
|
|
165
153
|
keysCapability: keysCapability(configuration, getContext),
|
|
166
|
-
provingService: provingService(configuration, getContext),
|
|
167
154
|
coinSelection: coinSelection(configuration, getContext),
|
|
168
155
|
transactionHistoryCapability: transactionHistoryCapability(configuration, getContext),
|
|
169
156
|
};
|
|
@@ -177,7 +164,6 @@ const isBuildStateFull = (buildState) => {
|
|
|
177
164
|
'transactingCapability',
|
|
178
165
|
'coinSelection',
|
|
179
166
|
'serializationCapability',
|
|
180
|
-
'provingService',
|
|
181
167
|
'coinsAndBalancesCapability',
|
|
182
168
|
'keysCapability',
|
|
183
169
|
'transactionHistoryCapability',
|
package/dist/v1/WalletError.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
2
2
|
import { LedgerOps } from '@midnight-ntwrk/wallet-sdk-utilities';
|
|
3
3
|
export declare const WalletError: {
|
|
4
|
-
proving(err: Error): WalletError;
|
|
5
4
|
other(err: unknown): WalletError;
|
|
6
5
|
submission(err: unknown): WalletError;
|
|
7
6
|
};
|
|
8
|
-
export type WalletError =
|
|
9
|
-
declare const ProvingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
10
|
-
readonly _tag: "Wallet.Proving";
|
|
11
|
-
} & Readonly<A>;
|
|
12
|
-
export declare class ProvingError extends ProvingError_base<{
|
|
13
|
-
message: string;
|
|
14
|
-
cause: Error;
|
|
15
|
-
}> {
|
|
16
|
-
}
|
|
7
|
+
export type WalletError = OtherWalletError | InsufficientFundsError | SubmissionError | AddressError | SyncWalletError | InvalidCoinHashesError | TransactingError | LedgerOps.LedgerError;
|
|
17
8
|
declare const OtherWalletError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
18
9
|
readonly _tag: "Wallet.Other";
|
|
19
10
|
} & Readonly<A>;
|
package/dist/v1/WalletError.js
CHANGED
|
@@ -12,12 +12,6 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { Data } from 'effect';
|
|
14
14
|
export const WalletError = {
|
|
15
|
-
proving(err) {
|
|
16
|
-
return new ProvingError({
|
|
17
|
-
message: `Wallet proving error: ${err.message}`,
|
|
18
|
-
cause: err,
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
15
|
other(err) {
|
|
22
16
|
let message;
|
|
23
17
|
if (err) {
|
|
@@ -41,8 +35,6 @@ export const WalletError = {
|
|
|
41
35
|
return new SubmissionError({ message: `Transaction submission error: ${message}`, cause: err });
|
|
42
36
|
},
|
|
43
37
|
};
|
|
44
|
-
export class ProvingError extends Data.TaggedError('Wallet.Proving') {
|
|
45
|
-
}
|
|
46
38
|
export class OtherWalletError extends Data.TaggedError('Wallet.Other') {
|
|
47
39
|
}
|
|
48
40
|
export class SyncWalletError extends Data.TaggedError('Wallet.Sync') {
|
package/dist/v1/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export * from './V1Builder.js';
|
|
2
2
|
export * as Sync from './Sync.js';
|
|
3
|
-
export * as SyncProgress from './SyncProgress.js';
|
|
4
3
|
export * as Transacting from './Transacting.js';
|
|
5
4
|
export * as TransactionHistory from './TransactionHistory.js';
|
|
6
5
|
export * as Serialization from './Serialization.js';
|
|
7
|
-
export * as Proving from './Proving.js';
|
|
8
6
|
export * as CoinsAndBalances from './CoinsAndBalances.js';
|
|
9
7
|
export * as Keys from './Keys.js';
|
|
10
8
|
export * from './RunningV1Variant.js';
|
package/dist/v1/index.js
CHANGED
|
@@ -12,11 +12,9 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export * from './V1Builder.js';
|
|
14
14
|
export * as Sync from './Sync.js';
|
|
15
|
-
export * as SyncProgress from './SyncProgress.js';
|
|
16
15
|
export * as Transacting from './Transacting.js';
|
|
17
16
|
export * as TransactionHistory from './TransactionHistory.js';
|
|
18
17
|
export * as Serialization from './Serialization.js';
|
|
19
|
-
export * as Proving from './Proving.js';
|
|
20
18
|
export * as CoinsAndBalances from './CoinsAndBalances.js';
|
|
21
19
|
export * as Keys from './Keys.js';
|
|
22
20
|
export * from './RunningV1Variant.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/wallet-sdk-shielded",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -29,15 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@midnight-ntwrk/ledger-v7": "7.0.0",
|
|
32
|
-
"@midnight-ntwrk/wallet-sdk-abstractions": "
|
|
32
|
+
"@midnight-ntwrk/wallet-sdk-abstractions": "2.0.0-rc.1",
|
|
33
33
|
"@midnight-ntwrk/wallet-sdk-address-format": "3.0.0",
|
|
34
|
-
"@midnight-ntwrk/wallet-sdk-capabilities": "3.1.0-rc.
|
|
35
|
-
"@midnight-ntwrk/wallet-sdk-indexer-client": "1.1.0-rc.
|
|
36
|
-
"@midnight-ntwrk/wallet-sdk-
|
|
37
|
-
"@midnight-ntwrk/wallet-sdk-
|
|
38
|
-
"@midnight-ntwrk/wallet-sdk-runtime": "1.0.0",
|
|
39
|
-
"@midnight-ntwrk/wallet-sdk-utilities": "1.0.0",
|
|
40
|
-
"@midnight-ntwrk/zkir-v2": "2.1.0",
|
|
34
|
+
"@midnight-ntwrk/wallet-sdk-capabilities": "3.1.0-rc.2",
|
|
35
|
+
"@midnight-ntwrk/wallet-sdk-indexer-client": "1.1.0-rc.2",
|
|
36
|
+
"@midnight-ntwrk/wallet-sdk-runtime": "1.0.1-rc.1",
|
|
37
|
+
"@midnight-ntwrk/wallet-sdk-utilities": "1.0.1-rc.0",
|
|
41
38
|
"@scure/base": "^1.1.9",
|
|
42
39
|
"effect": "^3.19.14",
|
|
43
40
|
"isomorphic-ws": "^5.0.0",
|
|
@@ -65,6 +62,7 @@
|
|
|
65
62
|
"@effect/rpc": "^0.68.0",
|
|
66
63
|
"@effect/sql": "^0.44.0",
|
|
67
64
|
"@effect/workflow": "^0.8.1",
|
|
65
|
+
"@midnight-ntwrk/wallet-sdk-prover-client": "1.1.0-rc.2",
|
|
68
66
|
"@polkadot/types": "^16.4.1",
|
|
69
67
|
"eslint": "^9.37.0",
|
|
70
68
|
"fast-check": "^4.2.0",
|
package/dist/v1/Proving.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
2
|
-
import type { KeyMaterialProvider } from '@midnight-ntwrk/zkir-v2';
|
|
3
|
-
import { ProverClient } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
|
|
4
|
-
import { InvalidProtocolSchemeError } from '@midnight-ntwrk/wallet-sdk-utilities/networking';
|
|
5
|
-
import { Effect, Layer } from 'effect';
|
|
6
|
-
import { WalletError } from './WalletError.js';
|
|
7
|
-
export interface ProvingService<TTransaction> {
|
|
8
|
-
prove(transaction: ledger.UnprovenTransaction): Effect.Effect<TTransaction, WalletError>;
|
|
9
|
-
}
|
|
10
|
-
export declare const makeProvingService: (clientLayer: Layer.Layer<ProverClient.ProverClient, InvalidProtocolSchemeError>) => ProvingService<ledger.FinalizedTransaction>;
|
|
11
|
-
export type WasmProvingConfiguration = {
|
|
12
|
-
keyMaterialProvider?: KeyMaterialProvider;
|
|
13
|
-
};
|
|
14
|
-
export type ProvingServerConfiguration = {
|
|
15
|
-
provingServerUrl: URL;
|
|
16
|
-
};
|
|
17
|
-
export type DefaultProvingConfiguration = ProvingServerConfiguration;
|
|
18
|
-
export declare const makeDefaultProvingService: (configuration: DefaultProvingConfiguration) => ProvingService<ledger.FinalizedTransaction>;
|
|
19
|
-
export declare const makeServerProvingService: (configuration: ProvingServerConfiguration) => ProvingService<ledger.FinalizedTransaction>;
|
|
20
|
-
export declare const makeWasmProvingService: (configuration: WasmProvingConfiguration) => ProvingService<ledger.FinalizedTransaction>;
|
|
21
|
-
export declare const makeSimulatorProvingService: () => ProvingService<ledger.ProofErasedTransaction>;
|
package/dist/v1/Proving.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C) 2025 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
|
-
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
14
|
-
import { HttpProverClient, WasmProver, ProverClient } from '@midnight-ntwrk/wallet-sdk-prover-client/effect';
|
|
15
|
-
import { Effect, pipe } from 'effect';
|
|
16
|
-
import { ProvingError } from './WalletError.js';
|
|
17
|
-
export const makeProvingService = (clientLayer) => {
|
|
18
|
-
return {
|
|
19
|
-
prove(transaction) {
|
|
20
|
-
return pipe(ProverClient.ProverClient, Effect.flatMap((client) => client.proveTransaction(transaction, ledger.CostModel.initialCostModel())), Effect.map((transaction) => transaction.bind()), Effect.provide(clientLayer), Effect.catchAll((error) => Effect.fail(new ProvingError({
|
|
21
|
-
message: error.message,
|
|
22
|
-
cause: error,
|
|
23
|
-
}))));
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export const makeDefaultProvingService = (configuration) => makeServerProvingService(configuration);
|
|
28
|
-
export const makeServerProvingService = (configuration) => {
|
|
29
|
-
const clientLayer = HttpProverClient.layer({
|
|
30
|
-
url: configuration.provingServerUrl,
|
|
31
|
-
});
|
|
32
|
-
return makeProvingService(clientLayer);
|
|
33
|
-
};
|
|
34
|
-
export const makeWasmProvingService = (configuration) => {
|
|
35
|
-
const proverLayer = WasmProver.layer({
|
|
36
|
-
keyMaterialProvider: configuration.keyMaterialProvider ?? WasmProver.makeDefaultKeyMaterialProvider(),
|
|
37
|
-
});
|
|
38
|
-
return makeProvingService(proverLayer);
|
|
39
|
-
};
|
|
40
|
-
export const makeSimulatorProvingService = () => {
|
|
41
|
-
return {
|
|
42
|
-
prove(transaction) {
|
|
43
|
-
return Effect.succeed(transaction.eraseProofs());
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface SyncProgressData {
|
|
2
|
-
readonly appliedIndex: bigint;
|
|
3
|
-
readonly highestRelevantWalletIndex: bigint;
|
|
4
|
-
readonly highestIndex: bigint;
|
|
5
|
-
readonly highestRelevantIndex: bigint;
|
|
6
|
-
readonly isConnected: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface SyncProgressOps {
|
|
9
|
-
isCompleteWithin(data: SyncProgressData, maxGap?: bigint): boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface SyncProgress extends SyncProgressData {
|
|
12
|
-
isStrictlyComplete(): boolean;
|
|
13
|
-
isCompleteWithin(maxGap?: bigint): boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare const SyncProgress: SyncProgressOps;
|
|
16
|
-
export declare const createSyncProgress: (params?: {
|
|
17
|
-
appliedIndex?: bigint;
|
|
18
|
-
highestRelevantWalletIndex?: bigint;
|
|
19
|
-
highestIndex?: bigint;
|
|
20
|
-
highestRelevantIndex?: bigint;
|
|
21
|
-
isConnected?: boolean;
|
|
22
|
-
}) => SyncProgress;
|
package/dist/v1/SyncProgress.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const SyncProgress = {
|
|
2
|
-
isCompleteWithin(data, maxGap = 50n) {
|
|
3
|
-
const applyLag = BigInt(Math.abs(Number(data.highestRelevantWalletIndex - data.appliedIndex)));
|
|
4
|
-
return data.isConnected && applyLag <= maxGap;
|
|
5
|
-
},
|
|
6
|
-
};
|
|
7
|
-
export const createSyncProgress = (params = {}) => {
|
|
8
|
-
const { appliedIndex = 0n, highestRelevantWalletIndex = 0n, highestIndex = 0n, highestRelevantIndex = 0n, isConnected = false, } = params;
|
|
9
|
-
const data = {
|
|
10
|
-
appliedIndex,
|
|
11
|
-
highestRelevantWalletIndex,
|
|
12
|
-
highestIndex,
|
|
13
|
-
highestRelevantIndex,
|
|
14
|
-
isConnected,
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
...data,
|
|
18
|
-
isStrictlyComplete() {
|
|
19
|
-
return SyncProgress.isCompleteWithin(this, 0n);
|
|
20
|
-
},
|
|
21
|
-
isCompleteWithin(maxGap) {
|
|
22
|
-
return SyncProgress.isCompleteWithin(this, maxGap);
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|