@fairmint/canton-node-sdk 0.0.276 → 0.0.278
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 +108 -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/external-signing/index.d.ts +1 -0
- package/build/src/utils/external-signing/index.d.ts.map +1 -1
- package/build/src/utils/external-signing/index.js +1 -0
- package/build/src/utils/external-signing/index.js.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership.d.ts +69 -0
- package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -0
- package/build/src/utils/external-signing/wallet-ownership.js +179 -0
- package/build/src/utils/external-signing/wallet-ownership.js.map +1 -0
- 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 +174 -0
- package/build/src/wallets/cip103.d.ts.map +1 -0
- package/build/src/wallets/cip103.js +452 -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 +238 -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 +66 -0
- package/build/src/wallets/errors.d.ts.map +1 -0
- package/build/src/wallets/errors.js +71 -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 +23 -0
- package/build/src/wallets/index.d.ts.map +1 -0
- package/build/src/wallets/index.js +36 -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/ownership.d.ts +79 -0
- package/build/src/wallets/ownership.d.ts.map +1 -0
- package/build/src/wallets/ownership.js +202 -0
- package/build/src/wallets/ownership.js.map +1 -0
- package/build/src/wallets/templates.d.ts +36 -0
- package/build/src/wallets/templates.d.ts.map +1 -0
- package/build/src/wallets/templates.js +70 -0
- package/build/src/wallets/templates.js.map +1 -0
- package/build/src/wallets/token-registry.d.ts +95 -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 +146 -0
- package/build/src/wallets/token-standard-wallet.d.ts.map +1 -0
- package/build/src/wallets/token-standard-wallet.js +269 -0
- package/build/src/wallets/token-standard-wallet.js.map +1 -0
- package/build/src/wallets/token-wallet.d.ts +50 -0
- package/build/src/wallets/token-wallet.d.ts.map +1 -0
- package/build/src/wallets/token-wallet.js +175 -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 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/wallets/da-utilities/client.ts"],"names":[],"mappings":";;;;;;;AAAA;;;;;GAKG;AACH,4CAAkE;AAClE,sCAAoE;AACpE,0CAA2C;AAC3C,kCAAiE;AACjE,2DAAoE;AACpE,4CAAsF;AAatF,6CAA6C;AAChC,QAAA,sBAAsB,GAAwC;IACzE,MAAM,EAAE,4CAA4C;IACpD,OAAO,EAAE,wCAAwC;CAClD,CAAC;AAmDF,uEAAuE;AAC1D,QAAA,6BAA6B,GACxC,CAAC,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,CAC5D,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,gCAAoB,EAAC,iCAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEjE,sGAAsG;AACzF,QAAA,yBAAyB,GAAsB;IAC1D,IAAA,gCAAoB,EAAC,iCAAqB,CAAC,iBAAiB,CAAC;CAC9D,CAAC;AAEF,MAAM,uBAAuB,GAAG,IAAA,yBAAa,EAAC,iCAAqB,CAAC,OAAO,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,4BAAmC,QAAwB;IACzD,IACE,CAAC,IAAA,6BAAiB,EAAC,QAAQ,CAAC,UAAU,EAAE,iCAAqB,CAAC,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O,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,EAAE,CAAC;IAC9C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Exact Daml `Decimal` amounts as scaled BigInt (10 decimal places). Never goes through a float. */
|
|
2
|
+
export declare const DECIMAL_PLACES = 10;
|
|
3
|
+
/** The largest Daml `Numeric 10` (10^28 - 10^-10), in units: 38 digits. */
|
|
4
|
+
export declare const MAX_DECIMAL_UNITS: bigint;
|
|
5
|
+
/** Units of 10^-10 in a non-negative decimal string, or null when it is not one (sign, exponent, >10 places, …). */
|
|
6
|
+
export declare function parseDecimalUnits(text: string): bigint | null;
|
|
7
|
+
/** Units as a decimal string with exactly 10 places, as the ledger prints Decimals (`40.0000000000`). */
|
|
8
|
+
export declare function formatDecimalUnits(units: bigint): string;
|
|
9
|
+
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/wallets/decimal.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAErG,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,QAAkB,CAAC;AAGjD,oHAAoH;AACpH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D;AAED,yGAAyG;AACzG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKxD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Exact Daml `Decimal` amounts as scaled BigInt (10 decimal places). Never goes through a float. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MAX_DECIMAL_UNITS = exports.DECIMAL_PLACES = void 0;
|
|
5
|
+
exports.parseDecimalUnits = parseDecimalUnits;
|
|
6
|
+
exports.formatDecimalUnits = formatDecimalUnits;
|
|
7
|
+
exports.DECIMAL_PLACES = 10;
|
|
8
|
+
const SCALE = 10n ** BigInt(exports.DECIMAL_PLACES);
|
|
9
|
+
/** The largest Daml `Numeric 10` (10^28 - 10^-10), in units: 38 digits. */
|
|
10
|
+
exports.MAX_DECIMAL_UNITS = 10n ** 38n - 1n;
|
|
11
|
+
const DECIMAL_PATTERN = /^(\d{1,28})(?:\.(\d{1,10}))?$/;
|
|
12
|
+
/** Units of 10^-10 in a non-negative decimal string, or null when it is not one (sign, exponent, >10 places, …). */
|
|
13
|
+
function parseDecimalUnits(text) {
|
|
14
|
+
const match = DECIMAL_PATTERN.exec(text);
|
|
15
|
+
if (!match)
|
|
16
|
+
return null;
|
|
17
|
+
const whole = match[1] ?? '0';
|
|
18
|
+
const fraction = (match[2] ?? '').padEnd(exports.DECIMAL_PLACES, '0');
|
|
19
|
+
return BigInt(whole) * SCALE + BigInt(fraction);
|
|
20
|
+
}
|
|
21
|
+
/** Units as a decimal string with exactly 10 places, as the ledger prints Decimals (`40.0000000000`). */
|
|
22
|
+
function formatDecimalUnits(units) {
|
|
23
|
+
if (units < 0n)
|
|
24
|
+
throw new RangeError('Amounts are never negative');
|
|
25
|
+
const whole = units / SCALE;
|
|
26
|
+
const fraction = (units % SCALE).toString().padStart(exports.DECIMAL_PLACES, '0');
|
|
27
|
+
return `${whole.toString()}.${fraction}`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=decimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/wallets/decimal.ts"],"names":[],"mappings":";AAAA,qGAAqG;;;;;AAExF,QAAA,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,QAAA,cAAc,CAAC,CAAC;AAC5C,2EAA2E;AAC9D,QAAA,iBAAiB,GAAG,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC;AACjD,MAAM,eAAe,GAAG,+BAA+B,CAAC;AAExD,oHAAoH;AACpH,2BAAkC,IAAY;IAC5C,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;IAC9B,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,QAAA,cAAc,EAAE,GAAG,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED,yGAAyG;AACzG,4BAAmC,KAAa;IAC9C,IAAI,KAAK,GAAG,EAAE;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAC5B,MAAM,QAAQ,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAA,cAAc,EAAE,GAAG,CAAC,CAAC;IAC1E,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,QAAQ,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Errors the wallets module throws. Each carries enough to decide whether a retry is safe. */
|
|
2
|
+
/**
|
|
3
|
+
* - `rejected-by-user`: the user declined in the wallet; nothing was submitted.
|
|
4
|
+
* - `failed`: nothing was committed (the ledger rejected it, or the wallet refused the request before taking it on).
|
|
5
|
+
* - `unknown`: the outcome is not known. Do not resubmit blindly: check the wallet or ledger first.
|
|
6
|
+
*/
|
|
7
|
+
export type WalletSubmitOutcome = 'rejected-by-user' | 'failed' | 'unknown';
|
|
8
|
+
/** A submission did not commit, or its outcome is unknown. The SDK never retries. */
|
|
9
|
+
export declare class WalletSubmitError extends Error {
|
|
10
|
+
readonly outcome: WalletSubmitOutcome;
|
|
11
|
+
/** The wallet's CIP-0103 error code, when it gave one. */
|
|
12
|
+
readonly code?: number;
|
|
13
|
+
readonly commandId?: string;
|
|
14
|
+
constructor(outcome: WalletSubmitOutcome, message: string, details?: {
|
|
15
|
+
code?: number;
|
|
16
|
+
commandId?: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** The wallet could not read the ledger or its account, or answered in a shape this module does not understand. */
|
|
20
|
+
export declare class WalletReadError extends Error {
|
|
21
|
+
/** The wallet's CIP-0103 error code, when it gave one (4100: not connected; 4200: method not supported). */
|
|
22
|
+
readonly code?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The wallet rate-limited the read (CIP-0103 -32005) and kept refusing after the SDK backed off. Nothing is wrong
|
|
25
|
+
* with the request: offer the user a retry after a moment.
|
|
26
|
+
*/
|
|
27
|
+
readonly rateLimited: boolean;
|
|
28
|
+
constructor(message: string, code?: number);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* - `invalid-challenge`: the challenge is malformed or expired; nothing was sent to the wallet.
|
|
32
|
+
* - `rejected-by-user`: the user declined to sign (CIP-0103 4001).
|
|
33
|
+
* - `failed`: the wallet could not sign, or answered without a signature.
|
|
34
|
+
*/
|
|
35
|
+
export type WalletSignErrorReason = 'invalid-challenge' | 'rejected-by-user' | 'failed';
|
|
36
|
+
/** The wallet did not sign the ownership message. */
|
|
37
|
+
export declare class WalletSignError extends Error {
|
|
38
|
+
readonly reason: WalletSignErrorReason;
|
|
39
|
+
/** The wallet's CIP-0103 error code, when it gave one. */
|
|
40
|
+
readonly code?: number;
|
|
41
|
+
constructor(reason: WalletSignErrorReason, message: string, code?: number);
|
|
42
|
+
}
|
|
43
|
+
/** A registry API answered with a non-2xx status. `body` is the raw response text. */
|
|
44
|
+
export declare class RegistryApiError extends Error {
|
|
45
|
+
readonly status: number;
|
|
46
|
+
readonly body: string;
|
|
47
|
+
readonly url: string;
|
|
48
|
+
constructor(status: number, body: string, url: string);
|
|
49
|
+
}
|
|
50
|
+
/** A registry API answered 2xx with a body this module refuses (wrong shape, unexpected factory). */
|
|
51
|
+
export declare class RegistryResponseError extends Error {
|
|
52
|
+
constructor(message: string);
|
|
53
|
+
}
|
|
54
|
+
export type TokenWalletErrorCode = 'invalid-input' | 'not-found' | 'not-addressed-to-wallet' | 'unexpected-registrar' | 'insufficient-balance'
|
|
55
|
+
/** The inputs that would cover the amount add up beyond the Daml `Numeric 10` range (10^28 - 10^-10). */
|
|
56
|
+
| 'amount-out-of-range' | 'preapproval-required'
|
|
57
|
+
/** The registry would now run the transfer as another kind than the caller previewed (`expectedKind`). */
|
|
58
|
+
| 'kind-changed'
|
|
59
|
+
/** Another write action of the same token wallet is still in progress. */
|
|
60
|
+
| 'busy';
|
|
61
|
+
/** A token action refused before anything was submitted. */
|
|
62
|
+
export declare class TokenWalletError extends Error {
|
|
63
|
+
readonly code: TokenWalletErrorCode;
|
|
64
|
+
constructor(code: TokenWalletErrorCode, message: string);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/wallets/errors.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAE/F;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAI5E,qFAAqF;AACrF,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,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;GACvG,qBAAqB,GACrB,sBAAsB;AACxB,0GAA0G;GACxG,cAAc;AAChB,0EAA0E;GACxE,MAAM,CAAC;AAEX,4DAA4D;AAC5D,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAEpC,YAAY,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAItD;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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.WalletSignError = 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
|
+
/** CIP-0103 -32005 (Limit exceeded): the wallet rate-limited the request. */
|
|
20
|
+
const LIMIT_EXCEEDED = -32005;
|
|
21
|
+
/** The wallet could not read the ledger or its account, or answered in a shape this module does not understand. */
|
|
22
|
+
class WalletReadError extends Error {
|
|
23
|
+
constructor(message, code) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'WalletReadError';
|
|
26
|
+
if (code !== undefined)
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.rateLimited = code === LIMIT_EXCEEDED;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.WalletReadError = WalletReadError;
|
|
32
|
+
/** The wallet did not sign the ownership message. */
|
|
33
|
+
class WalletSignError extends Error {
|
|
34
|
+
constructor(reason, message, code) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'WalletSignError';
|
|
37
|
+
this.reason = reason;
|
|
38
|
+
if (code !== undefined)
|
|
39
|
+
this.code = code;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.WalletSignError = WalletSignError;
|
|
43
|
+
/** A registry API answered with a non-2xx status. `body` is the raw response text. */
|
|
44
|
+
class RegistryApiError extends Error {
|
|
45
|
+
constructor(status, body, url) {
|
|
46
|
+
super(`Registry API ${status} for ${url}: ${body.slice(0, 500)}`);
|
|
47
|
+
this.name = 'RegistryApiError';
|
|
48
|
+
this.status = status;
|
|
49
|
+
this.body = body;
|
|
50
|
+
this.url = url;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.RegistryApiError = RegistryApiError;
|
|
54
|
+
/** A registry API answered 2xx with a body this module refuses (wrong shape, unexpected factory). */
|
|
55
|
+
class RegistryResponseError extends Error {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = 'RegistryResponseError';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.RegistryResponseError = RegistryResponseError;
|
|
62
|
+
/** A token action refused before anything was submitted. */
|
|
63
|
+
class TokenWalletError extends Error {
|
|
64
|
+
constructor(code, message) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = 'TokenWalletError';
|
|
67
|
+
this.code = code;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.TokenWalletError = TokenWalletError;
|
|
71
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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M,GAAG,MAAM,CAAC;QACrB,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,CAAC;AACd,CAAC;AAED,SAAS,OAAO,CACd,QAAwB,EACxB,MAKC;IAED,MAAM,KAAK,GAAG,IAAA,qBAAc,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,MAA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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,23 @@
|
|
|
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
|
|
7
|
+
* ownership proof's client side (`proveWalletOwnership` and the message it signs; the server verifies with
|
|
8
|
+
* `verifyWalletOwnership` from the package root, which is Node-only), the read back-off options, the errors and the
|
|
9
|
+
* data types. Command builders, parsers, error-code tables and the CIP-0103 client stay internal.
|
|
10
|
+
*/
|
|
11
|
+
export { createTokenWallet, type BurnRequestOptions, type TokenWallet, type TokenWalletOptions, type TokenWalletState, } from './token-wallet';
|
|
12
|
+
export { createTokenStandardWallet, type TokenStandardState, type TokenStandardWallet, type TokenStandardWalletOptions, type TransferOffers, type TransferOptions, type TransferRequest, type TransferResult, } from './token-standard-wallet';
|
|
13
|
+
export { DEFAULT_READ_RETRY_DELAYS_MS, primaryPartyId, type Cip103Account, type Cip103EventListener, type Cip103LedgerApiParams, type Cip103PrepareExecuteParams, type Cip103Provider, type Cip103Request, type Cip103SignMessageParams, type WalletReadRetryOptions, } from './cip103';
|
|
14
|
+
export { buildWalletOwnershipMessage, proveWalletOwnership, type ProveWalletOwnershipOptions, type WalletOwnershipChallenge, type WalletOwnershipMessageFields, type WalletOwnershipProof, } from './ownership';
|
|
15
|
+
export { createDaUtilitiesClient, type BurnRequestContextArgs, type DaNetwork, type DaUtilitiesClient, type DaUtilitiesClientOptions, type DaUtilitiesTarget, type FetchLike, } from './da-utilities/client';
|
|
16
|
+
export type { ChoiceContext, ChoiceContextData, FactoryWithChoiceContext, ReadContracts, TokenRegistry, TransferFactory, TransferFactoryArgs, TransferInstructionAction, TransferKind, TransferSpec, } from './token-registry';
|
|
17
|
+
export { RegistryApiError, RegistryResponseError, TokenWalletError, WalletReadError, WalletSignError, WalletSubmitError, type TokenWalletErrorCode, type WalletSignErrorReason, type WalletSubmitOutcome, } from './errors';
|
|
18
|
+
export type { BurnRequest, MintOffer, TransferOffer } from './contracts';
|
|
19
|
+
export type { Holding } from './holdings';
|
|
20
|
+
export type { ActiveContract, ContractFilter, CreateCommand, DisclosedContract, ExerciseCommand, InstrumentId, InterfaceView, LedgerCommand, SubmitResult, WalletSubmission, } from './types';
|
|
21
|
+
export type { JsonArray, JsonObject, JsonPrimitive, JsonValue } from './json';
|
|
22
|
+
export { formatDecimalUnits, parseDecimalUnits } from './decimal';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,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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,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDecimalUnits = exports.formatDecimalUnits = exports.WalletSubmitError = exports.WalletSignError = exports.WalletReadError = exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.createDaUtilitiesClient = exports.proveWalletOwnership = exports.buildWalletOwnershipMessage = exports.primaryPartyId = exports.DEFAULT_READ_RETRY_DELAYS_MS = 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
|
|
10
|
+
* ownership proof's client side (`proveWalletOwnership` and the message it signs; the server verifies with
|
|
11
|
+
* `verifyWalletOwnership` from the package root, which is Node-only), the read back-off options, the errors and the
|
|
12
|
+
* data types. Command builders, parsers, error-code tables and the CIP-0103 client stay internal.
|
|
13
|
+
*/
|
|
14
|
+
var token_wallet_1 = require("./token-wallet");
|
|
15
|
+
Object.defineProperty(exports, "createTokenWallet", { enumerable: true, get: function () { return token_wallet_1.createTokenWallet; } });
|
|
16
|
+
var token_standard_wallet_1 = require("./token-standard-wallet");
|
|
17
|
+
Object.defineProperty(exports, "createTokenStandardWallet", { enumerable: true, get: function () { return token_standard_wallet_1.createTokenStandardWallet; } });
|
|
18
|
+
var cip103_1 = require("./cip103");
|
|
19
|
+
Object.defineProperty(exports, "DEFAULT_READ_RETRY_DELAYS_MS", { enumerable: true, get: function () { return cip103_1.DEFAULT_READ_RETRY_DELAYS_MS; } });
|
|
20
|
+
Object.defineProperty(exports, "primaryPartyId", { enumerable: true, get: function () { return cip103_1.primaryPartyId; } });
|
|
21
|
+
var ownership_1 = require("./ownership");
|
|
22
|
+
Object.defineProperty(exports, "buildWalletOwnershipMessage", { enumerable: true, get: function () { return ownership_1.buildWalletOwnershipMessage; } });
|
|
23
|
+
Object.defineProperty(exports, "proveWalletOwnership", { enumerable: true, get: function () { return ownership_1.proveWalletOwnership; } });
|
|
24
|
+
var client_1 = require("./da-utilities/client");
|
|
25
|
+
Object.defineProperty(exports, "createDaUtilitiesClient", { enumerable: true, get: function () { return client_1.createDaUtilitiesClient; } });
|
|
26
|
+
var errors_1 = require("./errors");
|
|
27
|
+
Object.defineProperty(exports, "RegistryApiError", { enumerable: true, get: function () { return errors_1.RegistryApiError; } });
|
|
28
|
+
Object.defineProperty(exports, "RegistryResponseError", { enumerable: true, get: function () { return errors_1.RegistryResponseError; } });
|
|
29
|
+
Object.defineProperty(exports, "TokenWalletError", { enumerable: true, get: function () { return errors_1.TokenWalletError; } });
|
|
30
|
+
Object.defineProperty(exports, "WalletReadError", { enumerable: true, get: function () { return errors_1.WalletReadError; } });
|
|
31
|
+
Object.defineProperty(exports, "WalletSignError", { enumerable: true, get: function () { return errors_1.WalletSignError; } });
|
|
32
|
+
Object.defineProperty(exports, "WalletSubmitError", { enumerable: true, get: function () { return errors_1.WalletSubmitError; } });
|
|
33
|
+
var decimal_1 = require("./decimal");
|
|
34
|
+
Object.defineProperty(exports, "formatDecimalUnits", { enumerable: true, get: function () { return decimal_1.formatDecimalUnits; } });
|
|
35
|
+
Object.defineProperty(exports, "parseDecimalUnits", { enumerable: true, get: function () { return decimal_1.parseDecimalUnits; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,+CAMwB;AALtB,iHAAA,iBAAiB,OAAA;AAMnB,iEASiC;AAR/B,kIAAA,yBAAyB,OAAA;AAS3B,mCAWkB;AAVhB,sHAAA,4BAA4B,OAAA;AAC5B,wGAAA,cAAc,OAAA;AAUhB,yCAOqB;AANnB,wHAAA,2BAA2B,OAAA;AAC3B,iHAAA,oBAAoB,OAAA;AAMtB,gDAQ+B;AAP7B,iHAAA,uBAAuB,OAAA;AAoBzB,mCAUkB;AAThB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AAoBnB,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"}
|