@canton-network/wallet-gateway-remote 0.26.0 → 1.0.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/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +3 -1
- package/dist/ledger/transaction-service.d.ts.map +1 -1
- package/dist/ledger/transaction-service.js +25 -16
- package/dist/ledger/wallet-sync-service.d.ts +2 -1
- package/dist/ledger/wallet-sync-service.d.ts.map +1 -1
- package/dist/ledger/wallet-sync-service.js +64 -48
- package/dist/ledger/wallet-sync-service.test.js +169 -50
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +10 -7
- package/dist/user-api/rpc-gen/typings.d.ts +30 -7
- package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/web/frontend/404/index.html +2 -2
- package/dist/web/frontend/activities/index.html +3 -3
- package/dist/web/frontend/approve/index.html +5 -5
- package/dist/web/frontend/assets/404-CEXKCUlr.js +5 -0
- package/dist/web/frontend/assets/{activities-BdSUE0hv.js → activities-CPXS4OC3.js} +4 -3
- package/dist/web/frontend/assets/addIdentityProvider-BJjhu--M.js +28 -0
- package/dist/web/frontend/assets/{addNetwork-B4FpgV7D.js → addNetwork-B0olMmyv.js} +3 -3
- package/dist/web/frontend/assets/{addParty-D-UmQ0Oh.js → addParty-PUjps7Ie.js} +3 -3
- package/dist/web/frontend/assets/approve-CARzty9R.js +21 -0
- package/dist/web/frontend/assets/{callback-CXLUjUAK.js → callback-BqE26RlP.js} +1 -1
- package/dist/web/frontend/assets/{identityProviders-CtFhI1gg.js → identityProviders-Cnx8VIsD.js} +2 -2
- package/dist/web/frontend/assets/{index-dDAXt5F2.js → index-CgsIALyR.js} +1 -1
- package/dist/web/frontend/assets/index-UdyYJ_nU.js +4011 -0
- package/dist/web/frontend/assets/{index-DFhaSBOK.js → index-nOmkqkbK.js} +3 -3
- package/dist/web/frontend/assets/{login-CmwQEYxS.js → login-CkpIib74.js} +2 -2
- package/dist/web/frontend/assets/{networks-f8gSZxSb.js → networks-D7iP_lGh.js} +2 -2
- package/dist/web/frontend/assets/reviewIdentityProvider-BRb38sGH.js +43 -0
- package/dist/web/frontend/assets/{reviewNetwork-D3QSssLB.js → reviewNetwork-BVdYGugz.js} +3 -3
- package/dist/web/frontend/assets/{settings-Cc-Ij_uP.js → settings-CxEU64oG.js} +2 -2
- package/dist/web/frontend/assets/state-CypMU0cY.js +1 -0
- package/dist/web/frontend/assets/{utils-CVOqcw_M.js → utils-V1qa66Nv.js} +1 -1
- package/dist/web/frontend/callback/index.html +2 -2
- package/dist/web/frontend/identity-providers/add/index.html +3 -3
- package/dist/web/frontend/identity-providers/index.html +3 -3
- package/dist/web/frontend/identity-providers/review/index.html +3 -3
- package/dist/web/frontend/index.html +1 -1
- package/dist/web/frontend/login/index.html +4 -4
- package/dist/web/frontend/networks/add/index.html +3 -3
- package/dist/web/frontend/networks/index.html +3 -3
- package/dist/web/frontend/networks/review/index.html +3 -3
- package/dist/web/frontend/parties/add/index.html +5 -5
- package/dist/web/frontend/parties/index.html +4 -4
- package/dist/web/frontend/settings/index.html +3 -3
- package/package.json +19 -19
- package/dist/web/frontend/assets/404-CEw-fKbi.js +0 -5
- package/dist/web/frontend/assets/addIdentityProvider-Bzz1fUGn.js +0 -35
- package/dist/web/frontend/assets/approve-DP3Lfyhw.js +0 -21
- package/dist/web/frontend/assets/index-BuC7gGqj.js +0 -3942
- package/dist/web/frontend/assets/reviewIdentityProvider-CJFOHumn.js +0 -43
- package/dist/web/frontend/assets/state-CZ6wI2d4.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,WAAW,EAEd,MAAM,kCAAkC,CAAA;AAYzC,OAAO,EAAE,KAAK,EAAe,MAAM,mCAAmC,CAAA;AAQtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,SAAS,MAAM,EACf,SAAS,MAAM,EACf,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,QAAQ,MAAM,GAAG,IAAI,EACrB,UAAU,WAAW;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,WAAW,EAEd,MAAM,kCAAkC,CAAA;AAYzC,OAAO,EAAE,KAAK,EAAe,MAAM,mCAAmC,CAAA;AAQtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,SAAS,MAAM,EACf,SAAS,MAAM,EACf,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,QAAQ,MAAM,GAAG,IAAI,EACrB,UAAU,WAAW;;;;;;;;;;;;;;;CAmTxB,CAAA"}
|
|
@@ -143,11 +143,13 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
143
143
|
const notifier = notificationService.getNotifier(userId);
|
|
144
144
|
params.commandId = params.commandId || v4();
|
|
145
145
|
const commandId = params.commandId;
|
|
146
|
+
const transactionId = v4();
|
|
146
147
|
notifier.emit('txChanged', { status: 'pending', commandId });
|
|
147
148
|
const synchronizerId = network.synchronizerId ??
|
|
148
149
|
(await ledgerClient.getSynchronizerId());
|
|
149
150
|
const response = await prepareSubmission(context.userId, wallet.partyId, synchronizerId, params, ledgerClient);
|
|
150
151
|
const transaction = {
|
|
152
|
+
id: transactionId,
|
|
151
153
|
commandId,
|
|
152
154
|
status: 'pending',
|
|
153
155
|
preparedTransaction: response.preparedTransaction,
|
|
@@ -168,7 +170,7 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
168
170
|
await store.setTransaction(transaction);
|
|
169
171
|
return {
|
|
170
172
|
// closeafteraction query param flag makes approving or deleting tx close the popup
|
|
171
|
-
userUrl: `${userUrl}/approve/index.html?commandId=${commandId}&closeafteraction`,
|
|
173
|
+
userUrl: `${userUrl}/approve/index.html?transactionId=${transactionId}&commandId=${commandId}&closeafteraction`,
|
|
172
174
|
};
|
|
173
175
|
},
|
|
174
176
|
status: async () => {
|
|
@@ -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,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAGH,sBAAsB,EACtB,eAAe,EAElB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACH,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EACnB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAA;AAYjE,qBAAa,kBAAkB;IAEvB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IAGtB,OAAO,CAAC,QAAQ;gBALR,KAAK,EAAE,KAAK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d,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,GACvB,OAAO,CAAC,UAAU,CAAC;IAwGT,kBAAkB,CAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,GACvB,OAAO,CAAC,UAAU,CAAC;IA4GT,sBAAsB,CAC/B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,aAAa,CAAC;IAyCZ,mBAAmB,CAC5B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,aAAa,CAAC;CAuD5B"}
|
|
@@ -15,10 +15,10 @@ export class TransactionService {
|
|
|
15
15
|
this.signingDrivers = signingDrivers;
|
|
16
16
|
this.notifier = notifier;
|
|
17
17
|
}
|
|
18
|
-
async loadPreparedTransactionForSigning(
|
|
19
|
-
const existingTx = await this.store.getTransaction(
|
|
18
|
+
async loadPreparedTransactionForSigning(transactionId) {
|
|
19
|
+
const existingTx = await this.store.getTransaction(transactionId);
|
|
20
20
|
if (!existingTx) {
|
|
21
|
-
throw new Error(`Transaction not found with
|
|
21
|
+
throw new Error(`Transaction not found with id: ${transactionId}`);
|
|
22
22
|
}
|
|
23
23
|
return existingTx;
|
|
24
24
|
}
|
|
@@ -36,7 +36,7 @@ export class TransactionService {
|
|
|
36
36
|
throw new Error('Wallet Kernel signing driver not available');
|
|
37
37
|
}
|
|
38
38
|
const driver = signingProvider.controller(userId);
|
|
39
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.
|
|
39
|
+
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
40
40
|
const { signature } = await driver
|
|
41
41
|
.signTransaction({
|
|
42
42
|
tx: tx.preparedTransaction,
|
|
@@ -51,6 +51,7 @@ export class TransactionService {
|
|
|
51
51
|
}
|
|
52
52
|
const now = new Date();
|
|
53
53
|
const signedTx = {
|
|
54
|
+
id: tx.id,
|
|
54
55
|
commandId: tx.commandId,
|
|
55
56
|
status: 'signed',
|
|
56
57
|
preparedTransaction: tx.preparedTransaction,
|
|
@@ -61,7 +62,7 @@ export class TransactionService {
|
|
|
61
62
|
}),
|
|
62
63
|
signedAt: now,
|
|
63
64
|
};
|
|
64
|
-
await this.store.setTransactionSigned(tx.
|
|
65
|
+
await this.store.setTransactionSigned(tx.id, now);
|
|
65
66
|
this.notifier.emit('txChanged', signedTx);
|
|
66
67
|
return {
|
|
67
68
|
status: 'signed',
|
|
@@ -76,7 +77,7 @@ export class TransactionService {
|
|
|
76
77
|
throw new Error('Blockdaemon signing driver not available');
|
|
77
78
|
}
|
|
78
79
|
const driver = signingProvider.controller(userId);
|
|
79
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.
|
|
80
|
+
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
80
81
|
let signingResult;
|
|
81
82
|
if (tx && tx.externalTxId) {
|
|
82
83
|
signingResult = await driver
|
|
@@ -108,6 +109,7 @@ export class TransactionService {
|
|
|
108
109
|
throw new Error('No signature returned from signing driver');
|
|
109
110
|
}
|
|
110
111
|
const signedTx = {
|
|
112
|
+
id: tx.id,
|
|
111
113
|
commandId: tx.commandId,
|
|
112
114
|
status: signingResult.status,
|
|
113
115
|
preparedTransaction: tx.preparedTransaction,
|
|
@@ -119,7 +121,7 @@ export class TransactionService {
|
|
|
119
121
|
signedAt: now,
|
|
120
122
|
externalTxId: signingResult.txId,
|
|
121
123
|
};
|
|
122
|
-
await this.store.setTransactionSigned(tx.
|
|
124
|
+
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
123
125
|
this.notifier.emit('txChanged', signedTx);
|
|
124
126
|
return {
|
|
125
127
|
status: signingResult.status,
|
|
@@ -132,6 +134,7 @@ export class TransactionService {
|
|
|
132
134
|
else {
|
|
133
135
|
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
134
136
|
const pendingTx = {
|
|
137
|
+
id: tx.id,
|
|
135
138
|
commandId: tx.commandId,
|
|
136
139
|
status,
|
|
137
140
|
preparedTransaction: tx.preparedTransaction,
|
|
@@ -142,7 +145,7 @@ export class TransactionService {
|
|
|
142
145
|
createdAt: tx.createdAt,
|
|
143
146
|
}),
|
|
144
147
|
};
|
|
145
|
-
await this.store.setTransactionStatus(tx.
|
|
148
|
+
await this.store.setTransactionStatus(tx.id, status, {
|
|
146
149
|
externalTxId: signingResult.txId,
|
|
147
150
|
});
|
|
148
151
|
this.notifier.emit('txChanged', pendingTx);
|
|
@@ -159,7 +162,7 @@ export class TransactionService {
|
|
|
159
162
|
throw new Error('Fireblocks signing driver not available');
|
|
160
163
|
}
|
|
161
164
|
const driver = signingProvider.controller(userId);
|
|
162
|
-
const tx = await this.loadPreparedTransactionForSigning(signParams.
|
|
165
|
+
const tx = await this.loadPreparedTransactionForSigning(signParams.transactionId);
|
|
163
166
|
let signingResult;
|
|
164
167
|
if (tx && tx.externalTxId) {
|
|
165
168
|
signingResult = await driver
|
|
@@ -187,6 +190,7 @@ export class TransactionService {
|
|
|
187
190
|
throw new Error('No signature returned from signing driver');
|
|
188
191
|
}
|
|
189
192
|
const signedTx = {
|
|
193
|
+
id: tx.id,
|
|
190
194
|
commandId: tx.commandId,
|
|
191
195
|
status: signingResult.status,
|
|
192
196
|
preparedTransaction: tx.preparedTransaction,
|
|
@@ -198,7 +202,7 @@ export class TransactionService {
|
|
|
198
202
|
signedAt: now,
|
|
199
203
|
externalTxId: signingResult.txId,
|
|
200
204
|
};
|
|
201
|
-
await this.store.setTransactionSigned(tx.
|
|
205
|
+
await this.store.setTransactionSigned(tx.id, now, signingResult.txId);
|
|
202
206
|
this.notifier.emit('txChanged', signedTx);
|
|
203
207
|
// return signature in format that is already usable in execute
|
|
204
208
|
const decodedSignature = Buffer.from(signingResult.signature, 'hex').toString('base64');
|
|
@@ -213,6 +217,7 @@ export class TransactionService {
|
|
|
213
217
|
else {
|
|
214
218
|
const status = signingResult.status === 'pending' ? 'pending' : 'failed';
|
|
215
219
|
const pendingTx = {
|
|
220
|
+
id: tx.id,
|
|
216
221
|
commandId: tx.commandId,
|
|
217
222
|
status,
|
|
218
223
|
preparedTransaction: tx.preparedTransaction,
|
|
@@ -223,7 +228,7 @@ export class TransactionService {
|
|
|
223
228
|
createdAt: tx.createdAt,
|
|
224
229
|
}),
|
|
225
230
|
};
|
|
226
|
-
await this.store.setTransactionStatus(tx.
|
|
231
|
+
await this.store.setTransactionStatus(tx.id, status, {
|
|
227
232
|
externalTxId: signingResult.txId,
|
|
228
233
|
});
|
|
229
234
|
this.notifier.emit('txChanged', pendingTx);
|
|
@@ -235,11 +240,13 @@ export class TransactionService {
|
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
242
|
async executeWithParticipant(userId, executeParams, transaction, ledgerClient, network) {
|
|
238
|
-
const {
|
|
243
|
+
const { partyId } = executeParams;
|
|
244
|
+
const { commandId } = transaction;
|
|
239
245
|
const synchronizerId = network.synchronizerId ?? (await ledgerClient.getSynchronizerId());
|
|
240
246
|
const prep = ledgerPrepareParams(userId, partyId, synchronizerId, transaction.payload);
|
|
241
247
|
const res = await ledgerClient.postWithRetry('/v2/commands/submit-and-wait', prep);
|
|
242
248
|
const executedTx = {
|
|
249
|
+
id: transaction.id,
|
|
243
250
|
commandId,
|
|
244
251
|
status: 'executed',
|
|
245
252
|
preparedTransaction: transaction.preparedTransaction,
|
|
@@ -253,15 +260,16 @@ export class TransactionService {
|
|
|
253
260
|
signedAt: transaction.signedAt,
|
|
254
261
|
}),
|
|
255
262
|
};
|
|
256
|
-
await this.store.setTransactionStatus(
|
|
263
|
+
await this.store.setTransactionStatus(transaction.id, 'executed', {
|
|
257
264
|
payload: res,
|
|
258
265
|
});
|
|
259
266
|
this.notifier.emit('txChanged', executedTx);
|
|
260
267
|
return res;
|
|
261
268
|
}
|
|
262
269
|
async executeWithExternal(userId, executeParams, transaction, ledgerClient) {
|
|
263
|
-
const {
|
|
264
|
-
const
|
|
270
|
+
const { partyId, signature, signedBy } = executeParams;
|
|
271
|
+
const { commandId } = transaction;
|
|
272
|
+
const result = await ledgerClient.postWithRetry('/v2/interactive-submission/executeAndWait', {
|
|
265
273
|
userId,
|
|
266
274
|
preparedTransaction: transaction.preparedTransaction,
|
|
267
275
|
hashingSchemeVersion: 'HASHING_SCHEME_VERSION_V2',
|
|
@@ -286,6 +294,7 @@ export class TransactionService {
|
|
|
286
294
|
},
|
|
287
295
|
});
|
|
288
296
|
const executedTx = {
|
|
297
|
+
id: transaction.id,
|
|
289
298
|
commandId,
|
|
290
299
|
status: 'executed',
|
|
291
300
|
preparedTransaction: transaction.preparedTransaction,
|
|
@@ -299,7 +308,7 @@ export class TransactionService {
|
|
|
299
308
|
signedAt: transaction.signedAt,
|
|
300
309
|
}),
|
|
301
310
|
};
|
|
302
|
-
await this.store.setTransactionStatus(
|
|
311
|
+
await this.store.setTransactionStatus(transaction.id, 'executed', {
|
|
303
312
|
payload: result,
|
|
304
313
|
});
|
|
305
314
|
this.notifier.emit('txChanged', executedTx);
|
|
@@ -16,7 +16,8 @@ export declare class WalletSyncService {
|
|
|
16
16
|
private static readonly EMPTY_RIGHTS;
|
|
17
17
|
private sameRights;
|
|
18
18
|
run(timeoutMs: number): Promise<void>;
|
|
19
|
-
|
|
19
|
+
private getParticipantNamespace;
|
|
20
|
+
protected resolveSigningProvider(partyNamespace: string, participantNamespace: string): Promise<{
|
|
20
21
|
signingProviderId: SigningProvider.PARTICIPANT;
|
|
21
22
|
matched: boolean;
|
|
22
23
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-sync-service.d.ts","sourceRoot":"","sources":["../../src/ledger/wallet-sync-service.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,YAAY,EAEf,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,WAAW,EA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AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAGlE,qBAAa,iBAAiB;IAEtB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IAGtB,OAAO,CAAC,cAAc;gBAPd,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,OAAO,CAC3B,MAAM,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAClD,YAAK,EACE,cAAc,EAAE,sBAAsB;IAGlD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAwB;IAE5D,OAAO,CAAC,UAAU;IAUZ,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAU7B,uBAAuB;cAkBrB,sBAAsB,CAClC,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,MAAM,GAC7B,OAAO,CACJ;QACI,iBAAiB,EAAE,eAAe,CAAC,WAAW,CAAA;QAC9C,OAAO,EAAE,OAAO,CAAA;KACnB,GACD;QACI,iBAAiB,EAAE,OAAO,CACtB,eAAe,EACf,eAAe,CAAC,WAAW,CAC9B,CAAA;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,OAAO,CAAA;KACnB,CACN;YAwGa,iBAAiB;IA8DzB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;YA8D9B,yBAAyB;YA2EzB,0BAA0B;YAoD1B,mBAAmB;IAsB3B,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAgHlD"}
|
|
@@ -28,27 +28,23 @@ export class WalletSyncService {
|
|
|
28
28
|
await new Promise((res) => setTimeout(res, timeoutMs));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
async
|
|
31
|
+
async getParticipantNamespace() {
|
|
32
|
+
const { participantId } = await this.ledgerClient.getWithRetry('/v2/parties/participant-id', defaultRetryableOptions);
|
|
33
|
+
// Extract the namespace part from participantId
|
|
34
|
+
// Format is hint::namespace
|
|
35
|
+
const [, extractedNamespace] = participantId.split('::');
|
|
36
|
+
if (extractedNamespace) {
|
|
37
|
+
return extractedNamespace;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`Invalid participantId format: expected "hint::namespace", got "${participantId}"`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Protected for tests
|
|
44
|
+
async resolveSigningProvider(partyNamespace, participantNamespace) {
|
|
32
45
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
let participantNamespace;
|
|
36
|
-
try {
|
|
37
|
-
const { participantId } = await this.ledgerClient.getWithRetry('/v2/parties/participant-id', defaultRetryableOptions);
|
|
38
|
-
// Extract the namespace part from participantId
|
|
39
|
-
// Format is hint::namespace
|
|
40
|
-
const [, extractedNamespace] = participantId.split('::');
|
|
41
|
-
if (extractedNamespace) {
|
|
42
|
-
participantNamespace = extractedNamespace;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.logger.warn({ participantId }, `Invalid participantId format: expected "hint::namespace", got "${participantId}"`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
this.logger.warn({ err }, 'Failed to get participant namespace');
|
|
50
|
-
}
|
|
51
|
-
if (participantNamespace && namespace === participantNamespace) {
|
|
46
|
+
if (participantNamespace &&
|
|
47
|
+
partyNamespace === participantNamespace) {
|
|
52
48
|
return {
|
|
53
49
|
signingProviderId: SigningProvider.PARTICIPANT,
|
|
54
50
|
matched: true,
|
|
@@ -82,9 +78,9 @@ export class WalletSyncService {
|
|
|
82
78
|
if (!normalizedKey)
|
|
83
79
|
continue;
|
|
84
80
|
const keyNamespace = this.partyAllocator.createFingerprintFromKey(normalizedKey);
|
|
85
|
-
if (keyNamespace ===
|
|
81
|
+
if (keyNamespace === partyNamespace) {
|
|
86
82
|
this.logger.info({
|
|
87
|
-
namespace,
|
|
83
|
+
namespace: partyNamespace,
|
|
88
84
|
providerId,
|
|
89
85
|
keyId: key.id,
|
|
90
86
|
publicKey: key.publicKey,
|
|
@@ -104,14 +100,14 @@ export class WalletSyncService {
|
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
// No match found - use participant as default provider
|
|
107
|
-
this.logger.warn({ namespace }, 'No signing provider match found for namespace, using participant as default and marking wallet as unmatched (disabled)');
|
|
103
|
+
this.logger.warn({ namespace: partyNamespace }, 'No signing provider match found for namespace, using participant as default and marking wallet as unmatched (disabled)');
|
|
108
104
|
return {
|
|
109
105
|
signingProviderId: SigningProvider.PARTICIPANT,
|
|
110
106
|
matched: false,
|
|
111
107
|
};
|
|
112
108
|
}
|
|
113
109
|
catch (err) {
|
|
114
|
-
this.logger.error({ err, namespace }, 'Error resolving signing provider, using participant as default and marking wallet as unmatched (disabled)');
|
|
110
|
+
this.logger.error({ err, namespace: partyNamespace }, 'Error resolving signing provider, using participant as default and marking wallet as unmatched (disabled)');
|
|
115
111
|
// On error, use participant as default but mark as unmatched
|
|
116
112
|
return {
|
|
117
113
|
signingProviderId: SigningProvider.PARTICIPANT,
|
|
@@ -217,12 +213,12 @@ export class WalletSyncService {
|
|
|
217
213
|
}
|
|
218
214
|
// Participant wallets: disable when party not on ledger (participant node reset, namespace changed).
|
|
219
215
|
// Other wallets: mark as initialized so user can re-allocate (e.g. after external signing).
|
|
220
|
-
async handleWalletsWithoutParty(
|
|
221
|
-
const walletsWithoutParty =
|
|
222
|
-
const
|
|
223
|
-
const
|
|
216
|
+
async handleWalletsWithoutParty(allocatedWallets, partiesWithRights) {
|
|
217
|
+
const walletsWithoutParty = allocatedWallets.filter((wallet) => !partiesWithRights.has(wallet.partyId));
|
|
218
|
+
const updatedToInitialized = [];
|
|
219
|
+
const updatedToDisabled = [];
|
|
224
220
|
for (const wallet of walletsWithoutParty) {
|
|
225
|
-
if (wallet.status !== 'allocated')
|
|
221
|
+
if (wallet.status !== 'allocated' || wallet.disabled)
|
|
226
222
|
continue;
|
|
227
223
|
try {
|
|
228
224
|
if (wallet.signingProviderId === SigningProvider.PARTICIPANT) {
|
|
@@ -230,6 +226,12 @@ export class WalletSyncService {
|
|
|
230
226
|
partyId: wallet.partyId,
|
|
231
227
|
signingProviderId: wallet.signingProviderId,
|
|
232
228
|
}, 'Participant wallet party not on ledger, disabling (participant namespace changed)');
|
|
229
|
+
const disabledWallet = {
|
|
230
|
+
...wallet,
|
|
231
|
+
disabled: true,
|
|
232
|
+
reason: WALLET_DISABLED_REASON.PARTICIPANT_NAMESPACE_CHANGED,
|
|
233
|
+
...(wallet.primary && { primary: false }),
|
|
234
|
+
};
|
|
233
235
|
await this.store.updateWallet({
|
|
234
236
|
partyId: wallet.partyId,
|
|
235
237
|
networkId: wallet.networkId,
|
|
@@ -237,7 +239,7 @@ export class WalletSyncService {
|
|
|
237
239
|
reason: WALLET_DISABLED_REASON.PARTICIPANT_NAMESPACE_CHANGED,
|
|
238
240
|
...(wallet.primary && { primary: false }),
|
|
239
241
|
});
|
|
240
|
-
|
|
242
|
+
updatedToDisabled.push(disabledWallet);
|
|
241
243
|
}
|
|
242
244
|
else {
|
|
243
245
|
this.logger.info({
|
|
@@ -250,7 +252,12 @@ export class WalletSyncService {
|
|
|
250
252
|
status: 'initialized',
|
|
251
253
|
...(wallet.primary && { primary: false }),
|
|
252
254
|
});
|
|
253
|
-
|
|
255
|
+
const reinitialized = {
|
|
256
|
+
...wallet,
|
|
257
|
+
status: 'initialized',
|
|
258
|
+
...(wallet.primary && { primary: false }),
|
|
259
|
+
};
|
|
260
|
+
updatedToInitialized.push(reinitialized);
|
|
254
261
|
}
|
|
255
262
|
}
|
|
256
263
|
catch (err) {
|
|
@@ -258,16 +265,15 @@ export class WalletSyncService {
|
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
267
|
return {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
disabledExistingWallets,
|
|
268
|
+
updatedToInitialized,
|
|
269
|
+
updatedToDisabled,
|
|
264
270
|
};
|
|
265
271
|
}
|
|
266
272
|
// Creates wallets for parties user has rights to
|
|
267
|
-
async handlePartiesWithoutWallet(newParties, networkId, rightsByParty) {
|
|
273
|
+
async handlePartiesWithoutWallet(newParties, networkId, rightsByParty, participantNamespace) {
|
|
268
274
|
return await Promise.all(newParties.map(async (partyId) => {
|
|
269
275
|
const [hint, namespace] = partyId.split('::');
|
|
270
|
-
const resolvedSigningProvider = await this.resolveSigningProvider(namespace);
|
|
276
|
+
const resolvedSigningProvider = await this.resolveSigningProvider(namespace, participantNamespace);
|
|
271
277
|
const isMatched = resolvedSigningProvider.matched;
|
|
272
278
|
const walletPublicKey = resolvedSigningProvider.signingProviderId ===
|
|
273
279
|
SigningProvider.PARTICIPANT
|
|
@@ -316,6 +322,7 @@ export class WalletSyncService {
|
|
|
316
322
|
async syncWallets() {
|
|
317
323
|
this.logger.info('Starting wallet sync...');
|
|
318
324
|
try {
|
|
325
|
+
const participantNamespace = await this.getParticipantNamespace();
|
|
319
326
|
const network = await this.store.getCurrentNetwork();
|
|
320
327
|
this.logger.info(network, 'Current network');
|
|
321
328
|
const { rightsByParty, rightsByUser } = await this.getRightsSnapshot();
|
|
@@ -332,13 +339,14 @@ export class WalletSyncService {
|
|
|
332
339
|
const newParties = partiesWithRights.filter((party) => !existingPartiesOnNetwork.has(`${party}:${network.id}`)
|
|
333
340
|
// todo: filter on idp id
|
|
334
341
|
);
|
|
335
|
-
const {
|
|
342
|
+
const { updatedToInitialized, updatedToDisabled } = await this.handleWalletsWithoutParty(existingAllocatedWallets, new Set(partiesWithRights));
|
|
336
343
|
const rightsUpdatedWallets = await this.handleRightsUpdates(existingAllocatedWallets, rightsByParty);
|
|
337
344
|
this.logger.info({
|
|
338
345
|
newParties,
|
|
339
|
-
|
|
346
|
+
updatedToInitialized: updatedToInitialized.map((w) => w.partyId),
|
|
347
|
+
updatedToDisabled: updatedToDisabled.map((w) => w.partyId),
|
|
340
348
|
}, 'Wallets without parties');
|
|
341
|
-
const newParticipantWallets = await this.handlePartiesWithoutWallet(newParties, network.id, rightsByParty);
|
|
349
|
+
const newParticipantWallets = await this.handlePartiesWithoutWallet(newParties, network.id, rightsByParty, participantNamespace);
|
|
342
350
|
// Set primary wallet if none exists, or if primary is on an initialized wallet
|
|
343
351
|
const networkWallets = await this.store.getWallets();
|
|
344
352
|
const primaryWallet = networkWallets.find((w) => w.primary);
|
|
@@ -346,22 +354,30 @@ export class WalletSyncService {
|
|
|
346
354
|
const needsPrimaryReset = primaryWallet?.status === 'initialized' ||
|
|
347
355
|
(!primaryWallet && allocatedWallets.length > 0);
|
|
348
356
|
if (needsPrimaryReset && allocatedWallets.length > 0) {
|
|
349
|
-
this.store.setPrimaryWallet(allocatedWallets[0].partyId);
|
|
357
|
+
await this.store.setPrimaryWallet(allocatedWallets[0].partyId);
|
|
350
358
|
this.logger.info(`Set ${allocatedWallets[0].partyId} as primary wallet in network ${network.id}`);
|
|
351
359
|
}
|
|
360
|
+
const newWallets = newParticipantWallets;
|
|
361
|
+
const updatedRaw = [
|
|
362
|
+
...updatedToInitialized,
|
|
363
|
+
...rightsUpdatedWallets,
|
|
364
|
+
];
|
|
365
|
+
const added = newWallets.filter((wallet) => !wallet.disabled);
|
|
366
|
+
const updated = updatedRaw.filter((wallet) => !wallet.disabled);
|
|
352
367
|
const disabled = [
|
|
353
|
-
...
|
|
354
|
-
...
|
|
368
|
+
...newWallets.filter((wallet) => wallet.disabled),
|
|
369
|
+
...updatedRaw.filter((wallet) => wallet.disabled),
|
|
370
|
+
...updatedToDisabled,
|
|
355
371
|
];
|
|
356
372
|
this.logger.info({
|
|
357
|
-
added
|
|
358
|
-
updated
|
|
359
|
-
disabled
|
|
373
|
+
added,
|
|
374
|
+
updated,
|
|
375
|
+
disabled,
|
|
360
376
|
}, 'Wallet sync completed.');
|
|
361
377
|
return {
|
|
362
|
-
added
|
|
363
|
-
updated
|
|
364
|
-
disabled
|
|
378
|
+
added,
|
|
379
|
+
updated,
|
|
380
|
+
disabled,
|
|
365
381
|
};
|
|
366
382
|
}
|
|
367
383
|
catch (err) {
|