@fairmint/canton-node-sdk 0.0.308 → 0.0.310

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 (94) hide show
  1. package/README.md +95 -0
  2. package/build/src/clients/scan-api/ScanApiClient.generated.d.ts +1 -1
  3. package/build/src/clients/scan-api/ScanApiClient.generated.d.ts.map +1 -1
  4. package/build/src/clients/scan-api/operations/v0/scan.d.ts +11 -0
  5. package/build/src/clients/scan-api/operations/v0/scan.d.ts.map +1 -1
  6. package/build/src/clients/scan-api/operations/v0/scan.js +11 -0
  7. package/build/src/clients/scan-api/operations/v0/scan.js.map +1 -1
  8. package/build/src/clients/validator-api/ValidatorApiClient.generated.d.ts +0 -3
  9. package/build/src/clients/validator-api/ValidatorApiClient.generated.d.ts.map +1 -1
  10. package/build/src/clients/validator-api/ValidatorApiClient.generated.js +0 -2
  11. package/build/src/clients/validator-api/ValidatorApiClient.generated.js.map +1 -1
  12. package/build/src/clients/validator-api/operations/v0/scan-proxy/index.d.ts +0 -1
  13. package/build/src/clients/validator-api/operations/v0/scan-proxy/index.d.ts.map +1 -1
  14. package/build/src/clients/validator-api/operations/v0/scan-proxy/index.js +0 -1
  15. package/build/src/clients/validator-api/operations/v0/scan-proxy/index.js.map +1 -1
  16. package/build/src/clients/validator-api/schemas/api/scan-proxy.d.ts +0 -12
  17. package/build/src/clients/validator-api/schemas/api/scan-proxy.d.ts.map +1 -1
  18. package/build/src/clients/validator-api/schemas/api/scan-proxy.js +1 -13
  19. package/build/src/clients/validator-api/schemas/api/scan-proxy.js.map +1 -1
  20. package/build/src/clients/validator-api/schemas/operations/scan-proxy.d.ts +0 -5
  21. package/build/src/clients/validator-api/schemas/operations/scan-proxy.d.ts.map +1 -1
  22. package/build/src/clients/validator-api/schemas/operations/scan-proxy.js +1 -6
  23. package/build/src/clients/validator-api/schemas/operations/scan-proxy.js.map +1 -1
  24. package/build/src/utils/token-standard/v2/constants.d.ts +51 -0
  25. package/build/src/utils/token-standard/v2/constants.d.ts.map +1 -0
  26. package/build/src/utils/token-standard/v2/constants.js +54 -0
  27. package/build/src/utils/token-standard/v2/constants.js.map +1 -0
  28. package/build/src/utils/token-standard/v2/holdings.d.ts +0 -1
  29. package/build/src/utils/token-standard/v2/holdings.d.ts.map +1 -1
  30. package/build/src/utils/token-standard/v2/holdings.js +3 -3
  31. package/build/src/utils/token-standard/v2/holdings.js.map +1 -1
  32. package/build/src/utils/token-standard/v2/index.d.ts +1 -0
  33. package/build/src/utils/token-standard/v2/index.d.ts.map +1 -1
  34. package/build/src/utils/token-standard/v2/index.js +1 -0
  35. package/build/src/utils/token-standard/v2/index.js.map +1 -1
  36. package/build/src/utils/traffic/get-traffic-status.d.ts +15 -36
  37. package/build/src/utils/traffic/get-traffic-status.d.ts.map +1 -1
  38. package/build/src/utils/traffic/get-traffic-status.js +28 -27
  39. package/build/src/utils/traffic/get-traffic-status.js.map +1 -1
  40. package/build/src/wallets/amulet/registry.d.ts.map +1 -1
  41. package/build/src/wallets/amulet/registry.js +10 -91
  42. package/build/src/wallets/amulet/registry.js.map +1 -1
  43. package/build/src/wallets/cip103.d.ts.map +1 -1
  44. package/build/src/wallets/cip103.js +5 -1
  45. package/build/src/wallets/cip103.js.map +1 -1
  46. package/build/src/wallets/commands.d.ts +6 -0
  47. package/build/src/wallets/commands.d.ts.map +1 -1
  48. package/build/src/wallets/commands.js +22 -0
  49. package/build/src/wallets/commands.js.map +1 -1
  50. package/build/src/wallets/contracts.d.ts +80 -5
  51. package/build/src/wallets/contracts.d.ts.map +1 -1
  52. package/build/src/wallets/contracts.js +174 -2
  53. package/build/src/wallets/contracts.js.map +1 -1
  54. package/build/src/wallets/errors.d.ts +8 -1
  55. package/build/src/wallets/errors.d.ts.map +1 -1
  56. package/build/src/wallets/errors.js +5 -1
  57. package/build/src/wallets/errors.js.map +1 -1
  58. package/build/src/wallets/holding-view.d.ts +33 -1
  59. package/build/src/wallets/holding-view.d.ts.map +1 -1
  60. package/build/src/wallets/holding-view.js +49 -1
  61. package/build/src/wallets/holding-view.js.map +1 -1
  62. package/build/src/wallets/holdings.d.ts +38 -8
  63. package/build/src/wallets/holdings.d.ts.map +1 -1
  64. package/build/src/wallets/holdings.js +49 -9
  65. package/build/src/wallets/holdings.js.map +1 -1
  66. package/build/src/wallets/index.d.ts +11 -2
  67. package/build/src/wallets/index.d.ts.map +1 -1
  68. package/build/src/wallets/index.js +25 -2
  69. package/build/src/wallets/index.js.map +1 -1
  70. package/build/src/wallets/registry-http.d.ts +32 -0
  71. package/build/src/wallets/registry-http.d.ts.map +1 -0
  72. package/build/src/wallets/registry-http.js +105 -0
  73. package/build/src/wallets/registry-http.js.map +1 -0
  74. package/build/src/wallets/store.d.ts +3 -0
  75. package/build/src/wallets/store.d.ts.map +1 -1
  76. package/build/src/wallets/store.js +2 -1
  77. package/build/src/wallets/store.js.map +1 -1
  78. package/build/src/wallets/token-registry.d.ts +126 -0
  79. package/build/src/wallets/token-registry.d.ts.map +1 -0
  80. package/build/src/wallets/token-registry.js +249 -0
  81. package/build/src/wallets/token-registry.js.map +1 -0
  82. package/build/src/wallets/tokens.d.ts +16 -4
  83. package/build/src/wallets/tokens.d.ts.map +1 -1
  84. package/build/src/wallets/tokens.js +21 -15
  85. package/build/src/wallets/tokens.js.map +1 -1
  86. package/build/src/wallets/wallet.d.ts +30 -0
  87. package/build/src/wallets/wallet.d.ts.map +1 -1
  88. package/build/src/wallets/wallet.js +377 -18
  89. package/build/src/wallets/wallet.js.map +1 -1
  90. package/package.json +1 -1
  91. package/build/src/clients/validator-api/operations/v0/scan-proxy/get-member-traffic-status.d.ts +0 -33
  92. package/build/src/clients/validator-api/operations/v0/scan-proxy/get-member-traffic-status.d.ts.map +0 -1
  93. package/build/src/clients/validator-api/operations/v0/scan-proxy/get-member-traffic-status.js +0 -92
  94. package/build/src/clients/validator-api/operations/v0/scan-proxy/get-member-traffic-status.js.map +0 -1
