@fairmint/canton-node-sdk 0.0.281 → 0.0.283
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 +128 -154
- package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership-challenger.js +2 -3
- package/build/src/utils/external-signing/wallet-ownership-challenger.js.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership.js +8 -18
- package/build/src/utils/external-signing/wallet-ownership.js.map +1 -1
- package/build/src/wallets/acs.d.ts +2 -1
- package/build/src/wallets/acs.d.ts.map +1 -1
- package/build/src/wallets/acs.js +6 -31
- package/build/src/wallets/acs.js.map +1 -1
- package/build/src/wallets/cip103.d.ts +32 -68
- package/build/src/wallets/cip103.d.ts.map +1 -1
- package/build/src/wallets/cip103.js +112 -230
- package/build/src/wallets/cip103.js.map +1 -1
- package/build/src/wallets/commands.d.ts +39 -6
- package/build/src/wallets/commands.d.ts.map +1 -1
- package/build/src/wallets/commands.js +50 -5
- package/build/src/wallets/commands.js.map +1 -1
- package/build/src/wallets/contracts.d.ts +12 -0
- package/build/src/wallets/contracts.d.ts.map +1 -1
- package/build/src/wallets/contracts.js +21 -5
- package/build/src/wallets/contracts.js.map +1 -1
- package/build/src/wallets/da-utilities/client.d.ts +61 -29
- package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
- package/build/src/wallets/da-utilities/client.js +78 -75
- package/build/src/wallets/da-utilities/client.js.map +1 -1
- package/build/src/wallets/errors.d.ts +11 -8
- package/build/src/wallets/errors.d.ts.map +1 -1
- package/build/src/wallets/errors.js +13 -3
- package/build/src/wallets/errors.js.map +1 -1
- package/build/src/wallets/holdings.d.ts +14 -4
- package/build/src/wallets/holdings.d.ts.map +1 -1
- package/build/src/wallets/holdings.js +27 -47
- package/build/src/wallets/holdings.js.map +1 -1
- package/build/src/wallets/index.d.ts +17 -21
- package/build/src/wallets/index.d.ts.map +1 -1
- package/build/src/wallets/index.js +14 -23
- package/build/src/wallets/index.js.map +1 -1
- package/build/src/wallets/instrument.js +1 -1
- package/build/src/wallets/instrument.js.map +1 -1
- package/build/src/wallets/ownership.d.ts +20 -26
- package/build/src/wallets/ownership.d.ts.map +1 -1
- package/build/src/wallets/ownership.js +33 -27
- package/build/src/wallets/ownership.js.map +1 -1
- package/build/src/wallets/session.d.ts +30 -68
- package/build/src/wallets/session.d.ts.map +1 -1
- package/build/src/wallets/session.js +119 -167
- package/build/src/wallets/session.js.map +1 -1
- package/build/src/wallets/store.d.ts +148 -86
- package/build/src/wallets/store.d.ts.map +1 -1
- package/build/src/wallets/store.js +267 -99
- package/build/src/wallets/store.js.map +1 -1
- package/build/src/wallets/templates.d.ts +10 -23
- package/build/src/wallets/templates.d.ts.map +1 -1
- package/build/src/wallets/templates.js +9 -33
- package/build/src/wallets/templates.js.map +1 -1
- package/build/src/wallets/types.d.ts +6 -20
- package/build/src/wallets/types.d.ts.map +1 -1
- package/build/src/wallets/wallet.d.ts +130 -74
- package/build/src/wallets/wallet.d.ts.map +1 -1
- package/build/src/wallets/wallet.js +347 -185
- package/build/src/wallets/wallet.js.map +1 -1
- package/package.json +1 -1
- package/build/src/wallets/cip56-core.d.ts +0 -175
- package/build/src/wallets/cip56-core.d.ts.map +0 -1
- package/build/src/wallets/cip56-core.js +0 -325
- package/build/src/wallets/cip56-core.js.map +0 -1
- package/build/src/wallets/token-registry.d.ts +0 -97
- package/build/src/wallets/token-registry.d.ts.map +0 -1
- package/build/src/wallets/token-registry.js +0 -19
- package/build/src/wallets/token-registry.js.map +0 -1
|
@@ -4,11 +4,10 @@ exports.qualifiedName = qualifiedName;
|
|
|
4
4
|
exports.sameQualifiedName = sameQualifiedName;
|
|
5
5
|
exports.packageNameOf = packageNameOf;
|
|
6
6
|
exports.requireQualifiedName = requireQualifiedName;
|
|
7
|
-
exports.
|
|
8
|
-
exports.contractMatchesFilter = contractMatchesFilter;
|
|
7
|
+
exports.isTemplate = isTemplate;
|
|
9
8
|
/**
|
|
10
|
-
* `Module:Entity` of a template
|
|
11
|
-
*
|
|
9
|
+
* `Module:Entity` of a template id in either form (`#pkg-name:M:E` or `pkgId:M:E`), or null when the id is not of that
|
|
10
|
+
* shape.
|
|
12
11
|
*/
|
|
13
12
|
function qualifiedName(id) {
|
|
14
13
|
const separator = id.indexOf(':');
|
|
@@ -17,7 +16,7 @@ function qualifiedName(id) {
|
|
|
17
16
|
const rest = id.slice(separator + 1);
|
|
18
17
|
return /^[A-Za-z0-9_.]+:[A-Za-z0-9_.]+$/.test(rest) ? rest : null;
|
|
19
18
|
}
|
|
20
|
-
/** Whether two ids name the same template
|
|
19
|
+
/** Whether two ids name the same template, whatever package version or id form each uses. */
|
|
21
20
|
function sameQualifiedName(left, right) {
|
|
22
21
|
const name = qualifiedName(left);
|
|
23
22
|
return name !== null && name === qualifiedName(right);
|
|
@@ -36,35 +35,12 @@ function requireQualifiedName(id) {
|
|
|
36
35
|
throw new TypeError(`Malformed template id ${id}`);
|
|
37
36
|
return name;
|
|
38
37
|
}
|
|
39
|
-
/** A stable key of a filter: `t:<templateId>` or `i:<interfaceId>`. */
|
|
40
|
-
function contractFilterKey(filter) {
|
|
41
|
-
return 'templateId' in filter ? `t:${filter.templateId}` : `i:${filter.interfaceId}`;
|
|
42
|
-
}
|
|
43
38
|
/**
|
|
44
|
-
* Whether a contract of a
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* A template match needs proven package identity, not just the same `Module:Entity`: a cumulative read also returns
|
|
49
|
-
* contracts matched only by one of its interface filters, and any party can create a template of that name in its own
|
|
50
|
-
* package. So a package-name filter (`#pkg:M:E`) matches only a contract whose `packageName` is that package; the
|
|
51
|
-
* Ledger JSON API v2 (Canton 3.x) always reports `createdEvent.packageName` (a required field), so a contract without
|
|
52
|
-
* one is not classified at all (fail closed). A package-id filter matches only the exact template id.
|
|
39
|
+
* Whether a contract is of a template given in package-name form (`#pkg:Module:Entity`, as the SDK's constants spell
|
|
40
|
+
* them): the same `Module:Entity` and the same package name. Any party can create a template of that name in its own
|
|
41
|
+
* package, so the name alone proves nothing. An id in any other form matches nothing.
|
|
53
42
|
*/
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
if (!sameQualifiedName(contract.templateId, filter.templateId))
|
|
57
|
-
return false;
|
|
58
|
-
const filterPackage = packageNameOf(filter.templateId);
|
|
59
|
-
return filterPackage === null
|
|
60
|
-
? contract.templateId === filter.templateId
|
|
61
|
-
: contract.packageName !== undefined && contract.packageName === filterPackage;
|
|
62
|
-
}
|
|
63
|
-
// Same rule for interfaces: a package-id filter (`pkgId:M:E`) matches only that exact interface id, so two
|
|
64
|
-
// same-named interfaces from different packages in one cumulative read are never mixed up; a package-name filter
|
|
65
|
-
// (`#pkg:M:E`) matches by name (the ledger reports a view's interface id with the package id it resolved).
|
|
66
|
-
return contract.interfaceViews.some((view) => packageNameOf(filter.interfaceId) === null
|
|
67
|
-
? view.interfaceId === filter.interfaceId
|
|
68
|
-
: sameQualifiedName(view.interfaceId, filter.interfaceId));
|
|
43
|
+
function isTemplate(contract, templateId) {
|
|
44
|
+
return sameQualifiedName(contract.templateId, templateId) && contract.packageName === packageNameOf(templateId);
|
|
69
45
|
}
|
|
70
46
|
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/wallets/templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/wallets/templates.ts"],"names":[],"mappings":";;;;;;;AAMA;;;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,6FAA6F;AAC7F,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;AAED;;;;GAIG;AACH,oBAA2B,QAAwB,EAAE,UAAkB;IACrE,OAAO,iBAAiB,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,QAAQ,CAAC,WAAW,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC;AAClH,CAAC"}
|
|
@@ -29,46 +29,32 @@ export interface DisclosedContract {
|
|
|
29
29
|
readonly createdEventBlob: string;
|
|
30
30
|
readonly synchronizerId?: string;
|
|
31
31
|
}
|
|
32
|
-
/** One interface view of an active contract (only views the ledger computed successfully are kept). */
|
|
33
|
-
export interface InterfaceView {
|
|
34
|
-
readonly interfaceId: string;
|
|
35
|
-
readonly viewValue: JsonObject;
|
|
36
|
-
}
|
|
37
32
|
/** An active contract read from the wallet party's ACS. */
|
|
38
33
|
export interface ActiveContract {
|
|
39
34
|
readonly contractId: string;
|
|
40
35
|
/** As the ledger reports it: usually the package-id form `pkgId:Module:Entity`. */
|
|
41
36
|
readonly templateId: string;
|
|
42
|
-
/** The template's package name (`utility-registry-holding-v0`)
|
|
43
|
-
readonly packageName
|
|
37
|
+
/** The template's package name (`utility-registry-holding-v0`); entries without one are not read. */
|
|
38
|
+
readonly packageName: string;
|
|
44
39
|
/**
|
|
45
40
|
* The parties that signed the contract. Only these are guaranteed: anyone can create a contract of their own package
|
|
46
|
-
* with any create argument
|
|
41
|
+
* with any create argument, so trust in a contract comes from who signed it.
|
|
47
42
|
*/
|
|
48
43
|
readonly signatories: readonly string[];
|
|
49
|
-
/** Null when the ledger did not include it
|
|
44
|
+
/** Null when the ledger did not include it. */
|
|
50
45
|
readonly createArgument: JsonObject | null;
|
|
51
|
-
readonly interfaceViews: readonly InterfaceView[];
|
|
52
|
-
readonly createdEventBlob?: string;
|
|
53
46
|
/** The synchronizer the contract is assigned to, when the ledger reported it. */
|
|
54
47
|
readonly synchronizerId?: string;
|
|
55
48
|
}
|
|
56
|
-
/** Which contracts to read: one template or one interface (package-name `#pkg:Module:Entity` form). */
|
|
57
|
-
export type ContractFilter = {
|
|
58
|
-
readonly templateId: string;
|
|
59
|
-
} | {
|
|
60
|
-
readonly interfaceId: string;
|
|
61
|
-
};
|
|
62
49
|
/** What the SDK asks the wallet to sign and submit, acting as the wallet party only. */
|
|
63
50
|
export interface WalletSubmission {
|
|
64
51
|
readonly commands: readonly LedgerCommand[];
|
|
65
52
|
readonly disclosedContracts?: readonly DisclosedContract[];
|
|
66
|
-
/** Deduplication key; a random UUID when omitted. */
|
|
67
|
-
readonly commandId?: string;
|
|
68
53
|
}
|
|
69
54
|
/** A committed submission. */
|
|
70
55
|
export interface SubmitResult {
|
|
71
56
|
readonly updateId: string;
|
|
72
|
-
|
|
57
|
+
/** The command id the submission was sent with (a random UUID). */
|
|
58
|
+
readonly commandId: string;
|
|
73
59
|
}
|
|
74
60
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/wallets/types.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,aAAa,EAAE;QACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC;KACtC,CAAC;CACH;AAED,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,eAAe,EAAE;QACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;KACrC,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,eAAe,CAAC;AAE5D,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,
|
|
1
|
+
{"version":3,"file":"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AS,MAAM,EAAE,CAAC;IACxC,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3C,iFAAiF;IACjF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,wFAAwF;AACxF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC5D;AAED,8BAA8B;AAC9B,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -1,34 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One wallet party's DA Utility Registry token actions through any CIP-0103 wallet provider: holdings, transfers,
|
|
3
|
+
* transfer offers, mint offers, burn requests and transfer preapprovals. Every write reads its contracts fresh, fetches
|
|
4
|
+
* its choice context from DA's Utilities API, refuses anything that does not check out, and submits as the wallet party
|
|
5
|
+
* only.
|
|
6
|
+
*
|
|
7
|
+
* Trust: a holding counts when its registrar and owner signed it; an offer, a request or a preapproval when it names
|
|
8
|
+
* DA's operator and (offers and requests) a provider trusted for its instrument admin signed it. By default a registrar
|
|
9
|
+
* must be its own provider; `registry.trustedProviders` trusts others (see `isFromRegistry`).
|
|
10
|
+
*/
|
|
11
|
+
import { type Cip103Provider, type WalletReadRetryOptions } from './cip103';
|
|
12
|
+
import { type BurnRequest, type MintOffer, type TransferOffer, type TransferPreapproval } from './contracts';
|
|
13
|
+
import { type DaNetwork, type DaRegistryOptions, type TransferKind } from './da-utilities/client';
|
|
14
|
+
import { type Holding, type InstrumentBalance } from './holdings';
|
|
5
15
|
import type { InstrumentId, SubmitResult } from './types';
|
|
6
|
-
/** Burn requests: `executeBefore` defaults to now + 7 days, giving the registrar a week to accept or reject. */
|
|
7
|
-
export declare const BURN_TTL_MS: number;
|
|
8
16
|
/** A burn reference: no personal data (DA's operator and the registrar see it). */
|
|
9
17
|
export declare const BURN_REFERENCE_PATTERN: RegExp;
|
|
18
|
+
/** The reason a rejected mint offer gives the registrar: fixed, so nothing personal reaches the ledger. */
|
|
19
|
+
export declare const MINT_OFFER_REJECT_REASON = "Rejected by the holder";
|
|
10
20
|
/**
|
|
11
21
|
* A burn reference with no personal data: `holder-burn-<UTC yyyymmddThhmmssZ>-<6 random base-36 digits>` (DA's operator
|
|
12
22
|
* and the registrar see it). Never `redeem-…`, a prefix a transfer agent may reserve for the redemptions it files
|
|
13
23
|
* itself. `requestBurn` uses one when no `reference` is given.
|
|
14
24
|
*/
|
|
15
|
-
export declare function newBurnReference(now
|
|
25
|
+
export declare function newBurnReference(now: Date): string;
|
|
26
|
+
export interface WalletOptions {
|
|
27
|
+
/** Any CIP-0103 (Canton dApp API) provider, already connected as `partyId`. */
|
|
28
|
+
readonly provider: Cip103Provider;
|
|
29
|
+
/** The party every action reads and acts as. */
|
|
30
|
+
readonly partyId: string;
|
|
31
|
+
/** The DA network the provider's ledger is on; selects DA's Utilities API. */
|
|
32
|
+
readonly network: DaNetwork;
|
|
33
|
+
readonly registry?: DaRegistryOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the wallet session this wallet belongs to is still live. Once it answers false, every write is refused with
|
|
36
|
+
* `invalid-input` before its first read, and again right before the wallet signs, so nothing is submitted: the
|
|
37
|
+
* provider may now be signed in to another account. Reads are not limited. Default: always live.
|
|
38
|
+
*/
|
|
39
|
+
readonly isActive?: () => boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Test hooks beside {@link WalletOptions}; not part of the public options. */
|
|
42
|
+
export interface WalletInternalOptions extends WalletOptions {
|
|
43
|
+
/** Defaults to the system clock. */
|
|
44
|
+
readonly now?: () => Date;
|
|
45
|
+
/** How reads back off when the wallet rate-limits them. */
|
|
46
|
+
readonly readRetry?: WalletReadRetryOptions;
|
|
47
|
+
}
|
|
48
|
+
export interface TransferOffers {
|
|
49
|
+
/** Offers to the wallet party, which it can accept or reject. */
|
|
50
|
+
readonly incoming: TransferOffer[];
|
|
51
|
+
/** The wallet party's own offers, which it can withdraw. */
|
|
52
|
+
readonly outgoing: TransferOffer[];
|
|
53
|
+
}
|
|
54
|
+
/** Everything a wallet page shows, read as one snapshot of the ledger. */
|
|
55
|
+
export interface WalletState {
|
|
56
|
+
/** The ledger offset every list was read at. */
|
|
57
|
+
readonly offset: number;
|
|
58
|
+
/** The wallet party's DA holdings, locked ones included. */
|
|
59
|
+
readonly holdings: Holding[];
|
|
60
|
+
/** `holdings` summed per instrument (unlocked and locked apart), sorted by instrument id then admin. */
|
|
61
|
+
readonly balances: InstrumentBalance[];
|
|
62
|
+
readonly transferOffers: TransferOffers;
|
|
63
|
+
/** Mint offers to the wallet party. */
|
|
64
|
+
readonly mintOffers: MintOffer[];
|
|
65
|
+
/** The wallet party's open burn requests (pending redemptions). */
|
|
66
|
+
readonly burnRequests: BurnRequest[];
|
|
67
|
+
/** The wallet party's transfer preapprovals. */
|
|
68
|
+
readonly transferPreapprovals: TransferPreapproval[];
|
|
69
|
+
}
|
|
70
|
+
export interface TransferRequest {
|
|
71
|
+
readonly receiver: string;
|
|
72
|
+
readonly instrumentId: InstrumentId;
|
|
73
|
+
/** Positive decimal, at most 10 places. */
|
|
74
|
+
readonly amount: string;
|
|
75
|
+
/** Shown to the receiver as the transfer's reason (`splice.lfdecentralizedtrust.org/reason`). */
|
|
76
|
+
readonly memo?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Refuse (`preapproval-required`, at plan time, before anything is signed) unless the registry runs the transfer
|
|
79
|
+
* direct, so no offer is ever created.
|
|
80
|
+
*/
|
|
81
|
+
readonly requirePreapproval?: boolean;
|
|
82
|
+
/** Offer acceptance deadline; defaults to now + 24 h at submission; must be in the future. */
|
|
83
|
+
readonly executeBefore?: Date;
|
|
84
|
+
}
|
|
85
|
+
export interface TransferResult extends SubmitResult {
|
|
86
|
+
readonly kind: TransferKind;
|
|
87
|
+
}
|
|
16
88
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
89
|
+
* A planned transfer, to show the user how the registry will run it before they confirm. `submit` sends exactly the
|
|
90
|
+
* planned request; when the registry now answers another kind (a preapproval expired or appeared in between), it is
|
|
91
|
+
* refused with `kind-changed` before signing.
|
|
20
92
|
*/
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
readonly
|
|
24
|
-
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
|
|
93
|
+
export interface TransferPlan {
|
|
94
|
+
/** How the registry would run the transfer when it was planned. */
|
|
95
|
+
readonly kind: TransferKind;
|
|
96
|
+
/** A sentence explaining `kind` to the user. */
|
|
97
|
+
readonly description: string;
|
|
98
|
+
/** The party the transfer is from. */
|
|
99
|
+
readonly partyId: string;
|
|
100
|
+
/** The request as planned (a frozen copy). */
|
|
101
|
+
readonly request: Readonly<TransferRequest>;
|
|
102
|
+
/** Run the transfer (a write: one at a time, see `Wallet`). */
|
|
103
|
+
submit(): Promise<TransferResult>;
|
|
104
|
+
}
|
|
28
105
|
export interface BurnRequestOptions {
|
|
29
106
|
readonly instrumentId: InstrumentId;
|
|
30
107
|
readonly amount: string;
|
|
31
|
-
/** Matches {@link BURN_REFERENCE_PATTERN}; never personal data. Defaults to
|
|
108
|
+
/** Matches {@link BURN_REFERENCE_PATTERN}; never personal data. Defaults to a generated `holder-burn-…` reference. */
|
|
32
109
|
readonly reference?: string;
|
|
33
110
|
/** Defaults to now + 7 days. */
|
|
34
111
|
readonly executeBefore?: Date;
|
|
@@ -37,74 +114,53 @@ export interface BurnRequestOptions {
|
|
|
37
114
|
export interface BurnRequestResult extends SubmitResult {
|
|
38
115
|
readonly reference: string;
|
|
39
116
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
readonly
|
|
44
|
-
/** The wallet party's open DA burn requests; `[]` when the registry is not DA's. */
|
|
45
|
-
readonly burnRequests: BurnRequest[];
|
|
117
|
+
export interface TransferPreapprovalOptions {
|
|
118
|
+
readonly instrumentAdmin: string;
|
|
119
|
+
/** Up to 10 instrument ids of the admin; empty or omitted: every instrument of the admin. */
|
|
120
|
+
readonly instrumentIds?: readonly string[];
|
|
46
121
|
}
|
|
47
122
|
/**
|
|
48
|
-
* A wallet party's token actions through a CIP-0103 provider
|
|
49
|
-
* and DA's mint, burn and preapproval actions when the registry is DA's Utility Registry client. With another registry
|
|
50
|
-
* those DA actions are refused with `unsupported-by-registry` (before anything is read or signed), and `loadState`
|
|
51
|
-
* gives empty DA lists; `isDaUtilitiesClient` tells which registry a wallet has.
|
|
123
|
+
* A wallet party's DA Utility Registry token actions through a CIP-0103 provider.
|
|
52
124
|
*
|
|
53
|
-
* One write
|
|
54
|
-
*
|
|
55
|
-
* limited.
|
|
56
|
-
*
|
|
57
|
-
* Reads: `loadState` and the `list*` methods all read one snapshot (one ledger-end call and one paged ACS stream with
|
|
58
|
-
* every filter the wallet needs; a registry that declares no `pendingTransferFilters` costs one more ACS stream, read
|
|
59
|
-
* at the same offset), and calls made while a snapshot is in flight share it instead of reading again, unless a write
|
|
60
|
-
* settled since it started. Load a page with `loadState`; writes do their own fresh reads.
|
|
125
|
+
* One write at a time: a write started while another is in progress (from its first read to its submission's outcome)
|
|
126
|
+
* is refused at once with `busy`, so two writes never pick the same holdings. `loadState` and `planTransfer` are reads
|
|
127
|
+
* and are not limited.
|
|
61
128
|
*/
|
|
62
|
-
export interface Wallet
|
|
129
|
+
export interface Wallet {
|
|
130
|
+
readonly partyId: string;
|
|
131
|
+
readonly network: DaNetwork;
|
|
63
132
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
133
|
+
* One ledger snapshot: holdings and balances, transfer offers (incoming and outgoing), mint offers, burn requests and
|
|
134
|
+
* transfer preapprovals (one ledger-end call and one ACS read). Calls made while a snapshot is in flight share it,
|
|
135
|
+
* unless a write settled since it started.
|
|
67
136
|
*/
|
|
68
137
|
loadState(): Promise<WalletState>;
|
|
138
|
+
/** How the registry would run a transfer, kept to submit once the user confirmed it (see {@link TransferPlan}). */
|
|
139
|
+
planTransfer(request: TransferRequest): Promise<TransferPlan>;
|
|
140
|
+
acceptTransferOffer(transferOfferCid: string): Promise<SubmitResult>;
|
|
141
|
+
rejectTransferOffer(transferOfferCid: string): Promise<SubmitResult>;
|
|
142
|
+
/** Withdraw one of the party's own transfer offers, which unlocks its tokens (also after the offer expired). */
|
|
143
|
+
withdrawTransferOffer(transferOfferCid: string): Promise<SubmitResult>;
|
|
144
|
+
acceptMintOffer(mintOfferCid: string): Promise<SubmitResult>;
|
|
145
|
+
/** Reject a mint offer; the registrar sees {@link MINT_OFFER_REJECT_REASON}. */
|
|
146
|
+
rejectMintOffer(mintOfferCid: string): Promise<SubmitResult>;
|
|
69
147
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Accept a DA mint offer. Needs DA's Utility Registry client (`network`, or `registry:
|
|
76
|
-
* createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
|
|
77
|
-
*/
|
|
78
|
-
acceptMintOffer(mintOfferCid: string, options?: {
|
|
79
|
-
expectedRegistrar?: string;
|
|
80
|
-
}): Promise<SubmitResult>;
|
|
81
|
-
/**
|
|
82
|
-
* File a burn (redemption) request; DA locks the amount until the registrar accepts or rejects it. Resolves with the
|
|
83
|
-
* reference it was filed with, so a dApp can show it. If the submission fails, the `WalletSubmitError` carries that
|
|
84
|
-
* reference too (`burnReference`, and in its message): after an `unknown` outcome, find the burn request by it before
|
|
85
|
-
* filing another, or the amount may be locked twice. Needs DA's Utility Registry client (`network`, or `registry:
|
|
86
|
-
* createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
|
|
148
|
+
* File a burn (redemption) request; DA locks the amount until the registrar accepts or rejects it, or the holder
|
|
149
|
+
* cancels it. Resolves with the reference it was filed with. If the submission fails, the `WalletSubmitError` carries
|
|
150
|
+
* that reference too (`burnReference`, and in its message): after an `unknown` outcome, find the burn request by it
|
|
151
|
+
* before filing another, or the amount may be locked twice.
|
|
87
152
|
*/
|
|
88
153
|
requestBurn(options: BurnRequestOptions): Promise<BurnRequestResult>;
|
|
154
|
+
/** Cancel one of the party's open burn requests; DA unlocks the amount. */
|
|
155
|
+
cancelBurnRequest(burnRequestCid: string): Promise<SubmitResult>;
|
|
89
156
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* Utility Registry client (`network`, or `registry: createDaUtilitiesClient(...)`); refused with
|
|
93
|
-
* `unsupported-by-registry` otherwise.
|
|
157
|
+
* Create the party's transfer preapproval for an instrument admin, so transfers of those instruments to the party
|
|
158
|
+
* complete at once. Refused with `already-exists` when one of the party's preapprovals already covers them.
|
|
94
159
|
*/
|
|
95
|
-
createTransferPreapproval(options:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}): Promise<SubmitResult>;
|
|
99
|
-
/**
|
|
100
|
-
* The wallet party's open burn requests (pending redemptions). Needs DA's Utility Registry client (`network`, or
|
|
101
|
-
* `registry: createDaUtilitiesClient(...)`); refused with `unsupported-by-registry` otherwise.
|
|
102
|
-
*/
|
|
103
|
-
listBurnRequests(): Promise<BurnRequest[]>;
|
|
160
|
+
createTransferPreapproval(options: TransferPreapprovalOptions): Promise<SubmitResult>;
|
|
161
|
+
/** Withdraw one of the party's transfer preapprovals. */
|
|
162
|
+
removeTransferPreapproval(preapprovalCid: string): Promise<SubmitResult>;
|
|
104
163
|
}
|
|
105
|
-
/**
|
|
106
|
-
* A `Wallet` over a CIP-0103 provider: the CIP-56 actions with any `TokenRegistry`, and DA's actions too with DA's
|
|
107
|
-
* Utility Registry client (`network`, or `registry: createDaUtilitiesClient(...)`).
|
|
108
|
-
*/
|
|
164
|
+
/** The DA Registry token actions of `options.partyId` through `options.provider`. */
|
|
109
165
|
export declare function createWallet(options: WalletOptions): Wallet;
|
|
110
166
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallets/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallets/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAGL,KAAK,cAAc,EAEnB,KAAK,sBAAsB,EAC5B,MAAM,UAAU,CAAC;AAclB,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,iBAAiB,EAGtB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAoD,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpH,OAAO,KAAK,EAAkB,YAAY,EAAE,YAAY,EAAoB,MAAM,SAAS,CAAC;AAc5F,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,QAAuC,CAAC;AAC3E,2GAA2G;AAC3G,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAmBjE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAGlD;AAED,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;OAIG;IACH,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