@fairmint/canton-node-sdk 0.0.288 → 0.0.290
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 +178 -8
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.d.ts +10 -2
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.js +27 -3
- package/build/src/clients/ledger-json-api/operations/v2/parties/external/allocate-external-party.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/delete-user.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/delete-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.d.ts +2 -0
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.js +5 -6
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.d.ts +3 -0
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.js +5 -3
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user-identity-provider.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user-identity-provider.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user.js +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/operations/users.d.ts +2 -0
- package/build/src/clients/ledger-json-api/schemas/operations/users.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/operations/users.js +4 -0
- package/build/src/clients/ledger-json-api/schemas/operations/users.js.map +1 -1
- package/build/src/utils/external-signing/allocate-external-party.d.ts +2 -0
- package/build/src/utils/external-signing/allocate-external-party.d.ts.map +1 -1
- package/build/src/utils/external-signing/allocate-external-party.js +1 -0
- package/build/src/utils/external-signing/allocate-external-party.js.map +1 -1
- package/build/src/utils/external-signing/allocation-user-id.d.ts +6 -0
- package/build/src/utils/external-signing/allocation-user-id.d.ts.map +1 -0
- package/build/src/utils/external-signing/allocation-user-id.js +18 -0
- package/build/src/utils/external-signing/allocation-user-id.js.map +1 -0
- package/build/src/utils/external-signing/create-external-party.d.ts +6 -0
- package/build/src/utils/external-signing/create-external-party.d.ts.map +1 -1
- package/build/src/utils/external-signing/create-external-party.js +4 -1
- package/build/src/utils/external-signing/create-external-party.js.map +1 -1
- package/build/src/utils/external-signing/external-party-onboarding.d.ts +24 -0
- package/build/src/utils/external-signing/external-party-onboarding.d.ts.map +1 -1
- package/build/src/utils/external-signing/external-party-onboarding.js +71 -0
- package/build/src/utils/external-signing/external-party-onboarding.js.map +1 -1
- package/build/src/utils/external-signing/external-party-wallet.d.ts +110 -0
- package/build/src/utils/external-signing/external-party-wallet.d.ts.map +1 -1
- package/build/src/utils/external-signing/external-party-wallet.js +173 -1
- package/build/src/utils/external-signing/external-party-wallet.js.map +1 -1
- package/build/src/utils/external-signing/external-signing-client.d.ts +6 -0
- package/build/src/utils/external-signing/external-signing-client.d.ts.map +1 -1
- package/build/src/utils/external-signing/external-signing-client.js +4 -0
- package/build/src/utils/external-signing/external-signing-client.js.map +1 -1
- package/build/src/utils/token-standard/v1/holdings.d.ts +3 -9
- package/build/src/utils/token-standard/v1/holdings.d.ts.map +1 -1
- package/build/src/utils/token-standard/v1/holdings.js +6 -74
- package/build/src/utils/token-standard/v1/holdings.js.map +1 -1
- package/build/src/wallets/acs.d.ts.map +1 -1
- package/build/src/wallets/acs.js +21 -0
- package/build/src/wallets/acs.js.map +1 -1
- package/build/src/wallets/amulet/constants.d.ts +33 -0
- package/build/src/wallets/amulet/constants.d.ts.map +1 -0
- package/build/src/wallets/amulet/constants.js +34 -0
- package/build/src/wallets/amulet/constants.js.map +1 -0
- package/build/src/wallets/amulet/registry.d.ts +65 -0
- package/build/src/wallets/amulet/registry.d.ts.map +1 -0
- package/build/src/wallets/amulet/registry.js +187 -0
- package/build/src/wallets/amulet/registry.js.map +1 -0
- package/build/src/wallets/cip103.d.ts +17 -3
- package/build/src/wallets/cip103.d.ts.map +1 -1
- package/build/src/wallets/cip103.js +19 -6
- package/build/src/wallets/cip103.js.map +1 -1
- package/build/src/wallets/commands.d.ts +5 -0
- package/build/src/wallets/commands.d.ts.map +1 -1
- package/build/src/wallets/commands.js +23 -7
- package/build/src/wallets/commands.js.map +1 -1
- package/build/src/wallets/contracts.d.ts +56 -3
- package/build/src/wallets/contracts.d.ts.map +1 -1
- package/build/src/wallets/contracts.js +63 -11
- package/build/src/wallets/contracts.js.map +1 -1
- package/build/src/wallets/da-utilities/client.d.ts +4 -0
- package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
- package/build/src/wallets/da-utilities/client.js +2 -0
- package/build/src/wallets/da-utilities/client.js.map +1 -1
- package/build/src/wallets/errors.d.ts +3 -1
- package/build/src/wallets/errors.d.ts.map +1 -1
- package/build/src/wallets/errors.js +3 -2
- package/build/src/wallets/errors.js.map +1 -1
- package/build/src/wallets/holding-view.d.ts +47 -0
- package/build/src/wallets/holding-view.d.ts.map +1 -0
- package/build/src/wallets/holding-view.js +121 -0
- package/build/src/wallets/holding-view.js.map +1 -0
- package/build/src/wallets/holdings.d.ts +59 -5
- package/build/src/wallets/holdings.d.ts.map +1 -1
- package/build/src/wallets/holdings.js +85 -15
- package/build/src/wallets/holdings.js.map +1 -1
- package/build/src/wallets/index.d.ts +20 -3
- package/build/src/wallets/index.d.ts.map +1 -1
- package/build/src/wallets/index.js +30 -1
- package/build/src/wallets/index.js.map +1 -1
- package/build/src/wallets/store.d.ts +19 -1
- package/build/src/wallets/store.d.ts.map +1 -1
- package/build/src/wallets/store.js +78 -3
- package/build/src/wallets/store.js.map +1 -1
- package/build/src/wallets/tokens.d.ts +120 -0
- package/build/src/wallets/tokens.d.ts.map +1 -0
- package/build/src/wallets/tokens.js +166 -0
- package/build/src/wallets/tokens.js.map +1 -0
- package/build/src/wallets/types.d.ts +14 -0
- package/build/src/wallets/types.d.ts.map +1 -1
- package/build/src/wallets/wallet.d.ts +81 -5
- package/build/src/wallets/wallet.d.ts.map +1 -1
- package/build/src/wallets/wallet.js +331 -49
- package/build/src/wallets/wallet.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTransferOfferExpired = isTransferOfferExpired;
|
|
4
|
+
exports.lockedInExpiredOffers = lockedInExpiredOffers;
|
|
5
|
+
exports.expiredUnclaimedLocks = expiredUnclaimedLocks;
|
|
6
|
+
exports.unitsByInstrument = unitsByInstrument;
|
|
7
|
+
exports.walletTokens = walletTokens;
|
|
8
|
+
/**
|
|
9
|
+
* One view per token of a wallet state, so a page renders Canton Coin and DA Registry tokens alike: one picker and one
|
|
10
|
+
* panel, whatever the token. Also the rule that decides which of the party's own transfer offers are expired, and how
|
|
11
|
+
* much of a token they keep locked.
|
|
12
|
+
*/
|
|
13
|
+
const constants_1 = require("./amulet/constants");
|
|
14
|
+
const contracts_1 = require("./contracts");
|
|
15
|
+
const decimal_1 = require("./decimal");
|
|
16
|
+
const holdings_1 = require("./holdings");
|
|
17
|
+
/**
|
|
18
|
+
* Whether a transfer offer's `executeBefore` has passed at `atMs` (milliseconds since the epoch). The ledger decides by
|
|
19
|
+
* ledger time, which can differ from the clock by a little; an unreadable `executeBefore` is not expired.
|
|
20
|
+
*/
|
|
21
|
+
function isTransferOfferExpired(offer, atMs) {
|
|
22
|
+
const deadline = Date.parse(offer.executeBefore);
|
|
23
|
+
return !Number.isNaN(deadline) && deadline <= atMs;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Per instrument (by `instrumentKey`), the locked units that `offers` (the party's own expired outgoing offers) keep
|
|
27
|
+
* locked: an offer that names its locked holding (Canton Coin) counts that holding's amount while it is still a locked
|
|
28
|
+
* holding of the party, and nothing once it is gone (its lock was already released; withdrawing only archives the
|
|
29
|
+
* offer); an offer that names none (DA) counts its amount. Each instrument's total is capped at its locked total.
|
|
30
|
+
*/
|
|
31
|
+
function lockedInExpiredOffers(holdings, offers) {
|
|
32
|
+
const lockedHoldings = new Map(holdings.filter((h) => h.locked).map((h) => [h.contractId, h]));
|
|
33
|
+
const lockedTotals = new Map();
|
|
34
|
+
for (const holding of lockedHoldings.values()) {
|
|
35
|
+
const key = (0, holdings_1.instrumentKey)(holding.instrumentId);
|
|
36
|
+
lockedTotals.set(key, (lockedTotals.get(key) ?? 0n) + ((0, decimal_1.parseDecimalUnits)(holding.amount) ?? 0n));
|
|
37
|
+
}
|
|
38
|
+
const counted = new Set();
|
|
39
|
+
const totals = new Map();
|
|
40
|
+
for (const offer of offers) {
|
|
41
|
+
const key = (0, holdings_1.instrumentKey)(offer.instrumentId);
|
|
42
|
+
let units;
|
|
43
|
+
if (offer.lockedHoldingCid !== undefined) {
|
|
44
|
+
const holding = lockedHoldings.get(offer.lockedHoldingCid);
|
|
45
|
+
if (holding === undefined || counted.has(holding.contractId))
|
|
46
|
+
continue;
|
|
47
|
+
counted.add(holding.contractId);
|
|
48
|
+
units = (0, decimal_1.parseDecimalUnits)(holding.amount) ?? 0n;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
units = (0, decimal_1.parseDecimalUnits)(offer.amount) ?? 0n;
|
|
52
|
+
}
|
|
53
|
+
totals.set(key, (totals.get(key) ?? 0n) + units);
|
|
54
|
+
}
|
|
55
|
+
for (const [key, units] of totals) {
|
|
56
|
+
const cap = lockedTotals.get(key) ?? 0n;
|
|
57
|
+
if (units > cap)
|
|
58
|
+
totals.set(key, cap);
|
|
59
|
+
}
|
|
60
|
+
return totals;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The party's own Canton Coin locks that expired at `atMs` and that none of `offers` names (any direction): the offer
|
|
64
|
+
* that locked it is gone, or the lock was never an offer's. Splice lets the owner alone release such a lock
|
|
65
|
+
* (`LockedAmulet_OwnerExpireLockV2`). A lock with no absolute expiry (`lockExpiresAt` absent) is never counted, and an
|
|
66
|
+
* active offer's lock is left to withdrawing that offer. `holdings` are the party's own.
|
|
67
|
+
*/
|
|
68
|
+
function expiredUnclaimedLocks(holdings, offers, atMs) {
|
|
69
|
+
const named = new Set(offers.flatMap((offer) => (offer.lockedHoldingCid === undefined ? [] : [offer.lockedHoldingCid])));
|
|
70
|
+
return holdings.filter((holding) => {
|
|
71
|
+
if (!holding.locked || !(0, holdings_1.isCantonCoin)(holding) || holding.lockExpiresAt === undefined)
|
|
72
|
+
return false;
|
|
73
|
+
const expiry = Date.parse(holding.lockExpiresAt);
|
|
74
|
+
return !Number.isNaN(expiry) && expiry <= atMs && !named.has(holding.contractId);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** Per instrument (by `instrumentKey`), the units of `holdings`. */
|
|
78
|
+
function unitsByInstrument(holdings) {
|
|
79
|
+
const totals = new Map();
|
|
80
|
+
for (const holding of holdings) {
|
|
81
|
+
const key = (0, holdings_1.instrumentKey)(holding.instrumentId);
|
|
82
|
+
totals.set(key, (totals.get(key) ?? 0n) + ((0, decimal_1.parseDecimalUnits)(holding.amount) ?? 0n));
|
|
83
|
+
}
|
|
84
|
+
return totals;
|
|
85
|
+
}
|
|
86
|
+
const ZERO = (0, decimal_1.formatDecimalUnits)(0n);
|
|
87
|
+
const units = (text) => (text === undefined ? 0n : ((0, decimal_1.parseDecimalUnits)(text) ?? 0n));
|
|
88
|
+
const compareText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
89
|
+
/**
|
|
90
|
+
* One {@link WalletToken} per token the state names: every balance, and every token of an offer, mint offer or burn
|
|
91
|
+
* request (a token offered to the party before it holds any is listed with zero balances). Sorted by symbol, then
|
|
92
|
+
* instrument id, then admin, by code unit. Canton Coin and DA Registry tokens share the shape; `capabilities` says
|
|
93
|
+
* which actions apply.
|
|
94
|
+
*/
|
|
95
|
+
function walletTokens(state) {
|
|
96
|
+
const drafts = new Map();
|
|
97
|
+
const note = (instrumentId, cantonCoin, balance) => {
|
|
98
|
+
const key = (0, holdings_1.instrumentKey)(instrumentId);
|
|
99
|
+
const draft = drafts.get(key) ?? { instrumentId, cantonCoin: false };
|
|
100
|
+
draft.cantonCoin || (draft.cantonCoin = cantonCoin);
|
|
101
|
+
if (balance !== undefined)
|
|
102
|
+
draft.balance = balance;
|
|
103
|
+
drafts.set(key, draft);
|
|
104
|
+
};
|
|
105
|
+
for (const balance of state.balances)
|
|
106
|
+
note(balance.instrumentId, balance.source === 'amulet', balance);
|
|
107
|
+
for (const offer of [...state.transferOffers.incoming, ...state.transferOffers.outgoing]) {
|
|
108
|
+
note(offer.instrumentId, offer.registry === 'amulet');
|
|
109
|
+
}
|
|
110
|
+
for (const item of [...state.mintOffers, ...state.burnRequests])
|
|
111
|
+
note(item.instrumentId, false);
|
|
112
|
+
const of = (list, key) => list.filter((item) => (0, holdings_1.instrumentKey)(item.instrumentId) === key);
|
|
113
|
+
return [...drafts.entries()]
|
|
114
|
+
.map(([key, { instrumentId, balance, cantonCoin }]) => {
|
|
115
|
+
// Canton Coin offered before the party holds any has no balance to carry the registry's answer.
|
|
116
|
+
const metadata = balance?.metadata ?? (cantonCoin ? constants_1.CANTON_COIN_METADATA : undefined);
|
|
117
|
+
const incoming = of(state.transferOffers.incoming, key);
|
|
118
|
+
const outgoing = of(state.transferOffers.outgoing, key);
|
|
119
|
+
const expiredOutgoing = outgoing.filter((offer) => offer.expired === true);
|
|
120
|
+
const lockedUnits = units(balance?.locked);
|
|
121
|
+
const inLocks = units(balance?.lockedInExpiredLocks);
|
|
122
|
+
const reclaimable = units(balance?.lockedInExpiredOffers) + inLocks;
|
|
123
|
+
const preapproval = cantonCoin
|
|
124
|
+
? null
|
|
125
|
+
: (0, contracts_1.coveringPreapproval)(state.transferPreapprovals, {
|
|
126
|
+
instrumentAdmin: instrumentId.admin,
|
|
127
|
+
instrumentIds: [instrumentId.id],
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
key,
|
|
131
|
+
instrumentId,
|
|
132
|
+
symbol: metadata?.symbol ?? instrumentId.id,
|
|
133
|
+
name: metadata?.name ?? instrumentId.id,
|
|
134
|
+
decimals: metadata?.decimals ?? 10,
|
|
135
|
+
...(metadata !== undefined && { metadata }),
|
|
136
|
+
available: balance?.unlocked ?? ZERO,
|
|
137
|
+
locked: balance?.locked ?? ZERO,
|
|
138
|
+
lockedReclaimable: (0, decimal_1.formatDecimalUnits)(reclaimable > lockedUnits ? lockedUnits : reclaimable),
|
|
139
|
+
canReclaim: expiredOutgoing.length > 0 || inLocks > 0n,
|
|
140
|
+
holdingCount: balance?.holdingCount ?? 0,
|
|
141
|
+
isCantonCoin: cantonCoin,
|
|
142
|
+
capabilities: {
|
|
143
|
+
send: !cantonCoin,
|
|
144
|
+
burn: !cantonCoin,
|
|
145
|
+
preapprove: !cantonCoin,
|
|
146
|
+
answerOffers: true,
|
|
147
|
+
withdrawOffers: true,
|
|
148
|
+
answerMintOffers: !cantonCoin,
|
|
149
|
+
},
|
|
150
|
+
offers: {
|
|
151
|
+
incoming,
|
|
152
|
+
outgoing,
|
|
153
|
+
expiredIncoming: incoming.filter((offer) => offer.expired === true),
|
|
154
|
+
expiredOutgoing,
|
|
155
|
+
},
|
|
156
|
+
mintOffers: of(state.mintOffers, key),
|
|
157
|
+
burnRequests: of(state.burnRequests, key),
|
|
158
|
+
preapproval,
|
|
159
|
+
preapprovalStatus: cantonCoin ? 'unknown' : preapproval === null ? 'none' : 'covered',
|
|
160
|
+
};
|
|
161
|
+
})
|
|
162
|
+
.sort((a, b) => compareText(a.symbol, b.symbol) ||
|
|
163
|
+
compareText(a.instrumentId.id, b.instrumentId.id) ||
|
|
164
|
+
compareText(a.instrumentId.admin, b.instrumentId.admin));
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/wallets/tokens.ts"],"names":[],"mappings":";;;;;;;AAAA;;;;GAIG;AACH,kDAA0D;AAE1D,2CAAkD;AAClD,uCAAkE;AAClE,yCAAwH;AAGxH;;;GAGG;AACH,gCAAuC,KAA2C,EAAE,IAAY;IAC9F,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,+BACE,QAA4B,EAC5B,MAAgC;IAEhC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,IAAA,wBAAa,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAChD,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,YAAY,CA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BACN,QAAQ;gBACR,QAAQ;gBACR,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;gBACnE,eAAe;aAChB;YACD,UAAU,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC;YACrC,YAAY,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC;YACzC,WAAW;YACX,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SACtF,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QAC/B,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC;QACjD,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAC1D,CAAC;AACN,CAAC"}
|
|
@@ -29,6 +29,15 @@ export interface DisclosedContract {
|
|
|
29
29
|
readonly createdEventBlob: string;
|
|
30
30
|
readonly synchronizerId?: string;
|
|
31
31
|
}
|
|
32
|
+
/** An interface view the ledger computed for a contract (`JsInterfaceView`), as an interface filter asked for it. */
|
|
33
|
+
export interface InterfaceView {
|
|
34
|
+
/** As the ledger reports it: usually the package-id form `pkgId:Module:Interface`. */
|
|
35
|
+
readonly interfaceId: string;
|
|
36
|
+
/** `viewStatus.code`: 0 when the view was computed; anything else means `viewValue` is not usable. */
|
|
37
|
+
readonly viewStatusCode: number;
|
|
38
|
+
/** The view value; null when the ledger did not include one. */
|
|
39
|
+
readonly viewValue: JsonObject | null;
|
|
40
|
+
}
|
|
32
41
|
/** An active contract read from the wallet party's ACS. */
|
|
33
42
|
export interface ActiveContract {
|
|
34
43
|
readonly contractId: string;
|
|
@@ -45,6 +54,11 @@ export interface ActiveContract {
|
|
|
45
54
|
readonly createArgument: JsonObject | null;
|
|
46
55
|
/** The synchronizer the contract is assigned to, when the ledger reported it. */
|
|
47
56
|
readonly synchronizerId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The interface views the read asked for (an interface filter with `includeInterfaceView`); absent when the ledger
|
|
59
|
+
* returned none. A view is the contract's own claim: trust still comes from `signatories`.
|
|
60
|
+
*/
|
|
61
|
+
readonly interfaceViews?: readonly InterfaceView[];
|
|
48
62
|
}
|
|
49
63
|
/** What the SDK asks the wallet to sign and submit, acting as the wallet party only. */
|
|
50
64
|
export interface WalletSubmission {
|
|
@@ -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,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AgB;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"}
|
|
@@ -4,13 +4,22 @@
|
|
|
4
4
|
* its choice context from DA's Utilities API, refuses anything that does not check out, and submits as the wallet party
|
|
5
5
|
* only.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Canton Coin (on by default, `WalletOptions.cantonCoin`): the party's Canton Coin holdings (Splice `Amulet` and
|
|
8
|
+
* `LockedAmulet`, read through their `HoldingV1` interface view) are listed with its other tokens, and Canton Coin
|
|
9
|
+
* transfer offers (`AmuletTransferInstruction`s, for example a faucet's) beside DA's, to accept, reject or withdraw the
|
|
10
|
+
* same way. Canton Coin is not transferred or burnt through this wallet.
|
|
11
|
+
*
|
|
12
|
+
* Trust: a holding counts when its instrument admin (DA's registrar, or for Canton Coin the DSO) and its owner signed
|
|
13
|
+
* it; an offer, a request or a preapproval when it names DA's operator and (offers and requests) a provider trusted for
|
|
14
|
+
* its instrument admin signed it. By default a registrar must be its own provider; `registry.trustedProviders` trusts
|
|
15
|
+
* others (see `isFromRegistry`). A Canton Coin offer counts when it is of Canton Coin and the DSO and its sender signed
|
|
16
|
+
* it. The DSO party is resolved once for both (`createAmuletRegistry`): pinned, else the registry's `adminId`; while it
|
|
17
|
+
* is unconfirmed, no Canton Coin is listed (`WalletState.cantonCoinUnavailable`).
|
|
10
18
|
*/
|
|
11
19
|
import { type Cip103Provider, type WalletReadRetryOptions } from './cip103';
|
|
12
|
-
import { type BurnRequest, type MintOffer, type TransferOffer, type TransferPreapproval } from './contracts';
|
|
20
|
+
import { type BurnRequest, type MintOffer, type TransferOffer, type TransferOfferRegistry, type TransferPreapproval } from './contracts';
|
|
13
21
|
import { type DaNetwork, type DaRegistryOptions, type TransferKind } from './da-utilities/client';
|
|
22
|
+
import { type CantonCoinOptions } from './amulet/registry';
|
|
14
23
|
import { type Holding, type InstrumentBalance } from './holdings';
|
|
15
24
|
import type { InstrumentId, SubmitResult } from './types';
|
|
16
25
|
/** A burn reference: no personal data (DA's operator and the registrar see it). */
|
|
@@ -31,6 +40,14 @@ export interface WalletOptions {
|
|
|
31
40
|
/** The DA network the provider's ledger is on; selects DA's Utilities API. */
|
|
32
41
|
readonly network: DaNetwork;
|
|
33
42
|
readonly registry?: DaRegistryOptions;
|
|
43
|
+
/**
|
|
44
|
+
* Canton Coin, on by default: the party's Canton Coin holdings and Canton Coin transfer offers are listed with its
|
|
45
|
+
* other tokens and DA's offers. The DSO party is `dsoParty` when pinned, else the `adminId` of the Canton Coin
|
|
46
|
+
* registry (`registryUrl`, SV-1's Scan of `network` by default), asked only when the party has Canton Coin. While
|
|
47
|
+
* neither confirms it (Scan down or slow), no Canton Coin is listed and `WalletState.cantonCoinUnavailable` is true.
|
|
48
|
+
* `false`: no Canton Coin is read and the registry is never asked.
|
|
49
|
+
*/
|
|
50
|
+
readonly cantonCoin?: CantonCoinOptions | false;
|
|
34
51
|
/**
|
|
35
52
|
* Whether the wallet session this wallet belongs to is still live. Once it answers false, every write is refused with
|
|
36
53
|
* `invalid-input` before its first read, and again right before the wallet signs, so nothing is submitted: the
|
|
@@ -56,6 +73,7 @@ export interface WalletInternalOptions extends WalletOptions {
|
|
|
56
73
|
export interface WalletCallOptions {
|
|
57
74
|
readonly signal?: AbortSignal;
|
|
58
75
|
}
|
|
76
|
+
/** DA's and Canton Coin's pending transfers alike (`TransferOffer.registry` tells them apart). */
|
|
59
77
|
export interface TransferOffers {
|
|
60
78
|
/** Offers to the wallet party, which it can accept or reject. */
|
|
61
79
|
readonly incoming: TransferOffer[];
|
|
@@ -66,7 +84,7 @@ export interface TransferOffers {
|
|
|
66
84
|
export interface WalletState {
|
|
67
85
|
/** The ledger offset every list was read at. */
|
|
68
86
|
readonly offset: number;
|
|
69
|
-
/** The wallet party's DA holdings, locked ones included. */
|
|
87
|
+
/** The wallet party's holdings (DA Registry holdings and Canton Coin, see `Holding.source`), locked ones included. */
|
|
70
88
|
readonly holdings: Holding[];
|
|
71
89
|
/** `holdings` summed per instrument (unlocked and locked apart), sorted by instrument id then admin. */
|
|
72
90
|
readonly balances: InstrumentBalance[];
|
|
@@ -77,6 +95,14 @@ export interface WalletState {
|
|
|
77
95
|
readonly burnRequests: BurnRequest[];
|
|
78
96
|
/** The wallet party's transfer preapprovals. */
|
|
79
97
|
readonly transferPreapprovals: TransferPreapproval[];
|
|
98
|
+
/**
|
|
99
|
+
* True when the party has Canton Coin (holdings or transfer offers) but its DSO party could not be confirmed (the
|
|
100
|
+
* Canton Coin registry failed, timed out or is backing off after a failure, and no `cantonCoin.dsoParty` is pinned):
|
|
101
|
+
* `holdings`, `balances` and `transferOffers` then leave all Canton Coin out, and everything else is complete. Load
|
|
102
|
+
* again to retry. The wallet always sets it (false otherwise); optional so a state built without it still
|
|
103
|
+
* type-checks.
|
|
104
|
+
*/
|
|
105
|
+
readonly cantonCoinUnavailable?: boolean;
|
|
80
106
|
}
|
|
81
107
|
export interface TransferRequest {
|
|
82
108
|
readonly receiver: string;
|
|
@@ -125,6 +151,40 @@ export interface BurnRequestOptions {
|
|
|
125
151
|
export interface BurnRequestResult extends SubmitResult {
|
|
126
152
|
readonly reference: string;
|
|
127
153
|
}
|
|
154
|
+
/** One expired offer withdrawn: its submission, the offer and the amount it offered. */
|
|
155
|
+
export interface WithdrawnOffer extends SubmitResult {
|
|
156
|
+
readonly transferOfferCid: string;
|
|
157
|
+
readonly amount: string;
|
|
158
|
+
/** The registry that validated the offer: `'amulet'` for Canton Coin (its DSO confirmed by Scan), else `'da'`. */
|
|
159
|
+
readonly registry: TransferOfferRegistry;
|
|
160
|
+
}
|
|
161
|
+
/** One expired Canton Coin lock released (`LockedAmulet_OwnerExpireLockV2`): its submission, the holding and amount. */
|
|
162
|
+
export interface ReleasedLock extends SubmitResult {
|
|
163
|
+
readonly lockedHoldingCid: string;
|
|
164
|
+
readonly amount: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* What `reclaimLockedTokens` (or `withdrawExpiredTransferOffers`, whose `released` is always empty) did, in the order
|
|
168
|
+
* it did. When a submission after the first fails, or the call's `signal` aborts between submissions, the call resolves
|
|
169
|
+
* (it does not throw) with what already committed, the failure in `failed`, and the contract ids it did not get to in
|
|
170
|
+
* `notAttempted`; a failure before anything committed is thrown as usual.
|
|
171
|
+
*/
|
|
172
|
+
export interface WithdrawExpiredResult {
|
|
173
|
+
readonly withdrawn: readonly WithdrawnOffer[];
|
|
174
|
+
readonly released: readonly ReleasedLock[];
|
|
175
|
+
/**
|
|
176
|
+
* The submission that failed after others committed: the offer or locked holding it was for, and the error as thrown
|
|
177
|
+
* (pass it to `describeWalletError`; an `outcome-unknown` one may have committed).
|
|
178
|
+
*/
|
|
179
|
+
readonly failed?: {
|
|
180
|
+
readonly contractId: string;
|
|
181
|
+
readonly error: unknown;
|
|
182
|
+
};
|
|
183
|
+
/** Offers and locked holdings not submitted because of `failed`, in the order they would have been. */
|
|
184
|
+
readonly notAttempted: readonly string[];
|
|
185
|
+
}
|
|
186
|
+
/** {@link WithdrawExpiredResult} under the name of the call that usually returns it. */
|
|
187
|
+
export type ReclaimLockedTokensResult = WithdrawExpiredResult;
|
|
128
188
|
export interface TransferPreapprovalOptions {
|
|
129
189
|
readonly instrumentAdmin: string;
|
|
130
190
|
/** Up to 10 instrument ids of the admin; empty or omitted: every instrument of the admin. */
|
|
@@ -152,6 +212,22 @@ export interface Wallet {
|
|
|
152
212
|
rejectTransferOffer(transferOfferCid: string, options?: WalletCallOptions): Promise<SubmitResult>;
|
|
153
213
|
/** Withdraw one of the party's own transfer offers, which unlocks its tokens (also after the offer expired). */
|
|
154
214
|
withdrawTransferOffer(transferOfferCid: string, options?: WalletCallOptions): Promise<SubmitResult>;
|
|
215
|
+
/**
|
|
216
|
+
* Withdraw all of the party's own expired transfer offers of one token (`TransferOffer.expired`), so the tokens they
|
|
217
|
+
* keep locked (`InstrumentBalance.lockedInExpiredOffers`) are unlocked: one `TransferInstruction_Withdraw` per offer,
|
|
218
|
+
* each as `withdrawTransferOffer` sends it, through the offer's own registry. Refused with `not-found` when there is
|
|
219
|
+
* none. Stops at the first failure: thrown when nothing was withdrawn yet, else reported in the result's `failed`
|
|
220
|
+
* (see {@link WithdrawExpiredResult}).
|
|
221
|
+
*/
|
|
222
|
+
withdrawExpiredTransferOffers(instrumentId: InstrumentId, options?: WalletCallOptions): Promise<WithdrawExpiredResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Unlock everything of one token that no longer needs to be locked: first withdraw the party's expired outgoing
|
|
225
|
+
* offers (as `withdrawExpiredTransferOffers`), then, for Canton Coin, release each of the party's own expired locks
|
|
226
|
+
* that no active offer names (`LockedAmulet_OwnerExpireLockV2`, which Splice lets the owner alone run once the lock
|
|
227
|
+
* expired), one submission each. `WalletToken.canReclaim` says whether there is anything to do; refused with
|
|
228
|
+
* `not-found` when there is nothing. Failures as `withdrawExpiredTransferOffers`.
|
|
229
|
+
*/
|
|
230
|
+
reclaimLockedTokens(instrumentId: InstrumentId, options?: WalletCallOptions): Promise<ReclaimLockedTokensResult>;
|
|
155
231
|
acceptMintOffer(mintOfferCid: string, options?: WalletCallOptions): Promise<SubmitResult>;
|
|
156
232
|
/** Reject a mint offer; the registrar sees {@link MINT_OFFER_REJECT_REASON}. */
|
|
157
233
|
rejectMintOffer(mintOfferCid: string, options?: WalletCallOptions): Promise<SubmitResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallets/wallet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wallet.d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