@midnight-ntwrk/wallet-sdk-facade 1.0.0-beta.16 → 1.0.0-beta.17
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/index.d.ts +50 -8
- package/dist/index.js +119 -58
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,16 @@ import { type UnshieldedWallet, UnshieldedWalletState } from '@midnight-ntwrk/wa
|
|
|
4
4
|
import { AnyTransaction, DustWallet, DustWalletState, CoinsAndBalances as DustCoinsAndBalances } from '@midnight-ntwrk/wallet-sdk-dust-wallet';
|
|
5
5
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
6
6
|
export type UnboundTransaction = ledger.Transaction<ledger.SignatureEnabled, ledger.Proof, ledger.PreBinding>;
|
|
7
|
+
type TokenKind = 'dust' | 'shielded' | 'unshielded';
|
|
8
|
+
type TokenKindsToBalance = 'all' | TokenKind[];
|
|
9
|
+
declare const TokenKindsToBalance: {
|
|
10
|
+
allTokenKinds: string[];
|
|
11
|
+
toFlags: (tokenKinds: TokenKindsToBalance) => {
|
|
12
|
+
shouldBalanceUnshielded: boolean;
|
|
13
|
+
shouldBalanceShielded: boolean;
|
|
14
|
+
shouldBalanceDust: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
7
17
|
export type FinalizedTransactionRecipe = {
|
|
8
18
|
type: 'FINALIZED_TRANSACTION';
|
|
9
19
|
originalTransaction: ledger.FinalizedTransaction;
|
|
@@ -12,7 +22,7 @@ export type FinalizedTransactionRecipe = {
|
|
|
12
22
|
export type UnboundTransactionRecipe = {
|
|
13
23
|
type: 'UNBOUND_TRANSACTION';
|
|
14
24
|
baseTransaction: UnboundTransaction;
|
|
15
|
-
balancingTransaction
|
|
25
|
+
balancingTransaction?: ledger.UnprovenTransaction | undefined;
|
|
16
26
|
};
|
|
17
27
|
export type UnprovenTransactionRecipe = {
|
|
18
28
|
type: 'UNPROVEN_TRANSACTION';
|
|
@@ -58,22 +68,54 @@ export declare class WalletFacade {
|
|
|
58
68
|
state(): Observable<FacadeState>;
|
|
59
69
|
waitForSyncedState(): Promise<FacadeState>;
|
|
60
70
|
submitTransaction(tx: ledger.FinalizedTransaction): Promise<TransactionIdentifier>;
|
|
61
|
-
balanceFinalizedTransaction(
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
balanceFinalizedTransaction(tx: ledger.FinalizedTransaction, secretKeys: {
|
|
72
|
+
shieldedSecretKeys: ledger.ZswapSecretKeys;
|
|
73
|
+
dustSecretKey: ledger.DustSecretKey;
|
|
74
|
+
}, options: {
|
|
75
|
+
ttl: Date;
|
|
76
|
+
tokenKindsToBalance?: TokenKindsToBalance;
|
|
77
|
+
}): Promise<FinalizedTransactionRecipe>;
|
|
78
|
+
balanceUnboundTransaction(tx: UnboundTransaction, secretKeys: {
|
|
79
|
+
shieldedSecretKeys: ledger.ZswapSecretKeys;
|
|
80
|
+
dustSecretKey: ledger.DustSecretKey;
|
|
81
|
+
}, options: {
|
|
82
|
+
ttl: Date;
|
|
83
|
+
tokenKindsToBalance?: TokenKindsToBalance;
|
|
84
|
+
}): Promise<UnboundTransactionRecipe>;
|
|
85
|
+
balanceUnprovenTransaction(tx: ledger.UnprovenTransaction, secretKeys: {
|
|
86
|
+
shieldedSecretKeys: ledger.ZswapSecretKeys;
|
|
87
|
+
dustSecretKey: ledger.DustSecretKey;
|
|
88
|
+
}, options: {
|
|
89
|
+
ttl: Date;
|
|
90
|
+
tokenKindsToBalance?: TokenKindsToBalance;
|
|
91
|
+
}): Promise<UnprovenTransactionRecipe>;
|
|
64
92
|
finalizeRecipe(recipe: BalancingRecipe): Promise<ledger.FinalizedTransaction>;
|
|
65
93
|
signRecipe(recipe: BalancingRecipe, signSegment: (data: Uint8Array) => ledger.Signature): Promise<BalancingRecipe>;
|
|
66
|
-
|
|
94
|
+
signUnprovenTransaction(tx: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Promise<ledger.UnprovenTransaction>;
|
|
95
|
+
signUnboundTransaction(tx: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Promise<UnboundTransaction>;
|
|
67
96
|
finalizeTransaction(tx: ledger.UnprovenTransaction): Promise<ledger.FinalizedTransaction>;
|
|
68
97
|
calculateTransactionFee(tx: AnyTransaction): Promise<bigint>;
|
|
69
|
-
transferTransaction(
|
|
98
|
+
transferTransaction(outputs: CombinedTokenTransfer[], secretKeys: {
|
|
99
|
+
shieldedSecretKeys: ledger.ZswapSecretKeys;
|
|
100
|
+
dustSecretKey: ledger.DustSecretKey;
|
|
101
|
+
}, options: {
|
|
102
|
+
ttl: Date;
|
|
103
|
+
payFees?: boolean;
|
|
104
|
+
}): Promise<UnprovenTransactionRecipe>;
|
|
70
105
|
estimateRegistration(nightUtxos: readonly UtxoWithMeta[]): Promise<{
|
|
71
106
|
fee: bigint;
|
|
72
107
|
dustGenerationEstimations: ReadonlyArray<DustCoinsAndBalances.UtxoWithFullDustDetails>;
|
|
73
108
|
}>;
|
|
74
|
-
initSwap(
|
|
109
|
+
initSwap(desiredInputs: CombinedSwapInputs, desiredOutputs: CombinedSwapOutputs[], secretKeys: {
|
|
110
|
+
shieldedSecretKeys: ledger.ZswapSecretKeys;
|
|
111
|
+
dustSecretKey: ledger.DustSecretKey;
|
|
112
|
+
}, options: {
|
|
113
|
+
ttl: Date;
|
|
114
|
+
payFees?: boolean;
|
|
115
|
+
}): Promise<UnprovenTransactionRecipe>;
|
|
75
116
|
registerNightUtxosForDustGeneration(nightUtxos: readonly UtxoWithMeta[], nightVerifyingKey: ledger.SignatureVerifyingKey, signDustRegistration: (payload: Uint8Array) => ledger.Signature, dustReceiverAddress?: string): Promise<UnprovenTransactionRecipe>;
|
|
76
117
|
deregisterFromDustGeneration(nightUtxos: UtxoWithMeta[], nightVerifyingKey: ledger.SignatureVerifyingKey, signDustRegistration: (payload: Uint8Array) => ledger.Signature): Promise<UnprovenTransactionRecipe>;
|
|
77
|
-
start(
|
|
118
|
+
start(shieldedSecretKeys: ledger.ZswapSecretKeys, dustSecretKey: ledger.DustSecretKey): Promise<void>;
|
|
78
119
|
stop(): Promise<void>;
|
|
79
120
|
}
|
|
121
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
import { combineLatest, map } from 'rxjs';
|
|
14
14
|
import { Array as Arr, pipe } from 'effect';
|
|
15
15
|
import * as ledger from '@midnight-ntwrk/ledger-v7';
|
|
16
|
+
const TokenKindsToBalance = new (class {
|
|
17
|
+
allTokenKinds = ['shielded', 'unshielded', 'dust'];
|
|
18
|
+
toFlags = (tokenKinds) => {
|
|
19
|
+
return pipe(tokenKinds, (kinds) => (kinds === 'all' ? this.allTokenKinds : kinds), (kinds) => ({
|
|
20
|
+
shouldBalanceUnshielded: kinds.includes('unshielded'),
|
|
21
|
+
shouldBalanceShielded: kinds.includes('shielded'),
|
|
22
|
+
shouldBalanceDust: kinds.includes('dust'),
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
16
26
|
export class FacadeState {
|
|
17
27
|
shielded;
|
|
18
28
|
unshielded;
|
|
@@ -72,53 +82,89 @@ export class WalletFacade {
|
|
|
72
82
|
await this.shielded.submitTransaction(tx, 'Finalized');
|
|
73
83
|
return tx.identifiers().at(-1);
|
|
74
84
|
}
|
|
75
|
-
async balanceFinalizedTransaction(
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
?
|
|
82
|
-
:
|
|
85
|
+
async balanceFinalizedTransaction(tx, secretKeys, options) {
|
|
86
|
+
const { shieldedSecretKeys, dustSecretKey } = secretKeys;
|
|
87
|
+
const { ttl, tokenKindsToBalance = 'all' } = options;
|
|
88
|
+
const { shouldBalanceDust, shouldBalanceShielded, shouldBalanceUnshielded } = TokenKindsToBalance.toFlags(tokenKindsToBalance);
|
|
89
|
+
// Step 1: Run unshielded and shielded balancing
|
|
90
|
+
const unshieldedBalancingTx = shouldBalanceUnshielded
|
|
91
|
+
? await this.unshielded.balanceFinalizedTransaction(tx)
|
|
92
|
+
: undefined;
|
|
93
|
+
const shieldedBalancingTx = shouldBalanceShielded
|
|
94
|
+
? await this.shielded.balanceTransaction(shieldedSecretKeys, tx)
|
|
95
|
+
: undefined;
|
|
96
|
+
// Step 2: Merge unshielded and shielded balancing
|
|
97
|
+
const mergedBalancingTx = this.mergeUnprovenTransactions(shieldedBalancingTx, unshieldedBalancingTx);
|
|
98
|
+
// Step 3: Conditionally add dust/fee balancing
|
|
99
|
+
const feeBalancingTx = shouldBalanceDust
|
|
100
|
+
? await this.dust.balanceTransactions(dustSecretKey, mergedBalancingTx ? [tx, mergedBalancingTx] : [tx], ttl)
|
|
101
|
+
: undefined;
|
|
102
|
+
// Step 4: Merge fee balancing and create final recipe
|
|
103
|
+
const balancingTx = this.mergeUnprovenTransactions(mergedBalancingTx, feeBalancingTx);
|
|
104
|
+
if (!balancingTx) {
|
|
105
|
+
throw new Error('No balancing transaction was created. Please check your transaction.');
|
|
106
|
+
}
|
|
83
107
|
return {
|
|
84
108
|
type: 'FINALIZED_TRANSACTION',
|
|
85
109
|
originalTransaction: tx,
|
|
86
|
-
balancingTransaction,
|
|
110
|
+
balancingTransaction: balancingTx,
|
|
87
111
|
};
|
|
88
112
|
}
|
|
89
|
-
async balanceUnboundTransaction(
|
|
113
|
+
async balanceUnboundTransaction(tx, secretKeys, options) {
|
|
114
|
+
const { shieldedSecretKeys, dustSecretKey } = secretKeys;
|
|
115
|
+
const { ttl, tokenKindsToBalance = 'all' } = options;
|
|
116
|
+
const { shouldBalanceDust, shouldBalanceShielded, shouldBalanceUnshielded } = TokenKindsToBalance.toFlags(tokenKindsToBalance);
|
|
117
|
+
// Step 1: Run unshielded and shielded balancing
|
|
118
|
+
const shieldedBalancingTx = shouldBalanceShielded
|
|
119
|
+
? await this.shielded.balanceTransaction(shieldedSecretKeys, tx)
|
|
120
|
+
: undefined;
|
|
90
121
|
// For unbound transactions, unshielded balancing happens in place not with a balancing transaction
|
|
91
|
-
const balancedUnshieldedTx =
|
|
92
|
-
|
|
93
|
-
|
|
122
|
+
const balancedUnshieldedTx = shouldBalanceUnshielded
|
|
123
|
+
? await this.unshielded.balanceUnboundTransaction(tx)
|
|
124
|
+
: undefined;
|
|
125
|
+
// Step 2: Unbound unshielded tx are balanced in place, use it as base tx if present
|
|
94
126
|
const baseTx = balancedUnshieldedTx ?? tx;
|
|
95
|
-
//
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
127
|
+
// Step 3: Conditionally add dust/fee balancing
|
|
128
|
+
const feeBalancingTransaction = shouldBalanceDust
|
|
129
|
+
? await this.dust.balanceTransactions(dustSecretKey, shieldedBalancingTx ? [baseTx, shieldedBalancingTx] : [baseTx], ttl)
|
|
130
|
+
: undefined;
|
|
131
|
+
// Step 4: Create the final balancing transaction
|
|
132
|
+
const balancingTransaction = this.mergeUnprovenTransactions(shieldedBalancingTx, feeBalancingTransaction);
|
|
133
|
+
// if there is no balancingTransaction and there was no unshielded tx balancing (in place) throw an error.
|
|
134
|
+
if (!balancingTransaction && !balancedUnshieldedTx) {
|
|
135
|
+
throw new Error('No balancing transaction was created. Please check your transaction.');
|
|
136
|
+
}
|
|
102
137
|
return {
|
|
103
138
|
type: 'UNBOUND_TRANSACTION',
|
|
104
139
|
baseTransaction: baseTx,
|
|
105
|
-
balancingTransaction,
|
|
140
|
+
balancingTransaction: balancingTransaction ?? undefined,
|
|
106
141
|
};
|
|
107
142
|
}
|
|
108
|
-
async balanceUnprovenTransaction(
|
|
143
|
+
async balanceUnprovenTransaction(tx, secretKeys, options) {
|
|
144
|
+
const { shieldedSecretKeys, dustSecretKey } = secretKeys;
|
|
145
|
+
const { ttl, tokenKindsToBalance = 'all' } = options;
|
|
146
|
+
const { shouldBalanceDust, shouldBalanceShielded, shouldBalanceUnshielded } = TokenKindsToBalance.toFlags(tokenKindsToBalance);
|
|
147
|
+
// Step 1: Run unshielded and shielded balancing
|
|
148
|
+
const shieldedBalancingTx = shouldBalanceShielded
|
|
149
|
+
? await this.shielded.balanceTransaction(shieldedSecretKeys, tx)
|
|
150
|
+
: undefined;
|
|
109
151
|
// For unproven transactions, unshielded balancing happens in place
|
|
110
|
-
const balancedUnshieldedTx =
|
|
111
|
-
|
|
112
|
-
|
|
152
|
+
const balancedUnshieldedTx = shouldBalanceUnshielded
|
|
153
|
+
? await this.unshielded.balanceUnprovenTransaction(tx)
|
|
154
|
+
: undefined;
|
|
155
|
+
// Step 2: Use the balanced unshielded tx if present, otherwise use the original tx
|
|
113
156
|
const baseTx = balancedUnshieldedTx ?? tx;
|
|
114
|
-
// Merge shielded balancing into base tx if present
|
|
115
|
-
const mergedTx =
|
|
116
|
-
//
|
|
117
|
-
const
|
|
118
|
-
|
|
157
|
+
// Step 3: Merge shielded balancing into base tx if present
|
|
158
|
+
const mergedTx = this.mergeUnprovenTransactions(baseTx, shieldedBalancingTx);
|
|
159
|
+
// Step 4: Conditionally add dust/fee balancing
|
|
160
|
+
const feeBalancingTx = shouldBalanceDust
|
|
161
|
+
? await this.dust.balanceTransactions(dustSecretKey, [mergedTx], ttl)
|
|
162
|
+
: undefined;
|
|
163
|
+
// Step 5: Merge fee balancing if present
|
|
164
|
+
const balancedTx = this.mergeUnprovenTransactions(mergedTx, feeBalancingTx);
|
|
119
165
|
return {
|
|
120
166
|
type: 'UNPROVEN_TRANSACTION',
|
|
121
|
-
transaction:
|
|
167
|
+
transaction: balancedTx,
|
|
122
168
|
};
|
|
123
169
|
}
|
|
124
170
|
async finalizeRecipe(recipe) {
|
|
@@ -128,9 +174,11 @@ export class WalletFacade {
|
|
|
128
174
|
return recipe.originalTransaction.merge(finalizedBalancing);
|
|
129
175
|
}
|
|
130
176
|
case 'UNBOUND_TRANSACTION': {
|
|
131
|
-
const finalizedBalancingTx =
|
|
177
|
+
const finalizedBalancingTx = recipe.balancingTransaction
|
|
178
|
+
? await this.finalizeTransaction(recipe.balancingTransaction)
|
|
179
|
+
: undefined;
|
|
132
180
|
const finalizedTransaction = recipe.baseTransaction.bind();
|
|
133
|
-
return finalizedTransaction.merge(finalizedBalancingTx);
|
|
181
|
+
return finalizedBalancingTx ? finalizedTransaction.merge(finalizedBalancingTx) : finalizedTransaction;
|
|
134
182
|
}
|
|
135
183
|
case 'UNPROVEN_TRANSACTION': {
|
|
136
184
|
return await this.finalizeTransaction(recipe.transaction);
|
|
@@ -140,32 +188,38 @@ export class WalletFacade {
|
|
|
140
188
|
async signRecipe(recipe, signSegment) {
|
|
141
189
|
switch (recipe.type) {
|
|
142
190
|
case 'FINALIZED_TRANSACTION': {
|
|
143
|
-
const
|
|
191
|
+
const signedBalancingTx = await this.signUnprovenTransaction(recipe.balancingTransaction, signSegment);
|
|
144
192
|
return {
|
|
145
193
|
type: 'FINALIZED_TRANSACTION',
|
|
146
194
|
originalTransaction: recipe.originalTransaction,
|
|
147
|
-
balancingTransaction:
|
|
195
|
+
balancingTransaction: signedBalancingTx,
|
|
148
196
|
};
|
|
149
197
|
}
|
|
150
198
|
case 'UNBOUND_TRANSACTION': {
|
|
151
|
-
const
|
|
199
|
+
const signedBalancingTx = recipe.balancingTransaction
|
|
200
|
+
? await this.signUnprovenTransaction(recipe.balancingTransaction, signSegment)
|
|
201
|
+
: undefined;
|
|
202
|
+
const signedBaseTx = await this.signUnboundTransaction(recipe.baseTransaction, signSegment);
|
|
152
203
|
return {
|
|
153
204
|
type: 'UNBOUND_TRANSACTION',
|
|
154
|
-
baseTransaction:
|
|
155
|
-
balancingTransaction:
|
|
205
|
+
baseTransaction: signedBaseTx,
|
|
206
|
+
balancingTransaction: signedBalancingTx,
|
|
156
207
|
};
|
|
157
208
|
}
|
|
158
209
|
case 'UNPROVEN_TRANSACTION': {
|
|
159
|
-
const
|
|
210
|
+
const signedTx = await this.signUnprovenTransaction(recipe.transaction, signSegment);
|
|
160
211
|
return {
|
|
161
212
|
type: 'UNPROVEN_TRANSACTION',
|
|
162
|
-
transaction:
|
|
213
|
+
transaction: signedTx,
|
|
163
214
|
};
|
|
164
215
|
}
|
|
165
216
|
}
|
|
166
217
|
}
|
|
167
|
-
async
|
|
168
|
-
return await this.unshielded.
|
|
218
|
+
async signUnprovenTransaction(tx, signSegment) {
|
|
219
|
+
return await this.unshielded.signUnprovenTransaction(tx, signSegment);
|
|
220
|
+
}
|
|
221
|
+
async signUnboundTransaction(tx, signSegment) {
|
|
222
|
+
return await this.unshielded.signUnboundTransaction(tx, signSegment);
|
|
169
223
|
}
|
|
170
224
|
async finalizeTransaction(tx) {
|
|
171
225
|
return await this.shielded.finalizeTransaction(tx);
|
|
@@ -173,7 +227,9 @@ export class WalletFacade {
|
|
|
173
227
|
async calculateTransactionFee(tx) {
|
|
174
228
|
return await this.dust.calculateFee([tx]);
|
|
175
229
|
}
|
|
176
|
-
async transferTransaction(
|
|
230
|
+
async transferTransaction(outputs, secretKeys, options) {
|
|
231
|
+
const { shieldedSecretKeys, dustSecretKey } = secretKeys;
|
|
232
|
+
const { ttl, payFees = true } = options;
|
|
177
233
|
const unshieldedOutputs = outputs
|
|
178
234
|
.filter((output) => output.type === 'unshielded')
|
|
179
235
|
.flatMap((output) => output.outputs);
|
|
@@ -181,20 +237,17 @@ export class WalletFacade {
|
|
|
181
237
|
if (unshieldedOutputs.length === 0 && shieldedOutputs.length === 0) {
|
|
182
238
|
throw Error('At least one shielded or unshielded output is required.');
|
|
183
239
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
if (shieldedOutputs.length > 0) {
|
|
190
|
-
shieldedTx = await this.shielded.transferTransaction(zswapSecretKeys, shieldedOutputs);
|
|
191
|
-
}
|
|
240
|
+
const shieldedTx = shieldedOutputs.length > 0
|
|
241
|
+
? await this.shielded.transferTransaction(shieldedSecretKeys, shieldedOutputs)
|
|
242
|
+
: undefined;
|
|
243
|
+
const unshieldedTx = unshieldedOutputs.length > 0 ? await this.unshielded.transferTransaction(unshieldedOutputs, ttl) : undefined;
|
|
192
244
|
const mergedTxs = this.mergeUnprovenTransactions(shieldedTx, unshieldedTx);
|
|
193
245
|
// Add fee payment
|
|
194
|
-
const
|
|
246
|
+
const feeBalancingTx = payFees ? await this.dust.balanceTransactions(dustSecretKey, [mergedTxs], ttl) : undefined;
|
|
247
|
+
const finalTx = this.mergeUnprovenTransactions(mergedTxs, feeBalancingTx);
|
|
195
248
|
return {
|
|
196
249
|
type: 'UNPROVEN_TRANSACTION',
|
|
197
|
-
transaction:
|
|
250
|
+
transaction: finalTx,
|
|
198
251
|
};
|
|
199
252
|
}
|
|
200
253
|
async estimateRegistration(nightUtxos) {
|
|
@@ -211,7 +264,9 @@ export class WalletFacade {
|
|
|
211
264
|
dustGenerationEstimations,
|
|
212
265
|
};
|
|
213
266
|
}
|
|
214
|
-
async initSwap(
|
|
267
|
+
async initSwap(desiredInputs, desiredOutputs, secretKeys, options) {
|
|
268
|
+
const { shieldedSecretKeys, dustSecretKey } = secretKeys;
|
|
269
|
+
const { ttl, payFees = false } = options;
|
|
215
270
|
const { shielded: shieldedInputs, unshielded: unshieldedInputs } = desiredInputs;
|
|
216
271
|
const shieldedOutputs = desiredOutputs
|
|
217
272
|
.filter((output) => output.type === 'shielded')
|
|
@@ -225,7 +280,7 @@ export class WalletFacade {
|
|
|
225
280
|
throw Error('At least one shielded or unshielded swap is required.');
|
|
226
281
|
}
|
|
227
282
|
const shieldedTx = hasShieldedPart && shieldedInputs !== undefined
|
|
228
|
-
? await this.shielded.initSwap(
|
|
283
|
+
? await this.shielded.initSwap(shieldedSecretKeys, shieldedInputs, shieldedOutputs)
|
|
229
284
|
: undefined;
|
|
230
285
|
const unshieldedTx = hasUnshieldedPart && unshieldedInputs !== undefined
|
|
231
286
|
? await this.unshielded.initSwap(unshieldedInputs, unshieldedOutputs, ttl)
|
|
@@ -234,9 +289,11 @@ export class WalletFacade {
|
|
|
234
289
|
if (!combinedTx) {
|
|
235
290
|
throw Error('Unexpected transaction state.');
|
|
236
291
|
}
|
|
292
|
+
const feeBalancingTx = payFees ? await this.dust.balanceTransactions(dustSecretKey, [combinedTx], ttl) : undefined;
|
|
293
|
+
const finalTx = this.mergeUnprovenTransactions(combinedTx, feeBalancingTx);
|
|
237
294
|
return {
|
|
238
295
|
type: 'UNPROVEN_TRANSACTION',
|
|
239
|
-
transaction:
|
|
296
|
+
transaction: finalTx,
|
|
240
297
|
};
|
|
241
298
|
}
|
|
242
299
|
async registerNightUtxosForDustGeneration(nightUtxos, nightVerifyingKey, signDustRegistration, dustReceiverAddress) {
|
|
@@ -258,8 +315,12 @@ export class WalletFacade {
|
|
|
258
315
|
transaction: dustDeregistrationTx,
|
|
259
316
|
};
|
|
260
317
|
}
|
|
261
|
-
async start(
|
|
262
|
-
await Promise.all([
|
|
318
|
+
async start(shieldedSecretKeys, dustSecretKey) {
|
|
319
|
+
await Promise.all([
|
|
320
|
+
this.shielded.start(shieldedSecretKeys),
|
|
321
|
+
this.unshielded.start(),
|
|
322
|
+
this.dust.start(dustSecretKey),
|
|
323
|
+
]);
|
|
263
324
|
}
|
|
264
325
|
async stop() {
|
|
265
326
|
await Promise.all([this.shielded.stop(), this.unshielded.stop(), this.dust.stop()]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/wallet-sdk-facade",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@midnight-ntwrk/ledger-v7": "7.0.0
|
|
27
|
+
"@midnight-ntwrk/ledger-v7": "7.0.0",
|
|
28
28
|
"@midnight-ntwrk/wallet-sdk-abstractions": "1.0.0-beta.10",
|
|
29
|
-
"@midnight-ntwrk/wallet-sdk-address-format": "3.0.0-beta.
|
|
30
|
-
"@midnight-ntwrk/wallet-sdk-dust-wallet": "1.0.0-beta.
|
|
29
|
+
"@midnight-ntwrk/wallet-sdk-address-format": "3.0.0-beta.12",
|
|
30
|
+
"@midnight-ntwrk/wallet-sdk-dust-wallet": "1.0.0-beta.16",
|
|
31
31
|
"@midnight-ntwrk/wallet-sdk-hd": "3.0.0-beta.8",
|
|
32
|
-
"@midnight-ntwrk/wallet-sdk-shielded": "1.0.0-beta.
|
|
33
|
-
"@midnight-ntwrk/wallet-sdk-unshielded-wallet": "1.0.0-beta.
|
|
32
|
+
"@midnight-ntwrk/wallet-sdk-shielded": "1.0.0-beta.17",
|
|
33
|
+
"@midnight-ntwrk/wallet-sdk-unshielded-wallet": "1.0.0-beta.19",
|
|
34
34
|
"rxjs": "^7.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@midnight-ntwrk/wallet-sdk-prover-client": "1.0.0-beta.
|
|
37
|
+
"@midnight-ntwrk/wallet-sdk-prover-client": "1.0.0-beta.14",
|
|
38
38
|
"eslint": "^9.37.0",
|
|
39
39
|
"prettier": "^3.7.0",
|
|
40
40
|
"publint": "~0.3.14",
|