@fairmint/canton-node-sdk 0.0.282 → 0.0.283

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.
Files changed (72) hide show
  1. package/README.md +128 -154
  2. package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts.map +1 -1
  3. package/build/src/utils/external-signing/wallet-ownership-challenger.js +2 -3
  4. package/build/src/utils/external-signing/wallet-ownership-challenger.js.map +1 -1
  5. package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -1
  6. package/build/src/utils/external-signing/wallet-ownership.js +8 -18
  7. package/build/src/utils/external-signing/wallet-ownership.js.map +1 -1
  8. package/build/src/wallets/acs.d.ts +2 -1
  9. package/build/src/wallets/acs.d.ts.map +1 -1
  10. package/build/src/wallets/acs.js +6 -31
  11. package/build/src/wallets/acs.js.map +1 -1
  12. package/build/src/wallets/cip103.d.ts +32 -68
  13. package/build/src/wallets/cip103.d.ts.map +1 -1
  14. package/build/src/wallets/cip103.js +112 -230
  15. package/build/src/wallets/cip103.js.map +1 -1
  16. package/build/src/wallets/commands.d.ts +39 -6
  17. package/build/src/wallets/commands.d.ts.map +1 -1
  18. package/build/src/wallets/commands.js +50 -5
  19. package/build/src/wallets/commands.js.map +1 -1
  20. package/build/src/wallets/contracts.d.ts +12 -0
  21. package/build/src/wallets/contracts.d.ts.map +1 -1
  22. package/build/src/wallets/contracts.js +21 -5
  23. package/build/src/wallets/contracts.js.map +1 -1
  24. package/build/src/wallets/da-utilities/client.d.ts +61 -29
  25. package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
  26. package/build/src/wallets/da-utilities/client.js +78 -75
  27. package/build/src/wallets/da-utilities/client.js.map +1 -1
  28. package/build/src/wallets/errors.d.ts +11 -8
  29. package/build/src/wallets/errors.d.ts.map +1 -1
  30. package/build/src/wallets/errors.js +13 -3
  31. package/build/src/wallets/errors.js.map +1 -1
  32. package/build/src/wallets/holdings.d.ts +14 -4
  33. package/build/src/wallets/holdings.d.ts.map +1 -1
  34. package/build/src/wallets/holdings.js +27 -47
  35. package/build/src/wallets/holdings.js.map +1 -1
  36. package/build/src/wallets/index.d.ts +17 -21
  37. package/build/src/wallets/index.d.ts.map +1 -1
  38. package/build/src/wallets/index.js +14 -23
  39. package/build/src/wallets/index.js.map +1 -1
  40. package/build/src/wallets/instrument.js +1 -1
  41. package/build/src/wallets/instrument.js.map +1 -1
  42. package/build/src/wallets/ownership.d.ts +20 -26
  43. package/build/src/wallets/ownership.d.ts.map +1 -1
  44. package/build/src/wallets/ownership.js +33 -27
  45. package/build/src/wallets/ownership.js.map +1 -1
  46. package/build/src/wallets/session.d.ts +30 -68
  47. package/build/src/wallets/session.d.ts.map +1 -1
  48. package/build/src/wallets/session.js +119 -167
  49. package/build/src/wallets/session.js.map +1 -1
  50. package/build/src/wallets/store.d.ts +148 -86
  51. package/build/src/wallets/store.d.ts.map +1 -1
  52. package/build/src/wallets/store.js +267 -99
  53. package/build/src/wallets/store.js.map +1 -1
  54. package/build/src/wallets/templates.d.ts +10 -23
  55. package/build/src/wallets/templates.d.ts.map +1 -1
  56. package/build/src/wallets/templates.js +9 -33
  57. package/build/src/wallets/templates.js.map +1 -1
  58. package/build/src/wallets/types.d.ts +6 -20
  59. package/build/src/wallets/types.d.ts.map +1 -1
  60. package/build/src/wallets/wallet.d.ts +130 -74
  61. package/build/src/wallets/wallet.d.ts.map +1 -1
  62. package/build/src/wallets/wallet.js +347 -185
  63. package/build/src/wallets/wallet.js.map +1 -1
  64. package/package.json +1 -1
  65. package/build/src/wallets/cip56-core.d.ts +0 -175
  66. package/build/src/wallets/cip56-core.d.ts.map +0 -1
  67. package/build/src/wallets/cip56-core.js +0 -325
  68. package/build/src/wallets/cip56-core.js.map +0 -1
  69. package/build/src/wallets/token-registry.d.ts +0 -97
  70. package/build/src/wallets/token-registry.d.ts.map +0 -1
  71. package/build/src/wallets/token-registry.js +0 -19
  72. package/build/src/wallets/token-registry.js.map +0 -1
