@fairmint/canton-node-sdk 0.0.278 → 0.0.280

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 (66) hide show
  1. package/README.md +147 -23
  2. package/build/src/utils/external-signing/index.d.ts +1 -0
  3. package/build/src/utils/external-signing/index.d.ts.map +1 -1
  4. package/build/src/utils/external-signing/index.js +1 -0
  5. package/build/src/utils/external-signing/index.js.map +1 -1
  6. package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts +93 -0
  7. package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts.map +1 -0
  8. package/build/src/utils/external-signing/wallet-ownership-challenger.js +253 -0
  9. package/build/src/utils/external-signing/wallet-ownership-challenger.js.map +1 -0
  10. package/build/src/utils/external-signing/wallet-ownership.d.ts +3 -24
  11. package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -1
  12. package/build/src/utils/external-signing/wallet-ownership.js.map +1 -1
  13. package/build/src/wallets/cip103.d.ts +17 -1
  14. package/build/src/wallets/cip103.d.ts.map +1 -1
  15. package/build/src/wallets/cip103.js +8 -0
  16. package/build/src/wallets/cip103.js.map +1 -1
  17. package/build/src/wallets/{token-standard-wallet.d.ts → cip56-core.d.ts} +66 -37
  18. package/build/src/wallets/cip56-core.d.ts.map +1 -0
  19. package/build/src/wallets/{token-standard-wallet.js → cip56-core.js} +85 -29
  20. package/build/src/wallets/cip56-core.js.map +1 -0
  21. package/build/src/wallets/da-utilities/client.d.ts +7 -0
  22. package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
  23. package/build/src/wallets/da-utilities/client.js +21 -0
  24. package/build/src/wallets/da-utilities/client.js.map +1 -1
  25. package/build/src/wallets/errors.d.ts +43 -5
  26. package/build/src/wallets/errors.d.ts.map +1 -1
  27. package/build/src/wallets/errors.js +57 -4
  28. package/build/src/wallets/errors.js.map +1 -1
  29. package/build/src/wallets/holdings.d.ts +25 -0
  30. package/build/src/wallets/holdings.d.ts.map +1 -1
  31. package/build/src/wallets/holdings.js +47 -3
  32. package/build/src/wallets/holdings.js.map +1 -1
  33. package/build/src/wallets/index.d.ts +16 -11
  34. package/build/src/wallets/index.d.ts.map +1 -1
  35. package/build/src/wallets/index.js +22 -10
  36. package/build/src/wallets/index.js.map +1 -1
  37. package/build/src/wallets/notify.d.ts +7 -0
  38. package/build/src/wallets/notify.d.ts.map +1 -0
  39. package/build/src/wallets/notify.js +21 -0
  40. package/build/src/wallets/notify.js.map +1 -0
  41. package/build/src/wallets/ownership.d.ts +77 -0
  42. package/build/src/wallets/ownership.d.ts.map +1 -1
  43. package/build/src/wallets/ownership.js +72 -5
  44. package/build/src/wallets/ownership.js.map +1 -1
  45. package/build/src/wallets/session.d.ts +107 -0
  46. package/build/src/wallets/session.d.ts.map +1 -0
  47. package/build/src/wallets/session.js +371 -0
  48. package/build/src/wallets/session.js.map +1 -0
  49. package/build/src/wallets/store.d.ts +135 -0
  50. package/build/src/wallets/store.d.ts.map +1 -0
  51. package/build/src/wallets/store.js +272 -0
  52. package/build/src/wallets/store.js.map +1 -0
  53. package/build/src/wallets/token-registry.d.ts +4 -2
  54. package/build/src/wallets/token-registry.d.ts.map +1 -1
  55. package/build/src/wallets/token-registry.js.map +1 -1
  56. package/build/src/wallets/wallet.d.ts +110 -0
  57. package/build/src/wallets/wallet.d.ts.map +1 -0
  58. package/build/src/wallets/wallet.js +268 -0
  59. package/build/src/wallets/wallet.js.map +1 -0
  60. package/package.json +1 -1
  61. package/build/src/wallets/token-standard-wallet.d.ts.map +0 -1
  62. package/build/src/wallets/token-standard-wallet.js.map +0 -1
  63. package/build/src/wallets/token-wallet.d.ts +0 -50
  64. package/build/src/wallets/token-wallet.d.ts.map +0 -1
  65. package/build/src/wallets/token-wallet.js +0 -175
  66. package/build/src/wallets/token-wallet.js.map +0 -1
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWalletStore = createWalletStore;
4
+ /**
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.
8
+ *
9
+ * Observable for any UI framework: `subscribe` and `getSnapshot` (React: `useSyncExternalStore(store.subscribe,
10
+ * store.getSnapshot, store.getSnapshot)`).
11
+ */
12
+ const notify_1 = require("./notify");
13
+ const errors_1 = require("./errors");
14
+ 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');
18
+ }
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';
22
+ }
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');
28
+ }
29
+ return (0, wallet_1.createWallet)({ provider, partyId, network, isActive: context.isActive });
30
+ }
31
+ /**
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.
34
+ *
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.
41
+ */
42
+ function createWalletStore(options) {
43
+ const { session } = options;
44
+ const open = options.open ?? openWallet;
45
+ const listeners = new Set();
46
+ let sessionState = session.getSnapshot();
47
+ let wallet = null;
48
+ let tokens = null;
49
+ let state = null;
50
+ 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.
53
+ let generation = 0;
54
+ // Execution latch: wallet calls (actions and loads, of any wallet) asked and not yet settled.
55
+ let inFlight = 0;
56
+ // A load for the current wallet waits for the latch (one at most: queued loads coalesce).
57
+ let queued = false;
58
+ // A load for the current wallet is in flight.
59
+ let loadInFlight = false;
60
+ let running = null;
61
+ let outcome = null;
62
+ let disposed = false;
63
+ 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;
71
+ }
72
+ function buildView() {
73
+ return {
74
+ session: sessionState,
75
+ wallet,
76
+ state,
77
+ loading: loadInFlight || queued,
78
+ loadError,
79
+ running: running?.id ?? null,
80
+ busy: inFlight > 0 || queued,
81
+ outcome,
82
+ unknownOutcomeParty: unknownOutcomeParty(),
83
+ };
84
+ }
85
+ function publish() {
86
+ if (disposed)
87
+ return;
88
+ view = buildView();
89
+ (0, notify_1.notifyListeners)(listeners);
90
+ }
91
+ /** Whether `candidate` is still the wallet this store and its session show. Read after an await. */
92
+ function isCurrent(candidate) {
93
+ return !disposed && candidate === wallet && session.isCurrent(candidate);
94
+ }
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
+ */
99
+ 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.
102
+ if (disposed || wallet === null || tokens === null || !session.isCurrent(wallet))
103
+ return;
104
+ queued = true;
105
+ drain();
106
+ }
107
+ /** Start the queued load if the latch is free, then publish. Called whenever the latch may have freed. */
108
+ function drain() {
109
+ if (disposed)
110
+ 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.
114
+ if (queued && wallet !== null && !session.isCurrent(wallet))
115
+ queued = false;
116
+ if (queued && inFlight === 0 && wallet !== null && tokens !== null) {
117
+ queued = false;
118
+ startLoad(wallet, tokens);
119
+ }
120
+ publish();
121
+ }
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
+ */
127
+ function startLoad(forWallet, forTokens) {
128
+ const attempt = ++generation;
129
+ inFlight += 1;
130
+ loadInFlight = true;
131
+ // A reply counts only for the wallet the session still shows (a disposed session shows none).
132
+ const current = () => !disposed && attempt === generation && forWallet === wallet && session.isCurrent(forWallet);
133
+ void (async () => {
134
+ let next;
135
+ try {
136
+ next = { ok: true, snapshot: await forTokens.loadState() };
137
+ }
138
+ catch (error) {
139
+ next = { ok: false, error };
140
+ }
141
+ inFlight -= 1;
142
+ if (disposed)
143
+ 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
+ if (attempt === generation)
146
+ loadInFlight = false;
147
+ if (current()) {
148
+ if (next.ok) {
149
+ state = next.snapshot;
150
+ loadError = null;
151
+ }
152
+ else {
153
+ state = null; // nothing is offered from a stale snapshot
154
+ loadError = (0, errors_1.describeWalletError)(next.error);
155
+ }
156
+ }
157
+ drain();
158
+ })();
159
+ }
160
+ /** Follow the session: a new connected wallet gets a new token wallet, cleared state and a fresh load. */
161
+ function onSession() {
162
+ if (disposed)
163
+ return;
164
+ sessionState = session.getSnapshot();
165
+ const next = sessionState.status === 'connected' ? sessionState.wallet : null;
166
+ if (next === wallet) {
167
+ publish();
168
+ return;
169
+ }
170
+ wallet = next;
171
+ 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
173
+ loadInFlight = false;
174
+ state = null;
175
+ loadError = null;
176
+ 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) {
181
+ publish();
182
+ return;
183
+ }
184
+ try {
185
+ tokens = open(next, { isActive: () => session.isCurrent(next) });
186
+ }
187
+ catch (error) {
188
+ loadError = (0, errors_1.describeWalletError)(error);
189
+ publish();
190
+ return;
191
+ }
192
+ requestLoad(); // queued while the previous wallet's call is in flight
193
+ }
194
+ const unsubscribe = session.subscribe(onSession);
195
+ onSession();
196
+ return {
197
+ subscribe(listener) {
198
+ listeners.add(listener);
199
+ return () => {
200
+ listeners.delete(listener);
201
+ };
202
+ },
203
+ getSnapshot: () => view,
204
+ refresh() {
205
+ requestLoad();
206
+ },
207
+ async run(id, action, runOptions = {}) {
208
+ // Synchronous, before the first await: a second call in the same tick is refused.
209
+ const ranFor = wallet;
210
+ const ranTokens = tokens;
211
+ if (disposed || inFlight > 0 || queued || ranFor === null || ranTokens === null)
212
+ return false;
213
+ const readOnly = runOptions.readOnly === true;
214
+ const previous = outcome;
215
+ inFlight += 1;
216
+ running = { id, wallet: ranFor, readOnly };
217
+ outcome = null;
218
+ publish();
219
+ // 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.
222
+ if (!isCurrent(ranFor)) {
223
+ inFlight -= 1;
224
+ running = null;
225
+ if (previous !== null && outcomeUnknown(previous))
226
+ outcome = previous;
227
+ drain();
228
+ return false;
229
+ }
230
+ let settled;
231
+ try {
232
+ const message = await action({ tokens: ranTokens, wallet: ranFor });
233
+ settled = { ok: true, message: typeof message === 'string' ? message : null };
234
+ }
235
+ catch (error) {
236
+ settled = { ok: false, error };
237
+ }
238
+ inFlight -= 1;
239
+ running = null;
240
+ 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)
256
+ 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
+ drain();
260
+ return live && settled.ok;
261
+ },
262
+ dispose() {
263
+ if (disposed)
264
+ return;
265
+ disposed = true;
266
+ queued = false;
267
+ unsubscribe();
268
+ listeners.clear();
269
+ },
270
+ };
271
+ }
272
+ //# sourceMappingURL=store.js.map
@@ -0,0 +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;AACvH,CAAC;AAED,0FAA0F;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BAAM,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;gBACtB,OAAO,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3E,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAA,4BAAmB,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzF,CAAC;YACD,8GAA8G;YAC9G,IAAI,IAAI,IAAI,CAAC,QAAQ;gBAAE,MAAM,GAAG,IAAI,CAAC;YACrC,4GAA4G;YAC5G,qDAAqD;YACrD,KAAK,EAAE,CAAC;YACR,OAAO,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC;QAC5B,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"}
@@ -22,9 +22,11 @@ export interface FactoryWithChoiceContext extends ChoiceContext {
22
22
  /**
23
23
  * How the registry will run a transfer:
24
24
  *
25
- * - `offer`: a pending transfer the receiver must accept;
25
+ * - `offer`: a pending transfer the receiver must accept before it expires. The sender's tokens stay locked until the
26
+ * offer is accepted, rejected by the receiver or withdrawn by the sender; expiry alone only stops acceptance and does
27
+ * not unlock them (withdraw an expired offer to get them back);
26
28
  * - `direct`: the receiver pre-approved transfers, so the holdings move at once;
27
- * - `self`: sender and receiver are the same party.
29
+ * - `self`: sender and receiver are the same party (the holdings are merged or split).
28
30
  */
29
31
  export type TransferKind = 'offer' | 'direct' | 'self';
30
32
  export interface TransferFactory extends FactoryWithChoiceContext {
@@ -1 +1 @@
1
- {"version":3,"file":"token-registry.d.ts","sourceRoot":"","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ry.ts"],"names":[],"mappings":";;;AAOA,2CAA4C;AAgG5C;;;GAGG;AACH,8BACE,OAAiC,EACjC,iBAAoC;IAEpC,MAAM,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3G,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,mDAAmD,CAAC;IAC7D,CAAC;IACD,MAAM,IAAI,GAAG,IAAA,yBAAa,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,OAAO,IAAI,KAAK,IAAI,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtD,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,2DAA2D,SAAS,CAAC,UAAU,IAAI,CAAC;AAC1F,CAAC"}
1
+ {"version":3,"file":"token-registry.js","sourceRoot":"","sources":["../../../src/wallets/token-registry.ts"],"names":[],"mappings":";;;AAOA,2CAA4C;AAkG5C;;;GAGG;AACH,8BACE,OAAiC,EACjC,iBAAoC;IAEpC,MAAM,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3G,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,mDAAmD,CAAC;IAC7D,CAAC;IACD,MAAM,IAAI,GAAG,IAAA,yBAAa,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,OAAO,IAAI,KAAK,IAAI,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtD,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,2DAA2D,SAAS,CAAC,UAAU,IAAI,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { type BurnRequest, type MintOffer } from './contracts';
2
+ import { type DaNetwork } from './da-utilities/client';
3
+ import { type TokenRegistry } from './token-registry';
4
+ import { type BaseState, type CoreOptions, type TransferActions } from './cip56-core';
5
+ import type { InstrumentId, SubmitResult } from './types';
6
+ /** Burn requests: `executeBefore` defaults to now + 7 days, giving the registrar a week to accept or reject. */
7
+ export declare const BURN_TTL_MS: number;
8
+ /** A burn reference: no personal data (DA's operator and the registrar see it). */
9
+ export declare const BURN_REFERENCE_PATTERN: RegExp;
10
+ /**
11
+ * A burn reference with no personal data: `holder-burn-<UTC yyyymmddThhmmssZ>-<6 random base-36 digits>` (DA's operator
12
+ * and the registrar see it). Never `redeem-…`, a prefix a transfer agent may reserve for the redemptions it files
13
+ * itself. `requestBurn` uses one when no `reference` is given.
14
+ */
15
+ export declare function newBurnReference(now?: Date): string;
16
+ /**
17
+ * The wallet's provider, party and registry: pass `registry` (any `TokenRegistry`; DA's actions need
18
+ * `createDaUtilitiesClient(...)`), or `network` to get `createDaUtilitiesClient({ network })` with the global `fetch`
19
+ * and no trusted providers.
20
+ */
21
+ export type WalletOptions = Omit<CoreOptions, 'registry'> & ({
22
+ readonly registry: TokenRegistry;
23
+ readonly network?: undefined;
24
+ } | {
25
+ readonly network: DaNetwork;
26
+ readonly registry?: undefined;
27
+ });
28
+ export interface BurnRequestOptions {
29
+ readonly instrumentId: InstrumentId;
30
+ readonly amount: string;
31
+ /** Matches {@link BURN_REFERENCE_PATTERN}; never personal data. Defaults to {@link newBurnReference}. */
32
+ readonly reference?: string;
33
+ /** Defaults to now + 7 days. */
34
+ readonly executeBefore?: Date;
35
+ }
36
+ /** A filed burn request: the submission, and the reference it was filed with (the given one or a generated one). */
37
+ export interface BurnRequestResult extends SubmitResult {
38
+ readonly reference: string;
39
+ }
40
+ /** Everything a token wallet page shows, read as one snapshot of the ledger. */
41
+ export interface WalletState extends BaseState {
42
+ /** DA mint offers to the wallet party; `[]` when the registry is not DA's. */
43
+ readonly mintOffers: MintOffer[];
44
+ /** The wallet party's open DA burn requests; `[]` when the registry is not DA's. */
45
+ readonly burnRequests: BurnRequest[];
46
+ }
47
+ /**
48
+ * A wallet party's token actions through a CIP-0103 provider: the CIP-56 actions on any `TokenRegistry`'s instruments,
49
+ * and DA's mint, burn and preapproval actions when the registry is DA's Utility Registry client. With another registry
50
+ * those DA actions are refused with `unsupported-by-registry` (before anything is read or signed), and `loadState`
51
+ * gives empty DA lists; `isDaUtilitiesClient` tells which registry a wallet has.
52
+ *
53
+ * One write action at a time: a write started while another is in progress (from its first read to its submission's
54
+ * outcome) is refused at once with `busy`, so two writes never pick the same holdings. Reads and previews are not
55
+ * limited.
56
+ *
57
+ * Reads: `loadState` and the `list*` methods all read one snapshot (one ledger-end call and one paged ACS stream with
58
+ * every filter the wallet needs; a registry that declares no `pendingTransferFilters` costs one more ACS stream, read
59
+ * at the same offset), and calls made while a snapshot is in flight share it instead of reading again, unless a write
60
+ * settled since it started. Load a page with `loadState`; writes do their own fresh reads.
61
+ */
62
+ export interface Wallet extends TransferActions {
63
+ /**
64
+ * Holdings, transfer offers, mint offers and burn requests from one snapshot: one ledger-end call and one paged ACS
65
+ * stream for all four. Load a page with this rather than the `list*` calls (which share one snapshot when called
66
+ * together, but each still filters it). The DA lists are `[]` when the registry is not DA's.
67
+ */
68
+ loadState(): Promise<WalletState>;
69
+ /**
70
+ * Mint offers to the wallet party, made under their instrument admin's registry service. Needs DA's Utility Registry
71
+ * client (`network`, or `registry: createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
72
+ */
73
+ listMintOffers(): Promise<MintOffer[]>;
74
+ /**
75
+ * Accept a DA mint offer. Needs DA's Utility Registry client (`network`, or `registry:
76
+ * createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
77
+ */
78
+ acceptMintOffer(mintOfferCid: string, options?: {
79
+ expectedRegistrar?: string;
80
+ }): Promise<SubmitResult>;
81
+ /**
82
+ * File a burn (redemption) request; DA locks the amount until the registrar accepts or rejects it. Resolves with the
83
+ * reference it was filed with, so a dApp can show it. If the submission fails, the `WalletSubmitError` carries that
84
+ * reference too (`burnReference`, and in its message): after an `unknown` outcome, find the burn request by it before
85
+ * filing another, or the amount may be locked twice. Needs DA's Utility Registry client (`network`, or `registry:
86
+ * createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
87
+ */
88
+ requestBurn(options: BurnRequestOptions): Promise<BurnRequestResult>;
89
+ /**
90
+ * Experimental: create the wallet party's DA transfer preapproval for an instrument admin (every instrument of the
91
+ * admin when `instrumentIds` is empty or omitted, else up to 10). No live create has been observed yet. Needs DA's
92
+ * Utility Registry client (`network`, or `registry: createDaUtilitiesClient(...)`); refused with
93
+ * `unsupported-by-registry` otherwise.
94
+ */
95
+ createTransferPreapproval(options: {
96
+ instrumentAdmin: string;
97
+ instrumentIds?: readonly string[];
98
+ }): Promise<SubmitResult>;
99
+ /**
100
+ * The wallet party's open burn requests (pending redemptions). Needs DA's Utility Registry client (`network`, or
101
+ * `registry: createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
102
+ */
103
+ listBurnRequests(): Promise<BurnRequest[]>;
104
+ }
105
+ /**
106
+ * A `Wallet` over a CIP-0103 provider: the CIP-56 actions with any `TokenRegistry`, and DA's actions too with DA's
107
+ * Utility Registry client (`network`, or `registry: createDaUtilitiesClient(...)`).
108
+ */
109
+ export declare function createWallet(options: WalletOptions): Wallet;
110
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallets/wallet.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAoD,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,WAAW,EAEhB,KAAK,eAAe,EACrB,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