@fairmint/canton-node-sdk 0.0.276 → 0.0.277
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 +45 -0
- package/build/src/da-registry/setup/steps.js +2 -1
- package/build/src/da-registry/setup/steps.js.map +1 -1
- package/build/src/da-registry/templates.d.ts +4 -0
- package/build/src/da-registry/templates.d.ts.map +1 -1
- package/build/src/da-registry/templates.js +4 -0
- package/build/src/da-registry/templates.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +24 -1
- package/build/src/index.js.map +1 -1
- package/build/src/utils/token-standard/v1/constants.d.ts +2 -0
- package/build/src/utils/token-standard/v1/constants.d.ts.map +1 -1
- package/build/src/utils/token-standard/v1/constants.js +3 -1
- package/build/src/utils/token-standard/v1/constants.js.map +1 -1
- package/build/src/wallets/acs.d.ts +9 -0
- package/build/src/wallets/acs.d.ts.map +1 -0
- package/build/src/wallets/acs.js +87 -0
- package/build/src/wallets/acs.js.map +1 -0
- package/build/src/wallets/cip103.d.ts +96 -0
- package/build/src/wallets/cip103.d.ts.map +1 -0
- package/build/src/wallets/cip103.js +330 -0
- package/build/src/wallets/cip103.js.map +1 -0
- package/build/src/wallets/commands.d.ts +60 -0
- package/build/src/wallets/commands.d.ts.map +1 -0
- package/build/src/wallets/commands.js +121 -0
- package/build/src/wallets/commands.js.map +1 -0
- package/build/src/wallets/contracts.d.ts +63 -0
- package/build/src/wallets/contracts.d.ts.map +1 -0
- package/build/src/wallets/contracts.js +117 -0
- package/build/src/wallets/contracts.js.map +1 -0
- package/build/src/wallets/da-utilities/client.d.ts +75 -0
- package/build/src/wallets/da-utilities/client.d.ts.map +1 -0
- package/build/src/wallets/da-utilities/client.js +235 -0
- package/build/src/wallets/da-utilities/client.js.map +1 -0
- package/build/src/wallets/decimal.d.ts +9 -0
- package/build/src/wallets/decimal.d.ts.map +1 -0
- package/build/src/wallets/decimal.js +29 -0
- package/build/src/wallets/decimal.js.map +1 -0
- package/build/src/wallets/errors.d.ts +48 -0
- package/build/src/wallets/errors.d.ts.map +1 -0
- package/build/src/wallets/errors.js +57 -0
- package/build/src/wallets/errors.js.map +1 -0
- package/build/src/wallets/holdings.d.ts +48 -0
- package/build/src/wallets/holdings.d.ts.map +1 -0
- package/build/src/wallets/holdings.js +198 -0
- package/build/src/wallets/holdings.js.map +1 -0
- package/build/src/wallets/index.d.ts +20 -0
- package/build/src/wallets/index.d.ts.map +1 -0
- package/build/src/wallets/index.js +29 -0
- package/build/src/wallets/index.js.map +1 -0
- package/build/src/wallets/instrument.d.ts +5 -0
- package/build/src/wallets/instrument.d.ts.map +1 -0
- package/build/src/wallets/instrument.js +18 -0
- package/build/src/wallets/instrument.js.map +1 -0
- package/build/src/wallets/json.d.ts +16 -0
- package/build/src/wallets/json.d.ts.map +1 -0
- package/build/src/wallets/json.js +27 -0
- package/build/src/wallets/json.js.map +1 -0
- package/build/src/wallets/templates.d.ts +21 -0
- package/build/src/wallets/templates.d.ts.map +1 -0
- package/build/src/wallets/templates.js +46 -0
- package/build/src/wallets/templates.js.map +1 -0
- package/build/src/wallets/token-registry.d.ts +84 -0
- package/build/src/wallets/token-registry.d.ts.map +1 -0
- package/build/src/wallets/token-registry.js +19 -0
- package/build/src/wallets/token-registry.js.map +1 -0
- package/build/src/wallets/token-standard-wallet.d.ts +105 -0
- package/build/src/wallets/token-standard-wallet.d.ts.map +1 -0
- package/build/src/wallets/token-standard-wallet.js +193 -0
- package/build/src/wallets/token-standard-wallet.js.map +1 -0
- package/build/src/wallets/token-wallet.d.ts +39 -0
- package/build/src/wallets/token-wallet.d.ts.map +1 -0
- package/build/src/wallets/token-wallet.js +165 -0
- package/build/src/wallets/token-wallet.js.map +1 -0
- package/build/src/wallets/types.d.ts +74 -0
- package/build/src/wallets/types.d.ts.map +1 -0
- package/build/src/wallets/types.js +3 -0
- package/build/src/wallets/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Errors the wallets module throws. Each carries enough to decide whether a retry is safe. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.WalletReadError = exports.WalletSubmitError = void 0;
|
|
5
|
+
const UNKNOWN_HINT = 'The outcome is unknown: do not resubmit blindly; check the wallet for the result first.';
|
|
6
|
+
/** A submission did not commit, or its outcome is unknown. The SDK never retries. */
|
|
7
|
+
class WalletSubmitError extends Error {
|
|
8
|
+
constructor(outcome, message, details = {}) {
|
|
9
|
+
super(outcome === 'unknown' && !message.includes(UNKNOWN_HINT) ? `${message} ${UNKNOWN_HINT}` : message);
|
|
10
|
+
this.name = 'WalletSubmitError';
|
|
11
|
+
this.outcome = outcome;
|
|
12
|
+
if (details.code !== undefined)
|
|
13
|
+
this.code = details.code;
|
|
14
|
+
if (details.commandId !== undefined)
|
|
15
|
+
this.commandId = details.commandId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.WalletSubmitError = WalletSubmitError;
|
|
19
|
+
/** The wallet could not read the ledger or its account, or answered in a shape this module does not understand. */
|
|
20
|
+
class WalletReadError extends Error {
|
|
21
|
+
constructor(message, code) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'WalletReadError';
|
|
24
|
+
if (code !== undefined)
|
|
25
|
+
this.code = code;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.WalletReadError = WalletReadError;
|
|
29
|
+
/** A registry API answered with a non-2xx status. `body` is the raw response text. */
|
|
30
|
+
class RegistryApiError extends Error {
|
|
31
|
+
constructor(status, body, url) {
|
|
32
|
+
super(`Registry API ${status} for ${url}: ${body.slice(0, 500)}`);
|
|
33
|
+
this.name = 'RegistryApiError';
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.body = body;
|
|
36
|
+
this.url = url;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.RegistryApiError = RegistryApiError;
|
|
40
|
+
/** A registry API answered 2xx with a body this module refuses (wrong shape, unexpected factory). */
|
|
41
|
+
class RegistryResponseError extends Error {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = 'RegistryResponseError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.RegistryResponseError = RegistryResponseError;
|
|
48
|
+
/** A token action refused before anything was submitted. */
|
|
49
|
+
class TokenWalletError extends Error {
|
|
50
|
+
constructor(code, message) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = 'TokenWalletError';
|
|
53
|
+
this.code = code;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TokenWalletError = TokenWalletError;
|
|
57
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/wallets/errors.ts"],"names":[],"mappings":";AAAA,+FAA+F;;;AAS/F,MAAM,YAAY,GAAG,yFAAyF,CAAC;AAE/G,qFAAqF;AACrF,uBAA+B,SAAQ,KAAK;IAM1C,YAAY,OAA4B,EAAE,OAAe,EAAE,OAAO,GAA0C,EAAE;QAC5G,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzG,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzD,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAC1E,CAAC;CACF;;AAED,mHAAmH;AACnH,qBAA6B,SAAQ,KAAK;IAIxC,YAAY,OAAe,EAAE,IAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAC3C,CAAC;CACF;;AAED,sFAAsF;AACtF,sBAA8B,SAAQ,KAAK;IAKzC,YAAY,MAAc,EAAE,IAAY,EAAE,GAAW;QACnD,KAAK,CAAC,gBAAgB,MAAM,QAAQ,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;;AAED,qGAAqG;AACrG,2BAAmC,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;;AAgBD,4DAA4D;AAC5D,sBAA8B,SAAQ,KAAK;IAGzC,YAAY,IAA0B,EAAE,OAAe;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ActiveContract, InstrumentId } from './types';
|
|
2
|
+
export interface Holding {
|
|
3
|
+
readonly contractId: string;
|
|
4
|
+
readonly owner: string;
|
|
5
|
+
readonly instrumentId: InstrumentId;
|
|
6
|
+
/** Decimal string as the ledger reports it. */
|
|
7
|
+
readonly amount: string;
|
|
8
|
+
/** Locked to an allocation, a burn request or a transfer in flight: it cannot be spent. */
|
|
9
|
+
readonly locked: boolean;
|
|
10
|
+
/** The synchronizer the holding is assigned to, when the ledger reported it. Inputs never mix synchronizers. */
|
|
11
|
+
readonly synchronizerId?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A holding from its CIP-56 HoldingV1 interface view when the ledger gave one, else from a DA Registry `Holding`'s
|
|
15
|
+
* create argument (`owner`, `instrument {source, id}`, `amount`, `lock`). Null when neither reads: an unreadable
|
|
16
|
+
* holding is never spendable.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseHolding(contract: ActiveContract): Holding | null;
|
|
19
|
+
export interface HoldingSelection {
|
|
20
|
+
readonly inputHoldingCids: string[];
|
|
21
|
+
/** Sum of the selected holdings (decimal string, 10 places). */
|
|
22
|
+
readonly selectedTotal: string;
|
|
23
|
+
/** The requested amount, normalized to 10 places. */
|
|
24
|
+
readonly amount: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse a positive amount (at most 10 decimal places, at most the Daml `Numeric 10` maximum 10^28 - 10^-10) to units of
|
|
28
|
+
* 10^-10. Throws `invalid-input` otherwise.
|
|
29
|
+
*/
|
|
30
|
+
export declare function requirePositiveAmount(amount: string): bigint;
|
|
31
|
+
/**
|
|
32
|
+
* The most candidates (largest first) {@link skippingCover} searches. The search is quadratic, so a wallet with more
|
|
33
|
+
* unlocked holdings of the instrument than this is searched over its largest ones only.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MAX_SKIPPING_COVER_CANDIDATES = 500;
|
|
36
|
+
/**
|
|
37
|
+
* Pick unlocked holdings of `owner` and `instrumentId` that cover `amount`: largest first (ties by contract id), so the
|
|
38
|
+
* same holdings always give the same inputs, and as few as possible are used. The registry adds the inputs up as a Daml
|
|
39
|
+
* `Numeric 10`, so when that cover's total exceeds 10^28 - 10^-10 the smallest holdings are tried first instead, and
|
|
40
|
+
* when that overflows too, a cover that skips holdings (see {@link skippingCover}). Throws `insufficient-balance` when
|
|
41
|
+
* the unlocked total is short, and `amount-out-of-range` when no cover found is representable.
|
|
42
|
+
*/
|
|
43
|
+
export declare function selectHoldings(holdings: readonly Holding[], request: {
|
|
44
|
+
readonly owner: string;
|
|
45
|
+
readonly instrumentId: InstrumentId;
|
|
46
|
+
readonly amount: string;
|
|
47
|
+
}): HoldingSelection;
|
|
48
|
+
//# sourceMappingURL=holdings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holdings.d.ts","sourceRoot":"","sources":["../../../src/wallets/holdings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gHAAgH;IAChH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AA2CD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI,CA6BrE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACpC,gEAAgE;IAChE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAS5D;AAsBD;;;GAGG;AACH,eAAO,MAAM,6BAA6B,MAAM,CAAC;AA6BjD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,OAAO,EAAE;IACP,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACA,gBAAgB,CAmElB"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_SKIPPING_COVER_CANDIDATES = void 0;
|
|
4
|
+
exports.parseHolding = parseHolding;
|
|
5
|
+
exports.requirePositiveAmount = requirePositiveAmount;
|
|
6
|
+
exports.selectHoldings = selectHoldings;
|
|
7
|
+
/** Read holdings from the ACS and pick the inputs for a transfer or burn, with exact decimal arithmetic. */
|
|
8
|
+
const decimal_1 = require("./decimal");
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
const instrument_1 = require("./instrument");
|
|
11
|
+
const json_1 = require("./json");
|
|
12
|
+
const templates_1 = require("../da-registry/templates");
|
|
13
|
+
const constants_1 = require("../utils/token-standard/v1/constants");
|
|
14
|
+
const templates_2 = require("./templates");
|
|
15
|
+
/**
|
|
16
|
+
* Daml `Optional` read back: absent, `null` or `{tag: 'None'}` is unlocked; a record is a lock; anything else is not
|
|
17
|
+
* readable.
|
|
18
|
+
*/
|
|
19
|
+
function readLocked(value) {
|
|
20
|
+
if (value === undefined || value === null)
|
|
21
|
+
return false;
|
|
22
|
+
if (!(0, json_1.isRecord)(value))
|
|
23
|
+
return null;
|
|
24
|
+
if (value['tag'] === 'None')
|
|
25
|
+
return false;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
function holding(contract, fields) {
|
|
29
|
+
const owner = (0, json_1.nonEmptyString)(fields.owner);
|
|
30
|
+
const locked = readLocked(fields.lock);
|
|
31
|
+
if (owner === undefined ||
|
|
32
|
+
fields.instrumentId === null ||
|
|
33
|
+
typeof fields.amount !== 'string' ||
|
|
34
|
+
(0, decimal_1.parseDecimalUnits)(fields.amount) === null ||
|
|
35
|
+
locked === null) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
contractId: contract.contractId,
|
|
40
|
+
owner,
|
|
41
|
+
instrumentId: fields.instrumentId,
|
|
42
|
+
amount: fields.amount,
|
|
43
|
+
locked,
|
|
44
|
+
...(contract.synchronizerId !== undefined && { synchronizerId: contract.synchronizerId }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A holding from its CIP-56 HoldingV1 interface view when the ledger gave one, else from a DA Registry `Holding`'s
|
|
49
|
+
* create argument (`owner`, `instrument {source, id}`, `amount`, `lock`). Null when neither reads: an unreadable
|
|
50
|
+
* holding is never spendable.
|
|
51
|
+
*/
|
|
52
|
+
function parseHolding(contract) {
|
|
53
|
+
const view = contract.interfaceViews.find((v) => (0, templates_2.sameQualifiedName)(v.interfaceId, constants_1.TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID));
|
|
54
|
+
if (view) {
|
|
55
|
+
const v = view.viewValue;
|
|
56
|
+
return holding(contract, {
|
|
57
|
+
owner: v['owner'],
|
|
58
|
+
instrumentId: (0, instrument_1.readInstrumentId)(v['instrumentId']),
|
|
59
|
+
amount: v['amount'],
|
|
60
|
+
lock: v['lock'],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const args = contract.createArgument;
|
|
64
|
+
if (args !== null && (0, templates_2.sameQualifiedName)(contract.templateId, templates_1.DA_REGISTRY_TEMPLATES.holding)) {
|
|
65
|
+
const { instrument } = args;
|
|
66
|
+
return holding(contract, {
|
|
67
|
+
owner: args['owner'],
|
|
68
|
+
instrumentId: (0, json_1.isRecord)(instrument)
|
|
69
|
+
? (0, instrument_1.readInstrumentId)({
|
|
70
|
+
admin: instrument['source'],
|
|
71
|
+
id: instrument['id'],
|
|
72
|
+
})
|
|
73
|
+
: null,
|
|
74
|
+
amount: args['amount'],
|
|
75
|
+
lock: args['lock'],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parse a positive amount (at most 10 decimal places, at most the Daml `Numeric 10` maximum 10^28 - 10^-10) to units of
|
|
82
|
+
* 10^-10. Throws `invalid-input` otherwise.
|
|
83
|
+
*/
|
|
84
|
+
function requirePositiveAmount(amount) {
|
|
85
|
+
const units = (0, decimal_1.parseDecimalUnits)(amount.trim());
|
|
86
|
+
if (units === null || units === 0n || units > decimal_1.MAX_DECIMAL_UNITS) {
|
|
87
|
+
throw new errors_1.TokenWalletError('invalid-input', `Amount ${JSON.stringify(amount)} must be a positive decimal below 10^28 with at most 10 decimal places`);
|
|
88
|
+
}
|
|
89
|
+
return units;
|
|
90
|
+
}
|
|
91
|
+
/** The first holdings of `ordered` that reach `needed`, or null when they all fall short. */
|
|
92
|
+
function cover(ordered, needed) {
|
|
93
|
+
const picked = [];
|
|
94
|
+
let total = 0n;
|
|
95
|
+
for (const candidate of ordered) {
|
|
96
|
+
if (total >= needed)
|
|
97
|
+
break;
|
|
98
|
+
picked.push(candidate);
|
|
99
|
+
total += candidate.units;
|
|
100
|
+
}
|
|
101
|
+
return total >= needed ? { picked, total } : null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The most candidates (largest first) {@link skippingCover} searches. The search is quadratic, so a wallet with more
|
|
105
|
+
* unlocked holdings of the instrument than this is searched over its largest ones only.
|
|
106
|
+
*/
|
|
107
|
+
exports.MAX_SKIPPING_COVER_CANDIDATES = 500;
|
|
108
|
+
/**
|
|
109
|
+
* A representable cover that may skip holdings, for when neither prefix cover fits the Numeric 10 range: for each start
|
|
110
|
+
* index of the largest-first `ordered`, add the holdings from there on, skipping any that would take the total past
|
|
111
|
+
* 10^28 - 10^-10, until the total reaches `needed`. Of the covers found, the one with the fewest inputs (then the
|
|
112
|
+
* earliest start) wins, so the result is deterministic. Null when no start index gives one.
|
|
113
|
+
*/
|
|
114
|
+
function skippingCover(ordered, needed) {
|
|
115
|
+
let best = null;
|
|
116
|
+
for (let start = 0; start < ordered.length; start += 1) {
|
|
117
|
+
const picked = [];
|
|
118
|
+
let total = 0n;
|
|
119
|
+
for (let i = start; i < ordered.length && total < needed; i += 1) {
|
|
120
|
+
const candidate = ordered[i];
|
|
121
|
+
if (candidate === undefined || total + candidate.units > decimal_1.MAX_DECIMAL_UNITS)
|
|
122
|
+
continue;
|
|
123
|
+
picked.push(candidate);
|
|
124
|
+
total += candidate.units;
|
|
125
|
+
}
|
|
126
|
+
if (total >= needed && (best === null || picked.length < best.picked.length)) {
|
|
127
|
+
best = { picked, total };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return best;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Pick unlocked holdings of `owner` and `instrumentId` that cover `amount`: largest first (ties by contract id), so the
|
|
134
|
+
* same holdings always give the same inputs, and as few as possible are used. The registry adds the inputs up as a Daml
|
|
135
|
+
* `Numeric 10`, so when that cover's total exceeds 10^28 - 10^-10 the smallest holdings are tried first instead, and
|
|
136
|
+
* when that overflows too, a cover that skips holdings (see {@link skippingCover}). Throws `insufficient-balance` when
|
|
137
|
+
* the unlocked total is short, and `amount-out-of-range` when no cover found is representable.
|
|
138
|
+
*/
|
|
139
|
+
function selectHoldings(holdings, request) {
|
|
140
|
+
const needed = requirePositiveAmount(request.amount);
|
|
141
|
+
const candidates = holdings
|
|
142
|
+
.filter((h) => !h.locked && h.owner === request.owner && (0, instrument_1.sameInstrument)(h.instrumentId, request.instrumentId))
|
|
143
|
+
.flatMap((h) => {
|
|
144
|
+
const units = (0, decimal_1.parseDecimalUnits)(h.amount);
|
|
145
|
+
return units === null || units === 0n
|
|
146
|
+
? []
|
|
147
|
+
: [{ contractId: h.contractId, units, synchronizerId: h.synchronizerId }];
|
|
148
|
+
})
|
|
149
|
+
.sort((a, b) => {
|
|
150
|
+
if (a.units !== b.units)
|
|
151
|
+
return a.units > b.units ? -1 : 1;
|
|
152
|
+
return a.contractId < b.contractId ? -1 : a.contractId > b.contractId ? 1 : 0;
|
|
153
|
+
});
|
|
154
|
+
// One transaction cannot spend holdings assigned to different synchronizers, so select within one synchronizer:
|
|
155
|
+
// the group with the largest balance first (ties by synchronizer id), so the choice is deterministic.
|
|
156
|
+
const groups = new Map();
|
|
157
|
+
for (const candidate of candidates) {
|
|
158
|
+
const key = candidate.synchronizerId ?? '';
|
|
159
|
+
const group = groups.get(key);
|
|
160
|
+
if (group === undefined)
|
|
161
|
+
groups.set(key, [candidate]);
|
|
162
|
+
else
|
|
163
|
+
group.push(candidate);
|
|
164
|
+
}
|
|
165
|
+
const ordered = [...groups.entries()]
|
|
166
|
+
.map(([key, group]) => ({ key, group, total: group.reduce((sum, c) => sum + c.units, 0n) }))
|
|
167
|
+
.sort((a, b) => (a.total !== b.total ? (a.total > b.total ? -1 : 1) : a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
168
|
+
const total = candidates.reduce((sum, c) => sum + c.units, 0n);
|
|
169
|
+
const covering = ordered.filter((g) => g.total >= needed);
|
|
170
|
+
if (covering.length === 0) {
|
|
171
|
+
const spread = total >= needed && ordered.length > 1
|
|
172
|
+
? ` on any one synchronizer (the ${(0, decimal_1.formatDecimalUnits)(total)} is spread across ${ordered.length} synchronizers)`
|
|
173
|
+
: '';
|
|
174
|
+
throw new errors_1.TokenWalletError('insufficient-balance', `Insufficient unlocked ${request.instrumentId.id}: need ${(0, decimal_1.formatDecimalUnits)(needed)}, have ${(0, decimal_1.formatDecimalUnits)(spread === '' ? total : (ordered[0]?.total ?? 0n))}${spread}`);
|
|
175
|
+
}
|
|
176
|
+
const fits = (c) => c !== null && c.total <= decimal_1.MAX_DECIMAL_UNITS;
|
|
177
|
+
let representable = null;
|
|
178
|
+
let limited = '';
|
|
179
|
+
for (const { group } of covering) {
|
|
180
|
+
const searched = group.slice(0, exports.MAX_SKIPPING_COVER_CANDIDATES);
|
|
181
|
+
representable =
|
|
182
|
+
[cover(group, needed), cover([...group].reverse(), needed)].find(fits) ?? skippingCover(searched, needed);
|
|
183
|
+
if (representable !== null)
|
|
184
|
+
break;
|
|
185
|
+
if (searched.length < group.length) {
|
|
186
|
+
limited = ` (searched the largest ${exports.MAX_SKIPPING_COVER_CANDIDATES} of ${group.length} holdings)`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (representable === null) {
|
|
190
|
+
throw new errors_1.TokenWalletError('amount-out-of-range', `Found no set of unlocked ${request.instrumentId.id} holdings that covers ${(0, decimal_1.formatDecimalUnits)(needed)} within the Daml Numeric 10 range${limited}; nothing was submitted`);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
inputHoldingCids: representable.picked.map((c) => c.contractId),
|
|
194
|
+
selectedTotal: (0, decimal_1.formatDecimalUnits)(representable.total),
|
|
195
|
+
amount: (0, decimal_1.formatDecimalUnits)(needed),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=holdings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holdings.js","sourceRoot":"","sources":["../../../src/wallets/holdings.ts"],"names":[],"mappings":";;;;;;AAAA,4GAA4G;AAC5G,uCAAqF;AACrF,qCAA4C;AAC5C,6CAAgE;AAChE,iCAAkD;AAClD,wDAAiE;AACjE,oEAA8F;AAC9F,2CAAgD;AAehD;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,CAAC,IAAA,eAAQ,EAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,IAAI,C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AAM,CAAC,CAAC;QAC5G,IAAI,aAAa,KAAK,IAAI;YAAE,MAAM;QAClC,IAAI,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YACnC,OAAO,GAAG,0BAA0B,QAAA,6BAA6B,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;QACnG,CAAC;IACH,CAAC;IACD,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,yBAAgB,CACxB,qBAAqB,EACrB,4BAA4B,OAAO,CAAC,YAAY,CAAC,EAAE,yBAAyB,IAAA,4BAAkB,EAAC,MAAM,CAAC,oCAAoC,OAAO,yBAAyB,CAC3K,CAAC;IACJ,CAAC;IACD,OAAO;QACL,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;QAC/D,aAAa,EAAE,IAAA,4BAAkB,EAAC,aAAa,CAAC,KAAK,CAAC;QACtD,MAAM,EAAE,IAAA,4BAAkB,EAAC,MAAM,CAAC;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe token standard (CIP-56) and DA Utility Registry holder actions through any CIP-0103 (Canton dApp API)
|
|
3
|
+
* wallet provider. In a browser bundle import `@fairmint/canton-node-sdk/build/src/wallets/index.js`, which loads none
|
|
4
|
+
* of the SDK's Node dependencies; the package root also exports it as the `Wallets` namespace (for Node).
|
|
5
|
+
*
|
|
6
|
+
* The surface is small on purpose: plug in a CIP-0103 provider (`createTokenWallet`), the registry client, the errors
|
|
7
|
+
* and the data types. Command builders, parsers and the CIP-0103 client stay internal.
|
|
8
|
+
*/
|
|
9
|
+
export { createTokenWallet, type BurnRequestOptions, type TokenWallet, type TokenWalletOptions } from './token-wallet';
|
|
10
|
+
export { createTokenStandardWallet, type TokenStandardWallet, type TokenStandardWalletOptions, type TransferOffers, type TransferOptions, type TransferRequest, type TransferResult, } from './token-standard-wallet';
|
|
11
|
+
export { primaryPartyId, type Cip103EventListener, type Cip103LedgerApiParams, type Cip103PrepareExecuteParams, type Cip103Provider, type Cip103Request, } from './cip103';
|
|
12
|
+
export { createDaUtilitiesClient, type BurnRequestContextArgs, type DaNetwork, type DaUtilitiesClient, type DaUtilitiesClientOptions, type DaUtilitiesTarget, type FetchLike, } from './da-utilities/client';
|
|
13
|
+
export type { ChoiceContext, ChoiceContextData, FactoryWithChoiceContext, ReadContracts, TokenRegistry, TransferFactory, TransferFactoryArgs, TransferInstructionAction, TransferKind, TransferSpec, } from './token-registry';
|
|
14
|
+
export { RegistryApiError, RegistryResponseError, TokenWalletError, WalletReadError, WalletSubmitError, type TokenWalletErrorCode, type WalletSubmitOutcome, } from './errors';
|
|
15
|
+
export type { BurnRequest, MintOffer, TransferOffer } from './contracts';
|
|
16
|
+
export type { Holding } from './holdings';
|
|
17
|
+
export type { ActiveContract, ContractFilter, CreateCommand, DisclosedContract, ExerciseCommand, InstrumentId, InterfaceView, LedgerCommand, SubmitResult, WalletSubmission, } from './types';
|
|
18
|
+
export type { JsonArray, JsonObject, JsonPrimitive, JsonValue } from './json';
|
|
19
|
+
export { formatDecimalUnits, parseDecimalUnits } from './decimal';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvH,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,SAAS,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDecimalUnits = exports.formatDecimalUnits = exports.WalletSubmitError = exports.WalletReadError = exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.createDaUtilitiesClient = exports.primaryPartyId = exports.createTokenStandardWallet = exports.createTokenWallet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Browser-safe token standard (CIP-56) and DA Utility Registry holder actions through any CIP-0103 (Canton dApp API)
|
|
6
|
+
* wallet provider. In a browser bundle import `@fairmint/canton-node-sdk/build/src/wallets/index.js`, which loads none
|
|
7
|
+
* of the SDK's Node dependencies; the package root also exports it as the `Wallets` namespace (for Node).
|
|
8
|
+
*
|
|
9
|
+
* The surface is small on purpose: plug in a CIP-0103 provider (`createTokenWallet`), the registry client, the errors
|
|
10
|
+
* and the data types. Command builders, parsers and the CIP-0103 client stay internal.
|
|
11
|
+
*/
|
|
12
|
+
var token_wallet_1 = require("./token-wallet");
|
|
13
|
+
Object.defineProperty(exports, "createTokenWallet", { enumerable: true, get: function () { return token_wallet_1.createTokenWallet; } });
|
|
14
|
+
var token_standard_wallet_1 = require("./token-standard-wallet");
|
|
15
|
+
Object.defineProperty(exports, "createTokenStandardWallet", { enumerable: true, get: function () { return token_standard_wallet_1.createTokenStandardWallet; } });
|
|
16
|
+
var cip103_1 = require("./cip103");
|
|
17
|
+
Object.defineProperty(exports, "primaryPartyId", { enumerable: true, get: function () { return cip103_1.primaryPartyId; } });
|
|
18
|
+
var client_1 = require("./da-utilities/client");
|
|
19
|
+
Object.defineProperty(exports, "createDaUtilitiesClient", { enumerable: true, get: function () { return client_1.createDaUtilitiesClient; } });
|
|
20
|
+
var errors_1 = require("./errors");
|
|
21
|
+
Object.defineProperty(exports, "RegistryApiError", { enumerable: true, get: function () { return errors_1.RegistryApiError; } });
|
|
22
|
+
Object.defineProperty(exports, "RegistryResponseError", { enumerable: true, get: function () { return errors_1.RegistryResponseError; } });
|
|
23
|
+
Object.defineProperty(exports, "TokenWalletError", { enumerable: true, get: function () { return errors_1.TokenWalletError; } });
|
|
24
|
+
Object.defineProperty(exports, "WalletReadError", { enumerable: true, get: function () { return errors_1.WalletReadError; } });
|
|
25
|
+
Object.defineProperty(exports, "WalletSubmitError", { enumerable: true, get: function () { return errors_1.WalletSubmitError; } });
|
|
26
|
+
var decimal_1 = require("./decimal");
|
|
27
|
+
Object.defineProperty(exports, "formatDecimalUnits", { enumerable: true, get: function () { return decimal_1.formatDecimalUnits; } });
|
|
28
|
+
Object.defineProperty(exports, "parseDecimalUnits", { enumerable: true, get: function () { return decimal_1.parseDecimalUnits; } });
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,+CAAuH;AAA9G,iHAAA,iBAAiB,OAAA;AAC1B,iEAQiC;AAP/B,kIAAA,yBAAyB,OAAA;AAQ3B,mCAOkB;AANhB,wGAAA,cAAc,OAAA;AAOhB,gDAQ+B;AAP7B,iHAAA,uBAAuB,OAAA;AAoBzB,mCAQkB;AAPhB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AAmBnB,qCAAkE;AAAzD,6GAAA,kBAAkB,OAAA;AAAE,4GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InstrumentId } from './types';
|
|
2
|
+
/** `{admin, id}` when both are non-empty strings, else null. */
|
|
3
|
+
export declare function readInstrumentId(value: unknown): InstrumentId | null;
|
|
4
|
+
export declare function sameInstrument(left: InstrumentId, right: InstrumentId): boolean;
|
|
5
|
+
//# sourceMappingURL=instrument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../../../src/wallets/instrument.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAKpE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAE/E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readInstrumentId = readInstrumentId;
|
|
4
|
+
exports.sameInstrument = sameInstrument;
|
|
5
|
+
/** CIP-56 instrument ids read from untrusted JSON (interface views, create arguments, registry answers). */
|
|
6
|
+
const json_1 = require("./json");
|
|
7
|
+
/** `{admin, id}` when both are non-empty strings, else null. */
|
|
8
|
+
function readInstrumentId(value) {
|
|
9
|
+
if (!(0, json_1.isRecord)(value))
|
|
10
|
+
return null;
|
|
11
|
+
const admin = (0, json_1.nonEmptyString)(value['admin']);
|
|
12
|
+
const id = (0, json_1.nonEmptyString)(value['id']);
|
|
13
|
+
return admin !== undefined && id !== undefined ? { admin, id } : null;
|
|
14
|
+
}
|
|
15
|
+
function sameInstrument(left, right) {
|
|
16
|
+
return left.admin === right.admin && left.id === right.id;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=instrument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../src/wallets/instrument.ts"],"names":[],"mappings":";;;;AAAA,4GAA4G;AAC5G,iCAAkD;AAGlD,gEAAgE;AAChE,0BAAiC,KAAc;IAC7C,IAAI,CAAC,IAAA,eAAQ,EAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,KAAK,GAAG,IAAA,qBAAc,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,IAAA,qBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,OAAO,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC;AAED,wBAA+B,IAAkB,EAAE,KAAmB;IACpE,OAAO,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** JSON values as the Ledger JSON API and DA's registry API encode them, with guards for untrusted input. */
|
|
2
|
+
import { isRecord } from '../core/utils/type-guards';
|
|
3
|
+
/** A plain object (not an array, not null): the SDK's dependency-free guard, imported from its own file. */
|
|
4
|
+
export { isRecord };
|
|
5
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
6
|
+
export type JsonArray = readonly JsonValue[];
|
|
7
|
+
export interface JsonObject {
|
|
8
|
+
readonly [key: string]: JsonValue;
|
|
9
|
+
}
|
|
10
|
+
export type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
11
|
+
/** Whether `value` is a JSON value: finite numbers, no `undefined`, functions or class instances beyond plain data. */
|
|
12
|
+
export declare function isJsonValue(value: unknown): value is JsonValue;
|
|
13
|
+
export declare function isJsonObject(value: unknown): value is JsonObject;
|
|
14
|
+
/** A non-empty string, or undefined. */
|
|
15
|
+
export declare function nonEmptyString(value: unknown): string | undefined;
|
|
16
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/wallets/json.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,4GAA4G;AAC5G,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,SAAS,SAAS,EAAE,CAAC;AAC7C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AACD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/D,uHAAuH;AACvH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAK9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wCAAwC;AACxC,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEjE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRecord = void 0;
|
|
4
|
+
exports.isJsonValue = isJsonValue;
|
|
5
|
+
exports.isJsonObject = isJsonObject;
|
|
6
|
+
exports.nonEmptyString = nonEmptyString;
|
|
7
|
+
/** JSON values as the Ledger JSON API and DA's registry API encode them, with guards for untrusted input. */
|
|
8
|
+
const type_guards_1 = require("../core/utils/type-guards");
|
|
9
|
+
Object.defineProperty(exports, "isRecord", { enumerable: true, get: function () { return type_guards_1.isRecord; } });
|
|
10
|
+
/** Whether `value` is a JSON value: finite numbers, no `undefined`, functions or class instances beyond plain data. */
|
|
11
|
+
function isJsonValue(value) {
|
|
12
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
13
|
+
return true;
|
|
14
|
+
if (typeof value === 'number')
|
|
15
|
+
return Number.isFinite(value);
|
|
16
|
+
if (typeof value !== 'object')
|
|
17
|
+
return false;
|
|
18
|
+
return Array.isArray(value) ? value.every(isJsonValue) : Object.values(value).every(isJsonValue);
|
|
19
|
+
}
|
|
20
|
+
function isJsonObject(value) {
|
|
21
|
+
return (0, type_guards_1.isRecord)(value) && isJsonValue(value);
|
|
22
|
+
}
|
|
23
|
+
/** A non-empty string, or undefined. */
|
|
24
|
+
function nonEmptyString(value) {
|
|
25
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/wallets/json.ts"],"names":[],"mappings":";;;;;;AAAA,6GAA6G;AAC7G,2DAAqD;yFAA5C,sBAAQ;AAYjB,uHAAuH;AACvH,qBAA4B,KAAc;IACxC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3F,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACnG,CAAC;AAED,sBAA6B,KAAc;IACzC,OAAO,IAAA,sBAAQ,EAAC,KAAK,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,wCAAwC;AACxC,wBAA+B,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comparing template and interface ids across their two forms: package-name (`#package-name:Module:Entity`, as the
|
|
3
|
+
* SDK's constants spell them so they survive DAR upgrades) and package-id (`pkgId:Module:Entity`, as the ledger reports
|
|
4
|
+
* them).
|
|
5
|
+
*
|
|
6
|
+
* The ids themselves are the SDK's own: `DA_REGISTRY_TEMPLATES` (`da-registry/templates`) and the token standard V1
|
|
7
|
+
* interface ids (`utils/token-standard/v1/constants`). Both modules are dependency-free, so this module can import them
|
|
8
|
+
* and stay browser-safe.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* `Module:Entity` of a template or interface id in either form (`#pkg-name:M:E` or `pkgId:M:E`), or null when the id is
|
|
12
|
+
* not of that shape.
|
|
13
|
+
*/
|
|
14
|
+
export declare function qualifiedName(id: string): string | null;
|
|
15
|
+
/** Whether two ids name the same template or interface, whatever package version or id form each uses. */
|
|
16
|
+
export declare function sameQualifiedName(left: string, right: string): boolean;
|
|
17
|
+
/** The package name of a package-name form id (`#package-name:Module:Entity`), or null for any other form. */
|
|
18
|
+
export declare function packageNameOf(id: string): string | null;
|
|
19
|
+
/** `Module:Entity` of one of the SDK's own id constants; throws on a malformed constant rather than matching nothing. */
|
|
20
|
+
export declare function requireQualifiedName(id: string): string;
|
|
21
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/wallets/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvD;AAED,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED,8GAA8G;AAC9G,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIvD;AAED,yHAAyH;AACzH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAIvD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Comparing template and interface ids across their two forms: package-name (`#package-name:Module:Entity`, as the
|
|
4
|
+
* SDK's constants spell them so they survive DAR upgrades) and package-id (`pkgId:Module:Entity`, as the ledger reports
|
|
5
|
+
* them).
|
|
6
|
+
*
|
|
7
|
+
* The ids themselves are the SDK's own: `DA_REGISTRY_TEMPLATES` (`da-registry/templates`) and the token standard V1
|
|
8
|
+
* interface ids (`utils/token-standard/v1/constants`). Both modules are dependency-free, so this module can import them
|
|
9
|
+
* and stay browser-safe.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.qualifiedName = qualifiedName;
|
|
13
|
+
exports.sameQualifiedName = sameQualifiedName;
|
|
14
|
+
exports.packageNameOf = packageNameOf;
|
|
15
|
+
exports.requireQualifiedName = requireQualifiedName;
|
|
16
|
+
/**
|
|
17
|
+
* `Module:Entity` of a template or interface id in either form (`#pkg-name:M:E` or `pkgId:M:E`), or null when the id is
|
|
18
|
+
* not of that shape.
|
|
19
|
+
*/
|
|
20
|
+
function qualifiedName(id) {
|
|
21
|
+
const separator = id.indexOf(':');
|
|
22
|
+
if (separator <= 0)
|
|
23
|
+
return null;
|
|
24
|
+
const rest = id.slice(separator + 1);
|
|
25
|
+
return /^[A-Za-z0-9_.]+:[A-Za-z0-9_.]+$/.test(rest) ? rest : null;
|
|
26
|
+
}
|
|
27
|
+
/** Whether two ids name the same template or interface, whatever package version or id form each uses. */
|
|
28
|
+
function sameQualifiedName(left, right) {
|
|
29
|
+
const name = qualifiedName(left);
|
|
30
|
+
return name !== null && name === qualifiedName(right);
|
|
31
|
+
}
|
|
32
|
+
/** The package name of a package-name form id (`#package-name:Module:Entity`), or null for any other form. */
|
|
33
|
+
function packageNameOf(id) {
|
|
34
|
+
if (!id.startsWith('#'))
|
|
35
|
+
return null;
|
|
36
|
+
const separator = id.indexOf(':');
|
|
37
|
+
return separator > 1 ? id.slice(1, separator) : null;
|
|
38
|
+
}
|
|
39
|
+
/** `Module:Entity` of one of the SDK's own id constants; throws on a malformed constant rather than matching nothing. */
|
|
40
|
+
function requireQualifiedName(id) {
|
|
41
|
+
const name = qualifiedName(id);
|
|
42
|
+
if (name === null)
|
|
43
|
+
throw new TypeError(`Malformed template id ${id}`);
|
|
44
|
+
return name;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/wallets/templates.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AAEH;;;GAGG;AACH,uBAA8B,EAAU;IACtC,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACrC,OAAO,iCAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC;AAED,0GAA0G;AAC1G,2BAAkC,IAAY,EAAE,KAAa;IAC3D,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,8GAA8G;AAC9G,uBAA8B,EAAU;IACtC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC;AAED,yHAAyH;AACzH,8BAAqC,EAAU;IAC7C,MAAM,IAAI,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IAC/B,IAAI,IAAI,KAAK,IAAI;QAAE,MAAM,IAAI,SAAS,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC;AACd,CAAC"}
|