@midnight-ntwrk/wallet-sdk-unshielded-wallet 1.0.0-beta.17 → 1.0.0-beta.19
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/UnshieldedWallet.d.ts +14 -11
- package/dist/UnshieldedWallet.js +26 -5
- package/dist/v1/RunningV1Variant.d.ts +13 -9
- package/dist/v1/RunningV1Variant.js +18 -5
- package/dist/v1/Transacting.d.ts +67 -12
- package/dist/v1/Transacting.js +258 -179
- package/dist/v1/TransactionOps.d.ts +23 -0
- package/dist/v1/TransactionOps.js +95 -0
- package/dist/v1/V1Builder.d.ts +28 -30
- package/dist/v1/V1Builder.js +1 -12
- package/dist/v1/index.d.ts +1 -1
- package/dist/v1/index.js +1 -1
- package/package.json +8 -7
- package/dist/v1/Transaction.d.ts +0 -25
- package/dist/v1/Transaction.js +0 -155
- package/dist/v1/TransactionImbalances.d.ts +0 -8
- package/dist/v1/TransactionImbalances.js +0 -21
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ProtocolState, ProtocolVersion } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
2
|
-
import { BaseV1Configuration, DefaultV1Configuration, V1Variant, CoreWallet } from './v1/index.js';
|
|
2
|
+
import { BaseV1Configuration, DefaultV1Configuration, V1Variant, CoreWallet, UnboundTransaction } from './v1/index.js';
|
|
3
3
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
4
4
|
import * as rx from 'rxjs';
|
|
5
5
|
import { SerializationCapability } from './v1/Serialization.js';
|
|
6
6
|
import { TransactionHistoryService } from './v1/TransactionHistory.js';
|
|
7
7
|
import { CoinsAndBalancesCapability } from './v1/CoinsAndBalances.js';
|
|
8
8
|
import { KeysCapability } from './v1/Keys.js';
|
|
9
|
-
import { TokenTransfer } from './v1/Transacting.js';
|
|
9
|
+
import { TokenTransfer, FinalizedTransactionBalanceResult, UnboundTransactionBalanceResult, UnprovenTransactionBalanceResult } from './v1/Transacting.js';
|
|
10
10
|
import { WalletSyncUpdate } from './v1/SyncSchema.js';
|
|
11
11
|
import { UtxoWithMeta } from './v1/UnshieldedState.js';
|
|
12
12
|
import { Variant, VariantBuilder, WalletLike } from '@midnight-ntwrk/wallet-sdk-runtime/abstractions';
|
|
@@ -35,23 +35,26 @@ export declare class UnshieldedWalletState<TSerialized = string> {
|
|
|
35
35
|
constructor(state: ProtocolState.ProtocolState<CoreWallet>, capabilities: UnshieldedWalletCapabilities<TSerialized>);
|
|
36
36
|
serialize(): TSerialized;
|
|
37
37
|
}
|
|
38
|
-
export type UnshieldedWallet = CustomizedUnshieldedWallet<
|
|
39
|
-
export type UnshieldedWalletClass = CustomizedUnshieldedWalletClass<
|
|
40
|
-
export interface CustomizedUnshieldedWallet<
|
|
38
|
+
export type UnshieldedWallet = CustomizedUnshieldedWallet<WalletSyncUpdate, string>;
|
|
39
|
+
export type UnshieldedWalletClass = CustomizedUnshieldedWalletClass<WalletSyncUpdate, string, DefaultV1Configuration>;
|
|
40
|
+
export interface CustomizedUnshieldedWallet<TSyncUpdate = WalletSyncUpdate, TSerialized = string> extends WalletLike.WalletLike<[Variant.VersionedVariant<V1Variant<TSerialized, TSyncUpdate>>]> {
|
|
41
41
|
readonly state: rx.Observable<UnshieldedWalletState<TSerialized>>;
|
|
42
42
|
start(): Promise<void>;
|
|
43
|
-
|
|
43
|
+
balanceFinalizedTransaction(tx: ledger.FinalizedTransaction): Promise<FinalizedTransactionBalanceResult>;
|
|
44
|
+
balanceUnboundTransaction(tx: UnboundTransaction): Promise<UnboundTransactionBalanceResult>;
|
|
45
|
+
balanceUnprovenTransaction(tx: ledger.UnprovenTransaction): Promise<UnprovenTransactionBalanceResult>;
|
|
44
46
|
transferTransaction(outputs: readonly TokenTransfer[], ttl: Date): Promise<ledger.UnprovenTransaction>;
|
|
45
47
|
initSwap(desiredInputs: Record<ledger.RawTokenType, bigint>, desiredOutputs: readonly TokenTransfer[], ttl: Date): Promise<ledger.UnprovenTransaction>;
|
|
46
|
-
|
|
48
|
+
signUnprovenTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Promise<ledger.UnprovenTransaction>;
|
|
49
|
+
signUnboundTransaction(transaction: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Promise<UnboundTransaction>;
|
|
47
50
|
serializeState(): Promise<TSerialized>;
|
|
48
51
|
waitForSyncedState(allowedGap?: bigint): Promise<UnshieldedWalletState<TSerialized>>;
|
|
49
52
|
getAddress(): Promise<UnshieldedAddress>;
|
|
50
53
|
}
|
|
51
|
-
export interface CustomizedUnshieldedWalletClass<
|
|
54
|
+
export interface CustomizedUnshieldedWalletClass<TSyncUpdate = WalletSyncUpdate, TSerialized = string, TConfig extends BaseV1Configuration = DefaultV1Configuration> extends WalletLike.BaseWalletClass<[Variant.VersionedVariant<V1Variant<TSerialized, TSyncUpdate>>]> {
|
|
52
55
|
configuration: TConfig;
|
|
53
|
-
startWithPublicKey(publicKey: PublicKey): CustomizedUnshieldedWallet<
|
|
54
|
-
restore(serializedState: TSerialized): CustomizedUnshieldedWallet<
|
|
56
|
+
startWithPublicKey(publicKey: PublicKey): CustomizedUnshieldedWallet<TSyncUpdate, TSerialized>;
|
|
57
|
+
restore(serializedState: TSerialized): CustomizedUnshieldedWallet<TSyncUpdate, TSerialized>;
|
|
55
58
|
}
|
|
56
59
|
export declare function UnshieldedWallet(configuration: DefaultV1Configuration): UnshieldedWalletClass;
|
|
57
|
-
export declare function CustomUnshieldedWallet<TConfig extends BaseV1Configuration = DefaultV1Configuration,
|
|
60
|
+
export declare function CustomUnshieldedWallet<TConfig extends BaseV1Configuration = DefaultV1Configuration, TSyncUpdate = WalletSyncUpdate, TSerialized = string>(configuration: TConfig, builder: VariantBuilder.VariantBuilder<V1Variant<TSerialized, TSyncUpdate>, TConfig>): CustomizedUnshieldedWalletClass<TSyncUpdate, TSerialized, TConfig>;
|
package/dist/UnshieldedWallet.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { ProtocolVersion } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
14
|
-
import { V1Builder, V1Tag, CoreWallet } from './v1/index.js';
|
|
14
|
+
import { V1Builder, V1Tag, CoreWallet, } from './v1/index.js';
|
|
15
15
|
import { Effect, Either } from 'effect';
|
|
16
16
|
import * as rx from 'rxjs';
|
|
17
17
|
import { WalletBuilder } from '@midnight-ntwrk/wallet-sdk-runtime';
|
|
@@ -77,10 +77,24 @@ export function CustomUnshieldedWallet(configuration, builder) {
|
|
|
77
77
|
start() {
|
|
78
78
|
return this.runtime.dispatch({ [V1Tag]: (v1) => v1.startSyncInBackground() }).pipe(Effect.runPromise);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
balanceFinalizedTransaction(tx) {
|
|
81
81
|
return this.runtime
|
|
82
82
|
.dispatch({
|
|
83
|
-
[V1Tag]: (v1) => v1.
|
|
83
|
+
[V1Tag]: (v1) => v1.balanceFinalizedTransaction(tx),
|
|
84
|
+
})
|
|
85
|
+
.pipe(Effect.runPromise);
|
|
86
|
+
}
|
|
87
|
+
balanceUnboundTransaction(tx) {
|
|
88
|
+
return this.runtime
|
|
89
|
+
.dispatch({
|
|
90
|
+
[V1Tag]: (v1) => v1.balanceUnboundTransaction(tx),
|
|
91
|
+
})
|
|
92
|
+
.pipe(Effect.runPromise);
|
|
93
|
+
}
|
|
94
|
+
balanceUnprovenTransaction(tx) {
|
|
95
|
+
return this.runtime
|
|
96
|
+
.dispatch({
|
|
97
|
+
[V1Tag]: (v1) => v1.balanceUnprovenTransaction(tx),
|
|
84
98
|
})
|
|
85
99
|
.pipe(Effect.runPromise);
|
|
86
100
|
}
|
|
@@ -96,10 +110,17 @@ export function CustomUnshieldedWallet(configuration, builder) {
|
|
|
96
110
|
.dispatch({ [V1Tag]: (v1) => v1.initSwap(desiredInputs, desiredOutputs, ttl) })
|
|
97
111
|
.pipe(Effect.runPromise);
|
|
98
112
|
}
|
|
99
|
-
|
|
113
|
+
signUnprovenTransaction(transaction, signSegment) {
|
|
114
|
+
return this.runtime
|
|
115
|
+
.dispatch({
|
|
116
|
+
[V1Tag]: (v1) => v1.signUnprovenTransaction(transaction, signSegment),
|
|
117
|
+
})
|
|
118
|
+
.pipe(Effect.runPromise);
|
|
119
|
+
}
|
|
120
|
+
signUnboundTransaction(transaction, signSegment) {
|
|
100
121
|
return this.runtime
|
|
101
122
|
.dispatch({
|
|
102
|
-
[V1Tag]: (v1) => v1.
|
|
123
|
+
[V1Tag]: (v1) => v1.signUnboundTransaction(transaction, signSegment),
|
|
103
124
|
})
|
|
104
125
|
.pipe(Effect.runPromise);
|
|
105
126
|
}
|
|
@@ -3,7 +3,8 @@ import { WalletRuntimeError, Variant, StateChange } from '@midnight-ntwrk/wallet
|
|
|
3
3
|
import { SerializationCapability } from './Serialization.js';
|
|
4
4
|
import { SyncCapability, SyncService } from './Sync.js';
|
|
5
5
|
import { WalletSyncUpdate } from './SyncSchema.js';
|
|
6
|
-
import { TransactingCapability, TokenTransfer } from './Transacting.js';
|
|
6
|
+
import { TransactingCapability, TokenTransfer, FinalizedTransactionBalanceResult, UnboundTransactionBalanceResult, UnprovenTransactionBalanceResult } from './Transacting.js';
|
|
7
|
+
import { UnboundTransaction } from './TransactionOps.js';
|
|
7
8
|
import { WalletError } from './WalletError.js';
|
|
8
9
|
import { CoinsAndBalancesCapability } from './CoinsAndBalances.js';
|
|
9
10
|
import { KeysCapability } from './Keys.js';
|
|
@@ -12,30 +13,33 @@ import { CoreWallet } from './CoreWallet.js';
|
|
|
12
13
|
import { TransactionHistoryService } from './TransactionHistory.js';
|
|
13
14
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
14
15
|
export declare namespace RunningV1Variant {
|
|
15
|
-
type Context<TSerialized, TSyncUpdate
|
|
16
|
+
type Context<TSerialized, TSyncUpdate> = {
|
|
16
17
|
serializationCapability: SerializationCapability<CoreWallet, TSerialized>;
|
|
17
18
|
syncService: SyncService<CoreWallet, TSyncUpdate>;
|
|
18
19
|
syncCapability: SyncCapability<CoreWallet, TSyncUpdate>;
|
|
19
|
-
transactingCapability: TransactingCapability<
|
|
20
|
+
transactingCapability: TransactingCapability<CoreWallet>;
|
|
20
21
|
coinsAndBalancesCapability: CoinsAndBalancesCapability<CoreWallet>;
|
|
21
22
|
keysCapability: KeysCapability<CoreWallet>;
|
|
22
23
|
coinSelection: CoinSelection<ledger.Utxo>;
|
|
23
24
|
transactionHistoryService: TransactionHistoryService<WalletSyncUpdate>;
|
|
24
25
|
};
|
|
25
|
-
type AnyContext = Context<any, any
|
|
26
|
+
type AnyContext = Context<any, any>;
|
|
26
27
|
}
|
|
27
28
|
export declare const V1Tag: unique symbol;
|
|
28
|
-
export type DefaultRunningV1 = RunningV1Variant<string, WalletSyncUpdate
|
|
29
|
-
export declare class RunningV1Variant<TSerialized, TSyncUpdate
|
|
29
|
+
export type DefaultRunningV1 = RunningV1Variant<string, WalletSyncUpdate>;
|
|
30
|
+
export declare class RunningV1Variant<TSerialized, TSyncUpdate> implements Variant.RunningVariant<typeof V1Tag, CoreWallet> {
|
|
30
31
|
#private;
|
|
31
32
|
readonly __polyTag__: typeof V1Tag;
|
|
32
33
|
readonly state: Stream.Stream<StateChange.StateChange<CoreWallet>, WalletRuntimeError>;
|
|
33
|
-
constructor(scope: Scope.Scope, context: Variant.VariantContext<CoreWallet>, v1Context: RunningV1Variant.Context<TSerialized, TSyncUpdate
|
|
34
|
+
constructor(scope: Scope.Scope, context: Variant.VariantContext<CoreWallet>, v1Context: RunningV1Variant.Context<TSerialized, TSyncUpdate>);
|
|
34
35
|
startSyncInBackground(): Effect.Effect<void>;
|
|
35
36
|
startSync(): Stream.Stream<void, WalletError, Scope.Scope>;
|
|
36
|
-
|
|
37
|
+
balanceFinalizedTransaction(tx: ledger.FinalizedTransaction): Effect.Effect<FinalizedTransactionBalanceResult, WalletError>;
|
|
38
|
+
balanceUnboundTransaction(tx: UnboundTransaction): Effect.Effect<UnboundTransactionBalanceResult, WalletError>;
|
|
39
|
+
balanceUnprovenTransaction(tx: ledger.UnprovenTransaction): Effect.Effect<UnprovenTransactionBalanceResult, WalletError>;
|
|
37
40
|
transferTransaction(outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Effect.Effect<ledger.UnprovenTransaction, WalletError>;
|
|
38
41
|
initSwap(desiredInputs: Record<string, bigint>, desiredOutputs: ReadonlyArray<TokenTransfer>, ttl: Date): Effect.Effect<ledger.UnprovenTransaction, WalletError>;
|
|
39
|
-
|
|
42
|
+
signUnprovenTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Effect.Effect<ledger.UnprovenTransaction, WalletError>;
|
|
43
|
+
signUnboundTransaction(transaction: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Effect.Effect<UnboundTransaction, WalletError>;
|
|
40
44
|
serializeState(state: CoreWallet): TSerialized;
|
|
41
45
|
}
|
|
@@ -67,14 +67,24 @@ export class RunningV1Variant {
|
|
|
67
67
|
return Duration.millis(Math.min(delayWithJitter, Duration.toMillis(maxDelay)));
|
|
68
68
|
}))));
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
balanceFinalizedTransaction(tx) {
|
|
71
71
|
return SubscriptionRef.modifyEffect(this.#context.stateRef, (state) => {
|
|
72
|
-
return pipe(this.#v1Context.transactingCapability.
|
|
72
|
+
return pipe(this.#v1Context.transactingCapability.balanceFinalizedTransaction(state, tx), EitherOps.toEffect);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
balanceUnboundTransaction(tx) {
|
|
76
|
+
return SubscriptionRef.modifyEffect(this.#context.stateRef, (state) => {
|
|
77
|
+
return pipe(this.#v1Context.transactingCapability.balanceUnboundTransaction(state, tx), EitherOps.toEffect);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
balanceUnprovenTransaction(tx) {
|
|
81
|
+
return SubscriptionRef.modifyEffect(this.#context.stateRef, (state) => {
|
|
82
|
+
return pipe(this.#v1Context.transactingCapability.balanceUnprovenTransaction(state, tx), EitherOps.toEffect);
|
|
73
83
|
});
|
|
74
84
|
}
|
|
75
85
|
transferTransaction(outputs, ttl) {
|
|
76
86
|
return SubscriptionRef.modifyEffect(this.#context.stateRef, (state) => {
|
|
77
|
-
return pipe(this.#v1Context.transactingCapability.makeTransfer(state, outputs, ttl), EitherOps.toEffect, Effect.
|
|
87
|
+
return pipe(this.#v1Context.transactingCapability.makeTransfer(state, outputs, ttl), EitherOps.toEffect, Effect.map(({ transaction, newState }) => [transaction, newState]));
|
|
78
88
|
});
|
|
79
89
|
}
|
|
80
90
|
initSwap(desiredInputs, desiredOutputs, ttl) {
|
|
@@ -82,8 +92,11 @@ export class RunningV1Variant {
|
|
|
82
92
|
return pipe(this.#v1Context.transactingCapability.initSwap(state, desiredInputs, desiredOutputs, ttl), Effect.map(({ transaction, newState }) => [transaction, newState]));
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
|
-
|
|
86
|
-
return this.#v1Context.transactingCapability.
|
|
95
|
+
signUnprovenTransaction(transaction, signSegment) {
|
|
96
|
+
return this.#v1Context.transactingCapability.signUnprovenTransaction(transaction, signSegment);
|
|
97
|
+
}
|
|
98
|
+
signUnboundTransaction(transaction, signSegment) {
|
|
99
|
+
return this.#v1Context.transactingCapability.signUnboundTransaction(transaction, signSegment);
|
|
87
100
|
}
|
|
88
101
|
serializeState(state) {
|
|
89
102
|
return this.#v1Context.serializationCapability.serialize(state);
|
package/dist/v1/Transacting.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Either } from 'effect';
|
|
|
4
4
|
import { CoreWallet } from './CoreWallet.js';
|
|
5
5
|
import { WalletError } from './WalletError.js';
|
|
6
6
|
import { CoinSelection } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
7
|
-
import {
|
|
7
|
+
import { TransactionOps, UnboundTransaction } from './TransactionOps.js';
|
|
8
8
|
import { CoinsAndBalancesCapability } from './CoinsAndBalances.js';
|
|
9
9
|
import { KeysCapability } from './Keys.js';
|
|
10
10
|
export interface TokenTransfer {
|
|
@@ -12,15 +12,22 @@ export interface TokenTransfer {
|
|
|
12
12
|
readonly type: ledger.RawTokenType;
|
|
13
13
|
readonly receiverAddress: string;
|
|
14
14
|
}
|
|
15
|
+
export type FinalizedTransactionBalanceResult = ledger.UnprovenTransaction | undefined;
|
|
16
|
+
export type UnboundTransactionBalanceResult = UnboundTransaction | undefined;
|
|
17
|
+
export type UnprovenTransactionBalanceResult = ledger.UnprovenTransaction | undefined;
|
|
15
18
|
export type TransactingResult<TTransaction, TState> = {
|
|
16
19
|
readonly newState: TState;
|
|
17
20
|
readonly transaction: TTransaction;
|
|
18
21
|
};
|
|
19
|
-
export interface TransactingCapability<
|
|
22
|
+
export interface TransactingCapability<TState> {
|
|
20
23
|
makeTransfer(wallet: CoreWallet, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
21
24
|
initSwap(wallet: CoreWallet, desiredInputs: Record<string, bigint>, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
balanceFinalizedTransaction(wallet: CoreWallet, transaction: ledger.FinalizedTransaction): Either.Either<[FinalizedTransactionBalanceResult, CoreWallet], WalletError>;
|
|
26
|
+
balanceUnboundTransaction(wallet: CoreWallet, transaction: UnboundTransaction): Either.Either<[UnboundTransactionBalanceResult, CoreWallet], WalletError>;
|
|
27
|
+
balanceUnprovenTransaction(wallet: CoreWallet, transaction: ledger.UnprovenTransaction): Either.Either<[UnprovenTransactionBalanceResult, CoreWallet], WalletError>;
|
|
28
|
+
signUnprovenTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<ledger.UnprovenTransaction, WalletError>;
|
|
29
|
+
revert(wallet: CoreWallet, transaction: ledger.FinalizedTransaction | UnboundTransaction | ledger.UnprovenTransaction): Either.Either<CoreWallet, WalletError>;
|
|
30
|
+
signUnboundTransaction(transaction: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<UnboundTransaction, WalletError>;
|
|
24
31
|
}
|
|
25
32
|
export type DefaultTransactingConfiguration = {
|
|
26
33
|
networkId: NetworkId.NetworkId;
|
|
@@ -30,16 +37,64 @@ export type DefaultTransactingContext = {
|
|
|
30
37
|
coinsAndBalancesCapability: CoinsAndBalancesCapability<CoreWallet>;
|
|
31
38
|
keysCapability: KeysCapability<CoreWallet>;
|
|
32
39
|
};
|
|
33
|
-
export declare const makeDefaultTransactingCapability: (config: DefaultTransactingConfiguration, getContext: () => DefaultTransactingContext) => TransactingCapability<
|
|
34
|
-
export declare class TransactingCapabilityImplementation
|
|
40
|
+
export declare const makeDefaultTransactingCapability: (config: DefaultTransactingConfiguration, getContext: () => DefaultTransactingContext) => TransactingCapability<CoreWallet>;
|
|
41
|
+
export declare class TransactingCapabilityImplementation implements TransactingCapability<CoreWallet> {
|
|
42
|
+
#private;
|
|
35
43
|
readonly networkId: NetworkId.NetworkId;
|
|
36
44
|
readonly getCoinSelection: () => CoinSelection<ledger.Utxo>;
|
|
37
|
-
readonly
|
|
45
|
+
readonly txOps: TransactionOps;
|
|
38
46
|
readonly getCoins: () => CoinsAndBalancesCapability<CoreWallet>;
|
|
39
47
|
readonly getKeys: () => KeysCapability<CoreWallet>;
|
|
40
|
-
constructor(networkId: NetworkId.NetworkId, getCoinSelection: () => CoinSelection<ledger.Utxo>, getCoins: () => CoinsAndBalancesCapability<CoreWallet>, getKeys: () => KeysCapability<CoreWallet>,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
constructor(networkId: NetworkId.NetworkId, getCoinSelection: () => CoinSelection<ledger.Utxo>, getCoins: () => CoinsAndBalancesCapability<CoreWallet>, getKeys: () => KeysCapability<CoreWallet>, txOps: TransactionOps);
|
|
49
|
+
/**
|
|
50
|
+
* Balances an unbound transaction
|
|
51
|
+
* Note: Unbound transactions are balanced in place and returned
|
|
52
|
+
* @param wallet - The wallet to balance the transaction with
|
|
53
|
+
* @param transaction - The transaction to balance
|
|
54
|
+
* @returns The balanced transaction and the new wallet state if successful, otherwise an error
|
|
55
|
+
*/
|
|
56
|
+
balanceUnboundTransaction(wallet: CoreWallet, transaction: UnboundTransaction): Either.Either<[UnboundTransactionBalanceResult, CoreWallet], WalletError>;
|
|
57
|
+
/**
|
|
58
|
+
* Balances an unproven transaction
|
|
59
|
+
* Note: This method does the same thing as balanceUnboundTransaction but is provided for convenience and type safety
|
|
60
|
+
* @param wallet - The wallet to balance the transaction with
|
|
61
|
+
* @param transaction - The transaction to balance
|
|
62
|
+
* @returns The balanced transaction and the new wallet state if successful, otherwise an error
|
|
63
|
+
*/
|
|
64
|
+
balanceUnprovenTransaction(wallet: CoreWallet, transaction: ledger.UnprovenTransaction): Either.Either<[UnprovenTransactionBalanceResult, CoreWallet], WalletError>;
|
|
65
|
+
/**
|
|
66
|
+
* Balances a bound transaction
|
|
67
|
+
* Note: In bound transactions we can only balance the guaranteed section in intents
|
|
68
|
+
* @param wallet - The wallet to balance the transaction with
|
|
69
|
+
* @param transaction - The transaction to balance
|
|
70
|
+
* @returns A balancing counterpart transaction (which should be merged with the original transaction )
|
|
71
|
+
* and the new wallet state if successful, otherwise an error
|
|
72
|
+
*/
|
|
73
|
+
balanceFinalizedTransaction(wallet: CoreWallet, transaction: ledger.FinalizedTransaction): Either.Either<[FinalizedTransactionBalanceResult, CoreWallet], WalletError>;
|
|
74
|
+
/**
|
|
75
|
+
* Makes a transfer transaction
|
|
76
|
+
* @param wallet - The wallet to make the transfer with
|
|
77
|
+
* @param outputs - The outputs for the transfer
|
|
78
|
+
* @param ttl - The TTL for the transaction
|
|
79
|
+
* @returns The balanced transfer transaction and the new wallet state if successful, otherwise an error
|
|
80
|
+
*/
|
|
81
|
+
makeTransfer(wallet: CoreWallet, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, CoreWallet>, WalletError>;
|
|
82
|
+
/**
|
|
83
|
+
* Initializes a swap transaction
|
|
84
|
+
* @param wallet - The wallet to initialize the swap for
|
|
85
|
+
* @param desiredInputs - The desired inputs for the swap
|
|
86
|
+
* @param desiredOutputs - The desired outputs for the swap
|
|
87
|
+
* @param ttl - The TTL for the swap
|
|
88
|
+
* @returns The initialized swap transaction and the new wallet state if successful, otherwise an error
|
|
89
|
+
*/
|
|
90
|
+
initSwap(wallet: CoreWallet, desiredInputs: Record<ledger.RawTokenType, bigint>, desiredOutputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, CoreWallet>, WalletError>;
|
|
91
|
+
signUnprovenTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<ledger.UnprovenTransaction, WalletError>;
|
|
92
|
+
signUnboundTransaction(transaction: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<UnboundTransaction, WalletError>;
|
|
93
|
+
/**
|
|
94
|
+
* Reverts a transaction by rolling back all inputs owned by this wallet
|
|
95
|
+
* @param wallet - The wallet to revert the transaction for
|
|
96
|
+
* @param transaction - The transaction to revert (can be FinalizedTransaction, UnboundTransaction, or UnprovenTransaction)
|
|
97
|
+
* @returns The updated wallet with rolled back UTXOs if successful, otherwise an error
|
|
98
|
+
*/
|
|
99
|
+
revert(wallet: CoreWallet, transaction: ledger.FinalizedTransaction | UnboundTransaction | ledger.UnprovenTransaction): Either.Either<CoreWallet, WalletError>;
|
|
45
100
|
}
|