@@ -15,11 +15,19 @@
15
15
  * others (see `isFromRegistry`). A Canton Coin offer counts when it is of Canton Coin and the DSO and its sender signed
16
16
  * it. The DSO party is resolved once for both (`createAmuletRegistry`): pinned, else the registry's `adminId`; while it
17
17
  * is unconfirmed, no Canton Coin is listed (`WalletState.cantonCoinUnavailable`).
18
+ *
19
+ * Token-standard registries (`WalletOptions.registries`, each by URL and pinned admin party): their holdings and
20
+ * transfer instructions, V2 and V1, mint offers included, are listed when that admin signed them, and the offers are
21
+ * answered through the V1 interface (V2 for a contract that implements only V2, and for the admin's withdrawal of a
22
+ * mint offer) with the registry's own choice contexts, once its `adminId` is confirmed. Their tokens are not
23
+ * transferred or burnt here. The raw views of any further interfaces a registry names (`extraInterfaceIds`) are passed
24
+ * on undecoded, for a library outside this SDK to read.
18
25
  */
19
26
  import { type Cip103Provider, type WalletReadRetryOptions } from './cip103';
20
27
  import { type BurnRequest, type MintOffer, type TransferOffer, type TransferOfferRegistry, type TransferPreapproval } from './contracts';
21
28
  import { type DaNetwork, type DaRegistryOptions, type TransferKind } from './da-utilities/client';
22
29
  import { type CantonCoinOptions } from './amulet/registry';
30
+ import { type TokenRegistryOptions } from './token-registry';
23
31
  import { type Holding, type InstrumentBalance } from './holdings';
24
32
  import type { InstrumentId, SubmitResult, WalletSubmission } from './types';
25
33
  /** A burn reference: no personal data (DA's operator and the registrar see it). */
@@ -48,6 +56,18 @@ export interface WalletOptions {
48
56
  * `false`: no Canton Coin is read and the registry is never asked.
49
57
  */
50
58
  readonly cantonCoin?: CantonCoinOptions | false;
59
+ /**
60
+ * Token-standard registries beside DA's and Canton Coin's, each given by URL and admin party: their holdings (read
61
+ * through `HoldingV2`, else `HoldingV1`) and their transfer instructions (V2, else V1; mint offers included) are
62
+ * listed, and the offers can be accepted, rejected or withdrawn through the registry's own choice contexts (through
63
+ * V1 whenever the contract implements it). A contract counts only when its instrument admin is one of these
64
+ * registries and that admin (and the registry's `requiredSignatories`) signed it; nothing else is trusted. The admin
65
+ * is pinned: each registry's `adminId` is checked against it before any choice context is used (fail closed). Tokens
66
+ * of these registries are not transferred or burnt through this wallet. Only the interfaces the registries name
67
+ * (`TokenRegistryOptions.interfaces`, and their `extraInterfaceIds`, whose raw views are passed on) are read, and an
68
+ * interface whose package the participant does not have is left out of a read, so the rest of the state still loads.
69
+ */
70
+ readonly registries?: readonly TokenRegistryOptions[];
51
71
  /**
52
72
  * Whether the wallet session this wallet belongs to is still live. Once it answers false, every write is refused with
53
73
  * `invalid-input` before its first read, and again right before the wallet signs, so nothing is submitted: the
@@ -103,6 +123,16 @@ export interface WalletState {
103
123
  * type-checks.
104
124
  */
105
125
  readonly cantonCoinUnavailable?: boolean;
126
+ /**
127
+ * The configured registries' interfaces this state was read without, because the participant refused a read naming
128
+ * them (it does not have their package): a token-standard interface by its name (`holding-v2`, see
129
+ * {@link TokenStandardInterface}), an extra one (`TokenRegistryOptions.extraInterfaceIds`) by its id as configured.
130
+ * What the registries hold through a standard one is missing from `holdings`, `balances` and `transferOffers`; an
131
+ * extra one's views are missing from `interfaceViews`. All of them are named when the refusal did not say which.
132
+ * Empty when every interface was read (and without `registries`). Load again once the packages are on the
133
+ * participant. The wallet always sets it; optional so a state built without it still type-checks.
134
+ */
135
+ readonly registryInterfacesUnavailable?: string[];
106
136
  }
