@fairmint/canton-node-sdk 0.0.287 → 0.0.289
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -12
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.d.ts +10 -2
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.js +27 -3
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/delete-user.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/delete-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.d.ts +2 -0
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.js +5 -6
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.d.ts +3 -0
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.js +5 -3
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user-identity-provider.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user-identity-provider.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/operations/users.d.ts +2 -0
- package/build/src/clients/ledger-json-api/schemas/operations/users.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/operations/users.js +4 -0
- package/build/src/clients/ledger-json-api/schemas/operations/users.js.map +1 -1
- package/build/src/clients/scan-api/ScanApiClient.d.ts.map +1 -1
- package/build/src/clients/scan-api/ScanApiClient.js +2 -1
- package/build/src/clients/scan-api/ScanApiClient.js.map +1 -1
- package/build/src/core/http/HttpClient.d.ts.map +1 -1
- package/build/src/core/http/HttpClient.js +2 -1
- package/build/src/core/http/HttpClient.js.map +1 -1
- package/build/src/core/http/abort.d.ts +1 -3
- package/build/src/core/http/abort.d.ts.map +1 -1
- package/build/src/core/http/abort.js +6 -4
- package/build/src/core/http/abort.js.map +1 -1
- package/build/src/utils/external-signing/allocate-external-party.d.ts +2 -0
- package/build/src/utils/external-signing/allocate-external-party.d.ts.map +1 -1
- package/build/src/utils/external-signing/allocate-external-party.js +1 -0
- package/build/src/utils/external-signing/allocate-external-party.js.map +1 -1
- package/build/src/utils/external-signing/allocation-user-id.d.ts +6 -0
- package/build/src/utils/external-signing/allocation-user-id.d.ts.map +1 -0
- package/build/src/utils/external-signing/allocation-user-id.js +18 -0
- package/build/src/utils/external-signing/allocation-user-id.js.map +1 -0
- package/build/src/utils/external-signing/create-external-party.d.ts +6 -0
- package/build/src/utils/external-signing/create-external-party.d.ts.map +1 -1
- package/build/src/utils/external-signing/create-external-party.js +4 -1
- package/build/src/utils/external-signing/create-external-party.js.map +1 -1
- package/build/src/utils/external-signing/execute-external-transaction.d.ts +43 -10
- package/build/src/utils/external-signing/execute-external-transaction.d.ts.map +1 -1
- package/build/src/utils/external-signing/execute-external-transaction.js +42 -11
- package/build/src/utils/external-signing/execute-external-transaction.js.map +1 -1
- package/build/src/utils/external-signing/external-party-onboarding.d.ts +24 -0
- package/build/src/utils/external-signing/external-party-onboarding.d.ts.map +1 -1
- package/build/src/utils/external-signing/external-party-onboarding.js +71 -0
- package/build/src/utils/external-signing/external-party-onboarding.js.map +1 -1
- package/build/src/utils/external-signing/external-party-wallet.d.ts +110 -0
- package/build/src/utils/external-signing/external-party-wallet.d.ts.map +1 -1
- package/build/src/utils/external-signing/external-party-wallet.js +173 -1
- package/build/src/utils/external-signing/external-party-wallet.js.map +1 -1
- package/build/src/utils/external-signing/external-signing-client.d.ts +10 -0
- package/build/src/utils/external-signing/external-signing-client.d.ts.map +1 -1
- package/build/src/utils/external-signing/external-signing-client.js +4 -0
- package/build/src/utils/external-signing/external-signing-client.js.map +1 -1
- package/build/src/utils/token-standard/v1/holdings.d.ts +3 -9
- package/build/src/utils/token-standard/v1/holdings.d.ts.map +1 -1
- package/build/src/utils/token-standard/v1/holdings.js +6 -74
- package/build/src/utils/token-standard/v1/holdings.js.map +1 -1
- package/build/src/wallets/abort.d.ts +17 -0
- package/build/src/wallets/abort.d.ts.map +1 -0
- package/build/src/wallets/abort.js +98 -0
- package/build/src/wallets/abort.js.map +1 -0
- package/build/src/wallets/acs.d.ts.map +1 -1
- package/build/src/wallets/acs.js +21 -0
- package/build/src/wallets/acs.js.map +1 -1
- package/build/src/wallets/amulet/constants.d.ts +33 -0
- package/build/src/wallets/amulet/constants.d.ts.map +1 -0
- package/build/src/wallets/amulet/constants.js +34 -0
- package/build/src/wallets/amulet/constants.js.map +1 -0
- package/build/src/wallets/amulet/registry.d.ts +65 -0
- package/build/src/wallets/amulet/registry.d.ts.map +1 -0
- package/build/src/wallets/amulet/registry.js +187 -0
- package/build/src/wallets/amulet/registry.js.map +1 -0
- package/build/src/wallets/cip103.d.ts +40 -5
- package/build/src/wallets/cip103.d.ts.map +1 -1
- package/build/src/wallets/cip103.js +126 -10
- package/build/src/wallets/cip103.js.map +1 -1
- package/build/src/wallets/contracts.d.ts +32 -3
- package/build/src/wallets/contracts.d.ts.map +1 -1
- package/build/src/wallets/contracts.js +48 -11
- package/build/src/wallets/contracts.js.map +1 -1
- package/build/src/wallets/da-utilities/client.d.ts +22 -9
- package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
- package/build/src/wallets/da-utilities/client.js +35 -21
- package/build/src/wallets/da-utilities/client.js.map +1 -1
- package/build/src/wallets/discovery.d.ts +78 -0
- package/build/src/wallets/discovery.d.ts.map +1 -0
- package/build/src/wallets/discovery.js +364 -0
- package/build/src/wallets/discovery.js.map +1 -0
- package/build/src/wallets/errors.d.ts +67 -8
- package/build/src/wallets/errors.d.ts.map +1 -1
- package/build/src/wallets/errors.js +108 -11
- package/build/src/wallets/errors.js.map +1 -1
- package/build/src/wallets/holding-view.d.ts +47 -0
- package/build/src/wallets/holding-view.d.ts.map +1 -0
- package/build/src/wallets/holding-view.js +121 -0
- package/build/src/wallets/holding-view.js.map +1 -0
- package/build/src/wallets/holdings.d.ts +38 -5
- package/build/src/wallets/holdings.d.ts.map +1 -1
- package/build/src/wallets/holdings.js +84 -15
- package/build/src/wallets/holdings.js.map +1 -1
- package/build/src/wallets/index.d.ts +25 -7
- package/build/src/wallets/index.d.ts.map +1 -1
- package/build/src/wallets/index.js +38 -4
- package/build/src/wallets/index.js.map +1 -1
- package/build/src/wallets/ownership.d.ts +12 -0
- package/build/src/wallets/ownership.d.ts.map +1 -1
- package/build/src/wallets/ownership.js +29 -13
- package/build/src/wallets/ownership.js.map +1 -1
- package/build/src/wallets/session.d.ts +10 -2
- package/build/src/wallets/session.d.ts.map +1 -1
- package/build/src/wallets/session.js +186 -61
- package/build/src/wallets/session.js.map +1 -1
- package/build/src/wallets/store.d.ts +14 -3
- package/build/src/wallets/store.d.ts.map +1 -1
- package/build/src/wallets/store.js +36 -16
- package/build/src/wallets/store.js.map +1 -1
- package/build/src/wallets/types.d.ts +14 -0
- package/build/src/wallets/types.d.ts.map +1 -1
- package/build/src/wallets/wallet.d.ts +53 -16
- package/build/src/wallets/wallet.d.ts.map +1 -1
- package/build/src/wallets/wallet.js +271 -93
- package/build/src/wallets/wallet.js.map +1 -1
- package/package.json +107 -1
|
@@ -9,18 +9,31 @@ exports.createWallet = createWallet;
|
|
|
9
9
|
* its choice context from DA's Utilities API, refuses anything that does not check out, and submits as the wallet party
|
|
10
10
|
* only.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Canton Coin (on by default, `WalletOptions.cantonCoin`): the party's Canton Coin holdings (Splice `Amulet` and
|
|
13
|
+
* `LockedAmulet`, read through their `HoldingV1` interface view) are listed with its other tokens, and Canton Coin
|
|
14
|
+
* transfer offers (`AmuletTransferInstruction`s, for example a faucet's) beside DA's, to accept, reject or withdraw the
|
|
15
|
+
* same way. Canton Coin is not transferred or burnt through this wallet.
|
|
16
|
+
*
|
|
17
|
+
* Trust: a holding counts when its instrument admin (DA's registrar, or for Canton Coin the DSO) and its owner signed
|
|
18
|
+
* it; an offer, a request or a preapproval when it names DA's operator and (offers and requests) a provider trusted for
|
|
19
|
+
* its instrument admin signed it. By default a registrar must be its own provider; `registry.trustedProviders` trusts
|
|
20
|
+
* others (see `isFromRegistry`). A Canton Coin offer counts when it is of Canton Coin and the DSO and its sender signed
|
|
21
|
+
* it. The DSO party is resolved once for both (`createAmuletRegistry`): pinned, else the registry's `adminId`; while it
|
|
22
|
+
* is unconfirmed, no Canton Coin is listed (`WalletState.cantonCoinUnavailable`).
|
|
15
23
|
*/
|
|
16
24
|
const cip103_1 = require("./cip103");
|
|
17
25
|
const commands_1 = require("./commands");
|
|
18
26
|
const contracts_1 = require("./contracts");
|
|
19
27
|
const client_1 = require("./da-utilities/client");
|
|
28
|
+
const abort_1 = require("./abort");
|
|
29
|
+
const constants_1 = require("./amulet/constants");
|
|
30
|
+
const registry_1 = require("./amulet/registry");
|
|
20
31
|
const errors_1 = require("./errors");
|
|
32
|
+
const holding_view_1 = require("./holding-view");
|
|
21
33
|
const holdings_1 = require("./holdings");
|
|
22
|
-
const templates_1 = require("
|
|
23
|
-
const
|
|
34
|
+
const templates_1 = require("./templates");
|
|
35
|
+
const templates_2 = require("../da-registry/templates");
|
|
36
|
+
const constants_2 = require("../utils/token-standard/v1/constants");
|
|
24
37
|
const SECOND_MS = 1000;
|
|
25
38
|
const DAY_MS = 24 * 60 * 60 * SECOND_MS;
|
|
26
39
|
/** Transfers: `executeBefore` defaults to now + 24 h, a common wallet default. */
|
|
@@ -67,14 +80,37 @@ const TRANSFER_KIND_DESCRIPTIONS = {
|
|
|
67
80
|
offer: 'Offer: the receiver must accept it before it expires. Your tokens stay locked until it is accepted, rejected by the receiver or withdrawn by you; expiry only stops acceptance and does not unlock them.',
|
|
68
81
|
self: 'Self-transfer: the receiver is this wallet; the holdings are merged or split.',
|
|
69
82
|
};
|
|
70
|
-
/**
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
/** The DA templates a state snapshot reads. */
|
|
84
|
+
const DA_STATE_TEMPLATES = [
|
|
85
|
+
templates_2.DA_REGISTRY_TEMPLATES.holding,
|
|
86
|
+
templates_2.DA_REGISTRY_TEMPLATES.transferOffer,
|
|
87
|
+
templates_2.DA_REGISTRY_TEMPLATES.mintOffer,
|
|
88
|
+
templates_2.DA_REGISTRY_TEMPLATES.burnRequest,
|
|
89
|
+
templates_2.DA_REGISTRY_TEMPLATES.transferPreapproval,
|
|
90
|
+
];
|
|
91
|
+
/** Canton Coin's holdings, read through the `HoldingV1` view (the interface filter matches DA's `Holding` too). */
|
|
92
|
+
const CANTON_COIN_HOLDING_FILTERS = [
|
|
93
|
+
{ interfaceId: holding_view_1.HOLDING_V1_INTERFACE_ID, includeInterfaceView: true },
|
|
77
94
|
];
|
|
95
|
+
/**
|
|
96
|
+
* Every filter a state snapshot reads with Canton Coin on, in one cumulative filter: `HoldingV1` with its view (it
|
|
97
|
+
* matches Canton Coin's `Amulet` and `LockedAmulet`, and DA's `Holding` again, which the ledger returns once), the DA
|
|
98
|
+
* templates, and Canton Coin's transfer instructions.
|
|
99
|
+
*/
|
|
100
|
+
const CANTON_COIN_STATE_FILTERS = [
|
|
101
|
+
...CANTON_COIN_HOLDING_FILTERS,
|
|
102
|
+
...DA_STATE_TEMPLATES,
|
|
103
|
+
constants_1.AMULET_TEMPLATES.transferInstruction,
|
|
104
|
+
];
|
|
105
|
+
/** Canton Coin's holding templates. */
|
|
106
|
+
const CANTON_COIN_HOLDING_TEMPLATES = [constants_1.AMULET_TEMPLATES.amulet, constants_1.AMULET_TEMPLATES.lockedAmulet];
|
|
107
|
+
/** Canton Coin contracts whose DSO must be confirmed before they are listed. */
|
|
108
|
+
const CANTON_COIN_TEMPLATES = [
|
|
109
|
+
...CANTON_COIN_HOLDING_TEMPLATES,
|
|
110
|
+
constants_1.AMULET_TEMPLATES.transferInstruction,
|
|
111
|
+
];
|
|
112
|
+
/** Whether any of `contracts` is of one of `templateIds`. */
|
|
113
|
+
const anyOf = (contracts, templateIds) => contracts.some((contract) => templateIds.some((templateId) => (0, templates_1.isTemplate)(contract, templateId)));
|
|
78
114
|
function requireNonEmpty(value, field) {
|
|
79
115
|
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
80
116
|
throw new errors_1.WalletError('invalid-input', `${field} is required`);
|
|
@@ -115,6 +151,12 @@ function createWallet(options) {
|
|
|
115
151
|
throw new TypeError('createWallet: network must be devnet or mainnet');
|
|
116
152
|
const registry = (0, client_1.createDaUtilitiesClient)(network, options.registry);
|
|
117
153
|
const now = () => requireTime(clock(), 'now()');
|
|
154
|
+
/** Canton Coin's registry: the one DSO resolution holdings and offers share; null with `cantonCoin: false`. */
|
|
155
|
+
const cantonCoin = options.cantonCoin === false ? null : (0, registry_1.createAmuletRegistry)(network, options.cantonCoin, { now });
|
|
156
|
+
const stateFilters = cantonCoin === null ? DA_STATE_TEMPLATES : CANTON_COIN_STATE_FILTERS;
|
|
157
|
+
const offerTemplates = cantonCoin === null
|
|
158
|
+
? [templates_2.DA_REGISTRY_TEMPLATES.transferOffer]
|
|
159
|
+
: [templates_2.DA_REGISTRY_TEMPLATES.transferOffer, constants_1.AMULET_TEMPLATES.transferInstruction];
|
|
118
160
|
/** Refuse a write once the wallet session this wallet belongs to ended (`isActive`). */
|
|
119
161
|
function requireActive() {
|
|
120
162
|
if (isActive !== undefined && !isActive()) {
|
|
@@ -122,12 +164,15 @@ function createWallet(options) {
|
|
|
122
164
|
}
|
|
123
165
|
}
|
|
124
166
|
const ledger = (0, cip103_1.cip103Wallet)(provider, partyId, readRetry !== undefined ? { readRetry } : {});
|
|
125
|
-
|
|
126
|
-
|
|
167
|
+
/** A ledger read; an aborted `signal` stops waiting for it (the wallet's read itself cannot be cancelled). */
|
|
168
|
+
async function read(templateId, signal) {
|
|
169
|
+
const templateIds = typeof templateId === 'string' ? [templateId] : templateId;
|
|
170
|
+
return (await (0, abort_1.awaitWithAbort)(async () => ledger.readActiveContracts(templateIds), signal)).contracts;
|
|
127
171
|
}
|
|
128
|
-
async function submit(submission) {
|
|
172
|
+
async function submit(submission, signal) {
|
|
129
173
|
// Checked again right before the wallet signs: a write's reads and registry calls await, and the session may end
|
|
130
|
-
// meanwhile.
|
|
174
|
+
// (or the caller abort) meanwhile. Never after: a submission handed to the wallet runs to its outcome.
|
|
175
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
131
176
|
requireActive();
|
|
132
177
|
return ledger.submit(submission);
|
|
133
178
|
}
|
|
@@ -136,10 +181,11 @@ function createWallet(options) {
|
|
|
136
181
|
let busy = false;
|
|
137
182
|
// Bumped when a write settles: a snapshot started before then may predate the write, so later reads do not join it.
|
|
138
183
|
let writesSettled = 0;
|
|
139
|
-
async function exclusive(action) {
|
|
184
|
+
async function exclusive(signal, action) {
|
|
140
185
|
if (busy) {
|
|
141
186
|
throw new errors_1.WalletError('busy', 'Another wallet action is in progress; nothing was submitted');
|
|
142
187
|
}
|
|
188
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
143
189
|
requireActive();
|
|
144
190
|
busy = true;
|
|
145
191
|
try {
|
|
@@ -150,10 +196,66 @@ function createWallet(options) {
|
|
|
150
196
|
writesSettled += 1;
|
|
151
197
|
}
|
|
152
198
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
199
|
+
/**
|
|
200
|
+
* The confirmed DSO party for the Canton Coin among `contracts`. The registry is asked only when there is Canton Coin
|
|
201
|
+
* to check, so a party without any never calls it. `unavailable` when there is but the DSO cannot be confirmed: all
|
|
202
|
+
* of it is then left out (fail closed, never every DSO's).
|
|
203
|
+
*/
|
|
204
|
+
async function cantonCoinDso(contracts, signal, waitMs) {
|
|
205
|
+
if (cantonCoin === null || !anyOf(contracts, CANTON_COIN_TEMPLATES)) {
|
|
206
|
+
return { dso: undefined, unavailable: false };
|
|
207
|
+
}
|
|
208
|
+
const dso = await cantonCoin.dsoParty(signal, waitMs);
|
|
209
|
+
return { dso, unavailable: dso === undefined };
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The party's genuine holdings among `contracts`, each contract once. Canton Coin counts only when it is of the
|
|
213
|
+
* confirmed `dso`; without one, none does.
|
|
214
|
+
*/
|
|
215
|
+
function holdingsIn(contracts, dso) {
|
|
216
|
+
const seen = new Set();
|
|
217
|
+
return contracts.flatMap((contract) => {
|
|
218
|
+
const holding = (0, holdings_1.parseHolding)(contract);
|
|
219
|
+
if (holding?.owner !== partyId || seen.has(holding.contractId))
|
|
220
|
+
return [];
|
|
221
|
+
if ((0, holdings_1.isCantonCoin)(holding) && (dso === undefined || holding.instrumentId.admin !== dso))
|
|
222
|
+
return [];
|
|
223
|
+
seen.add(holding.contractId);
|
|
224
|
+
return [holding];
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/** The party's DA Registry holdings, for a transfer or burn (Canton Coin is read-only here). */
|
|
228
|
+
const daHoldingsIn = (contracts) => holdingsIn(contracts).filter((holding) => !(0, holdings_1.isCantonCoin)(holding));
|
|
229
|
+
/**
|
|
230
|
+
* Refuse a Canton Coin transfer or burn: this wallet only reads Canton Coin. Before any read when the instrument is
|
|
231
|
+
* the known DSO's `Amulet` (pinned, or already confirmed by the registry); otherwise (`holdings` given) an `Amulet`
|
|
232
|
+
* the party holds no DA Registry holding of. A DA Registry instrument a registrar named `Amulet` stays transferable.
|
|
233
|
+
*/
|
|
234
|
+
function refuseCantonCoin(instrumentId, action, holdings) {
|
|
235
|
+
if (instrumentId.id !== constants_1.AMULET_INSTRUMENT_ID)
|
|
236
|
+
return;
|
|
237
|
+
if (cantonCoin === null)
|
|
238
|
+
return;
|
|
239
|
+
const knownDso = cantonCoin.knownDsoParty();
|
|
240
|
+
// A known DSO decides; otherwise, with the holdings read, an `Amulet` the party holds no DA Registry holding of.
|
|
241
|
+
const isAmulet = knownDso !== undefined
|
|
242
|
+
? instrumentId.admin === knownDso
|
|
243
|
+
: holdings !== undefined &&
|
|
244
|
+
!holdings.some((holding) => holding.instrumentId.admin === instrumentId.admin && holding.instrumentId.id === instrumentId.id);
|
|
245
|
+
if (isAmulet) {
|
|
246
|
+
throw new errors_1.WalletError('invalid-input', `Canton Coin (Amulet) cannot be ${action} through this wallet yet; nothing was submitted`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Refuse a DA transfer preapproval for Canton Coin's DSO: it would do nothing for Canton Coin (a DSO
|
|
251
|
+
* `TransferPreapproval` is made through a validator, not this wallet). `dso` is the DSO party: pinned, or confirmed
|
|
252
|
+
* by Canton Coin's registry; undefined when neither is known.
|
|
253
|
+
*/
|
|
254
|
+
function refuseCantonCoinPreapproval(instrumentAdmin, dso) {
|
|
255
|
+
if (dso !== undefined && instrumentAdmin === dso) {
|
|
256
|
+
throw new errors_1.WalletError('invalid-input', `${instrumentAdmin} is Canton Coin's DSO party: a DA transfer preapproval does nothing for Canton Coin; nothing was submitted`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
157
259
|
/** The registry contracts of `parse` among `contracts` that DA's registry made (see `isFromRegistry`). */
|
|
158
260
|
function fromRegistry(contracts, parse, operator) {
|
|
159
261
|
return contracts.flatMap((contract) => {
|
|
@@ -165,13 +267,29 @@ function createWallet(options) {
|
|
|
165
267
|
}
|
|
166
268
|
const ownMintOffers = (contracts, operator) => fromRegistry(contracts, contracts_1.parseMintOffer, operator).filter((offer) => offer.holder === partyId);
|
|
167
269
|
const ownBurnRequests = (contracts, operator) => fromRegistry(contracts, contracts_1.parseBurnRequest, operator).filter((request) => request.holder === partyId);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
270
|
+
/**
|
|
271
|
+
* DA's transfer offers among `contracts` that DA's registry made, and Canton Coin's of the confirmed `dso` that the
|
|
272
|
+
* DSO and their sender signed (none without one).
|
|
273
|
+
*/
|
|
274
|
+
function transferOffers(contracts, operator, dso) {
|
|
275
|
+
return byDirection([
|
|
276
|
+
...fromRegistry(contracts, contracts_1.parseTransferOffer, operator),
|
|
277
|
+
...amuletTransferOffers(contracts, dso),
|
|
278
|
+
]);
|
|
279
|
+
}
|
|
280
|
+
/** Canton Coin's transfer offers among `contracts` of the confirmed `dso`, signed by it and their sender. */
|
|
281
|
+
function amuletTransferOffers(contracts, dso) {
|
|
282
|
+
if (dso === undefined)
|
|
283
|
+
return [];
|
|
284
|
+
return contracts.flatMap((contract) => {
|
|
285
|
+
const offer = (0, contracts_1.parseAmuletTransferOffer)(contract, dso);
|
|
286
|
+
return offer === null ? [] : [offer];
|
|
287
|
+
});
|
|
174
288
|
}
|
|
289
|
+
const byDirection = (offers) => ({
|
|
290
|
+
incoming: offers.filter((offer) => offer.receiver === partyId && offer.sender !== partyId),
|
|
291
|
+
outgoing: offers.filter((offer) => offer.sender === partyId),
|
|
292
|
+
});
|
|
175
293
|
/** The party's own preapprovals under DA's operator: the party is their only signatory. */
|
|
176
294
|
const ownPreapprovals = (contracts, operator) => contracts.flatMap((contract) => {
|
|
177
295
|
const preapproval = (0, contracts_1.parseTransferPreapproval)(contract);
|
|
@@ -190,43 +308,65 @@ function createWallet(options) {
|
|
|
190
308
|
}
|
|
191
309
|
return found;
|
|
192
310
|
}
|
|
193
|
-
|
|
311
|
+
/** The balances of `holdings`, each with its registry's metadata (Canton Coin's is given: it is looked up apart). */
|
|
312
|
+
async function balancesWithMetadata(holdings, cantonCoinMetadata) {
|
|
194
313
|
return Promise.all((0, holdings_1.instrumentBalances)(holdings).map(async (balance) => {
|
|
195
|
-
const metadata =
|
|
314
|
+
const metadata = (0, holdings_1.isCantonCoin)(balance)
|
|
315
|
+
? cantonCoinMetadata
|
|
316
|
+
: await registry.instrumentMetadata(balance.instrumentId);
|
|
196
317
|
return metadata === undefined ? balance : { ...balance, metadata };
|
|
197
318
|
}));
|
|
198
319
|
}
|
|
199
320
|
async function readState() {
|
|
200
|
-
const { offset, contracts } = await ledger.readActiveContracts(
|
|
201
|
-
|
|
202
|
-
|
|
321
|
+
const { offset, contracts } = await ledger.readActiveContracts(stateFilters);
|
|
322
|
+
// Asked only when the party has Canton Coin. The DSO and Canton Coin's metadata are looked up at once, so a
|
|
323
|
+
// snapshot waits for the registry once (see `createAmuletRegistry` for how long).
|
|
324
|
+
const [{ dso, unavailable }, cantonCoinMetadata] = await Promise.all([
|
|
325
|
+
cantonCoinDso(contracts, undefined),
|
|
326
|
+
cantonCoin !== null && anyOf(contracts, CANTON_COIN_HOLDING_TEMPLATES)
|
|
327
|
+
? cantonCoin.instrumentMetadata()
|
|
328
|
+
: undefined,
|
|
329
|
+
]);
|
|
330
|
+
const holdings = holdingsIn(contracts, dso);
|
|
331
|
+
const [operator, balances] = await Promise.all([
|
|
332
|
+
registry.operatorParty(),
|
|
333
|
+
balancesWithMetadata(holdings, cantonCoinMetadata),
|
|
334
|
+
]);
|
|
203
335
|
return {
|
|
204
336
|
offset,
|
|
205
337
|
holdings,
|
|
206
338
|
balances,
|
|
207
|
-
transferOffers: transferOffers(contracts, operator),
|
|
339
|
+
transferOffers: transferOffers(contracts, operator, dso),
|
|
208
340
|
mintOffers: ownMintOffers(contracts, operator),
|
|
209
341
|
burnRequests: ownBurnRequests(contracts, operator),
|
|
210
342
|
transferPreapprovals: ownPreapprovals(contracts, operator),
|
|
343
|
+
cantonCoinUnavailable: unavailable,
|
|
211
344
|
};
|
|
212
345
|
}
|
|
213
346
|
let inFlight;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
inFlight
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
347
|
+
/** The snapshot is shared by concurrent callers, so a caller's `signal` only stops that caller waiting for it. */
|
|
348
|
+
async function loadState({ signal } = {}) {
|
|
349
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
350
|
+
if (inFlight?.writesSettled !== writesSettled) {
|
|
351
|
+
const promise = readState().finally(() => {
|
|
352
|
+
if (inFlight?.promise === promise)
|
|
353
|
+
inFlight = undefined;
|
|
354
|
+
});
|
|
355
|
+
inFlight = { writesSettled, promise };
|
|
356
|
+
}
|
|
357
|
+
const shared = inFlight.promise;
|
|
358
|
+
// A cancelled caller may never observe `shared`; other callers still do, so a later failure is never unhandled.
|
|
359
|
+
void shared.catch(() => undefined);
|
|
360
|
+
return signal === undefined ? shared : (0, abort_1.awaitWithAbort)(async () => shared, signal);
|
|
223
361
|
}
|
|
224
362
|
/** A validated, frozen copy of a transfer request, so a later change to the caller's object changes nothing. */
|
|
225
363
|
function plannedRequest(request) {
|
|
226
364
|
const { memo, requirePreapproval, executeBefore } = request;
|
|
365
|
+
const instrumentId = requireInstrumentId(request.instrumentId);
|
|
366
|
+
refuseCantonCoin(instrumentId, 'transferred');
|
|
227
367
|
return Object.freeze({
|
|
228
368
|
receiver: requireNonEmpty(request.receiver, 'receiver'),
|
|
229
|
-
instrumentId: Object.freeze(
|
|
369
|
+
instrumentId: Object.freeze(instrumentId),
|
|
230
370
|
amount: request.amount,
|
|
231
371
|
...(memo !== undefined && memo.length > 0 && { memo }),
|
|
232
372
|
...(requirePreapproval === true && { requirePreapproval }),
|
|
@@ -237,10 +377,12 @@ function createWallet(options) {
|
|
|
237
377
|
* Select inputs and ask the registry for the factory. The factory must be a disclosed contract of a template DA uses
|
|
238
378
|
* for the kind it answered (a direct transfer runs through a `TransferPreapproval`, nothing else does).
|
|
239
379
|
*/
|
|
240
|
-
async function prepareTransfer(request) {
|
|
380
|
+
async function prepareTransfer(request, signal) {
|
|
241
381
|
const at = now();
|
|
242
382
|
const executeBefore = deadline(request.executeBefore, at, TRANSFER_TTL_MS);
|
|
243
|
-
const
|
|
383
|
+
const daHoldings = daHoldingsIn(await read(templates_2.DA_REGISTRY_TEMPLATES.holding, signal));
|
|
384
|
+
refuseCantonCoin(request.instrumentId, 'transferred', daHoldings);
|
|
385
|
+
const selection = (0, holdings_1.selectHoldings)(daHoldings, {
|
|
244
386
|
owner: partyId,
|
|
245
387
|
instrumentId: request.instrumentId,
|
|
246
388
|
amount: request.amount,
|
|
@@ -253,18 +395,21 @@ function createWallet(options) {
|
|
|
253
395
|
requestedAt: isoTime(at - REQUESTED_AT_SKEW_MS, 'requestedAt'),
|
|
254
396
|
executeBefore,
|
|
255
397
|
inputHoldingCids: selection.inputHoldingCids,
|
|
256
|
-
meta: { values: request.memo !== undefined ? { [
|
|
398
|
+
meta: { values: request.memo !== undefined ? { [constants_2.TOKEN_STANDARD_V1_REASON_META_KEY]: request.memo } : {} },
|
|
257
399
|
};
|
|
258
|
-
const factory = await registry.transferFactory(request.instrumentId.admin, transfer);
|
|
400
|
+
const factory = await registry.transferFactory(request.instrumentId.admin, transfer, signal);
|
|
259
401
|
const factoryError = (0, client_1.factoryTemplateError)(factory, client_1.DA_TRANSFER_FACTORY_TEMPLATES[factory.transferKind]);
|
|
260
402
|
if (factoryError !== null) {
|
|
261
403
|
throw new errors_1.RegistryResponseError(`${factoryError} It answered a ${factory.transferKind} transfer.`);
|
|
262
404
|
}
|
|
263
405
|
return { transfer, factory };
|
|
264
406
|
}
|
|
265
|
-
async function planTransfer(request) {
|
|
407
|
+
async function planTransfer(request, call = {}) {
|
|
408
|
+
// The plan's own `submit` takes its own signal: this one cancels planning only.
|
|
409
|
+
const planSignal = call.signal;
|
|
410
|
+
(0, abort_1.throwIfAborted)(planSignal);
|
|
266
411
|
const planned = plannedRequest(request);
|
|
267
|
-
const kind = (await prepareTransfer(planned)).factory.transferKind;
|
|
412
|
+
const kind = (await prepareTransfer(planned, planSignal)).factory.transferKind;
|
|
268
413
|
if (planned.requirePreapproval === true && kind !== 'direct') {
|
|
269
414
|
throw new errors_1.WalletError('preapproval-required', `The receiver has no matching transfer preapproval (the registry would make a${kind === 'offer' ? 'n offer' : ` ${kind} transfer`}); nothing was submitted`);
|
|
270
415
|
}
|
|
@@ -273,8 +418,8 @@ function createWallet(options) {
|
|
|
273
418
|
description: TRANSFER_KIND_DESCRIPTIONS[kind],
|
|
274
419
|
partyId,
|
|
275
420
|
request: planned,
|
|
276
|
-
submit: async () => exclusive(async () => {
|
|
277
|
-
const { transfer, factory } = await prepareTransfer(planned);
|
|
421
|
+
submit: async ({ signal } = {}) => exclusive(signal, async () => {
|
|
422
|
+
const { transfer, factory } = await prepareTransfer(planned, signal);
|
|
278
423
|
if (factory.transferKind !== kind) {
|
|
279
424
|
throw new errors_1.WalletError('kind-changed', `The registry would now make a${factory.transferKind === 'offer' ? 'n' : ''} ${factory.transferKind} transfer, not the planned ${kind}; nothing was submitted`);
|
|
280
425
|
}
|
|
@@ -288,37 +433,58 @@ function createWallet(options) {
|
|
|
288
433
|
}),
|
|
289
434
|
],
|
|
290
435
|
disclosedContracts: factory.disclosedContracts,
|
|
291
|
-
});
|
|
436
|
+
}, signal);
|
|
292
437
|
return { kind, ...result };
|
|
293
438
|
}),
|
|
294
439
|
});
|
|
295
440
|
}
|
|
296
|
-
async function answerTransferOffer(transferOfferCid, action) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
441
|
+
async function answerTransferOffer(transferOfferCid, action, signal) {
|
|
442
|
+
// Read the target first, then resolve only the registry that validates it: the DSO for a Canton Coin offer, DA's
|
|
443
|
+
// operator for a DA offer. Neither offer kind depends on the other registry being up.
|
|
444
|
+
const target = (await read(offerTemplates, signal)).filter((contract) => contract.contractId === transferOfferCid);
|
|
445
|
+
let offers;
|
|
446
|
+
if (cantonCoin !== null && anyOf(target, [constants_1.AMULET_TEMPLATES.transferInstruction])) {
|
|
447
|
+
const { dso, unavailable } = await cantonCoinDso(target, signal, registry_1.AMULET_REGISTRY_REQUEST_TIMEOUT_MS);
|
|
448
|
+
if (unavailable) {
|
|
449
|
+
throw new errors_1.RegistryResponseError(`${registry_1.AMULET_REGISTRY_NAME} could not confirm Canton Coin's DSO party, so transfer offer ${transferOfferCid} cannot be checked; nothing was submitted. Try again later, or pin cantonCoin.dsoParty.`);
|
|
450
|
+
}
|
|
451
|
+
offers = byDirection(amuletTransferOffers(target, dso));
|
|
452
|
+
}
|
|
453
|
+
else if (anyOf(target, [templates_2.DA_REGISTRY_TEMPLATES.transferOffer])) {
|
|
454
|
+
offers = byDirection(fromRegistry(target, contracts_1.parseTransferOffer, await registry.operatorParty(signal)));
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
offers = { incoming: [], outgoing: [] };
|
|
458
|
+
}
|
|
459
|
+
const { incoming, outgoing } = offers;
|
|
302
460
|
const offer = find(action === 'withdraw' ? outgoing : incoming, transferOfferCid, action === 'withdraw' ? 'Outgoing transfer offer' : 'Incoming transfer offer');
|
|
303
|
-
const context =
|
|
461
|
+
const context = offer.registry === 'amulet' && cantonCoin !== null
|
|
462
|
+
? await cantonCoin.transferInstructionContext(transferOfferCid, action, signal)
|
|
463
|
+
: await registry.transferInstructionContext(offer.instrumentId.admin, transferOfferCid, action, signal);
|
|
304
464
|
return submit({
|
|
305
465
|
commands: [(0, commands_1.transferInstructionCommand)(transferOfferCid, action, context.choiceContextData)],
|
|
306
466
|
disclosedContracts: context.disclosedContracts,
|
|
307
|
-
});
|
|
467
|
+
}, signal);
|
|
308
468
|
}
|
|
309
|
-
async function ownMintOffer(mintOfferCid) {
|
|
310
|
-
const [contracts, operator] = await Promise.all([
|
|
469
|
+
async function ownMintOffer(mintOfferCid, signal) {
|
|
470
|
+
const [contracts, operator] = await Promise.all([
|
|
471
|
+
read(templates_2.DA_REGISTRY_TEMPLATES.mintOffer, signal),
|
|
472
|
+
registry.operatorParty(signal),
|
|
473
|
+
]);
|
|
311
474
|
return find(ownMintOffers(contracts, operator), mintOfferCid, 'Mint offer');
|
|
312
475
|
}
|
|
313
|
-
async function runRequestBurn(burn) {
|
|
476
|
+
async function runRequestBurn(burn, signal) {
|
|
314
477
|
const instrumentId = requireInstrumentId(burn.instrumentId);
|
|
478
|
+
refuseCantonCoin(instrumentId, 'burned');
|
|
315
479
|
const at = now();
|
|
316
480
|
const reference = burn.reference ?? newBurnReference(new Date(at));
|
|
317
481
|
if (typeof reference !== 'string' || !exports.BURN_REFERENCE_PATTERN.test(reference)) {
|
|
318
482
|
throw new errors_1.WalletError('invalid-input', 'reference must be 1-100 characters of letters, digits and . _ : - (starting with a letter or digit), with no personal data');
|
|
319
483
|
}
|
|
320
484
|
const executeBefore = deadline(burn.executeBefore, at, BURN_TTL_MS);
|
|
321
|
-
const
|
|
485
|
+
const daHoldings = daHoldingsIn(await read(templates_2.DA_REGISTRY_TEMPLATES.holding, signal));
|
|
486
|
+
refuseCantonCoin(instrumentId, 'burned', daHoldings);
|
|
487
|
+
const selection = (0, holdings_1.selectHoldings)(daHoldings, {
|
|
322
488
|
owner: partyId,
|
|
323
489
|
instrumentId,
|
|
324
490
|
amount: burn.amount,
|
|
@@ -327,7 +493,7 @@ function createWallet(options) {
|
|
|
327
493
|
holder: partyId,
|
|
328
494
|
holdingContractIds: selection.inputHoldingCids,
|
|
329
495
|
instrumentId,
|
|
330
|
-
});
|
|
496
|
+
}, signal);
|
|
331
497
|
const factoryError = (0, client_1.factoryTemplateError)(factory, client_1.DA_BURN_FACTORY_TEMPLATES);
|
|
332
498
|
if (factoryError !== null)
|
|
333
499
|
throw new errors_1.RegistryResponseError(factoryError);
|
|
@@ -350,32 +516,44 @@ function createWallet(options) {
|
|
|
350
516
|
}),
|
|
351
517
|
],
|
|
352
518
|
disclosedContracts: factory.disclosedContracts,
|
|
353
|
-
});
|
|
519
|
+
}, signal);
|
|
354
520
|
return { ...result, reference };
|
|
355
521
|
}
|
|
356
522
|
catch (error) {
|
|
357
523
|
// The reference may have been generated here: the caller needs it to look the burn request up before a retry,
|
|
358
524
|
// above all after an unknown outcome, when the request may have been filed.
|
|
359
|
-
if (!(
|
|
525
|
+
if (!(0, errors_1.isWalletSubmitError)(error))
|
|
360
526
|
throw error;
|
|
361
527
|
throw new errors_1.WalletSubmitError(error.outcome, `${error.message} Burn reference: ${reference}.`, {
|
|
362
528
|
...(error.code !== undefined && { code: error.code }),
|
|
363
529
|
...(error.commandId !== undefined && { commandId: error.commandId }),
|
|
530
|
+
category: error.category,
|
|
531
|
+
...(error.cantonErrorId !== undefined && { cantonErrorId: error.cantonErrorId }),
|
|
364
532
|
burnReference: reference,
|
|
365
533
|
});
|
|
366
534
|
}
|
|
367
535
|
}
|
|
368
|
-
async function runCreateTransferPreapproval(preapproval) {
|
|
536
|
+
async function runCreateTransferPreapproval(preapproval, signal) {
|
|
369
537
|
const instrumentAdmin = requireNonEmpty(preapproval.instrumentAdmin, 'instrumentAdmin');
|
|
538
|
+
// A known DSO (pinned, or confirmed earlier) refuses before any read.
|
|
539
|
+
const knownDso = cantonCoin?.knownDsoParty();
|
|
540
|
+
refuseCantonCoinPreapproval(instrumentAdmin, knownDso);
|
|
370
541
|
const instrumentIds = [...new Set(preapproval.instrumentIds ?? [])];
|
|
371
542
|
if (instrumentIds.length > commands_1.MAX_PREAPPROVAL_INSTRUMENTS) {
|
|
372
543
|
throw new errors_1.WalletError('invalid-input', `A preapproval allows at most ${commands_1.MAX_PREAPPROVAL_INSTRUMENTS} instrument ids`);
|
|
373
544
|
}
|
|
374
545
|
instrumentIds.forEach((id) => requireNonEmpty(id, 'instrumentIds[]'));
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
546
|
+
// Only the party's preapprovals are read (never its holdings, which could exceed the participant's ACS list limit).
|
|
547
|
+
// Unpinned and not yet confirmed, Canton Coin's registry is asked for the DSO alongside, with its usual bounds (the
|
|
548
|
+
// whole request on a first lookup, then a short wait; nothing during the back-off after a failure). When it cannot
|
|
549
|
+
// confirm the DSO, the DA preapproval is still created (fail open): DA writes do not depend on Scan, and a DA
|
|
550
|
+
// preapproval naming the DSO is inert (it lets no Canton Coin in) and can be withdrawn.
|
|
551
|
+
const [contracts, operator, dso] = await Promise.all([
|
|
552
|
+
read(templates_2.DA_REGISTRY_TEMPLATES.transferPreapproval, signal),
|
|
553
|
+
registry.operatorParty(signal),
|
|
554
|
+
cantonCoin === null || knownDso !== undefined ? knownDso : cantonCoin.dsoParty(signal),
|
|
378
555
|
]);
|
|
556
|
+
refuseCantonCoinPreapproval(instrumentAdmin, dso);
|
|
379
557
|
const covering = ownPreapprovals(contracts, operator).find((existing) => existing.instrumentAdmin === instrumentAdmin &&
|
|
380
558
|
(existing.instrumentIds.length === 0 ||
|
|
381
559
|
(instrumentIds.length > 0 && instrumentIds.every((id) => existing.instrumentIds.includes(id)))));
|
|
@@ -384,47 +562,47 @@ function createWallet(options) {
|
|
|
384
562
|
}
|
|
385
563
|
return submit({
|
|
386
564
|
commands: [(0, commands_1.createDaTransferPreapprovalCommand)({ operator, receiver: partyId, instrumentAdmin, instrumentIds })],
|
|
387
|
-
});
|
|
565
|
+
}, signal);
|
|
388
566
|
}
|
|
389
|
-
async function runRemoveTransferPreapproval(preapprovalCid) {
|
|
567
|
+
async function runRemoveTransferPreapproval(preapprovalCid, signal) {
|
|
390
568
|
const [contracts, operator] = await Promise.all([
|
|
391
|
-
read(
|
|
392
|
-
registry.operatorParty(),
|
|
569
|
+
read(templates_2.DA_REGISTRY_TEMPLATES.transferPreapproval, signal),
|
|
570
|
+
registry.operatorParty(signal),
|
|
393
571
|
]);
|
|
394
572
|
find(ownPreapprovals(contracts, operator), preapprovalCid, 'Transfer preapproval');
|
|
395
|
-
return submit({ commands: [(0, commands_1.withdrawTransferPreapprovalCommand)(preapprovalCid, partyId)] });
|
|
573
|
+
return submit({ commands: [(0, commands_1.withdrawTransferPreapprovalCommand)(preapprovalCid, partyId)] }, signal);
|
|
396
574
|
}
|
|
397
575
|
return {
|
|
398
576
|
partyId,
|
|
399
577
|
network,
|
|
400
578
|
loadState,
|
|
401
579
|
planTransfer,
|
|
402
|
-
acceptTransferOffer: async (cid) => exclusive(async () => answerTransferOffer(cid, 'accept')),
|
|
403
|
-
rejectTransferOffer: async (cid) => exclusive(async () => answerTransferOffer(cid, 'reject')),
|
|
404
|
-
withdrawTransferOffer: async (cid) => exclusive(async () => answerTransferOffer(cid, 'withdraw')),
|
|
405
|
-
acceptMintOffer: async (cid) => exclusive(async () => {
|
|
406
|
-
await ownMintOffer(cid);
|
|
407
|
-
const context = await registry.mintOfferAcceptContext(cid);
|
|
580
|
+
acceptTransferOffer: async (cid, { signal } = {}) => exclusive(signal, async () => answerTransferOffer(cid, 'accept', signal)),
|
|
581
|
+
rejectTransferOffer: async (cid, { signal } = {}) => exclusive(signal, async () => answerTransferOffer(cid, 'reject', signal)),
|
|
582
|
+
withdrawTransferOffer: async (cid, { signal } = {}) => exclusive(signal, async () => answerTransferOffer(cid, 'withdraw', signal)),
|
|
583
|
+
acceptMintOffer: async (cid, { signal } = {}) => exclusive(signal, async () => {
|
|
584
|
+
await ownMintOffer(cid, signal);
|
|
585
|
+
const context = await registry.mintOfferAcceptContext(cid, signal);
|
|
408
586
|
return submit({
|
|
409
587
|
commands: [(0, commands_1.acceptMintOfferCommand)(cid, context.choiceContextData)],
|
|
410
588
|
disclosedContracts: context.disclosedContracts,
|
|
411
|
-
});
|
|
589
|
+
}, signal);
|
|
412
590
|
}),
|
|
413
|
-
rejectMintOffer: async (cid) => exclusive(async () => {
|
|
414
|
-
await ownMintOffer(cid);
|
|
415
|
-
return submit({ commands: [(0, commands_1.rejectMintOfferCommand)(cid, exports.MINT_OFFER_REJECT_REASON)] });
|
|
591
|
+
rejectMintOffer: async (cid, { signal } = {}) => exclusive(signal, async () => {
|
|
592
|
+
await ownMintOffer(cid, signal);
|
|
593
|
+
return submit({ commands: [(0, commands_1.rejectMintOfferCommand)(cid, exports.MINT_OFFER_REJECT_REASON)] }, signal);
|
|
416
594
|
}),
|
|
417
|
-
requestBurn: async (burn) => exclusive(async () => runRequestBurn(burn)),
|
|
418
|
-
cancelBurnRequest: async (cid) => exclusive(async () => {
|
|
595
|
+
requestBurn: async (burn, { signal } = {}) => exclusive(signal, async () => runRequestBurn(burn, signal)),
|
|
596
|
+
cancelBurnRequest: async (cid, { signal } = {}) => exclusive(signal, async () => {
|
|
419
597
|
const [contracts, operator] = await Promise.all([
|
|
420
|
-
read(
|
|
421
|
-
registry.operatorParty(),
|
|
598
|
+
read(templates_2.DA_REGISTRY_TEMPLATES.burnRequest, signal),
|
|
599
|
+
registry.operatorParty(signal),
|
|
422
600
|
]);
|
|
423
601
|
find(ownBurnRequests(contracts, operator), cid, 'Burn request');
|
|
424
|
-
return submit({ commands: [(0, commands_1.cancelBurnRequestCommand)(cid)] });
|
|
602
|
+
return submit({ commands: [(0, commands_1.cancelBurnRequestCommand)(cid)] }, signal);
|
|
425
603
|
}),
|
|
426
|
-
createTransferPreapproval: async (preapproval) => exclusive(async () => runCreateTransferPreapproval(preapproval)),
|
|
427
|
-
removeTransferPreapproval: async (cid) => exclusive(async () => runRemoveTransferPreapproval(cid)),
|
|
604
|
+
createTransferPreapproval: async (preapproval, { signal } = {}) => exclusive(signal, async () => runCreateTransferPreapproval(preapproval, signal)),
|
|
605
|
+
removeTransferPreapproval: async (cid, { signal } = {}) => exclusive(signal, async () => runRemoveTransferPreapproval(cid, signal)),
|
|
428
606
|
};
|
|
429
607
|
}
|
|
430
608
|
//# sourceMappingURL=wallet.js.map
|