@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,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_WALLET_OWNERSHIP_CLOCK_SKEW_MS = exports.DEFAULT_WALLET_OWNERSHIP_MAX_AGE_MS = void 0;
|
|
4
|
+
exports.verifyWalletOwnership = verifyWalletOwnership;
|
|
5
|
+
/**
|
|
6
|
+
* Server-side verification of a wallet ownership proof (`proveWalletOwnership` in the browser-safe wallets module).
|
|
7
|
+
* Node only: it uses `node:crypto` through the Canton signing helpers, so it is not exported from the wallets entry.
|
|
8
|
+
*
|
|
9
|
+
* What a `verified` result means: the party's own key signed the canonical message for this domain and this nonce,
|
|
10
|
+
* within its validity window. It rests on two facts this function checks itself, trusting nothing the browser says:
|
|
11
|
+
*
|
|
12
|
+
* 1. The Ed25519 signature over the UTF-8 bytes of the message verifies against the submitted public key.
|
|
13
|
+
* 2. The Canton fingerprint of that key (`1220` + SHA-256 of purpose 12 and the raw key) is the party's namespace (the
|
|
14
|
+
* part of the party id after `::`), which is how an external party's id is derived from its key. Loop's parties and
|
|
15
|
+
* the CIP-0103 reference wallet's are external parties of this kind.
|
|
16
|
+
*
|
|
17
|
+
* A party whose namespace is not its signing key's fingerprint (a participant-hosted party, an external party whose key
|
|
18
|
+
* was rotated, or a namespace delegation) fails with `key-not-bound-to-party`. Proving those would need the party's
|
|
19
|
+
* current topology from the ledger (its `PartyToKeyMapping` signing keys, and the namespace delegations that authorize
|
|
20
|
+
* them), which this function does not read.
|
|
21
|
+
*
|
|
22
|
+
* The caller must issue the nonce, store it, pass it as `expectedNonce`, and accept it once: this function cannot tell
|
|
23
|
+
* a replayed proof from a fresh one. Passing the issued times as `expectedIssuedAt` and `expectedExpiresAt` makes the
|
|
24
|
+
* signed text exactly the issued challenge.
|
|
25
|
+
*
|
|
26
|
+
* The message's `Network:` line (`expectedNetwork`, the result's `network`) is checked as text only. A party id is
|
|
27
|
+
* derived from its key and is the same on every network, so a verified proof does not show the party exists or is
|
|
28
|
+
* hosted on that network; a caller that needs that must look the party up on the network (Scan, or the ledger's party
|
|
29
|
+
* and topology APIs).
|
|
30
|
+
*/
|
|
31
|
+
const canton_protocol_1 = require("./canton-protocol");
|
|
32
|
+
const canton_ed25519_signer_1 = require("./canton-ed25519-signer");
|
|
33
|
+
const ownership_1 = require("../../wallets/ownership");
|
|
34
|
+
exports.DEFAULT_WALLET_OWNERSHIP_MAX_AGE_MS = 10 * 60 * 1000;
|
|
35
|
+
exports.DEFAULT_WALLET_OWNERSHIP_CLOCK_SKEW_MS = 60 * 1000;
|
|
36
|
+
const ED25519_DER_PREFIX_HEX = '302a300506032b6570032100';
|
|
37
|
+
/**
|
|
38
|
+
* The key as base64 for the Canton helpers: 64 hex characters (raw, as Loop registers it), 88 hex characters (DER
|
|
39
|
+
* SubjectPublicKeyInfo), a PEM public key, or base64/base64url of the raw or DER key (as the CIP-0103 reference wallet
|
|
40
|
+
* sends it). The helpers then accept only a 32-byte key or the exact Ed25519 DER prefix.
|
|
41
|
+
*/
|
|
42
|
+
function publicKeyBase64(value) {
|
|
43
|
+
const trimmed = value.trim();
|
|
44
|
+
const hex = trimmed.replace(/^0x/i, '');
|
|
45
|
+
if (/^[0-9a-fA-F]+$/.test(hex) &&
|
|
46
|
+
(hex.length === 64 || (hex.length === 88 && hex.toLowerCase().startsWith(ED25519_DER_PREFIX_HEX)))) {
|
|
47
|
+
return Buffer.from(hex, 'hex').toString('base64');
|
|
48
|
+
}
|
|
49
|
+
const pem = /^-----BEGIN PUBLIC KEY-----\s*([A-Za-z0-9+/=\s]+?)\s*-----END PUBLIC KEY-----$/.exec(trimmed);
|
|
50
|
+
return pem?.[1] !== undefined ? pem[1].replace(/\s+/g, '') : trimmed;
|
|
51
|
+
}
|
|
52
|
+
/** The signature as base64: 128 hex characters (Loop) or base64/base64url (the reference wallet), 64 bytes either way. */
|
|
53
|
+
function signatureBase64(value) {
|
|
54
|
+
const hex = value.trim().replace(/^0x/i, '');
|
|
55
|
+
if (/^[0-9a-fA-F]{128}$/.test(hex))
|
|
56
|
+
return (0, canton_ed25519_signer_1.normalizeCantonEd25519Signature)({ signatureHex: hex });
|
|
57
|
+
return (0, canton_ed25519_signer_1.normalizeCantonEd25519Signature)({ signatureBase64: value });
|
|
58
|
+
}
|
|
59
|
+
function readProof(proof) {
|
|
60
|
+
if (typeof proof !== 'object' || proof === null)
|
|
61
|
+
return null;
|
|
62
|
+
const record = proof;
|
|
63
|
+
const { partyId, publicKey, namespace, message, signature } = record;
|
|
64
|
+
if (typeof partyId !== 'string' ||
|
|
65
|
+
typeof publicKey !== 'string' ||
|
|
66
|
+
typeof message !== 'string' ||
|
|
67
|
+
typeof signature !== 'string' ||
|
|
68
|
+
(namespace !== undefined && typeof namespace !== 'string') ||
|
|
69
|
+
publicKey.length > 1024 ||
|
|
70
|
+
signature.length > 1024) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return { partyId, publicKey, message, signature, ...(namespace !== undefined && { namespace }) };
|
|
74
|
+
}
|
|
75
|
+
const fail = (reason, message) => ({
|
|
76
|
+
verified: false,
|
|
77
|
+
reason,
|
|
78
|
+
message,
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Verify a wallet ownership proof (see the module comment for what this does and does not establish). Never throws for
|
|
82
|
+
* a bad proof: the result says why it failed. Throws `TypeError` for invalid options.
|
|
83
|
+
*/
|
|
84
|
+
function verifyWalletOwnership(proof, options) {
|
|
85
|
+
const maxAgeMs = options.maxAgeMs ?? exports.DEFAULT_WALLET_OWNERSHIP_MAX_AGE_MS;
|
|
86
|
+
const skewMs = options.clockSkewMs ?? exports.DEFAULT_WALLET_OWNERSHIP_CLOCK_SKEW_MS;
|
|
87
|
+
const now = (options.now ?? new Date()).getTime();
|
|
88
|
+
if (typeof options.expectedNonce !== 'string' || options.expectedNonce.length === 0) {
|
|
89
|
+
throw new TypeError('expectedNonce is required');
|
|
90
|
+
}
|
|
91
|
+
if (typeof options.expectedDomain !== 'string' || options.expectedDomain.length === 0) {
|
|
92
|
+
throw new TypeError('expectedDomain is required');
|
|
93
|
+
}
|
|
94
|
+
if (!Number.isFinite(now) || !(maxAgeMs > 0) || !(skewMs >= 0)) {
|
|
95
|
+
throw new TypeError('now, maxAgeMs and clockSkewMs must be valid');
|
|
96
|
+
}
|
|
97
|
+
const read = readProof(proof);
|
|
98
|
+
if (read === null)
|
|
99
|
+
return fail('malformed-proof', 'The proof is not { partyId, publicKey, message, signature }');
|
|
100
|
+
const fields = (0, ownership_1.parseWalletOwnershipMessage)(read.message);
|
|
101
|
+
if (fields === null)
|
|
102
|
+
return fail('malformed-message', 'The signed text is not a canonical wallet ownership message');
|
|
103
|
+
if (fields.partyId !== read.partyId) {
|
|
104
|
+
return fail('party-mismatch', 'The signed message names another party than the proof');
|
|
105
|
+
}
|
|
106
|
+
if (options.expectedPartyId !== undefined && read.partyId !== options.expectedPartyId) {
|
|
107
|
+
return fail('party-mismatch', 'The proof is for another party than expected');
|
|
108
|
+
}
|
|
109
|
+
const partyNamespace = read.partyId.slice(read.partyId.indexOf('::') + 2);
|
|
110
|
+
if (read.namespace !== undefined && read.namespace !== partyNamespace) {
|
|
111
|
+
return fail('party-mismatch', "The wallet's namespace is not the party id's namespace");
|
|
112
|
+
}
|
|
113
|
+
if (fields.domain !== options.expectedDomain) {
|
|
114
|
+
return fail('domain-mismatch', `The message was signed for ${fields.domain}, not ${options.expectedDomain}`);
|
|
115
|
+
}
|
|
116
|
+
if (fields.nonce !== options.expectedNonce) {
|
|
117
|
+
return fail('nonce-mismatch', 'The message was signed for another challenge');
|
|
118
|
+
}
|
|
119
|
+
if (options.expectedNetwork !== undefined && fields.network !== options.expectedNetwork) {
|
|
120
|
+
return fail('network-mismatch', `The message names network ${fields.network ?? '(none)'}, not ${options.expectedNetwork}`);
|
|
121
|
+
}
|
|
122
|
+
if ((options.expectedIssuedAt !== undefined && fields.issuedAt !== options.expectedIssuedAt) ||
|
|
123
|
+
(options.expectedExpiresAt !== undefined && fields.expiresAt !== options.expectedExpiresAt)) {
|
|
124
|
+
return fail('window-mismatch', 'The message names another validity window than the server issued');
|
|
125
|
+
}
|
|
126
|
+
const issuedAt = Date.parse(fields.issuedAt);
|
|
127
|
+
const expiresAt = Date.parse(fields.expiresAt);
|
|
128
|
+
if (issuedAt > now + skewMs)
|
|
129
|
+
return fail('not-yet-valid', 'The message was issued in the future');
|
|
130
|
+
if (expiresAt - issuedAt > maxAgeMs) {
|
|
131
|
+
return fail('lifetime-too-long', `The message is valid for longer than ${maxAgeMs} ms`);
|
|
132
|
+
}
|
|
133
|
+
// With the lifetime bounded above, this also bounds the message's age by maxAgeMs.
|
|
134
|
+
if (now >= expiresAt)
|
|
135
|
+
return fail('expired', 'The message has expired');
|
|
136
|
+
let fingerprint;
|
|
137
|
+
let keyBase64;
|
|
138
|
+
try {
|
|
139
|
+
keyBase64 = publicKeyBase64(read.publicKey);
|
|
140
|
+
fingerprint = (0, canton_protocol_1.deriveCantonEd25519PublicKeyFingerprint)(keyBase64);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return fail('unsupported-public-key', 'The public key is not an Ed25519 key in hex, base64 (raw 32 bytes or DER SubjectPublicKeyInfo) or PEM');
|
|
144
|
+
}
|
|
145
|
+
let partyFingerprint;
|
|
146
|
+
try {
|
|
147
|
+
partyFingerprint = (0, canton_protocol_1.extractPublicKeyFingerprint)(read.partyId);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return fail('party-mismatch', 'The party id is not of the form hint::namespace');
|
|
151
|
+
}
|
|
152
|
+
if (partyFingerprint !== fingerprint) {
|
|
153
|
+
return fail('key-not-bound-to-party', "The public key's Canton fingerprint is not the party's namespace, so the key does not prove control of the party (a participant-hosted party, or a rotated or delegated key, needs a topology lookup)");
|
|
154
|
+
}
|
|
155
|
+
let signature;
|
|
156
|
+
try {
|
|
157
|
+
signature = signatureBase64(read.signature);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return fail('malformed-signature', 'The signature is not 64 bytes of hex or base64');
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
(0, canton_protocol_1.assertEd25519Signature)({ publicKeyBase64: keyBase64, payload: read.message, signatureBase64: signature });
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return fail('bad-signature', 'The signature does not verify against the public key');
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
verified: true,
|
|
170
|
+
partyId: read.partyId,
|
|
171
|
+
publicKeyFingerprint: fingerprint,
|
|
172
|
+
domain: fields.domain,
|
|
173
|
+
nonce: fields.nonce,
|
|
174
|
+
...(fields.network !== undefined && { network: fields.network }),
|
|
175
|
+
issuedAt: fields.issuedAt,
|
|
176
|
+
expiresAt: fields.expiresAt,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=wallet-ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-ownership.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-ownership.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,uDAI2B;AAC3B,mEAA0E;AAC1E,uDAAsE;AAwEzD,QAAA,mCAAmC,GAAG,EAAE,GAAG,EAAE,GAAG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MAAM,CAAC;QACP,OAAO,IAAI,CAAC,eAAe,EAAE,sDAAsD,CAAC,CAAC;IACvF,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,oBAAoB,EAAE,WAAW;QACjC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QAChE,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -16,6 +16,8 @@ export declare const TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = "#spl
|
|
|
16
16
|
export declare const TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = "#splice-api-token-allocation-instruction-v1:Splice.Api.Token.AllocationInstructionV1:AllocationFactory";
|
|
17
17
|
/** Exercise target for the three choices on a settled or unwinding allocation. */
|
|
18
18
|
export declare const TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = "#splice-api-token-allocation-v1:Splice.Api.Token.AllocationV1:Allocation";
|
|
19
|
+
/** The metadata key CIP-56 uses for a transfer's (or a mint's or burn's) reason, shown to the receiver as its memo. */
|
|
20
|
+
export declare const TOKEN_STANDARD_V1_REASON_META_KEY = "splice.lfdecentralizedtrust.org/reason";
|
|
19
21
|
/** Choice names as the Ledger JSON API spells them in an `ExerciseCommand`. */
|
|
20
22
|
export declare const TokenStandardV1Choice: {
|
|
21
23
|
readonly burnMint: 'BurnMintFactory_BurnMint';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MA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AAyC,EAAE,SAAS,MAAM,EAItE,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,sCAAsC,oEAAoE,CAAC;AAExH,sGAAsG;AACtG,eAAO,MAAM,gDAAgD,+EACiB,CAAC;AAE/E,sDAAsD;AACtD,eAAO,MAAM,+CAA+C,qGACwC,CAAC;AAErG,wEAAwE;AACxE,eAAO,MAAM,mDAAmD,yGACwC,CAAC;AAEzG,wDAAwD;AACxD,eAAO,MAAM,iDAAiD,2GAC4C,CAAC;AAE3G,kFAAkF;AAClF,eAAO,MAAM,yCAAyC,6EACsB,CAAC;AAE7E,uHAAuH;AACvH,eAAO,MAAM,iCAAiC,2CAA2C,CAAC;AAE1F,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB;aAChC,QAAQ,EAAE,0BAA0B;aACpC,QAAQ,EAAE,0BAA0B;aACpC,yBAAyB,EAAE,4BAA4B;aACvD,yBAAyB,EAAE,4BAA4B;aACvD,2BAA2B,EAAE,8BAA8B;aAC3D,yBAAyB,EAAE,4BAA4B;aACvD,QAAQ,EAAE,4BAA4B;aACtC,yBAAyB,EAAE,4BAA4B;aACvD,gBAAgB,EAAE,mBAAmB;aACrC,kBAAkB,EAAE,qBAAqB;CACjC,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAE3G;;;GAGG;AACH,eAAO,MAAM,yCAAyC,EAAE,SAAS,MAAM,EAMtE,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,gCAAgC;aAC3C,SAAS,EAAE,qCAAqC;aAChD,OAAO,EAAE,mCAAmC;aAC5C,MAAM,EAAE,kCAAkC;CAClC,CAAC;AAEX,eAAO,MAAM,sCAAsC,EAAE,SAAS,MAAM,EAEnE,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,kCAAkC;aAC7C,SAAS,EAAE,uCAAuC;aAClD,OAAO,EAAE,qCAAqC;aAC9C,MAAM,EAAE,oCAAoC;CACpC,CAAC;AAEX,eAAO,MAAM,wCAAwC,EAAE,SAAS,MAAM,EAErE,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,yCAAyC,EAAE,SAAS,MAAM,EAItE,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* keeps them stable across DAR upgrades.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES = exports.TOKEN_STANDARD_V1_ALLOCATION_RESULT_TAGS = exports.TokenStandardV1AllocationResultTag = exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_TAGS = exports.TokenStandardV1TransferResultTag = exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_CHOICES = exports.TokenStandardV1Choice = exports.TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = exports.TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = exports.TOKEN_STANDARD_V1_TRANSFER_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_BURN_MINT_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID = void 0;
|
|
10
|
+
exports.TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES = exports.TOKEN_STANDARD_V1_ALLOCATION_RESULT_TAGS = exports.TokenStandardV1AllocationResultTag = exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_TAGS = exports.TokenStandardV1TransferResultTag = exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_CHOICES = exports.TokenStandardV1Choice = exports.TOKEN_STANDARD_V1_REASON_META_KEY = exports.TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = exports.TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = exports.TOKEN_STANDARD_V1_TRANSFER_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_BURN_MINT_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID = void 0;
|
|
11
11
|
exports.TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID = '#splice-api-token-holding-v1:Splice.Api.Token.HoldingV1:Holding';
|
|
12
12
|
/** Exercise target for `BurnMintFactory_BurnMint`, which every mint, burn and redeem goes through. */
|
|
13
13
|
exports.TOKEN_STANDARD_V1_BURN_MINT_FACTORY_INTERFACE_ID = '#splice-api-token-burn-mint-v1:Splice.Api.Token.BurnMintV1:BurnMintFactory';
|
|
@@ -19,6 +19,8 @@ exports.TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = '#splice-api-token
|
|
|
19
19
|
exports.TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = '#splice-api-token-allocation-instruction-v1:Splice.Api.Token.AllocationInstructionV1:AllocationFactory';
|
|
20
20
|
/** Exercise target for the three choices on a settled or unwinding allocation. */
|
|
21
21
|
exports.TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = '#splice-api-token-allocation-v1:Splice.Api.Token.AllocationV1:Allocation';
|
|
22
|
+
/** The metadata key CIP-56 uses for a transfer's (or a mint's or burn's) reason, shown to the receiver as its memo. */
|
|
23
|
+
exports.TOKEN_STANDARD_V1_REASON_META_KEY = 'splice.lfdecentralizedtrust.org/reason';
|
|
22
24
|
/** Choice names as the Ledger JSON API spells them in an `ExerciseCommand`. */
|
|
23
25
|
exports.TokenStandardV1Choice = {
|
|
24
26
|
burnMint: 'BurnMintFactory_BurnMint',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"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AS,EAAE,uCAAuC;IAClD,OAAO,EAAE,qCAAqC;IAC9C,MAAM,EAAE,oCAAoC;CACpC,CAAC;AAEE,QAAA,wCAAwC,GAAsB,MAAM,CAAC,MAAM,CACtF,QAAA,kCAAkC,CACnC,CAAC;AAEF,kGAAkG;AACrF,QAAA,yCAAyC,GAAsB;IAC1E,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,gBAAgB;IACtC,QAAA,qBAAqB,CAAC,kBAAkB;CACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/constants.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEU,QAAA,sCAAsC,GAAG,iEAAiE,CAAC;AAExH,sGAAsG;AACzF,QAAA,gDAAgD,GAC3D,4EAA4E,CAAC;AAE/E,sDAAsD;AACzC,QAAA,+CAA+C,GAC1D,kGAAkG,CAAC;AAErG,wEAAwE;AAC3D,QAAA,mDAAmD,GAC9D,sGAAsG,CAAC;AAEzG,wDAAwD;AAC3C,QAAA,iDAAiD,GAC5D,wGAAwG,CAAC;AAE3G,kFAAkF;AACrE,QAAA,yCAAyC,GACpD,0EAA0E,CAAC;AAE7E,uHAAuH;AAC1G,QAAA,iCAAiC,GAAG,wCAAwC,CAAC;AAE1F,+EAA+E;AAClE,QAAA,qBAAqB,GAAG;IACnC,QAAQ,EAAE,0BAA0B;IACpC,QAAQ,EAAE,0BAA0B;IACpC,yBAAyB,EAAE,4BAA4B;IACvD,yBAAyB,EAAE,4BAA4B;IACvD,2BAA2B,EAAE,8BAA8B;IAC3D,yBAAyB,EAAE,4BAA4B;IACvD,QAAQ,EAAE,4BAA4B;IACtC,yBAAyB,EAAE,4BAA4B;IACvD,gBAAgB,EAAE,mBAAmB;IACrC,kBAAkB,EAAE,qBAAqB;CACjC,CAAC;AAIX;;;GAGG;AACU,QAAA,yCAAyC,GAAsB;IAC1E,QAAA,qBAAqB,CAAC,QAAQ;IAC9B,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,2BAA2B;IACjD,QAAA,qBAAqB,CAAC,yBAAyB;CAChD,CAAC;AAEF,kFAAkF;AACrE,QAAA,gCAAgC,GAAG;IAC9C,SAAS,EAAE,qCAAqC;IAChD,OAAO,EAAE,mCAAmC;IAC5C,MAAM,EAAE,kCAAkC;CAClC,CAAC;AAEE,QAAA,sCAAsC,GAAsB,MAAM,CAAC,MAAM,CACpF,QAAA,gCAAgC,CACjC,CAAC;AAEF,oFAAoF;AACvE,QAAA,kCAAkC,GAAG;IAChD,SAAS,EAAE,uCAAuC;IAClD,OAAO,EAAE,qCAAqC;IAC9C,MAAM,EAAE,oCAAoC;CACpC,CAAC;AAEE,QAAA,wCAAwC,GAAsB,MAAM,CAAC,MAAM,CACtF,QAAA,kCAAkC,CACnC,CAAC;AAEF,kGAAkG;AACrF,QAAA,yCAAyC,GAAsB;IAC1E,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,gBAAgB;IACtC,QAAA,qBAAqB,CAAC,kBAAkB;CACzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ActiveContract } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* One ACS entry as an `ActiveContract`, or null for entries that are not active contracts (`JsIncompleteAssigned`,
|
|
4
|
+
* `JsIncompleteUnassigned`, `JsEmpty`). Throws on an entry this parser does not recognise.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseActiveContractEntry(entry: unknown): ActiveContract | null;
|
|
7
|
+
/** Every active contract in a list of ACS entries. */
|
|
8
|
+
export declare function parseActiveContractEntries(entries: readonly unknown[]): ActiveContract[];
|
|
9
|
+
//# sourceMappingURL=acs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acs.d.ts","sourceRoot":"","sources":["../../../src/wallets/acs.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAkC7D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CA6B9E;AAED,sDAAsD;AACtD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,cAAc,EAAE,CAKxF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseActiveContractEntry = parseActiveContractEntry;
|
|
4
|
+
exports.parseActiveContractEntries = parseActiveContractEntries;
|
|
5
|
+
/**
|
|
6
|
+
* Parse Ledger JSON API v2 active-contract entries (`JsGetActiveContractsResponse`), read through the wallet's CIP-0103
|
|
7
|
+
* `ledgerApi`.
|
|
8
|
+
*/
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
const json_1 = require("./json");
|
|
11
|
+
/** A view the ledger computed: no `viewStatus`, or a status code of 0. */
|
|
12
|
+
function viewSucceeded(view) {
|
|
13
|
+
const status = view['viewStatus'];
|
|
14
|
+
if (status === undefined || status === null)
|
|
15
|
+
return true;
|
|
16
|
+
if (!(0, json_1.isRecord)(status))
|
|
17
|
+
return false;
|
|
18
|
+
const { code } = status;
|
|
19
|
+
return code === undefined || code === 0 || code === '0';
|
|
20
|
+
}
|
|
21
|
+
function parseInterfaceViews(value) {
|
|
22
|
+
if (!Array.isArray(value))
|
|
23
|
+
return [];
|
|
24
|
+
const views = [];
|
|
25
|
+
for (const view of value) {
|
|
26
|
+
if (!(0, json_1.isRecord)(view) || !viewSucceeded(view))
|
|
27
|
+
continue;
|
|
28
|
+
const interfaceId = (0, json_1.nonEmptyString)(view['interfaceId']);
|
|
29
|
+
const { viewValue } = view;
|
|
30
|
+
if (interfaceId !== undefined && (0, json_1.isJsonObject)(viewValue)) {
|
|
31
|
+
views.push({ interfaceId, viewValue });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return views;
|
|
35
|
+
}
|
|
36
|
+
/** A party list; anything else reads as no parties, so a contract without signatories counts as signed by no one. */
|
|
37
|
+
function parseParties(value) {
|
|
38
|
+
if (!Array.isArray(value))
|
|
39
|
+
return [];
|
|
40
|
+
return value.flatMap((party) => {
|
|
41
|
+
const id = (0, json_1.nonEmptyString)(party);
|
|
42
|
+
return id === undefined ? [] : [id];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One ACS entry as an `ActiveContract`, or null for entries that are not active contracts (`JsIncompleteAssigned`,
|
|
47
|
+
* `JsIncompleteUnassigned`, `JsEmpty`). Throws on an entry this parser does not recognise.
|
|
48
|
+
*/
|
|
49
|
+
function parseActiveContractEntry(entry) {
|
|
50
|
+
if (!(0, json_1.isRecord)(entry) || !(0, json_1.isRecord)(entry['contractEntry'])) {
|
|
51
|
+
throw new errors_1.WalletReadError('The wallet returned an active-contract entry without contractEntry');
|
|
52
|
+
}
|
|
53
|
+
const active = entry['contractEntry']['JsActiveContract'];
|
|
54
|
+
if (active === undefined)
|
|
55
|
+
return null;
|
|
56
|
+
const created = (0, json_1.isRecord)(active) ? active['createdEvent'] : undefined;
|
|
57
|
+
if (!(0, json_1.isRecord)(created)) {
|
|
58
|
+
throw new errors_1.WalletReadError('The wallet returned an active contract without createdEvent');
|
|
59
|
+
}
|
|
60
|
+
const contractId = (0, json_1.nonEmptyString)(created['contractId']);
|
|
61
|
+
const templateId = (0, json_1.nonEmptyString)(created['templateId']);
|
|
62
|
+
if (contractId === undefined || templateId === undefined) {
|
|
63
|
+
throw new errors_1.WalletReadError('The wallet returned an active contract without contractId or templateId');
|
|
64
|
+
}
|
|
65
|
+
const { createArgument } = created;
|
|
66
|
+
const createdEventBlob = (0, json_1.nonEmptyString)(created['createdEventBlob']);
|
|
67
|
+
const packageName = (0, json_1.nonEmptyString)(created['packageName']);
|
|
68
|
+
const synchronizerId = (0, json_1.isRecord)(active) ? (0, json_1.nonEmptyString)(active['synchronizerId']) : undefined;
|
|
69
|
+
return {
|
|
70
|
+
contractId,
|
|
71
|
+
templateId,
|
|
72
|
+
...(packageName !== undefined && { packageName }),
|
|
73
|
+
signatories: parseParties(created['signatories']),
|
|
74
|
+
createArgument: (0, json_1.isJsonObject)(createArgument) ? createArgument : null,
|
|
75
|
+
interfaceViews: parseInterfaceViews(created['interfaceViews']),
|
|
76
|
+
...(createdEventBlob !== undefined && { createdEventBlob }),
|
|
77
|
+
...(synchronizerId !== undefined && { synchronizerId }),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Every active contract in a list of ACS entries. */
|
|
81
|
+
function parseActiveContractEntries(entries) {
|
|
82
|
+
return entries.flatMap((entry) => {
|
|
83
|
+
const contract = parseActiveContractEntry(entry);
|
|
84
|
+
return contract === null ? [] : [contract];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=acs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acs.js","sourceRoot":"","sources":["../../../src/wallets/acs.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,qCAA2C;AAC3C,iCAAgE;AAGhE,0EAA0E;AAC1E,SAAS,aAAa,CAAC,IAA6B;IAClD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,CAAC,IAAA,eAAQ,EAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACxB,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,GAAG,CAAC;AAC1D,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,CAAC,KAAK,CAA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E,cAAc,EAAE,mBAAmB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC9D,GAAG,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,CAAC;QAC3D,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,EAAE,cAAc,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC;AAED,sDAAsD;AACtD,oCAA2C,OAA2B;IACpE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/B,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;QACjD,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { WalletSubmitError } from './errors';
|
|
2
|
+
import type { ActiveContract, ContractFilter, DisclosedContract, LedgerCommand, SubmitResult, WalletSubmission } from './types';
|
|
3
|
+
/** `prepareExecuteAndWait` params (the OpenRPC's `JsPrepareSubmissionRequest`), as far as this SDK sends them. */
|
|
4
|
+
export type Cip103PrepareExecuteParams = {
|
|
5
|
+
commandId?: string;
|
|
6
|
+
commands: LedgerCommand[];
|
|
7
|
+
disclosedContracts?: DisclosedContract[];
|
|
8
|
+
actAs?: string[];
|
|
9
|
+
};
|
|
10
|
+
/** `ledgerApi` params (the OpenRPC's `LedgerApiRequest`), as far as this SDK sends them. */
|
|
11
|
+
export type Cip103LedgerApiParams = {
|
|
12
|
+
requestMethod: 'get' | 'post';
|
|
13
|
+
resource: string;
|
|
14
|
+
body?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/** `signMessage` params (the OpenRPC's `SignMessageRequest`). */
|
|
17
|
+
export type Cip103SignMessageParams = {
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
/** The dApp API requests this SDK makes, each in CIP-0103's `{ method, params }` form. */
|
|
21
|
+
export type Cip103Request = {
|
|
22
|
+
method: 'getPrimaryAccount';
|
|
23
|
+
} | {
|
|
24
|
+
method: 'ledgerApi';
|
|
25
|
+
params: Cip103LedgerApiParams;
|
|
26
|
+
} | {
|
|
27
|
+
method: 'prepareExecuteAndWait';
|
|
28
|
+
params: Cip103PrepareExecuteParams;
|
|
29
|
+
} | {
|
|
30
|
+
method: 'signMessage';
|
|
31
|
+
params: Cip103SignMessageParams;
|
|
32
|
+
};
|
|
33
|
+
/** An event listener of CIP-0103's Provider API. */
|
|
34
|
+
export type Cip103EventListener = (...args: unknown[]) => void;
|
|
35
|
+
/**
|
|
36
|
+
* A CIP-0103 provider (the CIP's EIP-1193 Provider API), as far as this SDK uses it: `request` for the methods in
|
|
37
|
+
* {@link Cip103Request}, plus `on` and `removeListener` (the SDK never emits). Structural, so any conforming provider
|
|
38
|
+
* fits whatever SDK built it: Loop's `loop.getCip103Provider()`, `@canton-network/dapp-sdk`'s `Provider`,
|
|
39
|
+
* `window.canton`. Results are validated, never trusted.
|
|
40
|
+
*/
|
|
41
|
+
export interface Cip103Provider {
|
|
42
|
+
request(args: Cip103Request): Promise<unknown>;
|
|
43
|
+
on(event: string, listener: Cip103EventListener): unknown;
|
|
44
|
+
removeListener(event: string, listener: Cip103EventListener): unknown;
|
|
45
|
+
}
|
|
46
|
+
/** CIP-0103 error codes (EIP-1193 and EIP-1474), as `ProviderRpcError.code`. */
|
|
47
|
+
export declare const CIP103_ERROR_CODES: {
|
|
48
|
+
readonly userRejected: 4001;
|
|
49
|
+
readonly unauthorized: 4100;
|
|
50
|
+
readonly unsupportedMethod: 4200;
|
|
51
|
+
readonly disconnected: 4900;
|
|
52
|
+
readonly chainDisconnected: 4901;
|
|
53
|
+
readonly parseError: -32700;
|
|
54
|
+
readonly invalidRequest: -32600;
|
|
55
|
+
readonly methodNotFound: -32601;
|
|
56
|
+
readonly invalidParams: -32602;
|
|
57
|
+
readonly internalError: -32603;
|
|
58
|
+
readonly invalidInput: -32000;
|
|
59
|
+
readonly resourceNotFound: -32001;
|
|
60
|
+
readonly resourceUnavailable: -32002;
|
|
61
|
+
readonly transactionRejected: -32003;
|
|
62
|
+
readonly methodNotSupported: -32004;
|
|
63
|
+
readonly limitExceeded: -32005;
|
|
64
|
+
};
|
|
65
|
+
/** The numeric `code` of a provider error (`ProviderRpcError`, `JsonRpcError` or a plain object). */
|
|
66
|
+
export declare function cip103ErrorCode(error: unknown): number | undefined;
|
|
67
|
+
/** `message (CIP-0103 4200 Unsupported Method)`, so a UI can show what the wallet answered. */
|
|
68
|
+
export declare function describeError(error: unknown): string;
|
|
69
|
+
/**
|
|
70
|
+
* A provider error from `prepareExecuteAndWait` as a `WalletSubmitError`:
|
|
71
|
+
*
|
|
72
|
+
* - 4001 → `rejected-by-user`;
|
|
73
|
+
* - -32003 → `failed` (the ledger rejected it);
|
|
74
|
+
* - 4200 and the request/params errors (-32700, -32600, -32601, -32602, -32000, -32004) → `failed`: the wallet did not
|
|
75
|
+
* take the request on, so nothing was submitted;
|
|
76
|
+
* - 4100, 4900, 4901 → `unknown`: the wallet lost or changed its session, possibly after submitting;
|
|
77
|
+
* - Anything else (-32002 timeouts, -32603, no code) → `unknown`: never resubmit without checking the wallet.
|
|
78
|
+
*/
|
|
79
|
+
export declare function cip103SubmitError(error: unknown, commandId?: string): WalletSubmitError;
|
|
80
|
+
/**
|
|
81
|
+
* The fields of the CIP-0103 `Wallet` (account) this SDK reads. `publicKey` and `namespace` are as the wallet reports
|
|
82
|
+
* them (their encoding is not specified by CIP-0103); absent when the wallet did not send them.
|
|
83
|
+
*/
|
|
84
|
+
export interface Cip103Account {
|
|
85
|
+
readonly partyId: string;
|
|
86
|
+
readonly publicKey?: string;
|
|
87
|
+
readonly namespace?: string;
|
|
88
|
+
readonly networkId?: string;
|
|
89
|
+
readonly signingProviderId?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The wallet's primary account (`getPrimaryAccount`). The dApp runs its wallet's own connect flow first; a provider
|
|
93
|
+
* that is not connected answers 4100.
|
|
94
|
+
*/
|
|
95
|
+
export declare function primaryAccount(provider: Cip103Provider): Promise<Cip103Account>;
|
|
96
|
+
/** The wallet party: the primary account's `partyId` (`getPrimaryAccount`). */
|
|
97
|
+
export declare function primaryPartyId(provider: Cip103Provider): Promise<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Entries asked for per `/v2/state/active-contracts-page` request (`maxPageSize`). Well under the participant's default
|
|
100
|
+
* page and list limits, so a participant does not refuse it.
|
|
101
|
+
*/
|
|
102
|
+
export declare const ACS_PAGE_SIZE = 200;
|
|
103
|
+
/**
|
|
104
|
+
* The most `/v2/state/active-contracts-page` requests one read makes ({@link ACS_PAGE_SIZE} × this = 100,000 contracts
|
|
105
|
+
* of one filter). A read that needs more fails with `WalletReadError` instead of paging on.
|
|
106
|
+
*/
|
|
107
|
+
export declare const ACS_MAX_PAGES = 500;
|
|
108
|
+
/**
|
|
109
|
+
* Codes of a first paged ACS call after which the snapshot is read once through the unpaged
|
|
110
|
+
* `/v2/state/active-contracts` instead: the wallet does not offer the paged endpoint (4200, -32601, -32004), or refused
|
|
111
|
+
* the paged request's shape (-32602). Loop reports those cases differently (see {@link LOOP_HTTP_REFUSED_MESSAGE}). Any
|
|
112
|
+
* other failure (a rate limit, a timeout, a refused or disconnected session) is reported as it is: a second read would
|
|
113
|
+
* fail the same way and only add load.
|
|
114
|
+
*/
|
|
115
|
+
export declare const ACS_FALLBACK_CODES: ReadonlySet<number>;
|
|
116
|
+
/**
|
|
117
|
+
* Loop's message, with code -32002, for any non-OK HTTP reply of its ledger proxy other than 429 that carries no
|
|
118
|
+
* structured error (`@fivenorth/loop-sdk` `Connection.ledgerApi`): an endpoint its allowlist does not offer, a
|
|
119
|
+
* participant that serves the paged endpoint only as GET (Canton 3.5) or refuses its `maxPageSize`, or a server error.
|
|
120
|
+
* Loop's timeout or network failure is another message ("Ledger request failed or timed out") and does not fall back.
|
|
121
|
+
*/
|
|
122
|
+
export declare const LOOP_HTTP_REFUSED_MESSAGE = "Ledger access unavailable";
|
|
123
|
+
/**
|
|
124
|
+
* Whether a provider error is a rate limit: -32005, or -32603 whose message says HTTP status 429 (Loop's session check,
|
|
125
|
+
* which runs before every `ledgerApi` call, throws a plain `Error` that Loop's CIP-0103 adapter maps to -32603).
|
|
126
|
+
*/
|
|
127
|
+
export declare function isRateLimited(error: unknown): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Waits before each retry of a read the wallet rate-limited (-32005): 0.5 s, 1 s, 2 s, 4 s, so at most five attempts
|
|
130
|
+
* over about 7.5 s. Each wait is jittered to between half and all of its value, so parallel readers spread out.
|
|
131
|
+
*/
|
|
132
|
+
export declare const DEFAULT_READ_RETRY_DELAYS_MS: readonly number[];
|
|
133
|
+
/** How reads back off when the wallet rate-limits them (-32005). Never applied to submissions. */
|
|
134
|
+
export interface WalletReadRetryOptions {
|
|
135
|
+
/** The wait before each retry, in milliseconds; defaults to {@link DEFAULT_READ_RETRY_DELAYS_MS}. Empty: no retry. */
|
|
136
|
+
readonly delaysMs?: readonly number[];
|
|
137
|
+
/** Defaults to `setTimeout`. */
|
|
138
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
139
|
+
/** A number in [0, 1) for the jitter; defaults to `Math.random`. */
|
|
140
|
+
readonly random?: () => number;
|
|
141
|
+
}
|
|
142
|
+
/** Contracts of one ACS snapshot, read at one ledger offset. */
|
|
143
|
+
export interface AcsSnapshot {
|
|
144
|
+
readonly offset: number;
|
|
145
|
+
readonly contracts: ActiveContract[];
|
|
146
|
+
}
|
|
147
|
+
export interface AcsReadOptions {
|
|
148
|
+
/**
|
|
149
|
+
* Read at this ledger offset (one an earlier read reported) instead of the current ledger end, so a later read joins
|
|
150
|
+
* an earlier snapshot.
|
|
151
|
+
*/
|
|
152
|
+
readonly activeAtOffset?: number;
|
|
153
|
+
}
|
|
154
|
+
/** What the token actions need from a wallet: one party, its contracts, and a submit that waits for the commit. */
|
|
155
|
+
export interface Cip103Wallet {
|
|
156
|
+
readonly partyId: string;
|
|
157
|
+
/** Active contracts of `partyId` matching the filter, as one snapshot at the ledger end (or at `activeAtOffset`). */
|
|
158
|
+
listActiveContracts(filter: ContractFilter, options?: AcsReadOptions): Promise<ActiveContract[]>;
|
|
159
|
+
/**
|
|
160
|
+
* Active contracts of `partyId` matching any of the filters, as one snapshot at the ledger end: one ledger-end call
|
|
161
|
+
* and one paged ACS stream whose cumulative filter carries every filter. A contract matching several is returned
|
|
162
|
+
* once. With `activeAtOffset`, the snapshot is read at that offset and the ledger end is not read.
|
|
163
|
+
*/
|
|
164
|
+
readActiveContracts(filters: readonly ContractFilter[], options?: AcsReadOptions): Promise<AcsSnapshot>;
|
|
165
|
+
/** Sign and submit as `partyId`; resolves once committed, else throws `WalletSubmitError`. Never retries. */
|
|
166
|
+
submit(submission: WalletSubmission): Promise<SubmitResult>;
|
|
167
|
+
}
|
|
168
|
+
export interface Cip103WalletOptions {
|
|
169
|
+
/** How reads back off when the wallet rate-limits them. */
|
|
170
|
+
readonly readRetry?: WalletReadRetryOptions;
|
|
171
|
+
}
|
|
172
|
+
/** The SDK's CIP-0103 client acting as `partyId` through `provider`. */
|
|
173
|
+
export declare function cip103Wallet(provider: Cip103Provider, partyId: string, options?: Cip103WalletOptions): Cip103Wallet;
|
|
174
|
+
//# sourceMappingURL=cip103.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cip103.d.ts","sourceRoot":"","sources":["../../../src/wallets/cip103.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,kHAAkH;AAElH,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB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