@canton-network/wallet-gateway-remote 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ledger/transaction-service.d.ts +2 -8
- package/dist/ledger/transaction-service.d.ts.map +1 -1
- package/dist/ledger/transaction-service.js +51 -474
- package/dist/ledger/transaction-service.test.js +26 -18
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.d.ts.map +1 -1
- package/dist/ledger/wallet-allocation/signing-providers/fireblocks-wallet-allocator.js +5 -6
- package/dist/ledger/wallet-allocation/wallet-allocation-service.test.js +1 -1
- package/dist/web/frontend/activities/index.html +2 -2
- package/dist/web/frontend/approve/index.html +2 -2
- package/dist/web/frontend/assets/{activities-CuMcxQVi.js → activities-B5-XCCZC.js} +1 -1
- package/dist/web/frontend/assets/addParty-BQLGvzJS.js +13 -0
- package/dist/web/frontend/assets/{approve-4Xp3Ck4z.js → approve-CyDHnjOG.js} +1 -1
- package/dist/web/frontend/assets/common-Byz7o2Qs.js +31 -0
- package/dist/web/frontend/assets/editParty-Oe0m1yB6.js +14 -0
- package/dist/web/frontend/assets/index-Cvcr2Fng.js +2 -0
- package/dist/web/frontend/parties/add/index.html +2 -1
- package/dist/web/frontend/parties/edit/index.html +17 -0
- package/package.json +27 -28
- package/dist/web/frontend/assets/addParty-SChbVsEF.js +0 -43
- package/dist/web/frontend/assets/index-BjhQnXf1.js +0 -2
|
@@ -17,16 +17,10 @@ export declare class TransactionService {
|
|
|
17
17
|
private hashingSchemeVersion;
|
|
18
18
|
constructor(store: Store, logger: Logger, signingDrivers: SigningDrivers | undefined, notifier: Notifier, hashingSchemeVersion: HASHING_SCHEME_VERSION);
|
|
19
19
|
sign(authContext: AuthContext, wallet: Wallet, signParams: SignParams): Promise<SignResult>;
|
|
20
|
-
execute(userId: UserId, wallet: Wallet, transaction: Transaction, executeParams
|
|
20
|
+
execute(userId: UserId, wallet: Wallet, transaction: Transaction, executeParams: ExecuteParams, ledgerClient: LedgerClient, network?: Network): Promise<ExecuteResult>;
|
|
21
21
|
signAndExecute(authContext: AuthContext, network: Network, wallet: Wallet, transaction: Transaction): Promise<SignAndExecuteResult>;
|
|
22
22
|
private loadPreparedTransactionForSigning;
|
|
23
|
-
private
|
|
24
|
-
private signWithWalletKernel;
|
|
25
|
-
private signWithBlockdaemon;
|
|
26
|
-
private signWithFireblocks;
|
|
27
|
-
private signWithDfns;
|
|
28
|
-
private signWithSecurosys;
|
|
29
|
-
private signWithBitgo;
|
|
23
|
+
private signWithDriver;
|
|
30
24
|
private executeWithParticipant;
|
|
31
25
|
private executeWithExternal;
|
|
32
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-service.d.ts","sourceRoot":"","sources":["../../src/ledger/transaction-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAS,MAAM,oCAAoC,CAAA;AACxE,OAAO,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"transaction-service.d.ts","sourceRoot":"","sources":["../../src/ledger/transaction-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAS,MAAM,oCAAoC,CAAA;AACxE,OAAO,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAShE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EACH,aAAa,EACb,aAAa,EACb,UAAU,EACb,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAA;AAMjE,OAAO,EACH,WAAW,EAEd,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAElD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,aAAa,CAAA;AAW7D,qBAAa,kBAAkB;IAEvB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,oBAAoB;gBAJpB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,YAAK,EACnC,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,sBAAsB;IAG3C,IAAI,CACb,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,GACvB,OAAO,CAAC,UAAU,CAAC;IAoGf,OAAO,CACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,aAAa,CAAC;IAmCZ,cAAc,CACvB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,GACzB,OAAO,CAAC,oBAAoB,CAAC;YAyDlB,iCAAiC;YAkBjC,cAAc;YAoGd,sBAAsB;YAqDtB,mBAAmB;CAiEpC"}
|
|
@@ -25,30 +25,51 @@ export class TransactionService {
|
|
|
25
25
|
if (!driver) {
|
|
26
26
|
throw new Error(`No driver found for ${signingProvider}`);
|
|
27
27
|
}
|
|
28
|
+
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
29
|
+
const baseSignParams = {
|
|
30
|
+
tx: tx.preparedTransaction,
|
|
31
|
+
txHash: tx.preparedTransactionHash,
|
|
32
|
+
keyIdentifier: {
|
|
33
|
+
publicKey: wallet.publicKey,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const internalTxId = crypto
|
|
37
|
+
.randomUUID()
|
|
38
|
+
.replace(/-/g, '')
|
|
39
|
+
.substring(0, 16);
|
|
40
|
+
/**
|
|
41
|
+
* The ultimate goal is that every signing driver is indistinguishable,
|
|
42
|
+
* and so we can just call the same function for all of them.
|
|
43
|
+
* However, some drivers have different requirements, so we need to handle them separately for now.
|
|
44
|
+
*
|
|
45
|
+
* This is a soft-blocker for 3rd-party driver plugins, since we wouldn't be able to add them to the codebase here
|
|
46
|
+
*/
|
|
28
47
|
switch (signingProvider) {
|
|
29
|
-
case SigningProvider.PARTICIPANT:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case SigningProvider.
|
|
33
|
-
return this.
|
|
48
|
+
case SigningProvider.PARTICIPANT:
|
|
49
|
+
case SigningProvider.WALLET_KERNEL:
|
|
50
|
+
case SigningProvider.DFNS:
|
|
51
|
+
case SigningProvider.BITGO: {
|
|
52
|
+
return this.signWithDriver(driver, signingProvider, authContext.userId, wallet, tx, baseSignParams);
|
|
34
53
|
}
|
|
35
54
|
case SigningProvider.BLOCKDAEMON: {
|
|
36
55
|
if (!authContext.email) {
|
|
37
56
|
throw new Error('Email is required for Blockdaemon wallet allocation');
|
|
38
57
|
}
|
|
39
|
-
|
|
58
|
+
const blockdaemonDriver = this.signingDrivers[SigningProvider.BLOCKDAEMON]?.controller(authContext.email);
|
|
59
|
+
return this.signWithDriver(blockdaemonDriver, // we checked the driver existence above, so this is safe
|
|
60
|
+
signingProvider, authContext.email, wallet, tx, { ...baseSignParams, internalTxId });
|
|
40
61
|
}
|
|
41
62
|
case SigningProvider.FIREBLOCKS: {
|
|
42
|
-
return this.
|
|
43
|
-
}
|
|
44
|
-
case SigningProvider.DFNS: {
|
|
45
|
-
return this.signWithDfns(authContext.userId, wallet, signParams);
|
|
63
|
+
return this.signWithDriver(driver, signingProvider, authContext.userId, wallet, tx, { ...baseSignParams, userId: authContext.userId });
|
|
46
64
|
}
|
|
47
65
|
case SigningProvider.SECUROSYS: {
|
|
48
|
-
return this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
return this.signWithDriver(driver, signingProvider, authContext.userId, wallet, tx, {
|
|
67
|
+
...baseSignParams,
|
|
68
|
+
keyIdentifier: {
|
|
69
|
+
id: keyLabelFromPublicKey(wallet.publicKey),
|
|
70
|
+
publicKey: wallet.publicKey,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
52
73
|
}
|
|
53
74
|
default:
|
|
54
75
|
throw new Error(`Unsupported signing provider: ${wallet.signingProviderId}`);
|
|
@@ -58,42 +79,19 @@ export class TransactionService {
|
|
|
58
79
|
if (transaction.status !== 'signed') {
|
|
59
80
|
throw new Error(`Cannot execute a ${transaction.status} transaction. Expected status: signed.`);
|
|
60
81
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
throw new Error('Execute params are required for participant signing');
|
|
66
|
-
}
|
|
67
|
-
if (!ledgerClient) {
|
|
68
|
-
throw new Error('Ledger client is required for participant signing');
|
|
69
|
-
}
|
|
70
|
-
if (!network) {
|
|
71
|
-
throw new Error('Network is required for participant signing');
|
|
72
|
-
}
|
|
73
|
-
return this.executeWithParticipant(userId, executeParams, transaction, ledgerClient, network);
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
this.logger.error(error, 'Failed to submit transaction');
|
|
77
|
-
throw error;
|
|
82
|
+
if (wallet.signingProviderId === SigningProvider.PARTICIPANT) {
|
|
83
|
+
try {
|
|
84
|
+
if (!network) {
|
|
85
|
+
throw new Error('Network is required for participant signing');
|
|
78
86
|
}
|
|
87
|
+
return this.executeWithParticipant(userId, executeParams, transaction, ledgerClient, network);
|
|
79
88
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
case SigningProvider.DFNS:
|
|
84
|
-
case SigningProvider.SECUROSYS:
|
|
85
|
-
case SigningProvider.BITGO: {
|
|
86
|
-
if (!executeParams) {
|
|
87
|
-
throw new Error('Execute params are required for external signing');
|
|
88
|
-
}
|
|
89
|
-
if (!ledgerClient) {
|
|
90
|
-
throw new Error('Ledger client is required for external signing');
|
|
91
|
-
}
|
|
92
|
-
return this.executeWithExternal(userId, executeParams, transaction, ledgerClient);
|
|
89
|
+
catch (error) {
|
|
90
|
+
this.logger.error(error, 'Failed to submit transaction');
|
|
91
|
+
throw error;
|
|
93
92
|
}
|
|
94
|
-
default:
|
|
95
|
-
throw new Error(`Unsupported signing provider: ${wallet.signingProviderId}`);
|
|
96
93
|
}
|
|
94
|
+
return this.executeWithExternal(userId, executeParams, transaction, ledgerClient);
|
|
97
95
|
}
|
|
98
96
|
async signAndExecute(authContext, network, wallet, transaction) {
|
|
99
97
|
const signParams = {
|
|
@@ -137,258 +135,7 @@ export class TransactionService {
|
|
|
137
135
|
}
|
|
138
136
|
return existingTx;
|
|
139
137
|
}
|
|
140
|
-
|
|
141
|
-
// For participant both signing and execution are handled by /v2/commands/submit-and-wait using participant keys
|
|
142
|
-
// This behavior is unique to signing provider participant.
|
|
143
|
-
// This step intended for making participant wallets conform to a common API.
|
|
144
|
-
async signWithParticipant(wallet, signParams) {
|
|
145
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
146
|
-
const now = new Date();
|
|
147
|
-
const signedTx = {
|
|
148
|
-
id: tx.id,
|
|
149
|
-
commandId: tx.commandId,
|
|
150
|
-
status: 'signed',
|
|
151
|
-
preparedTransaction: tx.preparedTransaction,
|
|
152
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
153
|
-
origin: tx?.origin ?? null,
|
|
154
|
-
...(tx?.createdAt && {
|
|
155
|
-
createdAt: tx.createdAt,
|
|
156
|
-
}),
|
|
157
|
-
signedAt: now,
|
|
158
|
-
};
|
|
159
|
-
await this.store.setTransactionSigned(tx.id, now);
|
|
160
|
-
this.notifier.emit('txChanged', signedTx);
|
|
161
|
-
return {
|
|
162
|
-
status: 'signed',
|
|
163
|
-
signature: 'none',
|
|
164
|
-
signedBy: wallet.namespace,
|
|
165
|
-
partyId: wallet.partyId,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
async signWithWalletKernel(userId, wallet, signParams) {
|
|
169
|
-
const signingProvider = this.signingDrivers[SigningProvider.WALLET_KERNEL];
|
|
170
|
-
if (!signingProvider) {
|
|
171
|
-
throw new Error('Wallet Gateway signing driver not available');
|
|
172
|
-
}
|
|
173
|
-
const driver = signingProvider.controller(userId);
|
|
174
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
175
|
-
const { signature } = await driver
|
|
176
|
-
.signTransaction({
|
|
177
|
-
tx: tx.preparedTransaction,
|
|
178
|
-
txHash: tx.preparedTransactionHash,
|
|
179
|
-
keyIdentifier: {
|
|
180
|
-
publicKey: wallet.publicKey,
|
|
181
|
-
},
|
|
182
|
-
})
|
|
183
|
-
.then(handleSigningError);
|
|
184
|
-
if (!signature) {
|
|
185
|
-
throw new Error('Failed to sign transaction: ' + JSON.stringify(signature));
|
|
186
|
-
}
|
|
187
|
-
const now = new Date();
|
|
188
|
-
const signedTx = {
|
|
189
|
-
id: tx.id,
|
|
190
|
-
commandId: tx.commandId,
|
|
191
|
-
status: 'signed',
|
|
192
|
-
preparedTransaction: tx.preparedTransaction,
|
|
193
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
194
|
-
origin: tx?.origin ?? null,
|
|
195
|
-
...(tx?.createdAt && {
|
|
196
|
-
createdAt: tx.createdAt,
|
|
197
|
-
}),
|
|
198
|
-
signedAt: now,
|
|
199
|
-
};
|
|
200
|
-
await this.store.setTransactionSigned(tx.id, now);
|
|
201
|
-
this.notifier.emit('txChanged', signedTx);
|
|
202
|
-
return {
|
|
203
|
-
status: 'signed',
|
|
204
|
-
signature,
|
|
205
|
-
signedBy: wallet.namespace,
|
|
206
|
-
partyId: wallet.partyId,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
async signWithBlockdaemon(userId, wallet, signParams) {
|
|
210
|
-
const signingProvider = this.signingDrivers[SigningProvider.BLOCKDAEMON];
|
|
211
|
-
if (!signingProvider) {
|
|
212
|
-
throw new Error('Blockdaemon signing driver not available');
|
|
213
|
-
}
|
|
214
|
-
const driver = signingProvider.controller(userId);
|
|
215
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
216
|
-
let signingResult;
|
|
217
|
-
if (tx.externalTxId) {
|
|
218
|
-
signingResult = await driver
|
|
219
|
-
.getTransaction({
|
|
220
|
-
userId,
|
|
221
|
-
txId: tx.externalTxId,
|
|
222
|
-
})
|
|
223
|
-
.then(handleSigningError);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
const internalTxId = crypto
|
|
227
|
-
.randomUUID()
|
|
228
|
-
.replace(/-/g, '')
|
|
229
|
-
.substring(0, 16);
|
|
230
|
-
signingResult = await driver
|
|
231
|
-
.signTransaction({
|
|
232
|
-
tx: tx.preparedTransaction,
|
|
233
|
-
txHash: tx.preparedTransactionHash,
|
|
234
|
-
keyIdentifier: {
|
|
235
|
-
publicKey: wallet.publicKey,
|
|
236
|
-
},
|
|
237
|
-
internalTxId,
|
|
238
|
-
})
|
|
239
|
-
.then(handleSigningError);
|
|
240
|
-
}
|
|
241
|
-
const now = new Date();
|
|
242
|
-
logDynamically(this.logger, 'Blockdaemon signing result', {
|
|
243
|
-
info: { transactionId: tx.id, status: signingResult.status },
|
|
244
|
-
debug: { signingResult, tx },
|
|
245
|
-
});
|
|
246
|
-
if (signingResult.status === 'signed') {
|
|
247
|
-
if (!signingResult.signature) {
|
|
248
|
-
throw new Error('No signature returned from signing driver');
|
|
249
|
-
}
|
|
250
|
-
const signedTx = {
|
|
251
|
-
id: tx.id,
|
|
252
|
-
commandId: tx.commandId,
|
|
253
|
-
status: signingResult.status,
|
|
254
|
-
preparedTransaction: tx.preparedTransaction,
|
|
255
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
256
|
-
origin: tx?.origin ?? null,
|
|
257
|
-
...(tx?.createdAt && {
|
|
258
|
-
createdAt: tx.createdAt,
|
|
259
|
-
}),
|
|
260
|
-
signedAt: now,
|
|
261
|
-
externalTxId: signingResult.txId,
|
|
262
|
-
};
|
|
263
|
-
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
264
|
-
this.notifier.emit('txChanged', signedTx);
|
|
265
|
-
return {
|
|
266
|
-
status: signingResult.status,
|
|
267
|
-
signature: signingResult.signature,
|
|
268
|
-
signedBy: wallet.namespace,
|
|
269
|
-
partyId: wallet.partyId,
|
|
270
|
-
externalTxId: signingResult.txId,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
275
|
-
const pendingTx = {
|
|
276
|
-
id: tx.id,
|
|
277
|
-
commandId: tx.commandId,
|
|
278
|
-
status,
|
|
279
|
-
preparedTransaction: tx.preparedTransaction,
|
|
280
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
281
|
-
externalTxId: signingResult.txId,
|
|
282
|
-
origin: tx?.origin ?? null,
|
|
283
|
-
...(tx?.createdAt && {
|
|
284
|
-
createdAt: tx.createdAt,
|
|
285
|
-
}),
|
|
286
|
-
};
|
|
287
|
-
await this.store.setTransactionStatus(tx.id, status, {
|
|
288
|
-
externalTxId: signingResult.txId,
|
|
289
|
-
});
|
|
290
|
-
this.notifier.emit('txChanged', pendingTx);
|
|
291
|
-
return {
|
|
292
|
-
status: signingResult.status,
|
|
293
|
-
externalTxId: signingResult.txId,
|
|
294
|
-
partyId: wallet.partyId,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
async signWithFireblocks(userId, wallet, signParams) {
|
|
299
|
-
const signingProvider = this.signingDrivers[SigningProvider.FIREBLOCKS];
|
|
300
|
-
if (!signingProvider) {
|
|
301
|
-
throw new Error('Fireblocks signing driver not available');
|
|
302
|
-
}
|
|
303
|
-
const driver = signingProvider.controller(userId);
|
|
304
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
305
|
-
let signingResult;
|
|
306
|
-
if (tx.externalTxId) {
|
|
307
|
-
signingResult = await driver
|
|
308
|
-
.getTransaction({
|
|
309
|
-
userId,
|
|
310
|
-
txId: tx.externalTxId,
|
|
311
|
-
})
|
|
312
|
-
.then(handleSigningError);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
signingResult = await driver
|
|
316
|
-
.signTransaction({
|
|
317
|
-
userId,
|
|
318
|
-
tx: tx.preparedTransaction,
|
|
319
|
-
txHash: Buffer.from(tx.preparedTransactionHash, 'base64').toString('hex'),
|
|
320
|
-
keyIdentifier: {
|
|
321
|
-
publicKey: wallet.publicKey,
|
|
322
|
-
},
|
|
323
|
-
})
|
|
324
|
-
.then(handleSigningError);
|
|
325
|
-
}
|
|
326
|
-
const now = new Date();
|
|
327
|
-
logDynamically(this.logger, 'Fireblocks signing result', {
|
|
328
|
-
info: { transactionId: tx.id, status: signingResult.status },
|
|
329
|
-
debug: { signingResult, tx },
|
|
330
|
-
});
|
|
331
|
-
if (signingResult.status === 'signed') {
|
|
332
|
-
if (!signingResult.signature) {
|
|
333
|
-
throw new Error('No signature returned from signing driver');
|
|
334
|
-
}
|
|
335
|
-
const signedTx = {
|
|
336
|
-
id: tx.id,
|
|
337
|
-
commandId: tx.commandId,
|
|
338
|
-
status: signingResult.status,
|
|
339
|
-
preparedTransaction: tx.preparedTransaction,
|
|
340
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
341
|
-
origin: tx?.origin ?? null,
|
|
342
|
-
...(tx?.createdAt && {
|
|
343
|
-
createdAt: tx.createdAt,
|
|
344
|
-
}),
|
|
345
|
-
signedAt: now,
|
|
346
|
-
externalTxId: signingResult.txId,
|
|
347
|
-
};
|
|
348
|
-
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
349
|
-
this.notifier.emit('txChanged', signedTx);
|
|
350
|
-
// return signature in format that is already usable in execute
|
|
351
|
-
const decodedSignature = Buffer.from(signingResult.signature, 'hex').toString('base64');
|
|
352
|
-
return {
|
|
353
|
-
status: signingResult.status,
|
|
354
|
-
signature: decodedSignature,
|
|
355
|
-
signedBy: wallet.namespace,
|
|
356
|
-
partyId: wallet.partyId,
|
|
357
|
-
externalTxId: signingResult.txId,
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
362
|
-
const pendingTx = {
|
|
363
|
-
id: tx.id,
|
|
364
|
-
commandId: tx.commandId,
|
|
365
|
-
status,
|
|
366
|
-
preparedTransaction: tx.preparedTransaction,
|
|
367
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
368
|
-
externalTxId: signingResult.txId,
|
|
369
|
-
origin: tx?.origin ?? null,
|
|
370
|
-
...(tx?.createdAt && {
|
|
371
|
-
createdAt: tx.createdAt,
|
|
372
|
-
}),
|
|
373
|
-
};
|
|
374
|
-
await this.store.setTransactionStatus(tx.id, status, {
|
|
375
|
-
externalTxId: signingResult.txId,
|
|
376
|
-
});
|
|
377
|
-
this.notifier.emit('txChanged', pendingTx);
|
|
378
|
-
return {
|
|
379
|
-
status: signingResult.status,
|
|
380
|
-
externalTxId: signingResult.txId,
|
|
381
|
-
partyId: wallet.partyId,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
async signWithDfns(userId, wallet, signParams) {
|
|
386
|
-
const signingProvider = this.signingDrivers[SigningProvider.DFNS];
|
|
387
|
-
if (!signingProvider) {
|
|
388
|
-
throw new Error('Dfns signing driver not available');
|
|
389
|
-
}
|
|
390
|
-
const driver = signingProvider.controller(userId);
|
|
391
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
138
|
+
async signWithDriver(driver, driverId, userId, wallet, tx, signTransactionParams) {
|
|
392
139
|
let signingResult;
|
|
393
140
|
if (tx.externalTxId) {
|
|
394
141
|
signingResult = await driver
|
|
@@ -400,102 +147,16 @@ export class TransactionService {
|
|
|
400
147
|
}
|
|
401
148
|
else {
|
|
402
149
|
signingResult = await driver
|
|
403
|
-
.signTransaction(
|
|
404
|
-
tx: tx.preparedTransaction,
|
|
405
|
-
txHash: tx.preparedTransactionHash,
|
|
406
|
-
keyIdentifier: {
|
|
407
|
-
publicKey: wallet.publicKey,
|
|
408
|
-
},
|
|
409
|
-
})
|
|
150
|
+
.signTransaction(signTransactionParams)
|
|
410
151
|
.then(handleSigningError);
|
|
411
152
|
}
|
|
412
153
|
const now = new Date();
|
|
413
|
-
logDynamically(this.logger, '
|
|
414
|
-
info: {
|
|
415
|
-
|
|
416
|
-
});
|
|
417
|
-
if (signingResult.status === 'signed') {
|
|
418
|
-
if (!signingResult.signature) {
|
|
419
|
-
throw new Error('No signature returned from Dfns signing driver');
|
|
420
|
-
}
|
|
421
|
-
const signedTx = {
|
|
422
|
-
id: tx.id,
|
|
423
|
-
commandId: tx.commandId,
|
|
424
|
-
status: signingResult.status,
|
|
425
|
-
preparedTransaction: tx.preparedTransaction,
|
|
426
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
427
|
-
origin: tx?.origin ?? null,
|
|
428
|
-
...(tx?.createdAt && {
|
|
429
|
-
createdAt: tx.createdAt,
|
|
430
|
-
}),
|
|
431
|
-
signedAt: now,
|
|
432
|
-
externalTxId: signingResult.txId,
|
|
433
|
-
};
|
|
434
|
-
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
435
|
-
this.notifier.emit('txChanged', signedTx);
|
|
436
|
-
return {
|
|
154
|
+
logDynamically(this.logger, 'Driver signing result', {
|
|
155
|
+
info: {
|
|
156
|
+
transactionId: tx.id,
|
|
437
157
|
status: signingResult.status,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
partyId: wallet.partyId,
|
|
441
|
-
externalTxId: signingResult.txId,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
446
|
-
const pendingTx = {
|
|
447
|
-
id: tx.id,
|
|
448
|
-
commandId: tx.commandId,
|
|
449
|
-
status,
|
|
450
|
-
preparedTransaction: tx.preparedTransaction,
|
|
451
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
452
|
-
externalTxId: signingResult.txId,
|
|
453
|
-
origin: tx?.origin ?? null,
|
|
454
|
-
...(tx?.createdAt && {
|
|
455
|
-
createdAt: tx.createdAt,
|
|
456
|
-
}),
|
|
457
|
-
};
|
|
458
|
-
await this.store.setTransactionStatus(tx.id, status, {
|
|
459
|
-
externalTxId: signingResult.txId,
|
|
460
|
-
});
|
|
461
|
-
this.notifier.emit('txChanged', pendingTx);
|
|
462
|
-
return {
|
|
463
|
-
status: signingResult.status,
|
|
464
|
-
externalTxId: signingResult.txId,
|
|
465
|
-
partyId: wallet.partyId,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
async signWithSecurosys(userId, wallet, signParams) {
|
|
470
|
-
const signingProvider = this.signingDrivers[SigningProvider.SECUROSYS];
|
|
471
|
-
if (!signingProvider) {
|
|
472
|
-
throw new Error('Securosys signing driver not available');
|
|
473
|
-
}
|
|
474
|
-
const driver = signingProvider.controller(userId);
|
|
475
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
476
|
-
let signingResult;
|
|
477
|
-
if (tx.externalTxId) {
|
|
478
|
-
signingResult = await driver
|
|
479
|
-
.getTransaction({
|
|
480
|
-
txId: tx.externalTxId,
|
|
481
|
-
})
|
|
482
|
-
.then(handleSigningError);
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
signingResult = await driver
|
|
486
|
-
.signTransaction({
|
|
487
|
-
tx: tx.preparedTransaction,
|
|
488
|
-
txHash: tx.preparedTransactionHash,
|
|
489
|
-
keyIdentifier: {
|
|
490
|
-
id: keyLabelFromPublicKey(wallet.publicKey),
|
|
491
|
-
publicKey: wallet.publicKey,
|
|
492
|
-
},
|
|
493
|
-
})
|
|
494
|
-
.then(handleSigningError);
|
|
495
|
-
}
|
|
496
|
-
const now = new Date();
|
|
497
|
-
logDynamically(this.logger, 'Securosys signing result', {
|
|
498
|
-
info: { transactionId: tx.id, status: signingResult.status },
|
|
158
|
+
driverId,
|
|
159
|
+
},
|
|
499
160
|
debug: { signingResult, tx },
|
|
500
161
|
});
|
|
501
162
|
if (signingResult.status === 'signed') {
|
|
@@ -550,90 +211,6 @@ export class TransactionService {
|
|
|
550
211
|
};
|
|
551
212
|
}
|
|
552
213
|
}
|
|
553
|
-
async signWithBitgo(userId, wallet, signParams) {
|
|
554
|
-
const signingProvider = this.signingDrivers[SigningProvider.BITGO];
|
|
555
|
-
if (!signingProvider) {
|
|
556
|
-
throw new Error('BitGo signing driver not available');
|
|
557
|
-
}
|
|
558
|
-
const driver = signingProvider.controller(userId);
|
|
559
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
560
|
-
let signingResult;
|
|
561
|
-
if (tx.externalTxId) {
|
|
562
|
-
signingResult = await driver
|
|
563
|
-
.getTransaction({
|
|
564
|
-
userId,
|
|
565
|
-
txId: tx.externalTxId,
|
|
566
|
-
})
|
|
567
|
-
.then(handleSigningError);
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
signingResult = await driver
|
|
571
|
-
.signTransaction({
|
|
572
|
-
tx: tx.preparedTransaction,
|
|
573
|
-
txHash: tx.preparedTransactionHash,
|
|
574
|
-
keyIdentifier: {
|
|
575
|
-
publicKey: wallet.publicKey,
|
|
576
|
-
},
|
|
577
|
-
})
|
|
578
|
-
.then(handleSigningError);
|
|
579
|
-
}
|
|
580
|
-
const now = new Date();
|
|
581
|
-
logDynamically(this.logger, 'BitGo signing result', {
|
|
582
|
-
info: { transactionId: tx.id, status: signingResult.status },
|
|
583
|
-
debug: { signingResult, tx },
|
|
584
|
-
});
|
|
585
|
-
if (signingResult.status === 'signed') {
|
|
586
|
-
if (!signingResult.signature) {
|
|
587
|
-
throw new Error('No signature returned from BitGo signing driver');
|
|
588
|
-
}
|
|
589
|
-
const signedTx = {
|
|
590
|
-
id: tx.id,
|
|
591
|
-
commandId: tx.commandId,
|
|
592
|
-
status: signingResult.status,
|
|
593
|
-
preparedTransaction: tx.preparedTransaction,
|
|
594
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
595
|
-
origin: tx?.origin ?? null,
|
|
596
|
-
...(tx?.createdAt && {
|
|
597
|
-
createdAt: tx.createdAt,
|
|
598
|
-
}),
|
|
599
|
-
signedAt: now,
|
|
600
|
-
externalTxId: signingResult.txId,
|
|
601
|
-
};
|
|
602
|
-
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
603
|
-
this.notifier.emit('txChanged', signedTx);
|
|
604
|
-
return {
|
|
605
|
-
status: signingResult.status,
|
|
606
|
-
signature: signingResult.signature,
|
|
607
|
-
signedBy: wallet.namespace,
|
|
608
|
-
partyId: wallet.partyId,
|
|
609
|
-
externalTxId: signingResult.txId,
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
else {
|
|
613
|
-
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
614
|
-
const pendingTx = {
|
|
615
|
-
id: tx.id,
|
|
616
|
-
commandId: tx.commandId,
|
|
617
|
-
status,
|
|
618
|
-
preparedTransaction: tx.preparedTransaction,
|
|
619
|
-
preparedTransactionHash: tx.preparedTransactionHash,
|
|
620
|
-
externalTxId: signingResult.txId,
|
|
621
|
-
origin: tx?.origin ?? null,
|
|
622
|
-
...(tx?.createdAt && {
|
|
623
|
-
createdAt: tx.createdAt,
|
|
624
|
-
}),
|
|
625
|
-
};
|
|
626
|
-
await this.store.setTransactionStatus(tx.id, status, {
|
|
627
|
-
externalTxId: signingResult.txId,
|
|
628
|
-
});
|
|
629
|
-
this.notifier.emit('txChanged', pendingTx);
|
|
630
|
-
return {
|
|
631
|
-
status: signingResult.status,
|
|
632
|
-
externalTxId: signingResult.txId,
|
|
633
|
-
partyId: wallet.partyId,
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
214
|
async executeWithParticipant(userId, executeParams, transaction, ledgerClient, network) {
|
|
638
215
|
const { partyId } = executeParams;
|
|
639
216
|
const { commandId } = transaction;
|