@midnight-ntwrk/wallet-sdk-shielded 1.0.0-beta.10
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/ShieldedWallet.d.ts +70 -0
- package/dist/ShieldedWallet.js +136 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -0
- package/dist/v1/CoinsAndBalances.d.ts +24 -0
- package/dist/v1/CoinsAndBalances.js +46 -0
- package/dist/v1/CoreWallet.d.ts +49 -0
- package/dist/v1/CoreWallet.js +152 -0
- package/dist/v1/Keys.d.ts +8 -0
- package/dist/v1/Keys.js +16 -0
- package/dist/v1/Proving.d.ts +12 -0
- package/dist/v1/Proving.js +53 -0
- package/dist/v1/ProvingRecipe.d.ts +18 -0
- package/dist/v1/ProvingRecipe.js +3 -0
- package/dist/v1/RunningV1Variant.d.ts +46 -0
- package/dist/v1/RunningV1Variant.js +95 -0
- package/dist/v1/Serialization.d.ts +12 -0
- package/dist/v1/Serialization.js +103 -0
- package/dist/v1/Simulator.d.ts +22 -0
- package/dist/v1/Simulator.js +102 -0
- package/dist/v1/Submission.d.ts +31 -0
- package/dist/v1/Submission.js +69 -0
- package/dist/v1/Sync.d.ts +51 -0
- package/dist/v1/Sync.js +139 -0
- package/dist/v1/SyncProgress.d.ts +22 -0
- package/dist/v1/SyncProgress.js +25 -0
- package/dist/v1/Transacting.d.ts +69 -0
- package/dist/v1/Transacting.js +374 -0
- package/dist/v1/Transaction.d.ts +17 -0
- package/dist/v1/Transaction.js +76 -0
- package/dist/v1/TransactionHistory.d.ts +16 -0
- package/dist/v1/TransactionHistory.js +55 -0
- package/dist/v1/TransactionImbalances.d.ts +10 -0
- package/dist/v1/TransactionImbalances.js +30 -0
- package/dist/v1/V1Builder.d.ts +109 -0
- package/dist/v1/V1Builder.js +201 -0
- package/dist/v1/WalletError.d.ts +75 -0
- package/dist/v1/WalletError.js +59 -0
- package/dist/v1/index.d.ts +16 -0
- package/dist/v1/index.js +28 -0
- package/package.json +77 -0
|
@@ -0,0 +1,76 @@
|
|
|
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 { pipe } from 'effect';
|
|
14
|
+
import { Imbalances } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
15
|
+
export const TransactionTrait = new (class {
|
|
16
|
+
default = {
|
|
17
|
+
getImbalances(tx) {
|
|
18
|
+
return TransactionTrait.shared.getImbalances(tx);
|
|
19
|
+
},
|
|
20
|
+
id(tx) {
|
|
21
|
+
return tx.identifiers().at(0);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
proofErased = {
|
|
25
|
+
getImbalances(tx) {
|
|
26
|
+
return TransactionTrait.shared.getImbalances(tx);
|
|
27
|
+
},
|
|
28
|
+
id(tx) {
|
|
29
|
+
return tx.identifiers().at(0);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
unproven = {
|
|
33
|
+
getImbalances(tx) {
|
|
34
|
+
return TransactionTrait.shared.getImbalances(tx);
|
|
35
|
+
},
|
|
36
|
+
id(tx) {
|
|
37
|
+
return tx.identifiers().at(0);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
shared = {
|
|
41
|
+
getImbalances(tx) {
|
|
42
|
+
const guaranteedImbalances = TransactionTrait.shared.getGuaranteedImbalances(tx);
|
|
43
|
+
const fallibleImbalances = TransactionTrait.shared.getFallibleImbalances(tx);
|
|
44
|
+
return pipe({
|
|
45
|
+
guaranteed: guaranteedImbalances,
|
|
46
|
+
fallible: fallibleImbalances,
|
|
47
|
+
fees: 0n,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
getGuaranteedImbalances: (tx) => {
|
|
51
|
+
const rawGuaranteedImbalances = tx
|
|
52
|
+
.imbalances(0)
|
|
53
|
+
.entries()
|
|
54
|
+
.filter(([token]) => token.tag === 'shielded')
|
|
55
|
+
.map(([token, value]) => {
|
|
56
|
+
return [token.raw.toString(), value];
|
|
57
|
+
});
|
|
58
|
+
return Imbalances.fromEntries(rawGuaranteedImbalances);
|
|
59
|
+
},
|
|
60
|
+
getFallibleImbalances: (tx) => {
|
|
61
|
+
try {
|
|
62
|
+
const rawFallibleImbalances = tx
|
|
63
|
+
.imbalances(1)
|
|
64
|
+
.entries()
|
|
65
|
+
.filter(([token]) => token.tag === 'shielded')
|
|
66
|
+
.map(([token, value]) => {
|
|
67
|
+
return [token.raw.toString(), value];
|
|
68
|
+
});
|
|
69
|
+
return Imbalances.fromEntries(rawFallibleImbalances);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return Imbalances.empty();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as ledger from '@midnight-ntwrk/ledger-v6';
|
|
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
|
+
export type TransactionHistoryCapability<TState, TTransaction> = {
|
|
10
|
+
updateTxHistory(state: TState, newTxs: TTransaction[]): TState;
|
|
11
|
+
transactionHistory(state: TState): readonly TTransaction[];
|
|
12
|
+
progress(state: TState): ProgressUpdate;
|
|
13
|
+
};
|
|
14
|
+
export declare const makeDefaultTransactionHistoryCapability: () => TransactionHistoryCapability<CoreWallet, ledger.FinalizedTransaction>;
|
|
15
|
+
export declare const makeSimulatorTransactionHistoryCapability: () => TransactionHistoryCapability<CoreWallet, ledger.ProofErasedTransaction>;
|
|
16
|
+
export declare const makeDiscardTransactionHistoryCapability: () => TransactionHistoryCapability<CoreWallet, ledger.FinalizedTransaction>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CoreWallet } from './CoreWallet.js';
|
|
2
|
+
export const makeDefaultTransactionHistoryCapability = () => {
|
|
3
|
+
return {
|
|
4
|
+
updateTxHistory: (state, newTxs) => {
|
|
5
|
+
return newTxs.reduce((acc, tx) => CoreWallet.addTransaction(acc, tx), state);
|
|
6
|
+
},
|
|
7
|
+
transactionHistory: (state) => {
|
|
8
|
+
return state.txHistoryArray;
|
|
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
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export const makeSimulatorTransactionHistoryCapability = () => {
|
|
21
|
+
return {
|
|
22
|
+
updateTxHistory: (state, newTxs) => {
|
|
23
|
+
return CoreWallet.updateTxHistory(state, newTxs); // @TODO fix this cast
|
|
24
|
+
},
|
|
25
|
+
transactionHistory: (state) => {
|
|
26
|
+
return state.txHistoryArray; // @TODO fix this cast
|
|
27
|
+
},
|
|
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
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const makeDiscardTransactionHistoryCapability = () => {
|
|
39
|
+
return {
|
|
40
|
+
updateTxHistory: (state) => {
|
|
41
|
+
return state;
|
|
42
|
+
},
|
|
43
|
+
transactionHistory: (state) => {
|
|
44
|
+
return state.txHistoryArray;
|
|
45
|
+
},
|
|
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
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Imbalances, TransactionCostModel } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
2
|
+
export declare const ShieldedCostModel: TransactionCostModel;
|
|
3
|
+
export type TransactionImbalances = Readonly<{
|
|
4
|
+
guaranteed: Imbalances;
|
|
5
|
+
fallible: Imbalances;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const TransactionImbalances: {
|
|
8
|
+
empty: () => TransactionImbalances;
|
|
9
|
+
areBalanced: (imbalances: TransactionImbalances) => boolean;
|
|
10
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { Imbalances } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
14
|
+
export const ShieldedCostModel = {
|
|
15
|
+
inputFeeOverhead: 0n,
|
|
16
|
+
outputFeeOverhead: 0n,
|
|
17
|
+
};
|
|
18
|
+
export const TransactionImbalances = new (class {
|
|
19
|
+
empty = () => {
|
|
20
|
+
return {
|
|
21
|
+
guaranteed: Imbalances.empty(),
|
|
22
|
+
fallible: Imbalances.empty(),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
areBalanced = (imbalances) => {
|
|
26
|
+
const areFallibleAllZeroes = imbalances.fallible.entries().every(([, value]) => value === 0n);
|
|
27
|
+
const areGuaranteedAllZeroes = imbalances.guaranteed.entries().every(([, value]) => value === 0n);
|
|
28
|
+
return areFallibleAllZeroes && areGuaranteedAllZeroes;
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as ledger from '@midnight-ntwrk/ledger-v6';
|
|
2
|
+
import { Either, Types } from 'effect';
|
|
3
|
+
import { NetworkId } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
4
|
+
import { Variant, VariantBuilder } from '@midnight-ntwrk/wallet-sdk-runtime/abstractions';
|
|
5
|
+
import { DefaultProvingConfiguration, ProvingService } from './Proving.js';
|
|
6
|
+
import { RunningV1Variant, V1Tag } from './RunningV1Variant.js';
|
|
7
|
+
import { SerializationCapability } from './Serialization.js';
|
|
8
|
+
import { DefaultSyncContext, DefaultSyncConfiguration, SyncCapability, SyncService, WalletSyncUpdate } from './Sync.js';
|
|
9
|
+
import { DefaultTransactingConfiguration, DefaultTransactingContext, TransactingCapability } from './Transacting.js';
|
|
10
|
+
import { WalletError } from './WalletError.js';
|
|
11
|
+
import { CoinsAndBalancesCapability } from './CoinsAndBalances.js';
|
|
12
|
+
import { KeysCapability } from './Keys.js';
|
|
13
|
+
import { DefaultSubmissionConfiguration, SubmissionService } from './Submission.js';
|
|
14
|
+
import { CoinSelection } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
15
|
+
import { CoreWallet } from './CoreWallet.js';
|
|
16
|
+
import { TransactionHistoryCapability } from './TransactionHistory.js';
|
|
17
|
+
export type BaseV1Configuration = {
|
|
18
|
+
networkId: NetworkId.NetworkId;
|
|
19
|
+
};
|
|
20
|
+
export type DefaultV1Configuration = BaseV1Configuration & DefaultSyncConfiguration & DefaultProvingConfiguration & DefaultTransactingConfiguration & DefaultSubmissionConfiguration;
|
|
21
|
+
declare const V1BuilderSymbol: {
|
|
22
|
+
readonly typeId: unique symbol;
|
|
23
|
+
};
|
|
24
|
+
export type V1Variant<TSerialized, TSyncUpdate, TTransaction, TAuxData> = Variant.Variant<typeof V1Tag, CoreWallet, null, RunningV1Variant<TSerialized, TSyncUpdate, TTransaction, TAuxData>> & {
|
|
25
|
+
deserializeState: (serialized: TSerialized) => Either.Either<CoreWallet, WalletError>;
|
|
26
|
+
coinsAndBalances: CoinsAndBalancesCapability<CoreWallet>;
|
|
27
|
+
keys: KeysCapability<CoreWallet>;
|
|
28
|
+
serialization: SerializationCapability<CoreWallet, null, TSerialized>;
|
|
29
|
+
transactionHistory: TransactionHistoryCapability<CoreWallet, TTransaction>;
|
|
30
|
+
};
|
|
31
|
+
export type AnyV1Variant = V1Variant<any, any, any, any>;
|
|
32
|
+
export type DefaultV1Variant = V1Variant<string, WalletSyncUpdate, ledger.FinalizedTransaction, ledger.ZswapSecretKeys>;
|
|
33
|
+
export type TransactionOf<T extends AnyV1Variant> = T extends V1Variant<any, any, infer TTransaction, any> ? TTransaction : never;
|
|
34
|
+
export type AuxDataOf<T extends AnyV1Variant> = T extends V1Variant<any, any, any, infer TAuxData> ? TAuxData : never;
|
|
35
|
+
export type SerializedStateOf<T extends AnyV1Variant> = T extends V1Variant<infer TSerialized, any, any, any> ? TSerialized : never;
|
|
36
|
+
export type DefaultV1Builder = V1Builder<DefaultV1Configuration, RunningV1Variant.Context<string, WalletSyncUpdate, ledger.FinalizedTransaction, ledger.ZswapSecretKeys>, string, WalletSyncUpdate, ledger.FinalizedTransaction, ledger.ZswapSecretKeys>;
|
|
37
|
+
export declare class V1Builder<TConfig extends BaseV1Configuration = BaseV1Configuration, TContext extends Partial<RunningV1Variant.AnyContext> = object, TSerialized = never, TSyncUpdate = never, TTransaction = never, TStartAux extends object = object> implements VariantBuilder.VariantBuilder<V1Variant<TSerialized, TSyncUpdate, TTransaction, TStartAux>, TConfig> {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(buildState?: V1Builder.PartialBuildState<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>);
|
|
40
|
+
withDefaults(): DefaultV1Builder;
|
|
41
|
+
withTransactionType<Transaction>(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, Transaction, TStartAux>;
|
|
42
|
+
withDefaultTransactionType(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
43
|
+
withSyncDefaults(): V1Builder<TConfig & DefaultSyncConfiguration, TContext & DefaultSyncContext, TSerialized, WalletSyncUpdate, TTransaction, ledger.ZswapSecretKeys>;
|
|
44
|
+
withSync<TSyncConfig, TSyncContext extends Partial<RunningV1Variant.AnyContext>, TSyncUpdate, TStartAux extends object>(syncService: (configuration: TSyncConfig, getContext: () => TSyncContext) => SyncService<CoreWallet, TStartAux, TSyncUpdate>, syncCapability: (configuration: TSyncConfig, getContext: () => TSyncContext) => SyncCapability<CoreWallet, TSyncUpdate>): V1Builder<TConfig & TSyncConfig, TContext & TSyncContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
45
|
+
withSerializationDefaults(): V1Builder<TConfig, TContext, string, TSyncUpdate, TTransaction, TStartAux>;
|
|
46
|
+
withSerialization<TSerializationConfig, TSerializationContext extends Partial<RunningV1Variant.AnyContext>, TSerialized>(serializationCapability: (configuration: TSerializationConfig, getContext: () => TSerializationContext) => SerializationCapability<CoreWallet, null, TSerialized>): V1Builder<TConfig & TSerializationConfig, TContext & TSerializationContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
47
|
+
withTransactingDefaults(this: V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>): V1Builder<TConfig & DefaultTransactingConfiguration, TContext & DefaultTransactingContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
48
|
+
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>;
|
|
49
|
+
withCoinSelection<TCoinSelectionConfig, TCoinSelectionContext extends Partial<RunningV1Variant.AnyContext>>(coinSelection: (config: TCoinSelectionConfig, getContext: () => TCoinSelectionContext) => CoinSelection<ledger.QualifiedShieldedCoinInfo>): V1Builder<TConfig & TCoinSelectionConfig, TContext & TCoinSelectionContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
50
|
+
withCoinSelectionDefaults(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
51
|
+
withProving<TProvingConfig, TProvingContext extends Partial<RunningV1Variant.AnyContext>>(provingService: (config: TProvingConfig, getContext: () => TProvingContext) => ProvingService<TTransaction>): V1Builder<TConfig & TProvingConfig, TContext & TProvingContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
52
|
+
withProvingDefaults(this: V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>): V1Builder<TConfig & DefaultProvingConfiguration, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
53
|
+
withCoinsAndBalancesDefaults(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
54
|
+
withCoinsAndBalances<TBalancesConfig, TBalancesContext extends Partial<RunningV1Variant.AnyContext>>(coinsAndBalancesCapability: (configuration: TBalancesConfig, getContext: () => TBalancesContext) => CoinsAndBalancesCapability<CoreWallet>): V1Builder<TConfig & TBalancesConfig, TContext & TBalancesContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
55
|
+
withTransactionHistoryDefaults(this: V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
56
|
+
withTransactionHistory<TTransactionHistoryConfig, TTransactionHistoryContext extends Partial<RunningV1Variant.AnyContext>>(transactionHistoryCapability: (configuration: TTransactionHistoryConfig, getContext: () => TTransactionHistoryContext) => TransactionHistoryCapability<CoreWallet, TTransaction>): V1Builder<TConfig & TTransactionHistoryConfig, TContext & TTransactionHistoryContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
57
|
+
withKeysDefaults(): V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
58
|
+
withKeys<TKeysConfig, TKeysContext extends Partial<RunningV1Variant.AnyContext>>(keysCapability: (configuration: TKeysConfig, getContext: () => TKeysContext) => KeysCapability<CoreWallet>): V1Builder<TConfig & TKeysConfig, TContext & TKeysContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
59
|
+
withSubmission<TSubmissionConfig, TSubmissionContext extends Partial<RunningV1Variant.AnyContext>>(submissionService: (config: TSubmissionConfig, getContext: () => TSubmissionContext) => SubmissionService<TTransaction>): V1Builder<TConfig & TSubmissionConfig, TContext & TSubmissionContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
60
|
+
withSubmissionDefaults(this: V1Builder<TConfig, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>): V1Builder<TConfig & DefaultSubmissionConfiguration, TContext, TSerialized, TSyncUpdate, ledger.FinalizedTransaction, TStartAux>;
|
|
61
|
+
build(this: V1Builder<TConfig, RunningV1Variant.Context<TSerialized, TSyncUpdate, TTransaction, TStartAux>, TSerialized, TSyncUpdate, TTransaction, TStartAux>, configuration: TConfig): V1Variant<TSerialized, TSyncUpdate, TTransaction, TStartAux>;
|
|
62
|
+
}
|
|
63
|
+
/** @internal */
|
|
64
|
+
declare namespace V1Builder {
|
|
65
|
+
type HasSync<TConfig, TContext, TSyncUpdate, TStartAux> = {
|
|
66
|
+
readonly syncService: (configuration: TConfig, getContext: () => TContext) => SyncService<CoreWallet, TStartAux, TSyncUpdate>;
|
|
67
|
+
readonly syncCapability: (configuration: TConfig, getContext: () => TContext) => SyncCapability<CoreWallet, TSyncUpdate>;
|
|
68
|
+
};
|
|
69
|
+
type HasTransacting<TConfig, TContext, TTransaction> = {
|
|
70
|
+
readonly transactingCapability: (configuration: TConfig, getContext: () => TContext) => TransactingCapability<ledger.ZswapSecretKeys, CoreWallet, TTransaction>;
|
|
71
|
+
};
|
|
72
|
+
type HasCoinSelection<TConfig, TContext> = {
|
|
73
|
+
readonly coinSelection: (configuration: TConfig, getContext: () => TContext) => CoinSelection<ledger.QualifiedShieldedCoinInfo>;
|
|
74
|
+
};
|
|
75
|
+
type HasSerialization<TConfig, TContext, TSerialized> = {
|
|
76
|
+
readonly serializationCapability: (configuration: TConfig, getContext: () => TContext) => SerializationCapability<CoreWallet, null, TSerialized>;
|
|
77
|
+
};
|
|
78
|
+
type HasProving<TConfig, TContext, TTransaction> = {
|
|
79
|
+
readonly provingService: (configuration: TConfig, getContext: () => TContext) => ProvingService<TTransaction>;
|
|
80
|
+
};
|
|
81
|
+
type HasCoinsAndBalances<TConfig, TContext> = {
|
|
82
|
+
readonly coinsAndBalancesCapability: (configuration: TConfig, getContext: () => TContext) => CoinsAndBalancesCapability<CoreWallet>;
|
|
83
|
+
};
|
|
84
|
+
type HasTransactionHistory<TConfig, TContext, TTransaction> = {
|
|
85
|
+
readonly transactionHistoryCapability: (configuration: TConfig, getContext: () => TContext) => TransactionHistoryCapability<CoreWallet, TTransaction>;
|
|
86
|
+
};
|
|
87
|
+
type HasKeys<TConfig, TContext> = {
|
|
88
|
+
readonly keysCapability: (configuration: TConfig, getContext: () => TContext) => KeysCapability<CoreWallet>;
|
|
89
|
+
};
|
|
90
|
+
type HasSubmission<TConfig, TContext, TTransaction> = {
|
|
91
|
+
readonly submissionService: (configuration: TConfig, getContext: () => TContext) => SubmissionService<TTransaction>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The internal build state of {@link V1Builder}.
|
|
95
|
+
*/
|
|
96
|
+
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> & HasProving<TConfig, TContext, TTransaction> & HasSubmission<TConfig, TContext, TTransaction> & HasCoinsAndBalances<TConfig, TContext> & HasKeys<TConfig, TContext> & HasTransactionHistory<TConfig, TContext, TTransaction>>;
|
|
97
|
+
type PartialBuildState<TConfig = object, TContext = object, TSerialized = never, TSyncUpdate = never, TTransaction = never, TStartAux = object> = {
|
|
98
|
+
[K in keyof FullBuildState<never, never, never, never, never, never>]?: FullBuildState<TConfig, TContext, TSerialized, TSyncUpdate, TTransaction, TStartAux>[K] | undefined;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Utility interface that manages the type variance of {@link V1Builder}.
|
|
102
|
+
*/
|
|
103
|
+
interface Variance<R> {
|
|
104
|
+
readonly [V1BuilderSymbol.typeId]: {
|
|
105
|
+
readonly _R: Types.Covariant<R>;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
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-v6';
|
|
14
|
+
import { Effect, Scope } from 'effect';
|
|
15
|
+
import { WalletSeed } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
16
|
+
import { makeDefaultProvingService } from './Proving.js';
|
|
17
|
+
import { RunningV1Variant, V1Tag } from './RunningV1Variant.js';
|
|
18
|
+
import { makeDefaultV1SerializationCapability } from './Serialization.js';
|
|
19
|
+
import { makeEventsSyncService, makeEventsSyncCapability, } from './Sync.js';
|
|
20
|
+
import { makeDefaultTransactingCapability, } from './Transacting.js';
|
|
21
|
+
import { makeDefaultCoinsAndBalancesCapability } from './CoinsAndBalances.js';
|
|
22
|
+
import { makeDefaultKeysCapability } from './Keys.js';
|
|
23
|
+
import { makeDefaultSubmissionService } from './Submission.js';
|
|
24
|
+
import { chooseCoin } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
25
|
+
import { CoreWallet, PublicKeys } from './CoreWallet.js';
|
|
26
|
+
import { makeDefaultTransactionHistoryCapability } from './TransactionHistory.js';
|
|
27
|
+
const V1BuilderSymbol = {
|
|
28
|
+
typeId: Symbol('@midnight-ntwrk/wallet#V1Builder'),
|
|
29
|
+
};
|
|
30
|
+
export class V1Builder {
|
|
31
|
+
#buildState;
|
|
32
|
+
constructor(buildState = {}) {
|
|
33
|
+
this.#buildState = buildState;
|
|
34
|
+
}
|
|
35
|
+
withDefaults() {
|
|
36
|
+
return this.withDefaultTransactionType()
|
|
37
|
+
.withSyncDefaults()
|
|
38
|
+
.withSerializationDefaults()
|
|
39
|
+
.withTransactingDefaults()
|
|
40
|
+
.withCoinsAndBalancesDefaults()
|
|
41
|
+
.withTransactionHistoryDefaults()
|
|
42
|
+
.withKeysDefaults()
|
|
43
|
+
.withProvingDefaults()
|
|
44
|
+
.withSubmissionDefaults()
|
|
45
|
+
.withCoinSelectionDefaults();
|
|
46
|
+
}
|
|
47
|
+
withTransactionType() {
|
|
48
|
+
return new V1Builder({
|
|
49
|
+
...this.#buildState,
|
|
50
|
+
provingService: undefined,
|
|
51
|
+
transactingCapability: undefined,
|
|
52
|
+
submissionService: undefined,
|
|
53
|
+
transactionHistoryCapability: undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
withDefaultTransactionType() {
|
|
57
|
+
return this.withTransactionType();
|
|
58
|
+
}
|
|
59
|
+
withSyncDefaults() {
|
|
60
|
+
return this.withSync(makeEventsSyncService, makeEventsSyncCapability);
|
|
61
|
+
}
|
|
62
|
+
withSync(syncService, syncCapability) {
|
|
63
|
+
return new V1Builder({
|
|
64
|
+
...this.#buildState,
|
|
65
|
+
syncService,
|
|
66
|
+
syncCapability,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
withSerializationDefaults() {
|
|
70
|
+
return this.withSerialization(makeDefaultV1SerializationCapability);
|
|
71
|
+
}
|
|
72
|
+
withSerialization(serializationCapability) {
|
|
73
|
+
return new V1Builder({
|
|
74
|
+
...this.#buildState,
|
|
75
|
+
serializationCapability,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
withTransactingDefaults() {
|
|
79
|
+
return this.withTransacting(makeDefaultTransactingCapability);
|
|
80
|
+
}
|
|
81
|
+
withTransacting(transactingCapability) {
|
|
82
|
+
return new V1Builder({
|
|
83
|
+
...this.#buildState,
|
|
84
|
+
transactingCapability,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
withCoinSelection(coinSelection) {
|
|
88
|
+
return new V1Builder({
|
|
89
|
+
...this.#buildState,
|
|
90
|
+
coinSelection,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
withCoinSelectionDefaults() {
|
|
94
|
+
return this.withCoinSelection(() => chooseCoin);
|
|
95
|
+
}
|
|
96
|
+
withProving(provingService) {
|
|
97
|
+
return new V1Builder({
|
|
98
|
+
...this.#buildState,
|
|
99
|
+
provingService,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
withProvingDefaults() {
|
|
103
|
+
return this.withProving(makeDefaultProvingService);
|
|
104
|
+
}
|
|
105
|
+
withCoinsAndBalancesDefaults() {
|
|
106
|
+
return this.withCoinsAndBalances(makeDefaultCoinsAndBalancesCapability);
|
|
107
|
+
}
|
|
108
|
+
withCoinsAndBalances(coinsAndBalancesCapability) {
|
|
109
|
+
return new V1Builder({
|
|
110
|
+
...this.#buildState,
|
|
111
|
+
coinsAndBalancesCapability,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
withTransactionHistoryDefaults() {
|
|
115
|
+
return this.withTransactionHistory(makeDefaultTransactionHistoryCapability);
|
|
116
|
+
}
|
|
117
|
+
withTransactionHistory(transactionHistoryCapability) {
|
|
118
|
+
return new V1Builder({
|
|
119
|
+
...this.#buildState,
|
|
120
|
+
transactionHistoryCapability,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
withKeysDefaults() {
|
|
124
|
+
return this.withKeys(makeDefaultKeysCapability);
|
|
125
|
+
}
|
|
126
|
+
withKeys(keysCapability) {
|
|
127
|
+
return new V1Builder({
|
|
128
|
+
...this.#buildState,
|
|
129
|
+
keysCapability,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
withSubmission(submissionService) {
|
|
133
|
+
return new V1Builder({
|
|
134
|
+
...this.#buildState,
|
|
135
|
+
submissionService,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
withSubmissionDefaults() {
|
|
139
|
+
return this.withSubmission(makeDefaultSubmissionService);
|
|
140
|
+
}
|
|
141
|
+
build(configuration) {
|
|
142
|
+
const v1Context = this.#buildContextFromBuildState(configuration);
|
|
143
|
+
const { networkId } = configuration;
|
|
144
|
+
return {
|
|
145
|
+
__polyTag__: V1Tag,
|
|
146
|
+
coinsAndBalances: v1Context.coinsAndBalancesCapability,
|
|
147
|
+
keys: v1Context.keysCapability,
|
|
148
|
+
serialization: v1Context.serializationCapability,
|
|
149
|
+
transactionHistory: v1Context.transactionHistoryCapability,
|
|
150
|
+
start(context) {
|
|
151
|
+
return Effect.gen(function* () {
|
|
152
|
+
yield* Effect.addFinalizer(() => v1Context.submissionService.close());
|
|
153
|
+
const scope = yield* Scope.Scope;
|
|
154
|
+
return new RunningV1Variant(scope, context, v1Context);
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
migrateState(_previousState) {
|
|
158
|
+
const seed = WalletSeed.fromString('0000000000000000000000000000000000000000000000000000000000000001');
|
|
159
|
+
return Effect.succeed(CoreWallet.empty(PublicKeys.fromSecretKeys(ledger.ZswapSecretKeys.fromSeed(seed)), networkId));
|
|
160
|
+
},
|
|
161
|
+
deserializeState: (serialized) => {
|
|
162
|
+
return v1Context.serializationCapability.deserialize(null, serialized);
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
#buildContextFromBuildState(configuration) {
|
|
167
|
+
if (!isBuildStateFull(this.#buildState)) {
|
|
168
|
+
throw new Error('Not all components are configured in V1 Builder');
|
|
169
|
+
}
|
|
170
|
+
const { syncCapability, syncService, transactingCapability, serializationCapability, provingService, coinSelection, coinsAndBalancesCapability, keysCapability, submissionService, transactionHistoryCapability, } = this.#buildState;
|
|
171
|
+
const getContext = () => context;
|
|
172
|
+
const context = {
|
|
173
|
+
serializationCapability: serializationCapability(configuration, getContext),
|
|
174
|
+
syncCapability: syncCapability(configuration, getContext),
|
|
175
|
+
syncService: syncService(configuration, getContext),
|
|
176
|
+
transactingCapability: transactingCapability(configuration, getContext),
|
|
177
|
+
coinsAndBalancesCapability: coinsAndBalancesCapability(configuration, getContext),
|
|
178
|
+
keysCapability: keysCapability(configuration, getContext),
|
|
179
|
+
provingService: provingService(configuration, getContext),
|
|
180
|
+
coinSelection: coinSelection(configuration, getContext),
|
|
181
|
+
submissionService: submissionService(configuration, getContext),
|
|
182
|
+
transactionHistoryCapability: transactionHistoryCapability(configuration, getContext),
|
|
183
|
+
};
|
|
184
|
+
return context;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const isBuildStateFull = (buildState) => {
|
|
188
|
+
const allBuildStateKeys = [
|
|
189
|
+
'syncService',
|
|
190
|
+
'syncCapability',
|
|
191
|
+
'transactingCapability',
|
|
192
|
+
'coinSelection',
|
|
193
|
+
'serializationCapability',
|
|
194
|
+
'provingService',
|
|
195
|
+
'coinsAndBalancesCapability',
|
|
196
|
+
'keysCapability',
|
|
197
|
+
'submissionService',
|
|
198
|
+
'transactionHistoryCapability',
|
|
199
|
+
];
|
|
200
|
+
return allBuildStateKeys.every((key) => typeof buildState[key] == 'function');
|
|
201
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as ledger from '@midnight-ntwrk/ledger-v6';
|
|
2
|
+
import { LedgerOps } from '@midnight-ntwrk/wallet-sdk-utilities';
|
|
3
|
+
export declare const WalletError: {
|
|
4
|
+
proving(err: Error): WalletError;
|
|
5
|
+
other(err: unknown): WalletError;
|
|
6
|
+
submission(err: unknown): WalletError;
|
|
7
|
+
};
|
|
8
|
+
export type WalletError = ProvingError | OtherWalletError | InsufficientFundsError | SubmissionError | AddressError | SyncWalletError | InvalidCoinHashesError | TransactingError | LedgerOps.LedgerError;
|
|
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
|
+
}
|
|
17
|
+
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
|
+
readonly _tag: "Wallet.Other";
|
|
19
|
+
} & Readonly<A>;
|
|
20
|
+
export declare class OtherWalletError extends OtherWalletError_base<{
|
|
21
|
+
message: string;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
}> {
|
|
24
|
+
}
|
|
25
|
+
declare const SyncWalletError_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 & {
|
|
26
|
+
readonly _tag: "Wallet.Sync";
|
|
27
|
+
} & Readonly<A>;
|
|
28
|
+
export declare class SyncWalletError extends SyncWalletError_base<{
|
|
29
|
+
message: string;
|
|
30
|
+
cause?: unknown;
|
|
31
|
+
}> {
|
|
32
|
+
}
|
|
33
|
+
declare const SubmissionError_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 & {
|
|
34
|
+
readonly _tag: "Wallet.SubmissionWalletError";
|
|
35
|
+
} & Readonly<A>;
|
|
36
|
+
export declare class SubmissionError extends SubmissionError_base<{
|
|
37
|
+
message: string;
|
|
38
|
+
cause?: unknown;
|
|
39
|
+
}> {
|
|
40
|
+
}
|
|
41
|
+
declare const InsufficientFundsError_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 & {
|
|
42
|
+
readonly _tag: "Wallet.InsufficientFunds";
|
|
43
|
+
} & Readonly<A>;
|
|
44
|
+
export declare class InsufficientFundsError extends InsufficientFundsError_base<{
|
|
45
|
+
message: string;
|
|
46
|
+
tokenType: ledger.RawTokenType;
|
|
47
|
+
amount: bigint;
|
|
48
|
+
}> {
|
|
49
|
+
}
|
|
50
|
+
declare const AddressError_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 & {
|
|
51
|
+
readonly _tag: "Wallet.Address";
|
|
52
|
+
} & Readonly<A>;
|
|
53
|
+
export declare class AddressError extends AddressError_base<{
|
|
54
|
+
message: string;
|
|
55
|
+
originalAddress: string;
|
|
56
|
+
cause?: unknown;
|
|
57
|
+
}> {
|
|
58
|
+
}
|
|
59
|
+
declare const InvalidCoinHashesError_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 & {
|
|
60
|
+
readonly _tag: "Wallet.InvalidCoinHashes";
|
|
61
|
+
} & Readonly<A>;
|
|
62
|
+
export declare class InvalidCoinHashesError extends InvalidCoinHashesError_base<{
|
|
63
|
+
message: string;
|
|
64
|
+
missingNonces: Set<ledger.Nonce>;
|
|
65
|
+
}> {
|
|
66
|
+
}
|
|
67
|
+
declare const TransactingError_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 & {
|
|
68
|
+
readonly _tag: "Wallet.Transacting";
|
|
69
|
+
} & Readonly<A>;
|
|
70
|
+
export declare class TransactingError extends TransactingError_base<{
|
|
71
|
+
message: string;
|
|
72
|
+
cause?: unknown;
|
|
73
|
+
}> {
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { Data } from 'effect';
|
|
14
|
+
export const WalletError = {
|
|
15
|
+
proving(err) {
|
|
16
|
+
return new ProvingError({
|
|
17
|
+
message: `Wallet proving error: ${err.message}`,
|
|
18
|
+
cause: err,
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
other(err) {
|
|
22
|
+
let message;
|
|
23
|
+
if (err) {
|
|
24
|
+
if (typeof err == 'object' && 'message' in err) {
|
|
25
|
+
message = String(err.message);
|
|
26
|
+
}
|
|
27
|
+
else if (typeof err == 'string') {
|
|
28
|
+
message = err;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
message = '';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
message = '';
|
|
36
|
+
}
|
|
37
|
+
return new OtherWalletError({ message: `Other wallet error: ${message}`, cause: err });
|
|
38
|
+
},
|
|
39
|
+
submission(err) {
|
|
40
|
+
const message = err && typeof err == 'object' && 'message' in err ? String(err.message) : '';
|
|
41
|
+
return new SubmissionError({ message: `Transaction submission error: ${message}`, cause: err });
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export class ProvingError extends Data.TaggedError('Wallet.Proving') {
|
|
45
|
+
}
|
|
46
|
+
export class OtherWalletError extends Data.TaggedError('Wallet.Other') {
|
|
47
|
+
}
|
|
48
|
+
export class SyncWalletError extends Data.TaggedError('Wallet.Sync') {
|
|
49
|
+
}
|
|
50
|
+
export class SubmissionError extends Data.TaggedError('Wallet.SubmissionWalletError') {
|
|
51
|
+
}
|
|
52
|
+
export class InsufficientFundsError extends Data.TaggedError('Wallet.InsufficientFunds') {
|
|
53
|
+
}
|
|
54
|
+
export class AddressError extends Data.TaggedError('Wallet.Address') {
|
|
55
|
+
}
|
|
56
|
+
export class InvalidCoinHashesError extends Data.TaggedError('Wallet.InvalidCoinHashes') {
|
|
57
|
+
}
|
|
58
|
+
export class TransactingError extends Data.TaggedError('Wallet.Transacting') {
|
|
59
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './V1Builder.js';
|
|
2
|
+
export * as Sync from './Sync.js';
|
|
3
|
+
export * as SyncProgress from './SyncProgress.js';
|
|
4
|
+
export * as Transacting from './Transacting.js';
|
|
5
|
+
export * as TransactionHistory from './TransactionHistory.js';
|
|
6
|
+
export * as Serialization from './Serialization.js';
|
|
7
|
+
export * as Proving from './Proving.js';
|
|
8
|
+
export * as ProvingRecipe from './ProvingRecipe.js';
|
|
9
|
+
export * as CoinsAndBalances from './CoinsAndBalances.js';
|
|
10
|
+
export * as Keys from './Keys.js';
|
|
11
|
+
export * from './RunningV1Variant.js';
|
|
12
|
+
export * as Simulator from './Simulator.js';
|
|
13
|
+
export * as Submission from './Submission.js';
|
|
14
|
+
export * as WalletError from './WalletError.js';
|
|
15
|
+
export * from './CoreWallet.js';
|
|
16
|
+
export * from './Transaction.js';
|