@@ -1,55 +1,179 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walletActionKey = walletActionKey;
4
+ exports.canAct = canAct;
3
5
  exports.createWalletStore = createWalletStore;
4
6
  /**
5
- * A token wallet page's state and actions over a `Cip103Session`: one token wallet per connected wallet, its ledger
6
- * snapshot, one wallet call at a time, a reload after every write attempt, and outcomes tagged with the session they
7
- * ran for, so a reply from an ended session is never shown as a success.
7
+ * A token wallet page's state and actions over a `Cip103Session`: one DA token wallet per connected wallet, its ledger
8
+ * snapshot, typed actions run one wallet call at a time, a reload after every write attempt, the outcome of the last
9
+ * action with a sentence for the user, and a sticky warning for a write whose outcome is unknown.
8
10
  *
9
11
  * Observable for any UI framework: `subscribe` and `getSnapshot` (React: `useSyncExternalStore(store.subscribe,
10
12
  * store.getSnapshot, store.getSnapshot)`).
11
13
  */
12
14
  const notify_1 = require("./notify");
13
15
  const errors_1 = require("./errors");
16
+ const holdings_1 = require("./holdings");
17
+ const ownership_1 = require("./ownership");
14
18
  const wallet_1 = require("./wallet");
15
- /** Whether the outcome leaves open if a write committed: `interrupted`, or a failure the wallet could not confirm. */
16
- function outcomeUnknown(outcome) {
17
- return outcome.status === 'interrupted' || (outcome.status === 'failed' && outcome.error.kind === 'outcome-unknown');
19
+ /**
20
+ * A stable key for an action: its type and the contract or instrument it acts on. Compare it with `view.running?.key`
21
+ * to show a button's spinner.
22
+ */
23
+ function walletActionKey(action) {
24
+ switch (action.type) {
25
+ case 'acceptMintOffer':
26
+ case 'rejectMintOffer':
27
+ return `${action.type}:${action.mintOfferCid}`;
28
+ case 'acceptTransferOffer':
29
+ case 'rejectTransferOffer':
30
+ case 'withdrawTransferOffer':
31
+ return `${action.type}:${action.transferOfferCid}`;
32
+ case 'requestBurn':
33
+ return `${action.type}:${(0, holdings_1.instrumentKey)(action.instrumentId)}`;
34
+ case 'cancelBurnRequest':
35
+ return `${action.type}:${action.burnRequestCid}`;
36
+ case 'planTransfer':
37
+ return `${action.type}:${(0, holdings_1.instrumentKey)(action.request.instrumentId)}`;
38
+ case 'submitTransfer':
39
+ return `${action.type}:${(0, holdings_1.instrumentKey)(action.plan.request.instrumentId)}`;
40
+ case 'createTransferPreapproval':
41
+ return `${action.type}:${action.instrumentAdmin}`;
42
+ case 'removeTransferPreapproval':
43
+ return `${action.type}:${action.preapprovalCid}`;
44
+ case 'proveOwnership':
45
+ return action.type;
46
+ }
18
47
  }
19
- /** Whether `error` is the SDK's refusal before anything was submitted (`WalletError`). */
20
- function refusedUnsent(error) {
21
- return (0, errors_1.describeWalletError)(error).kind === 'refused';
48
+ const READ_ONLY = new Set(['planTransfer', 'proveOwnership']);
49
+ /**
50
+ * Whether `store.act(action)` would run it now: the store is `ready`, not busy, and, for a write, no outcome is
51
+ * unknown. Use it to enable the action's button.
52
+ */
53
+ function canAct(view, action) {
54
+ return view.ready && !view.busy && (READ_ONLY.has(action.type) || view.unknownOutcome === null);
22
55
  }
23
- /** The default token wallet: DA's registry for the network the wallet connected for, acting as its party only. */
24
- function openWallet(wallet, context) {
25
- const { provider, partyId, network } = wallet;
26
- if (network === undefined) {
27
- throw new errors_1.WalletError('invalid-input', 'The connected wallet names no network: connect with { network }, or pass open to createWalletStore');
56
+ /**
57
+ * The failures a submission itself reports (`WalletSubmitError`). The wallet throws every other failure before it
58
+ * submits, so nothing was sent.
59
+ */
60
+ const SUBMISSION_FAILURES = new Set([
61
+ 'declined',
62
+ 'not-committed',
63
+ 'outcome-unknown',
64
+ ]);
65
+ const update = (result) => `(update ${result.updateId})`;
66
+ /** What a transfer of each kind did, for the user. */
67
+ const TRANSFER_SENTENCES = {
68
+ direct: 'Sent: the tokens moved to the receiver',
69
+ offer: 'Transfer offer sent: the receiver must accept it before it expires',
70
+ self: 'Self-transfer done',
71
+ };
72
+ /** Submitting a store's plan directly would skip the store's checks (one call at a time, the unknown-outcome lock). */
73
+ // eslint-disable-next-line @typescript-eslint/require-await -- TransferPlan.submit is async: it rejects, never throws
74
+ async function submitThroughStore() {
75
+ throw new errors_1.WalletError('invalid-input', "Send this plan with store.act({ type: 'submitTransfer', plan })");
76
+ }
77
+ /** Run `action` with `tokens` for `wallet`; throws what the wallet throws. */
78
+ async function perform(plans, tokens, wallet, action) {
79
+ const written = (result, sentence) => ({
80
+ ok: true,
81
+ result,
82
+ message: `${sentence} ${update(result)}.`,
83
+ });
84
+ switch (action.type) {
85
+ case 'acceptMintOffer':
86
+ return written(await tokens.acceptMintOffer(action.mintOfferCid), 'Mint offer accepted');
87
+ case 'rejectMintOffer':
88
+ return written(await tokens.rejectMintOffer(action.mintOfferCid), 'Mint offer rejected');
89
+ case 'acceptTransferOffer':
90
+ return written(await tokens.acceptTransferOffer(action.transferOfferCid), 'Transfer accepted');
91
+ case 'rejectTransferOffer':
92
+ return written(await tokens.rejectTransferOffer(action.transferOfferCid), 'Transfer offer rejected');
93
+ case 'withdrawTransferOffer':
94
+ return written(await tokens.withdrawTransferOffer(action.transferOfferCid), 'Transfer offer withdrawn; its tokens are unlocked');
95
+ case 'requestBurn': {
96
+ const { instrumentId, amount, reference, executeBefore } = action;
97
+ const result = await tokens.requestBurn({
98
+ instrumentId,
99
+ amount,
100
+ ...(reference !== undefined && { reference }),
101
+ ...(executeBefore !== undefined && { executeBefore }),
102
+ });
103
+ return {
104
+ ok: true,
105
+ result,
106
+ message: `Redemption ${result.reference} requested ${update(result)}. The registrar burns the amount or returns it.`,
107
+ };
108
+ }
109
+ case 'cancelBurnRequest':
110
+ return written(await tokens.cancelBurnRequest(action.burnRequestCid), 'Redemption cancelled; the amount is unlocked');
111
+ case 'planTransfer': {
112
+ const plan = await tokens.planTransfer(action.request);
113
+ const { kind, description, partyId, request } = plan;
114
+ const handed = Object.freeze({ kind, description, partyId, request, submit: submitThroughStore });
115
+ plans.set(handed, { wallet, plan });
116
+ return { ok: true, result: handed, message: null };
117
+ }
118
+ case 'submitTransfer': {
119
+ const planned = plans.get(action.plan);
120
+ if (planned?.wallet !== wallet) {
121
+ throw new errors_1.WalletError('invalid-input', 'This transfer was planned for another wallet connection; plan it again before sending');
122
+ }
123
+ const result = await planned.plan.submit();
124
+ return written(result, TRANSFER_SENTENCES[result.kind]);
125
+ }
126
+ case 'createTransferPreapproval': {
127
+ const { instrumentAdmin, instrumentIds } = action;
128
+ return written(await tokens.createTransferPreapproval({
129
+ instrumentAdmin,
130
+ ...(instrumentIds !== undefined && { instrumentIds }),
131
+ }), instrumentIds === undefined || instrumentIds.length === 0
132
+ ? `Transfer preapproval created: transfers of ${instrumentAdmin}'s instruments now complete at once`
133
+ : `Transfer preapproval created: transfers of ${instrumentIds.join(', ')} by ${instrumentAdmin} now complete at once`);
134
+ }
135
+ case 'removeTransferPreapproval':
136
+ return written(await tokens.removeTransferPreapproval(action.preapprovalCid), 'Transfer preapproval removed');
137
+ case 'proveOwnership': {
138
+ const { challengeUrl, verifyUrl, fetch } = action;
139
+ const verdict = await (0, ownership_1.requestWalletOwnershipVerdict)(wallet, {
140
+ challengeUrl,
141
+ verifyUrl,
142
+ ...(fetch !== undefined && { fetch }),
143
+ });
144
+ if (!verdict.verified)
145
+ return { ok: false, error: { kind: 'not-verified', message: verdict.message } };
146
+ return {
147
+ ok: true,
148
+ result: verdict,
149
+ message: `Verified: this wallet holds the key of ${verdict.partyId} (key fingerprint ${verdict.publicKeyFingerprint}).`,
150
+ };
151
+ }
28
152
  }
29
- return (0, wallet_1.createWallet)({ provider, partyId, network, isActive: context.isActive });
153
+ }
154
+ /** `message`, naming `partyId` when the view shows another wallet (or none). */
155
+ function forParty(message, partyId, current) {
156
+ return current?.partyId === partyId ? message : `${message} (party ${partyId})`;
30
157
  }
31
158
  /**
32
- * The observable state and actions of a token wallet page over `session`. The store follows the session: each new
33
- * `ConnectedWallet` gets its own token wallet (from `open`) and a fresh load, and its state is cleared.
159
+ * The observable state and actions of a token wallet page over `session`. Each new `ConnectedWallet` gets its own token
160
+ * wallet (`createWallet` on the session's network, bound to the session by `isActive`) and a fresh load.
34
161
  *
35
- * One wallet call at a time: an execution latch counts every call in flight (actions and loads, of the current wallet
36
- * or a previous one, since a dropped reply does not cancel its request). `run()` refuses while it is held. A load asked
37
- * for meanwhile (a new wallet's first load, a Retry, the reload after a write) is queued; queued loads coalesce into
38
- * one, which runs for the wallet current when the latch frees. Ending the session drops the queued load, and so does
39
- * `dispose()`. A wallet call that never settles holds the latch, since it cannot be cancelled. The token wallet's own
40
- * write latch (`busy`) stays as the inner guard.
162
+ * One wallet call at a time: a latch counts every call in flight (actions and loads, of the current wallet or a
163
+ * previous one, since a dropped reply does not cancel its request). `act()` refuses while it is held. A load asked for
164
+ * meanwhile (a new wallet's first load, a Retry, the reload after a write) is queued; queued loads coalesce into one,
165
+ * which runs for the wallet current when the latch frees. A wallet call that never settles holds the latch.
41
166
  */
42
167
  function createWalletStore(options) {
43
- const { session } = options;
44
- const open = options.open ?? openWallet;
168
+ const { session, registry, openWallet = wallet_1.createWallet } = options;
45
169
  const listeners = new Set();
170
+ const plans = new WeakMap();
46
171
  let sessionState = session.getSnapshot();
47
172
  let wallet = null;
48
173
  let tokens = null;
49
174
  let state = null;
50
175
  let loadError = null;
51
- // Stale replies: every load and wallet change takes a new number; a load's reply counts only while its number is the
52
- // latest and its wallet still current. This drops replies; it does not free the latch.
176
+ // Every load and wallet change takes a new number; a load's reply counts only while its number is the latest.
53
177
  let generation = 0;
54
178
  // Execution latch: wallet calls (actions and loads, of any wallet) asked and not yet settled.
55
179
  let inFlight = 0;
@@ -59,27 +183,59 @@ function createWalletStore(options) {
59
183
  let loadInFlight = false;
60
184
  let running = null;
61
185
  let outcome = null;
186
+ let unknownOutcome = null;
62
187
  let disposed = false;
63
188
  let view = buildView();
64
- function unknownOutcomeParty() {
65
- if (running !== null && !running.readOnly && running.wallet !== wallet)
66
- return running.wallet.partyId;
67
- if (outcome === null || !outcomeUnknown(outcome))
68
- return null;
69
- // The current wallet's own `outcome-unknown` failure is shown as the outcome itself.
70
- return outcome.status === 'interrupted' || outcome.partyId !== wallet?.partyId ? outcome.partyId : null;
189
+ function notices() {
190
+ const list = [];
191
+ if (sessionState.status === 'disconnected' && sessionState.error !== null) {
192
+ const { error } = sessionState;
193
+ list.push({ key: 'session', level: error.kind === 'declined' ? 'info' : 'error', message: error.message });
194
+ }
195
+ if (unknownOutcome !== null) {
196
+ list.push({
197
+ key: 'unknown-outcome',
198
+ level: 'warning',
199
+ title: 'Outcome unknown',
200
+ message: forParty(unknownOutcome.message, unknownOutcome.partyId, wallet),
201
+ acknowledge: true,
202
+ });
203
+ }
204
+ if (loadError !== null) {
205
+ const rateLimited = loadError.kind === 'rate-limited';
206
+ list.push({
207
+ key: 'load',
208
+ level: rateLimited ? 'warning' : 'error',
209
+ title: rateLimited ? 'The wallet is busy' : 'The wallet could not be read',
210
+ message: loadError.message,
211
+ ...(tokens !== null && { retry: true }),
212
+ });
213
+ }
214
+ if (outcome?.status === 'succeeded') {
215
+ list.push({ key: 'outcome', level: 'success', message: forParty(outcome.message, outcome.partyId, wallet) });
216
+ }
217
+ else if (outcome?.status === 'failed') {
218
+ list.push({
219
+ key: 'outcome',
220
+ level: outcome.error.kind === 'declined' ? 'info' : 'error',
221
+ message: forParty(outcome.error.message, outcome.partyId, wallet),
222
+ });
223
+ }
224
+ return list;
71
225
  }
72
226
  function buildView() {
73
227
  return {
74
228
  session: sessionState,
75
229
  wallet,
230
+ ready: tokens !== null,
76
231
  state,
77
232
  loading: loadInFlight || queued,
78
233
  loadError,
79
- running: running?.id ?? null,
234
+ running: running === null ? null : { action: running.action, key: running.key },
80
235
  busy: inFlight > 0 || queued,
81
236
  outcome,
82
- unknownOutcomeParty: unknownOutcomeParty(),
237
+ unknownOutcome,
238
+ notices: notices(),
83
239
  };
84
240
  }
85
241
  function publish() {
@@ -92,13 +248,9 @@ function createWalletStore(options) {
92
248
  function isCurrent(candidate) {
93
249
  return !disposed && candidate === wallet && session.isCurrent(candidate);
94
250
  }
95
- /**
96
- * Ask for a load of the current wallet's snapshot: it starts now when no wallet call is in flight, and otherwise
97
- * waits for the latch (`drain`). Publishes.
98
- */
251
+ /** Ask for a load of the current wallet's snapshot: now when the latch is free, else once it frees. Publishes. */
99
252
  function requestLoad() {
100
- // A session listener that runs before this store's own may ask after the session left `wallet`: the store's
101
- // pending `onSession` then resets it, and no load goes to a wallet whose session ended.
253
+ // A session listener that runs before this store's own may ask after the session left `wallet`.
102
254
  if (disposed || wallet === null || tokens === null || !session.isCurrent(wallet))
103
255
  return;
104
256
  queued = true;
@@ -108,9 +260,7 @@ function createWalletStore(options) {
108
260
  function drain() {
109
261
  if (disposed)
110
262
  return;
111
- // A wallet the session has left gets no load: `onSession` drops the queued load and queues the next wallet's. A
112
- // session that left it without publishing (`dispose()`) never calls `onSession`, so the queued load is dropped here:
113
- // a wallet never becomes current again once the session left it.
263
+ // A wallet the session has left (also a disposed session, which publishes nothing) gets no load.
114
264
  if (queued && wallet !== null && !session.isCurrent(wallet))
115
265
  queued = false;
116
266
  if (queued && inFlight === 0 && wallet !== null && tokens !== null) {
@@ -119,16 +269,11 @@ function createWalletStore(options) {
119
269
  }
120
270
  publish();
121
271
  }
122
- /**
123
- * Load `forWallet`'s snapshot, holding the latch until the wallet answers. The reply is dropped when another wallet
124
- * superseded it (loads never overlap, so a newer load of the same wallet cannot); the latch frees either way, and the
125
- * queued load, if any, starts.
126
- */
272
+ /** Load `forWallet`'s snapshot, holding the latch until the wallet answers; the reply is dropped once superseded. */
127
273
  function startLoad(forWallet, forTokens) {
128
274
  const attempt = ++generation;
129
275
  inFlight += 1;
130
276
  loadInFlight = true;
131
- // A reply counts only for the wallet the session still shows (a disposed session shows none).
132
277
  const current = () => !disposed && attempt === generation && forWallet === wallet && session.isCurrent(forWallet);
133
278
  void (async () => {
134
279
  let next;
@@ -141,7 +286,6 @@ function createWalletStore(options) {
141
286
  inFlight -= 1;
142
287
  if (disposed)
143
288
  return;
144
- // No newer load of this wallet runs, so this one no longer counts as loading, whether its reply is kept or not.
145
289
  if (attempt === generation)
146
290
  loadInFlight = false;
147
291
  if (current()) {
@@ -169,27 +313,60 @@ function createWalletStore(options) {
169
313
  }
170
314
  wallet = next;
171
315
  generation += 1; // drop the previous wallet's load reply (its call still holds the latch until it settles)
172
- queued = false; // a queued load was for the previous wallet
316
+ queued = false;
173
317
  loadInFlight = false;
174
318
  state = null;
175
319
  loadError = null;
320
+ outcome = null;
176
321
  tokens = null;
177
- // Another wallet never sees this one's result, but a write whose outcome is unknown stays reported.
178
- if (outcome !== null && !outcomeUnknown(outcome))
179
- outcome = null;
180
- if (next === null) {
322
+ if (next !== null) {
323
+ try {
324
+ tokens = openWallet({
325
+ provider: next.provider,
326
+ partyId: next.partyId,
327
+ network: next.network,
328
+ ...(registry !== undefined && { registry }),
329
+ isActive: () => session.isCurrent(next),
330
+ });
331
+ }
332
+ catch (error) {
333
+ // An invalid `registry` option: the wallet is connected but cannot act; say why instead of loading forever.
334
+ loadError = (0, errors_1.describeWalletError)(error);
335
+ }
336
+ }
337
+ if (tokens === null)
181
338
  publish();
339
+ else
340
+ requestLoad(); // queued while the previous wallet's call is in flight
341
+ }
342
+ /** Record how an action settled; `live`: its wallet is still the current one. */
343
+ function record(ran, settled, live) {
344
+ const { action, key } = ran;
345
+ const { partyId } = ran.wallet;
346
+ const readOnly = READ_ONLY.has(action.type);
347
+ if (!live && readOnly)
348
+ return; // nothing it did can commit, and its wallet is gone
349
+ if (settled.ok) {
350
+ if (settled.message !== null)
351
+ outcome = { action, key, partyId, status: 'succeeded', message: settled.message };
182
352
  return;
183
353
  }
184
- try {
185
- tokens = open(next, { isActive: () => session.isCurrent(next) });
186
- }
187
- catch (error) {
188
- loadError = (0, errors_1.describeWalletError)(error);
189
- publish();
354
+ const { error } = settled;
355
+ if (error.kind === 'outcome-unknown') {
356
+ unknownOutcome = {
357
+ action,
358
+ key,
359
+ partyId,
360
+ message: error.message,
361
+ ...(error.commandId !== undefined && { commandId: error.commandId }),
362
+ ...(error.burnReference !== undefined && { burnReference: error.burnReference }),
363
+ };
190
364
  return;
191
365
  }
192
- requestLoad(); // queued while the previous wallet's call is in flight
366
+ // A failure before anything was submitted is nothing to report for a wallet that is gone.
367
+ if (!live && !SUBMISSION_FAILURES.has(error.kind))
368
+ return;
369
+ outcome = { action, key, partyId, status: 'failed', error };
193
370
  }
194
371
  const unsubscribe = session.subscribe(onSession);
195
372
  onSession();
@@ -201,63 +378,54 @@ function createWalletStore(options) {
201
378
  };
202
379
  },
203
380
  getSnapshot: () => view,
204
- refresh() {
205
- requestLoad();
206
- },
207
- async run(id, action, runOptions = {}) {
381
+ async act(action) {
208
382
  // Synchronous, before the first await: a second call in the same tick is refused.
209
383
  const ranFor = wallet;
210
384
  const ranTokens = tokens;
211
385
  if (disposed || inFlight > 0 || queued || ranFor === null || ranTokens === null)
212
- return false;
213
- const readOnly = runOptions.readOnly === true;
214
- const previous = outcome;
386
+ return null;
387
+ // Until the user checked the wallet, a write could repeat the one whose outcome is unknown.
388
+ if (unknownOutcome !== null && !READ_ONLY.has(action.type))
389
+ return null;
390
+ const ran = { action, key: walletActionKey(action), wallet: ranFor };
215
391
  inFlight += 1;
216
- running = { id, wallet: ranFor, readOnly };
217
- outcome = null;
392
+ running = ran;
218
393
  publish();
219
394
  // A listener of that publish may have ended the session, switched the wallet or disposed the store: then the
220
- // action must not start (nothing was sent, so no outcome is recorded), and queued work runs instead. A previous
221
- // write whose outcome is unknown stays reported, as it does across a wallet change.
395
+ // action must not start, and queued work runs instead.
222
396
  if (!isCurrent(ranFor)) {
223
397
  inFlight -= 1;
224
398
  running = null;
225
- if (previous !== null && outcomeUnknown(previous))
226
- outcome = previous;
227
399
  drain();
228
- return false;
400
+ return null;
229
401
  }
230
402
  let settled;
231
403
  try {
232
- const message = await action({ tokens: ranTokens, wallet: ranFor });
233
- settled = { ok: true, message: typeof message === 'string' ? message : null };
404
+ settled = await perform(plans, ranTokens, ranFor, action);
234
405
  }
235
406
  catch (error) {
236
- settled = { ok: false, error };
407
+ settled = { ok: false, error: (0, errors_1.describeWalletError)(error) };
237
408
  }
238
409
  inFlight -= 1;
239
410
  running = null;
240
411
  const live = isCurrent(ranFor);
241
- const { partyId } = ranFor;
242
- if (!live) {
243
- // Whether a write committed is unknown, unless the SDK refused it before submitting anything (the token
244
- // wallet's check before signing, once its session ended mid-write).
245
- outcome =
246
- readOnly || (!settled.ok && refusedUnsent(settled.error)) ? null : { id, partyId, status: 'interrupted' };
247
- }
248
- else if (settled.ok) {
249
- outcome = { id, partyId, status: 'succeeded', message: settled.message };
250
- }
251
- else {
252
- outcome = { id, partyId, status: 'failed', error: (0, errors_1.describeWalletError)(settled.error) };
253
- }
254
- // A failed write may still have committed, so reload after failures too. This only reads; nothing is retried.
255
- if (live && !readOnly)
412
+ record(ran, settled, live);
413
+ // A failed write may still have committed, so reload after failures too. This only reads.
414
+ if (live && !READ_ONLY.has(action.type))
256
415
  queued = true;
257
- // Start the queued load: this write's reload, a refresh asked meanwhile, or the first load of a wallet that
258
- // replaced this action's one. Busy until it answers.
259
416
  drain();
260
- return live && settled.ok;
417
+ // Asked again: a listener of drain()'s publish may have ended the session or switched the wallet.
418
+ // The result type follows from the action type (`perform`'s switch).
419
+ return isCurrent(ranFor) && settled.ok ? settled.result : null;
420
+ },
421
+ refresh() {
422
+ requestLoad();
423
+ },
424
+ acknowledgeUnknownOutcome() {
425
+ if (disposed || unknownOutcome === null)
426
+ return;
427
+ unknownOutcome = null;
428
+ publish();
261
429
  },
262
430
  dispose() {
263
431
  if (disposed)
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/wallets/store.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,qCAA2C;AAC3C,qCAAyF;AAEzF,qCAAuE;AAqHvE,sHAAsH;AACtH,SAAS,cAAc,CAAC,OAAsB;IAC5C,OAAO,OAAO,CAAC,MAAM,KAAK,aAAa,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC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,CAAC,IAAI,CAAC;gBAAE,MAAM,GAAG,IAAI,CAAC;YACvD,KAAK,EAAE,CAAC;YACR,kGAAkG;YAClG,qEAAqE;YACrE,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,CAAE,OAAO,CAAC,MAA4B,CAAC,CAAC,CAAC,IAAI,CAAC;QACxF,CAAC;QAED,OAAO;YACL,WAAW,EAAE,CAAC;QAChB,CAAC;QAED,yBAAyB;YACvB,IAAI,QAAQ,IAAI,cAAc,KAAK,IAAI;gBAAE,OAAO;YAChD,cAAc,GAAG,IAAI,CAAC;YACtB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM,GAAG,KAAK,CAAC;YACf,WAAW,EAAE,CAAC;YACd,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,36 +1,23 @@
1
1
  /**
2
- * Comparing template and interface ids across their two forms: package-name (`#package-name:Module:Entity`, as the
3
- * SDK's constants spell them so they survive DAR upgrades) and package-id (`pkgId:Module:Entity`, as the ledger reports
4
- * them).
5
- *
6
- * The ids themselves are the SDK's own: `DA_REGISTRY_TEMPLATES` (`da-registry/templates`) and the token standard V1
7
- * interface ids (`utils/token-standard/v1/constants`). Both modules are dependency-free, so this module can import them
8
- * and stay browser-safe.
2
+ * Comparing template ids across their two forms: package-name (`#package-name:Module:Entity`, as the SDK's constants
3
+ * spell them so they survive DAR upgrades) and package-id (`pkgId:Module:Entity`, as the ledger reports them).
9
4
  */
10
- import type { ActiveContract, ContractFilter } from './types';
5
+ import type { ActiveContract } from './types';
11
6
  /**
12
- * `Module:Entity` of a template or interface id in either form (`#pkg-name:M:E` or `pkgId:M:E`), or null when the id is
13
- * not of that shape.
7
+ * `Module:Entity` of a template id in either form (`#pkg-name:M:E` or `pkgId:M:E`), or null when the id is not of that
8
+ * shape.
14
9
  */
15
10
  export declare function qualifiedName(id: string): string | null;
16
- /** Whether two ids name the same template or interface, whatever package version or id form each uses. */
11
+ /** Whether two ids name the same template, whatever package version or id form each uses. */
17
12
  export declare function sameQualifiedName(left: string, right: string): boolean;
18
13
  /** The package name of a package-name form id (`#package-name:Module:Entity`), or null for any other form. */
19
14
  export declare function packageNameOf(id: string): string | null;
20
15
  /** `Module:Entity` of one of the SDK's own id constants; throws on a malformed constant rather than matching nothing. */
21
16
  export declare function requireQualifiedName(id: string): string;
22
- /** A stable key of a filter: `t:<templateId>` or `i:<interfaceId>`. */
23
- export declare function contractFilterKey(filter: ContractFilter): string;
24
17
  /**
25
- * Whether a contract of a snapshot read with several filters at once is one the given filter would have returned on its
26
- * own: of the template, or carrying a view of the interface (the ledger computes views only for the interfaces the read
27
- * asked for).
28
- *
29
- * A template match needs proven package identity, not just the same `Module:Entity`: a cumulative read also returns
30
- * contracts matched only by one of its interface filters, and any party can create a template of that name in its own
31
- * package. So a package-name filter (`#pkg:M:E`) matches only a contract whose `packageName` is that package; the
32
- * Ledger JSON API v2 (Canton 3.x) always reports `createdEvent.packageName` (a required field), so a contract without
33
- * one is not classified at all (fail closed). A package-id filter matches only the exact template id.
18
+ * Whether a contract is of a template given in package-name form (`#pkg:Module:Entity`, as the SDK's constants spell
19
+ * them): the same `Module:Entity` and the same package name. Any party can create a template of that name in its own
20
+ * package, so the name alone proves nothing. An id in any other form matches nothing.
34
21
  */
35
- export declare function contractMatchesFilter(contract: ActiveContract, filter: ContractFilter): boolean;
22
+ export declare function isTemplate(contract: ActiveContract, templateId: string): boolean;
36
23
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/wallets/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9D;;;GAGG;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