107
137
  export interface TransferRequest {
108
138
  readonly receiver: string;
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallets/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,sBAAsB,EAC5B,MAAM,UAAU,CAAC;AAelB,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,iBAAiB,EAGtB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AA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C,CAAC;IAC/F,2EAA2E;IAC3E,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9F;;;OAGG;IACH,yBAAyB,CACvB,WAAW,EAAE,0BAA0B,EACvC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,yDAAyD;IACzD,yBAAyB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACtG;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9F;AAmND,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA6jC3D"}
@@ -20,6 +20,13 @@ exports.createWallet = createWallet;
20
20
  * others (see `isFromRegistry`). A Canton Coin offer counts when it is of Canton Coin and the DSO and its sender signed
21
21
  * it. The DSO party is resolved once for both (`createAmuletRegistry`): pinned, else the registry's `adminId`; while it
22
22
  * is unconfirmed, no Canton Coin is listed (`WalletState.cantonCoinUnavailable`).
23
+ *
24
+ * Token-standard registries (`WalletOptions.registries`, each by URL and pinned admin party): their holdings and
25
+ * transfer instructions, V2 and V1, mint offers included, are listed when that admin signed them, and the offers are
26
+ * answered through the V1 interface (V2 for a contract that implements only V2, and for the admin's withdrawal of a
27
+ * mint offer) with the registry's own choice contexts, once its `adminId` is confirmed. Their tokens are not
28
+ * transferred or burnt here. The raw views of any further interfaces a registry names (`extraInterfaceIds`) are passed
29
+ * on undecoded, for a library outside this SDK to read.
23
30
  */
24
31
  const cip103_1 = require("./cip103");
25
32
  const commands_1 = require("./commands");
@@ -30,6 +37,7 @@ const constants_1 = require("./amulet/constants");
30
37
  const registry_1 = require("./amulet/registry");
31
38
  const errors_1 = require("./errors");
32
39
  const holding_view_1 = require("./holding-view");
40
+ const token_registry_1 = require("./token-registry");
33
41
  const holdings_1 = require("./holdings");
34
42
  const decimal_1 = require("./decimal");
35
43
  const instrument_1 = require("./instrument");
@@ -38,6 +46,7 @@ const templates_1 = require("./templates");
38
46
  const tokens_1 = require("./tokens");
39
47
  const templates_2 = require("../da-registry/templates");
40
48
  const constants_2 = require("../utils/token-standard/v1/constants");
49
+ const constants_3 = require("../utils/token-standard/v2/constants");
41
50
  const SECOND_MS = 1000;
42
51
  const DAY_MS = 24 * 60 * 60 * SECOND_MS;
43
52
  /** Transfers: `executeBefore` defaults to now + 24 h, a common wallet default. */
@@ -106,6 +115,114 @@ const CANTON_COIN_STATE_FILTERS = [
106
115
  ...DA_STATE_TEMPLATES,
107
116
  constants_1.AMULET_TEMPLATES.transferInstruction,
108
117
  ];
118
+ /**
119
+ * The interface (with its view) each token-standard interface of a configured registry is read through: holdings
120
+ * (`HoldingV2`, and `HoldingV1` for a registry that implements only CIP-56) and transfer instructions (V2 and V1).
121
+ * Which contracts count is decided per contract (`parseHolding`, `tokenStandardOffers`).
122
+ */
123
+ const TOKEN_STANDARD_INTERFACE_FILTERS = {
124
+ 'holding-v2': { interfaceId: holding_view_1.HOLDING_V2_INTERFACE_ID, includeInterfaceView: true },
125
+ 'holding-v1': { interfaceId: holding_view_1.HOLDING_V1_INTERFACE_ID, includeInterfaceView: true },
126
+ 'transfer-instruction-v2': {
127
+ interfaceId: constants_3.TOKEN_STANDARD_V2_TRANSFER_INSTRUCTION_INTERFACE_ID,
128
+ includeInterfaceView: true,
129
+ },
130
+ 'transfer-instruction-v1': {
131
+ interfaceId: constants_2.TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID,
132
+ includeInterfaceView: true,
133
+ },
134
+ };
135
+ /**
136
+ * How `WalletState.registryInterfacesUnavailable` names the interface a filter reads: a token-standard interface of
137
+ * {@link TOKEN_STANDARD_INTERFACE_FILTERS} by its name, an extra interface by its id.
138
+ */
139
+ function filterInterfaceName(filter) {
140
+ const standard = token_registry_1.TOKEN_STANDARD_INTERFACES.find((entry) => TOKEN_STANDARD_INTERFACE_FILTERS[entry] === filter);
141
+ return standard ?? (typeof filter === 'string' ? filter : filter.interfaceId);
142
+ }
143
+ /** The transfer instruction interfaces, for a read of offers only. */
144
+ const TOKEN_STANDARD_OFFER_INTERFACES = [
145
+ 'transfer-instruction-v2',
146
+ 'transfer-instruction-v1',
147
+ ];
148
+ /** The holding interfaces, to tell a configured registry's token apart before refusing its transfer or burn. */
149
+ const TOKEN_STANDARD_HOLDING_INTERFACES = ['holding-v2', 'holding-v1'];
150
+ /**
151
+ * The Canton errors a participant answers a read with when a filter names a package or interface it does not have. The
152
+ * wallet then reads again without the configured registries' filters the error names (all of them when it names none),
153
+ * so a participant without one registry interface still loads the rest of the state; the state names the interfaces
154
+ * left out (`WalletState.registryInterfacesUnavailable`).
155
+ */
156
+ const UNRESOLVED_FILTER_ERRORS = new Set([
157
+ 'PACKAGE_NAMES_NOT_FOUND',
158
+ 'TEMPLATES_OR_INTERFACES_NOT_FOUND',
159
+ ]);
160
+ /** How much of a refusal's text is searched for the filters it names. */
161
+ const UNRESOLVED_FILTER_TEXT_CHARS = 16384;
162
+ /** A refusal's message and data as text, bounded; never throws. */
163
+ function refusalText(error) {
164
+ const parts = [];
165
+ const add = (value) => {
166
+ if (typeof value === 'string') {
167
+ parts.push(value);
168
+ return;
169
+ }
170
+ if (value === undefined)
171
+ return;
172
+ try {
173
+ parts.push(JSON.stringify(value));
174
+ }
175
+ catch {
176
+ // Unserializable data names nothing.
177
+ }
178
+ };
179
+ if (error instanceof Error)
180
+ add(error.message);
181
+ const cause = (0, json_1.isRecord)(error) ? error['cause'] : undefined;
182
+ if ((0, json_1.isRecord)(cause)) {
183
+ if (typeof cause['message'] === 'string')
184
+ add(cause['message']);
185
+ add(cause['data']);
186
+ }
187
+ return parts.join('\n').slice(0, UNRESOLVED_FILTER_TEXT_CHARS);
188
+ }
189
+ /**
190
+ * The text of a read refused because a filter names a package or interface the participant does not have, or undefined
191
+ * for any other failure.
192
+ */
193
+ function unresolvedFilterRefusal(error) {
194
+ if (!(0, errors_1.isWalletReadError)(error))
195
+ return undefined;
196
+ const id = error.cantonErrorId;
197
+ return id !== undefined && UNRESOLVED_FILTER_ERRORS.has(id) ? refusalText(error) : undefined;
198
+ }
199
+ const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
200
+ /**
201
+ * Whether a refusal's `text` names `filter`'s interface: its id, its package (name or id) as a whole word, or its
202
+ * `Module:Entity` part as a whole name (a refusal that names the interface by the other id form).
203
+ */
204
+ function refusalNames(text, filter) {
205
+ const id = typeof filter === 'string' ? filter : filter.interfaceId;
206
+ if (text.includes(id) || text.includes(id.replace(/^#/, '')))
207
+ return true;
208
+ const parts = /^#?([^:]+):(.+)$/.exec(id);
209
+ if (parts === null)
210
+ return false;
211
+ const [, packageName = '', qualifiedName = ''] = parts;
212
+ return (new RegExp(`(^|[^\\w-])${escapeRegExp(packageName)}($|[^\\w-])`).test(text) ||
213
+ new RegExp(`(^|[^\\w.-])${escapeRegExp(qualifiedName)}($|[^\\w.-])`).test(text));
214
+ }
215
+ /** `filters` without repeats (an interface filter asked twice, by the same id and view flag). */
216
+ function uniqueFilters(filters) {
217
+ const seen = new Set();
218
+ return filters.filter((filter) => {
219
+ const key = typeof filter === 'string' ? filter : `${filter.interfaceId}+${filter.includeInterfaceView === true}`;
220
+ if (seen.has(key))
221
+ return false;
222
+ seen.add(key);
223
+ return true;
224
+ });
225
+ }
109
226
  /** Canton Coin's holding templates. */
110
227
  const CANTON_COIN_HOLDING_TEMPLATES = [constants_1.AMULET_TEMPLATES.amulet, constants_1.AMULET_TEMPLATES.lockedAmulet];
111
228
  /** Canton Coin contracts whose DSO must be confirmed before they are listed. */
@@ -146,6 +263,21 @@ function deadline(executeBefore, at, defaultMs) {
146
263
  throw new errors_1.WalletError('invalid-input', 'executeBefore must be in the future');
147
264
  return isoTime(ms, 'executeBefore');
148
265
  }
266
+ /** The `TransferInstruction` versions a token-standard offer implements (`standards`, else its one `standard`). */
267
+ function implementedStandards(offer) {
268
+ return offer.standards ?? [offer.standard ?? 'v1'];
269
+ }
270
+ /**
271
+ * The `TransferInstruction` version the wallet exercises `action` through on a token-standard offer: V1 whenever the
272
+ * contract implements it, so a holder only ever needs the CIP-56 V1 choices its signing policy already allows, and V2
273
+ * for a contract that implements V2 alone. A mint offer is withdrawn through V2: its V1 view names the stub party as
274
+ * sender, so a V1 withdrawal would be refused on the ledger (one without V2 is refused before this).
275
+ */
276
+ function answerStandard(offer, action) {
277
+ if (offer.mint === true && action === 'withdraw')
278
+ return 'v2';
279
+ return implementedStandards(offer).includes('v1') ? 'v1' : 'v2';
280
+ }
149
281
  /** The DA Registry token actions of `options.partyId` through `options.provider`. */
150
282
  function createWallet(options) {
151
283
  const { provider, isActive, now: clock = () => new Date(), readRetry } = options;
@@ -157,10 +289,29 @@ function createWallet(options) {
157
289
  const now = () => requireTime(clock(), 'now()');
158
290
  /** Canton Coin's registry: the one DSO resolution holdings and offers share; null with `cantonCoin: false`. */
159
291
  const cantonCoin = options.cantonCoin === false ? null : (0, registry_1.createAmuletRegistry)(network, options.cantonCoin, { now });
160
- const stateFilters = cantonCoin === null ? DA_STATE_TEMPLATES : CANTON_COIN_STATE_FILTERS;
292
+ /** The configured token-standard registries, by admin party; empty without `registries`. */
293
+ const tokenRegistries = (0, token_registry_1.createTokenRegistries)(options.registries, { now });
294
+ const configured = {
295
+ trusts: (admin, contract) => tokenRegistries.get(admin)?.trusts(contract) === true,
296
+ };
297
+ const hasTokenRegistries = tokenRegistries.size > 0;
298
+ /** The interfaces any configured registry is read through; none without `registries`. */
299
+ const readInterfaces = new Set([...tokenRegistries.values()].flatMap((entry) => entry.interfaces));
300
+ /** The filters of `interfaces` that a configured registry is read through. */
301
+ const tokenStandardFilters = (interfaces) => interfaces.filter((entry) => readInterfaces.has(entry)).map((entry) => TOKEN_STANDARD_INTERFACE_FILTERS[entry]);
302
+ const stateTemplates = cantonCoin === null ? DA_STATE_TEMPLATES : CANTON_COIN_STATE_FILTERS;
303
+ /** The configured registries' filters of a state snapshot; empty without `registries`. */
304
+ const tokenStandardStateFilters = tokenStandardFilters(token_registry_1.TOKEN_STANDARD_INTERFACES);
305
+ /**
306
+ * The registries' extra interfaces (with their views), read in a state snapshot beside the standard ones, each once;
307
+ * empty when no registry names any, so the snapshot reads exactly the standard filters.
308
+ */
309
+ const extraInterfaceFilters = uniqueFilters([...tokenRegistries.values()].flatMap((entry) => entry.extraInterfaceIds.map((interfaceId) => ({ interfaceId, includeInterfaceView: true }))));
161
310
  const offerTemplates = cantonCoin === null
162
311
  ? [templates_2.DA_REGISTRY_TEMPLATES.transferOffer]
163
312
  : [templates_2.DA_REGISTRY_TEMPLATES.transferOffer, constants_1.AMULET_TEMPLATES.transferInstruction];
313
+ /** The configured registries' transfer instruction filters, for an answer to an offer; empty without `registries`. */
314
+ const tokenStandardOfferFilters = tokenStandardFilters(TOKEN_STANDARD_OFFER_INTERFACES);
164
315
  /** Refuse a write once the wallet session this wallet belongs to ended (`isActive`). */
165
316
  function requireActive() {
166
317
  if (isActive !== undefined && !isActive()) {
@@ -169,9 +320,44 @@ function createWallet(options) {
169
320
  }
170
321
  const ledger = (0, cip103_1.cip103Wallet)(provider, partyId, readRetry !== undefined ? { readRetry } : {});
171
322
  /** A ledger read; an aborted `signal` stops waiting for it (the wallet's read itself cannot be cancelled). */
172
- async function read(templateId, signal) {
173
- const templateIds = typeof templateId === 'string' ? [templateId] : templateId;
174
- return (await (0, abort_1.awaitWithAbort)(async () => ledger.readActiveContracts(templateIds), signal)).contracts;
323
+ async function read(filter, signal) {
324
+ const filters = Array.isArray(filter) ? filter : [filter];
325
+ return (await (0, abort_1.awaitWithAbort)(async () => ledger.readActiveContracts(filters), signal)).contracts;
326
+ }
327
+ /**
328
+ * One snapshot of `required` and the configured registries' `optional` filters. When the participant refuses the read
329
+ * because a filter names a package or interface it does not have, it is read again without the optional filters the
330
+ * refusal names (every optional filter when it names none), until it answers or no optional filter is left; any other
331
+ * failure, or a refusal of the required filters alone, is thrown. Without optional filters this is one read, exactly
332
+ * as before. `snapshot` is undefined when nothing is left to read (no required filter, and every optional one left
333
+ * out); `omitted` are the optional filters left out, in the order given.
334
+ */
335
+ async function snapshotWithOptional(required, optional) {
336
+ const base = uniqueFilters(required);
337
+ const keyOf = (entry) => typeof entry === 'string' ? entry : `${entry.interfaceId}+${entry.includeInterfaceView === true}`;
338
+ const baseKeys = new Set(base.map(keyOf));
339
+ const wanted = uniqueFilters(optional).filter((entry) => !baseKeys.has(keyOf(entry)));
340
+ let remaining = wanted;
341
+ const omitted = () => wanted.filter((entry) => !remaining.includes(entry));
342
+ for (;;) {
343
+ const filters = [...base, ...remaining];
344
+ if (filters.length === 0)
345
+ return { snapshot: undefined, omitted: omitted() };
346
+ try {
347
+ return { snapshot: await ledger.readActiveContracts(filters), omitted: omitted() };
348
+ }
349
+ catch (error) {
350
+ const refusal = remaining.length > 0 ? unresolvedFilterRefusal(error) : undefined;
351
+ if (refusal === undefined)
352
+ throw error;
353
+ const named = remaining.filter((entry) => refusalNames(refusal, entry));
354
+ remaining = named.length > 0 ? remaining.filter((entry) => !named.includes(entry)) : [];
355
+ }
356
+ }
357
+ }
358
+ /** The contracts of {@link snapshotWithOptional}; none when nothing is left to read. */
359
+ async function readWithOptional(required, optional, signal) {
360
+ return ((await (0, abort_1.awaitWithAbort)(async () => snapshotWithOptional(required, optional), signal)).snapshot?.contracts ?? []);
175
361
  }
176
362
  async function submit(submission, signal) {
177
363
  // Checked again right before the wallet signs: a write's reads and registry calls await, and the session may end
@@ -231,7 +417,7 @@ function createWallet(options) {
231
417
  function holdingsIn(contracts, dso) {
232
418
  const seen = new Set();
233
419
  return contracts.flatMap((contract) => {
234
- const holding = (0, holdings_1.parseHolding)(contract);
420
+ const holding = (0, holdings_1.parseHolding)(contract, hasTokenRegistries ? configured : undefined);
235
421
  if (holding?.owner !== partyId || seen.has(holding.contractId))
236
422
  return [];
237
423
  if ((0, holdings_1.isCantonCoin)(holding) && (dso === undefined || holding.instrumentId.admin !== dso))
@@ -240,8 +426,49 @@ function createWallet(options) {
240
426
  return [holding];
241
427
  });
242
428
  }
243
- /** The party's DA Registry holdings, for a transfer or burn (Canton Coin is read-only here). */
244
- const daHoldingsIn = (contracts) => holdingsIn(contracts).filter((holding) => !(0, holdings_1.isCantonCoin)(holding));
429
+ /**
430
+ * The party's DA Registry holdings, for a transfer or burn (Canton Coin and the configured registries' holdings are
431
+ * read-only here).
432
+ */
433
+ const daHoldingsIn = (contracts) => holdingsIn(contracts).filter((holding) => (holding.source ?? 'da-registry') === 'da-registry');
434
+ /**
435
+ * The party's token-standard holding of this instrument, when its admin is a configured registry; else undefined.
436
+ * Read only for a configured registry's admin. One party may administer DA Registry instruments too, so a refusal
437
+ * goes by the instrument the party holds, never by its admin alone.
438
+ */
439
+ async function tokenStandardHoldingOf(instrumentId, signal) {
440
+ if (!tokenRegistries.has(instrumentId.admin))
441
+ return undefined;
442
+ return holdingsIn(await readWithOptional([], tokenStandardFilters(TOKEN_STANDARD_HOLDING_INTERFACES), signal)).find((holding) => holding.source === 'token-standard' && (0, instrument_1.sameInstrument)(holding.instrumentId, instrumentId));
443
+ }
444
+ /**
445
+ * Refuse a transfer of an instrument the party holds through a configured registry and not through DA: this wallet
446
+ * does not transfer them. A DA Registry instrument of the same admin stays transferable.
447
+ */
448
+ async function refuseTokenStandardTransfer(instrumentId, signal) {
449
+ if (!tokenRegistries.has(instrumentId.admin))
450
+ return;
451
+ // A DA instrument of the same admin goes to the DA path, decided from the DA holdings the transfer reads anyway,
452
+ // so no interface read (which can also match Canton Coin's holdings and reach the list limit) is made for it.
453
+ const daHoldings = daHoldingsIn(await read(templates_2.DA_REGISTRY_TEMPLATES.holding, signal));
454
+ if (daHoldings.some((holding) => (0, instrument_1.sameInstrument)(holding.instrumentId, instrumentId)))
455
+ return;
456
+ if ((await tokenStandardHoldingOf(instrumentId, signal)) === undefined)
457
+ return;
458
+ throw new errors_1.WalletError('invalid-input', `Tokens of ${tokenRegistries.get(instrumentId.admin)?.name ?? instrumentId.admin} cannot be transferred through this wallet yet; nothing was submitted`);
459
+ }
460
+ /**
461
+ * Refuse a burn of an instrument the party holds through a configured registry and not through DA: this wallet burns
462
+ * DA Registry instruments only. Checked once the party holds no DA holding of it, so a DA instrument of the same
463
+ * admin stays burnable.
464
+ */
465
+ async function refuseTokenStandardBurn(instrumentId, daHoldings, signal) {
466
+ if (daHoldings.some((holding) => (0, instrument_1.sameInstrument)(holding.instrumentId, instrumentId)))
467
+ return;
468
+ if ((await tokenStandardHoldingOf(instrumentId, signal)) === undefined)
469
+ return;
470
+ throw new errors_1.WalletError('invalid-input', `Tokens of ${tokenRegistries.get(instrumentId.admin)?.name ?? instrumentId.admin} cannot be burned through this wallet; nothing was submitted`);
471
+ }
245
472
  /**
246
473
  * Refuse a Canton Coin transfer or burn: this wallet only reads Canton Coin. Before any read when the instrument is
247
474
  * the known DSO's `Amulet` (pinned, or already confirmed by the registry); otherwise (`holdings` given) an `Amulet`
@@ -291,8 +518,32 @@ function createWallet(options) {
291
518
  return byDirection([
292
519
  ...fromRegistry(contracts, contracts_1.parseTransferOffer, operator),
293
520
  ...amuletTransferOffers(contracts, dso),
521
+ ...tokenStandardOffers(contracts),
294
522
  ]);
295
523
  }
524
+ /**
525
+ * The configured registries' transfer instructions among `contracts` (V2 view, else V1; DA's and Canton Coin's own
526
+ * templates are read by their own rules): the instrument admin is a configured registry that `trusts` the contract
527
+ * (it and the registry's required signatories signed it). Each contract once.
528
+ */
529
+ function tokenStandardOffers(contracts) {
530
+ if (!hasTokenRegistries)
531
+ return [];
532
+ const seen = new Set();
533
+ return contracts.flatMap((contract) => {
534
+ if (seen.has(contract.contractId))
535
+ return [];
536
+ if ((0, templates_1.isTemplate)(contract, templates_2.DA_REGISTRY_TEMPLATES.transferOffer))
537
+ return [];
538
+ if ((0, templates_1.isTemplate)(contract, constants_1.AMULET_TEMPLATES.transferInstruction))
539
+ return [];
540
+ const offer = (0, contracts_1.parseTokenStandardTransferOffer)(contract);
541
+ if (offer === null || !configured.trusts(offer.instrumentId.admin, contract))
542
+ return [];
543
+ seen.add(contract.contractId);
544
+ return [offer];
545
+ });
546
+ }
296
547
  /** Canton Coin's transfer offers among `contracts` of the confirmed `dso`, signed by it and their sender. */
297
548
  function amuletTransferOffers(contracts, dso) {
298
549
  if (dso === undefined)
@@ -302,8 +553,12 @@ function createWallet(options) {
302
553
  return offer === null ? [] : [offer];
303
554
  });
304
555
  }
556
+ /**
557
+ * The party's offers by direction. A self-transfer is outgoing only; a mint offer to the registry admin itself (its
558
+ * `sender` is the admin, standing in for the mint account) is both: the admin receives it and may also withdraw it.
559
+ */
305
560
  const byDirection = (offers) => ({
306
- incoming: offers.filter((offer) => offer.receiver === partyId && offer.sender !== partyId),
561
+ incoming: offers.filter((offer) => offer.receiver === partyId && (offer.sender !== partyId || offer.mint === true)),
307
562
  outgoing: offers.filter((offer) => offer.sender === partyId),
308
563
  });
309
564
  /** The party's own preapprovals under DA's operator: the party is their only signatory. */
@@ -324,17 +579,79 @@ function createWallet(options) {
324
579
  }
325
580
  return found;
326
581
  }
327
- /** The balances of `holdings`, each with its registry's metadata (Canton Coin's is given: it is looked up apart). */
328
- async function balancesWithMetadata(holdings, cantonCoinMetadata) {
582
+ /**
583
+ * Each configured registry's entry for each of its instruments among `holdings`, by `instrumentKey` (looked up by id
584
+ * at the instrument's own registry; an instrument it did not answer is left out).
585
+ */
586
+ async function registryInstruments(holdings) {
587
+ const ids = new Map();
588
+ for (const holding of holdings) {
589
+ if (holding.source === 'token-standard')
590
+ ids.set((0, holdings_1.instrumentKey)(holding.instrumentId), holding.instrumentId);
591
+ }
592
+ const answers = await Promise.all([...ids.entries()].map(async ([key, instrumentId]) => {
593
+ const entry = await tokenRegistries.get(instrumentId.admin)?.instrument(instrumentId);
594
+ return [key, entry];
595
+ }));
596
+ return new Map(answers.flatMap(([key, entry]) => (entry === undefined ? [] : [[key, entry]])));
597
+ }
598
+ /**
599
+ * The balances of `holdings`, each with its registry's metadata (Canton Coin's is given: it is looked up apart; the
600
+ * configured registries' come from `instruments`).
601
+ */
602
+ async function balancesWithMetadata(holdings, cantonCoinMetadata, instruments) {
329
603
  return Promise.all((0, holdings_1.instrumentBalances)(holdings).map(async (balance) => {
330
- const metadata = (0, holdings_1.isCantonCoin)(balance)
331
- ? cantonCoinMetadata
332
- : await registry.instrumentMetadata(balance.instrumentId);
604
+ let metadata;
605
+ if ((0, holdings_1.isCantonCoin)(balance)) {
606
+ metadata = cantonCoinMetadata;
607
+ }
608
+ else if (balance.source === 'token-standard') {
609
+ const entry = instruments.get(balance.key);
610
+ metadata =
611
+ entry === undefined ? undefined : { name: entry.name, symbol: entry.symbol, decimals: entry.decimals };
612
+ }
613
+ else {
614
+ metadata = await registry.instrumentMetadata(balance.instrumentId);
615
+ }
333
616
  return metadata === undefined ? balance : { ...balance, metadata };
334
617
  }));
335
618
  }
619
+ /**
620
+ * The raw views of the extra interfaces (`TokenRegistryOptions.extraInterfaceIds`) that the registry of `admin`
621
+ * names, among `contract`'s views, keyed by the id as configured: each one's single, successfully computed view
622
+ * (matched by `Module:Entity`, as the ledger reports a view by package id). Undefined when the registry names none or
623
+ * the contract has none of their views.
624
+ */
625
+ function extraInterfaceViews(admin, contract) {
626
+ const ids = tokenRegistries.get(admin)?.extraInterfaceIds ?? [];
627
+ if (contract === undefined || ids.length === 0)
628
+ return undefined;
629
+ const views = Object.create(null);
630
+ let found = false;
631
+ for (const interfaceId of ids) {
632
+ const value = (0, holding_view_1.interfaceViewValue)(contract, interfaceId);
633
+ if (value === undefined || value === null)
634
+ continue;
635
+ views[interfaceId] = value;
636
+ found = true;
637
+ }
638
+ return found ? Object.freeze(views) : undefined;
639
+ }
640
+ /** `entry` with its extra interface views (see {@link extraInterfaceViews}), for a configured registry's entry. */
641
+ function withInterfaceViews(entry, contractsById) {
642
+ if (extraInterfaceFilters.length === 0)
643
+ return entry;
644
+ const interfaceViews = extraInterfaceViews(entry.instrumentId.admin, contractsById.get(entry.contractId));
645
+ return interfaceViews === undefined ? entry : { ...entry, interfaceViews };
646
+ }
336
647
  async function readState() {
337
- const { offset, contracts } = await ledger.readActiveContracts(stateFilters);
648
+ // Always at least the DA templates, so there is always a snapshot.
649
+ const stateRead = await snapshotWithOptional(stateTemplates, [
650
+ ...tokenStandardStateFilters,
651
+ ...extraInterfaceFilters,
652
+ ]);
653
+ const { offset, contracts } = stateRead.snapshot;
654
+ const registryInterfacesUnavailable = stateRead.omitted.map(filterInterfaceName);
338
655
  // Asked only when the party has Canton Coin. The DSO and Canton Coin's metadata are looked up at once, so a
339
656
  // snapshot waits for the registry once (see `createAmuletRegistry` for how long).
340
657
  const [{ dso, unavailable }, cantonCoinMetadata] = await Promise.all([
@@ -343,14 +660,18 @@ function createWallet(options) {
343
660
  ? cantonCoin.instrumentMetadata()
344
661
  : undefined,
345
662
  ]);
346
- const holdings = holdingsIn(contracts, dso);
663
+ const contractsById = new Map(extraInterfaceFilters.length === 0 ? [] : contracts.map((contract) => [contract.contractId, contract]));
664
+ const holdings = holdingsIn(contracts, dso).map((holding) => holding.source === 'token-standard' ? withInterfaceViews(holding, contractsById) : holding);
665
+ const instruments = await registryInstruments(holdings);
347
666
  const [operator, balances] = await Promise.all([
348
667
  registry.operatorParty(),
349
- balancesWithMetadata(holdings, cantonCoinMetadata),
668
+ balancesWithMetadata(holdings, cantonCoinMetadata, instruments),
350
669
  ]);
351
670
  const at = now();
352
671
  const withExpiry = (offers) => offers.map((offer) => ({ ...offer, expired: (0, tokens_1.isTransferOfferExpired)(offer, at) }));
353
- const offers = transferOffers(contracts, operator, dso);
672
+ const withViews = (list) => list.map((offer) => (offer.registry === 'token-standard' ? withInterfaceViews(offer, contractsById) : offer));
673
+ const listed = transferOffers(contracts, operator, dso);
674
+ const offers = { incoming: withViews(listed.incoming), outgoing: withViews(listed.outgoing) };
354
675
  const outgoing = withExpiry(offers.outgoing);
355
676
  const reclaimable = (0, tokens_1.lockedInExpiredOffers)(holdings, outgoing.filter((offer) => offer.expired === true));
356
677
  const inExpiredLocks = (0, tokens_1.unitsByInstrument)((0, tokens_1.expiredUnclaimedLocks)(holdings, [...offers.incoming, ...offers.outgoing], at));
@@ -367,6 +688,7 @@ function createWallet(options) {
367
688
  burnRequests: ownBurnRequests(contracts, operator),
368
689
  transferPreapprovals: ownPreapprovals(contracts, operator),
369
690
  cantonCoinUnavailable: unavailable,
691
+ registryInterfacesUnavailable,
370
692
  };
371
693
  }
372
694
  let inFlight;
@@ -462,6 +784,7 @@ function createWallet(options) {
462
784
  const planSignal = call.signal;
463
785
  (0, abort_1.throwIfAborted)(planSignal);
464
786
  const planned = plannedRequest(request);
787
+ await refuseTokenStandardTransfer(planned.instrumentId, planSignal);
465
788
  const kind = (await prepareTransfer(planned, planSignal)).factory.transferKind;
466
789
  requirePreapprovalIfAsked(planned, kind);
467
790
  return Object.freeze({
@@ -479,7 +802,7 @@ function createWallet(options) {
479
802
  async function answerTransferOfferSubmission(transferOfferCid, action, signal) {
480
803
  // Read the target first, then resolve only the registry that validates it: the DSO for a Canton Coin offer, DA's
481
804
  // operator for a DA offer. Neither offer kind depends on the other registry being up.
482
- const target = (await read(offerTemplates, signal)).filter((contract) => contract.contractId === transferOfferCid);
805
+ const target = (await readWithOptional(offerTemplates, tokenStandardOfferFilters, signal)).filter((contract) => contract.contractId === transferOfferCid);
483
806
  let offers;
484
807
  if (cantonCoin !== null && anyOf(target, [constants_1.AMULET_TEMPLATES.transferInstruction])) {
485
808
  const { dso, unavailable } = await cantonCoinDso(target, signal, registry_1.AMULET_REGISTRY_REQUEST_TIMEOUT_MS);
@@ -491,16 +814,50 @@ function createWallet(options) {
491
814
  else if (anyOf(target, [templates_2.DA_REGISTRY_TEMPLATES.transferOffer])) {
492
815
  offers = byDirection(fromRegistry(target, contracts_1.parseTransferOffer, await registry.operatorParty(signal)));
493
816
  }
817
+ else if (hasTokenRegistries) {
818
+ offers = byDirection(tokenStandardOffers(target));
819
+ }
494
820
  else {
495
821
  offers = { incoming: [], outgoing: [] };
496
822
  }
497
823
  const { incoming, outgoing } = offers;
498
824
  const offer = find(action === 'withdraw' ? outgoing : incoming, transferOfferCid, action === 'withdraw' ? 'Outgoing transfer offer' : 'Incoming transfer offer');
825
+ if (offer.registry === 'token-standard')
826
+ refuseTokenStandardAnswer(offer, action);
499
827
  return offerAnswerSubmission(offer, action, signal);
500
828
  }
829
+ /**
830
+ * Refuse, before any registry call, an action a configured registry's instruction does not let the party take alone
831
+ * (its V2 `availableActions`), and a withdrawal of a mint offer that does not implement V2 (its V1 sender is the mint
832
+ * account's stub party, which nothing can act as).
833
+ */
834
+ function refuseTokenStandardAnswer(offer, action) {
835
+ if (offer.mint === true && action === 'withdraw' && !implementedStandards(offer).includes('v2')) {
836
+ throw new errors_1.WalletError('invalid-input', `Mint offer ${offer.contractId} implements only the V1 TransferInstruction, whose sender is the mint account: it cannot be withdrawn through this wallet; nothing was submitted`);
837
+ }
838
+ if (!(0, contracts_1.partyMayAct)(offer, action, partyId)) {
839
+ throw new errors_1.WalletError('invalid-input', `Transfer instruction ${offer.contractId} does not let ${partyId} ${action} it alone; nothing was submitted`);
840
+ }
841
+ }
501
842
  /** Exercise `action` on a transfer offer already read and validated, with its own registry's choice context. */
502
843
  async function offerAnswerSubmission(offer, action, signal) {
503
844
  const transferOfferCid = offer.contractId;
845
+ if (offer.registry === 'token-standard') {
846
+ const owner = tokenRegistries.get(offer.instrumentId.admin);
847
+ if (owner === undefined) {
848
+ throw new errors_1.WalletError('not-found', `No registry is configured for ${offer.instrumentId.admin}, so transfer offer ${transferOfferCid} cannot be answered; nothing was submitted`);
849
+ }
850
+ const standard = answerStandard(offer, action);
851
+ const tokenContext = await owner.transferInstructionContext(transferOfferCid, action, standard, signal);
852
+ return {
853
+ commands: [
854
+ standard === 'v2'
855
+ ? (0, commands_1.transferInstructionV2Command)(transferOfferCid, action, partyId, tokenContext.choiceContextData)
856
+ : (0, commands_1.transferInstructionCommand)(transferOfferCid, action, tokenContext.choiceContextData),
857
+ ],
858
+ disclosedContracts: tokenContext.disclosedContracts,
859
+ };
860
+ }
504
861
  const context = offer.registry === 'amulet' && cantonCoin !== null
505
862
  ? await cantonCoin.transferInstructionContext(transferOfferCid, action, signal)
506
863
  : await registry.transferInstructionContext(offer.instrumentId.admin, transferOfferCid, action, signal);
@@ -630,6 +987,7 @@ function createWallet(options) {
630
987
  const executeBefore = deadline(burn.executeBefore, at, BURN_TTL_MS);
631
988
  const daHoldings = daHoldingsIn(await read(templates_2.DA_REGISTRY_TEMPLATES.holding, signal));
632
989
  refuseCantonCoin(instrumentId, 'burned', daHoldings);
990
+ await refuseTokenStandardBurn(instrumentId, daHoldings, signal);
633
991
  const selection = (0, holdings_1.selectHoldings)(daHoldings, {
634
992
  owner: partyId,
635
993
  instrumentId,
@@ -750,6 +1108,7 @@ function createWallet(options) {
750
1108
  /** A transfer planned and prepared in one go, refused as `planTransfer` refuses it. */
751
1109
  async function transferRequestSubmission(request, signal) {
752
1110
  const planned = plannedRequest(request);
1111
+ await refuseTokenStandardTransfer(planned.instrumentId, signal);
753
1112
  const { transfer, factory } = await prepareTransfer(planned, signal);
754
1113
  requirePreapprovalIfAsked(planned, factory.transferKind);
755
1114
  return transferSubmission(transfer, factory);