@agoric/inter-protocol 0.16.2-u12.0 → 0.16.2-u14.0
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/CHANGELOG.md +23 -0
- package/package.json +15 -16
- package/scripts/add-collateral-core.js +1 -0
- package/scripts/init-core.js +2 -0
- package/src/clientSupport.js +72 -71
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.16.2-u14.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/inter-protocol@0.16.2-u13.0...@agoric/inter-protocol@0.16.2-u14.0) (2024-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* smartWallet verstion 2 with watchedPromises ([31d7c2f](https://github.com/Agoric/agoric-sdk/commit/31d7c2f4ecea9a34956cc6716fb8d73cbeb12e64))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **smartWallet:** handle upgrade disconnects from purse notifiers ([f82b82b](https://github.com/Agoric/agoric-sdk/commit/f82b82bb79b21c0789609cc26b1c8f58ccdb32bc))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### [0.16.2-u13.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/inter-protocol@0.16.2-u12.0...@agoric/inter-protocol@0.16.2-u13.0) (2023-12-07)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **inter-protocol:** brands in CLI need not start with A-Z ([#8258](https://github.com/Agoric/agoric-sdk/issues/8258)) ([fd9a44d](https://github.com/Agoric/agoric-sdk/commit/fd9a44db84e2cb9c9c78f850be7dbb8911650d54))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
### [0.16.2-u12.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/inter-protocol@0.16.2-u11wf.0...@agoric/inter-protocol@0.16.2-u12.0) (2023-11-10)
|
|
7
30
|
|
|
8
31
|
**Note:** Version bump only for package @agoric/inter-protocol
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.2-
|
|
3
|
+
"version": "0.16.2-u14.0",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -30,28 +30,27 @@
|
|
|
30
30
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@agoric/assert": "^0.6.1-u11wf.0",
|
|
33
|
-
"@agoric/ertp": "^0.16.3-
|
|
34
|
-
"@agoric/governance": "^0.10.4-
|
|
35
|
-
"@agoric/internal": "^0.4.0-
|
|
36
|
-
"@agoric/notifier": "^0.6.3-
|
|
37
|
-
"@agoric/store": "^0.9.3-
|
|
38
|
-
"@agoric/time": "^0.3.3-
|
|
39
|
-
"@agoric/vat-data": "^0.5.3-
|
|
40
|
-
"@agoric/vats": "^0.15.2-
|
|
41
|
-
"@agoric/zoe": "^0.26.3-
|
|
33
|
+
"@agoric/ertp": "^0.16.3-u14.0",
|
|
34
|
+
"@agoric/governance": "^0.10.4-u14.0",
|
|
35
|
+
"@agoric/internal": "^0.4.0-u14.0",
|
|
36
|
+
"@agoric/notifier": "^0.6.3-u14.0",
|
|
37
|
+
"@agoric/store": "^0.9.3-u14.0",
|
|
38
|
+
"@agoric/time": "^0.3.3-u14.0",
|
|
39
|
+
"@agoric/vat-data": "^0.5.3-u14.0",
|
|
40
|
+
"@agoric/vats": "^0.15.2-u14.0",
|
|
41
|
+
"@agoric/zoe": "^0.26.3-u14.0",
|
|
42
42
|
"@endo/captp": "3.1.1",
|
|
43
43
|
"@endo/eventual-send": "0.17.2",
|
|
44
44
|
"@endo/far": "0.2.18",
|
|
45
45
|
"@endo/marshal": "0.8.5",
|
|
46
46
|
"@endo/nat": "4.1.27",
|
|
47
|
-
"agoric": "^0.21.2-u12.0",
|
|
48
47
|
"jessie.js": "^0.3.2"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@agoric/deploy-script-support": "^0.10.4-
|
|
52
|
-
"@agoric/smart-wallet": "^0.5.4-
|
|
53
|
-
"@agoric/swingset-liveslots": "^0.10.3-
|
|
54
|
-
"@agoric/swingset-vat": "^0.32.3-
|
|
50
|
+
"@agoric/deploy-script-support": "^0.10.4-u14.0",
|
|
51
|
+
"@agoric/smart-wallet": "^0.5.4-u14.0",
|
|
52
|
+
"@agoric/swingset-liveslots": "^0.10.3-u14.0",
|
|
53
|
+
"@agoric/swingset-vat": "^0.32.3-u14.0",
|
|
55
54
|
"@endo/bundle-source": "2.5.2-upstream-rollup",
|
|
56
55
|
"@endo/init": "0.5.56",
|
|
57
56
|
"@endo/promise-kit": "0.2.56",
|
|
@@ -78,5 +77,5 @@
|
|
|
78
77
|
"publishConfig": {
|
|
79
78
|
"access": "public"
|
|
80
79
|
},
|
|
81
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "b3a6f3374cb3bddab39fc6d6f426429cae6c29c6"
|
|
82
81
|
}
|
|
@@ -107,6 +107,7 @@ export default async (homeP, endowments) => {
|
|
|
107
107
|
|
|
108
108
|
await writeCoreProposal('gov-add-collateral', defaultProposalBuilder);
|
|
109
109
|
await writeCoreProposal('gov-start-psm', opts =>
|
|
110
|
+
// @ts-expect-error XXX makeInstallCache types
|
|
110
111
|
psmProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
|
|
111
112
|
);
|
|
112
113
|
};
|
package/scripts/init-core.js
CHANGED
|
@@ -188,9 +188,11 @@ export default async (homeP, endowments) => {
|
|
|
188
188
|
});
|
|
189
189
|
await Promise.all([
|
|
190
190
|
writeCoreProposal('gov-econ-committee', opts =>
|
|
191
|
+
// @ts-expect-error XXX makeInstallCache types
|
|
191
192
|
committeeProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
|
|
192
193
|
),
|
|
193
194
|
writeCoreProposal('gov-amm-vaults-etc', opts =>
|
|
195
|
+
// @ts-expect-error XXX makeInstallCache types
|
|
194
196
|
mainProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
|
|
195
197
|
),
|
|
196
198
|
]);
|
package/src/clientSupport.js
CHANGED
|
@@ -9,29 +9,31 @@ import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
|
9
9
|
const COSMOS_UNIT = 1_000_000n;
|
|
10
10
|
const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
|
|
11
11
|
|
|
12
|
+
// TODO use '@satisfies" in TS 5.1 to make sure these each conform to OfferMaker interface
|
|
13
|
+
|
|
12
14
|
// NB: not really a Proposal because the brands are not remotes
|
|
13
15
|
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
|
|
14
16
|
// mustMatch(harden(proposal), ProposalShape);
|
|
15
17
|
/**
|
|
16
18
|
* Give/want
|
|
17
19
|
*
|
|
18
|
-
* @param {
|
|
20
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
19
21
|
* @param {{ giveMinted?: number, wantMinted?: number } | { collateralBrandKey: string, giveCollateral?: number, wantCollateral?: number }} opts
|
|
20
22
|
* @returns {Proposal}
|
|
21
23
|
*/
|
|
22
|
-
const makeVaultProposal = (
|
|
24
|
+
const makeVaultProposal = ({ brand }, opts) => {
|
|
23
25
|
const proposal = { give: {}, want: {} };
|
|
24
26
|
|
|
25
27
|
if ('giveCollateral' in opts && opts.giveCollateral) {
|
|
26
28
|
const { collateralBrandKey } = opts;
|
|
27
29
|
proposal.give.Collateral = {
|
|
28
|
-
brand:
|
|
30
|
+
brand: brand[collateralBrandKey],
|
|
29
31
|
value: scaleDecimals(opts.giveCollateral),
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
if ('giveMinted' in opts && opts.giveMinted) {
|
|
33
35
|
proposal.give.Minted = {
|
|
34
|
-
brand:
|
|
36
|
+
brand: brand.IST,
|
|
35
37
|
value: scaleDecimals(opts.giveMinted),
|
|
36
38
|
};
|
|
37
39
|
}
|
|
@@ -39,13 +41,13 @@ const makeVaultProposal = (brands, opts) => {
|
|
|
39
41
|
if ('wantCollateral' in opts && opts.wantCollateral) {
|
|
40
42
|
const { collateralBrandKey } = opts;
|
|
41
43
|
proposal.want.Collateral = {
|
|
42
|
-
brand:
|
|
44
|
+
brand: brand[collateralBrandKey],
|
|
43
45
|
value: scaleDecimals(opts.wantCollateral),
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
if ('wantMinted' in opts && opts.wantMinted) {
|
|
47
49
|
proposal.want.Minted = {
|
|
48
|
-
brand:
|
|
50
|
+
brand: brand.IST,
|
|
49
51
|
value: scaleDecimals(opts.wantMinted),
|
|
50
52
|
};
|
|
51
53
|
}
|
|
@@ -54,18 +56,18 @@ const makeVaultProposal = (brands, opts) => {
|
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
|
-
* @param {
|
|
59
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
58
60
|
* @param {{ offerId: string, wantMinted: number, giveCollateral: number, collateralBrandKey: string }} opts
|
|
59
61
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
60
62
|
*/
|
|
61
|
-
const makeOpenOffer = (
|
|
62
|
-
const proposal = makeVaultProposal(
|
|
63
|
+
const makeOpenOffer = ({ brand }, opts) => {
|
|
64
|
+
const proposal = makeVaultProposal({ brand }, opts);
|
|
63
65
|
|
|
64
66
|
// NB: not really a Proposal because the brands are not remotes
|
|
65
67
|
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
|
|
66
68
|
// mustMatch(harden(proposal), ProposalShape);
|
|
67
69
|
|
|
68
|
-
const collateralBrand =
|
|
70
|
+
const collateralBrand = brand[opts.collateralBrandKey];
|
|
69
71
|
|
|
70
72
|
return {
|
|
71
73
|
id: opts.offerId,
|
|
@@ -82,16 +84,16 @@ const makeOpenOffer = (brands, opts) => {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
|
-
* @param {
|
|
87
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
86
88
|
* @param {{ offerId: string, collateralBrandKey?: string, giveCollateral?: number, wantCollateral?: number, giveMinted?: number, wantMinted?: number }} opts
|
|
87
89
|
* @param {string} previousOffer
|
|
88
90
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
89
91
|
*/
|
|
90
|
-
const makeAdjustOffer = (
|
|
92
|
+
const makeAdjustOffer = ({ brand }, opts, previousOffer) => {
|
|
91
93
|
// NB: not really a Proposal because the brands are not remotes
|
|
92
94
|
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
|
|
93
95
|
// mustMatch(harden(proposal), ProposalShape);
|
|
94
|
-
const proposal = makeVaultProposal(
|
|
96
|
+
const proposal = makeVaultProposal({ brand }, opts);
|
|
95
97
|
|
|
96
98
|
return {
|
|
97
99
|
id: opts.offerId,
|
|
@@ -105,13 +107,13 @@ const makeAdjustOffer = (brands, opts, previousOffer) => {
|
|
|
105
107
|
};
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
|
-
* @param {
|
|
110
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
109
111
|
* @param {{ offerId: string, collateralBrandKey?: string, giveMinted: number }} opts
|
|
110
112
|
* @param {string} previousOffer
|
|
111
113
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
112
114
|
*/
|
|
113
|
-
const makeCloseOffer = (
|
|
114
|
-
const proposal = makeVaultProposal(
|
|
115
|
+
const makeCloseOffer = ({ brand }, opts, previousOffer) => {
|
|
116
|
+
const proposal = makeVaultProposal({ brand }, opts);
|
|
115
117
|
|
|
116
118
|
return {
|
|
117
119
|
id: opts.offerId,
|
|
@@ -171,19 +173,19 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
|
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
/**
|
|
176
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
174
177
|
* @param {Instance} instance
|
|
175
|
-
* @param {Record<string, Brand>} brands
|
|
176
178
|
* @param {{ offerId: string, feePct?: number, pair: [string, string] } &
|
|
177
179
|
* ({ wantMinted: number } | { giveMinted: number })} opts
|
|
178
180
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
179
181
|
*/
|
|
180
|
-
const makePsmSwapOffer = (
|
|
182
|
+
const makePsmSwapOffer = ({ brand }, instance, opts) => {
|
|
181
183
|
const method =
|
|
182
184
|
'wantMinted' in opts
|
|
183
185
|
? 'makeWantMintedInvitation'
|
|
184
186
|
: 'makeGiveMintedInvitation'; // ref psm.js
|
|
185
187
|
const proposal = makePsmProposal(
|
|
186
|
-
|
|
188
|
+
brand,
|
|
187
189
|
opts,
|
|
188
190
|
opts.feePct ? opts.feePct / 100 : undefined,
|
|
189
191
|
opts.pair[1],
|
|
@@ -205,13 +207,55 @@ const makePsmSwapOffer = (instance, brands, opts) => {
|
|
|
205
207
|
};
|
|
206
208
|
|
|
207
209
|
/**
|
|
208
|
-
* @param {
|
|
210
|
+
* @param {{
|
|
211
|
+
* brand: Record<string, Brand>,
|
|
212
|
+
* vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
|
|
213
|
+
* }} agoricNames
|
|
214
|
+
* @param {(msg: string) => Error} makeError error constructor
|
|
215
|
+
* @returns {(a: string) => Amount<'nat'>}
|
|
216
|
+
*/
|
|
217
|
+
export const makeParseAmount =
|
|
218
|
+
(agoricNames, makeError = msg => RangeError(msg)) =>
|
|
219
|
+
opt => {
|
|
220
|
+
assert.typeof(opt, 'string', 'parseAmount expected string');
|
|
221
|
+
const m = opt.match(
|
|
222
|
+
/^(?<value>[\d_]+(?:\.[\d_]+)?)\s*(?<brand>[A-Za-z]\w*)$/,
|
|
223
|
+
);
|
|
224
|
+
if (!m || !m.groups) {
|
|
225
|
+
throw makeError(`invalid amount: ${opt}`);
|
|
226
|
+
}
|
|
227
|
+
const anyBrand = agoricNames.brand[m.groups.brand];
|
|
228
|
+
if (!anyBrand) {
|
|
229
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
230
|
+
}
|
|
231
|
+
const assetDesc = Object.values(agoricNames.vbankAsset).find(
|
|
232
|
+
d => d.brand === anyBrand,
|
|
233
|
+
);
|
|
234
|
+
if (!assetDesc) {
|
|
235
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
236
|
+
}
|
|
237
|
+
const { displayInfo } = assetDesc;
|
|
238
|
+
if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
|
|
239
|
+
throw makeError(`bad brand: ${displayInfo}`);
|
|
240
|
+
}
|
|
241
|
+
const value = BigInt(
|
|
242
|
+
Number(m.groups.value.replace(/_/g, '')) *
|
|
243
|
+
10 ** displayInfo.decimalPlaces,
|
|
244
|
+
);
|
|
245
|
+
/** @type {Brand<'nat'>} */
|
|
246
|
+
// @ts-expect-error dynamic cast
|
|
247
|
+
const natBrand = anyBrand;
|
|
248
|
+
const amt = { value, brand: natBrand };
|
|
249
|
+
return amt;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand' | 'vbankAsset'>} agoricNames
|
|
209
254
|
* @param {{
|
|
210
255
|
* offerId: string,
|
|
211
256
|
* give: string,
|
|
212
257
|
* maxBuy: string,
|
|
213
258
|
* wantMinimum?: string,
|
|
214
|
-
* parseAmount: (x: string) => Amount<'nat'>,
|
|
215
259
|
* } & ({
|
|
216
260
|
* price: number,
|
|
217
261
|
* } | {
|
|
@@ -219,14 +263,13 @@ const makePsmSwapOffer = (instance, brands, opts) => {
|
|
|
219
263
|
* })} opts
|
|
220
264
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
221
265
|
*/
|
|
222
|
-
const makeBidOffer = (
|
|
223
|
-
assert.typeof(opts.parseAmount, 'function');
|
|
266
|
+
const makeBidOffer = (agoricNames, opts) => {
|
|
224
267
|
assertAllDefined({
|
|
225
268
|
offerId: opts.offerId,
|
|
226
269
|
give: opts.give,
|
|
227
270
|
maxBuy: opts.maxBuy,
|
|
228
271
|
});
|
|
229
|
-
const
|
|
272
|
+
const parseAmount = makeParseAmount(agoricNames);
|
|
230
273
|
const proposal = {
|
|
231
274
|
give: { Bid: parseAmount(opts.give) },
|
|
232
275
|
...(opts.wantMinimum
|
|
@@ -276,7 +319,7 @@ const makeBidOffer = (_brands, opts) => {
|
|
|
276
319
|
};
|
|
277
320
|
|
|
278
321
|
/**
|
|
279
|
-
* @param {
|
|
322
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
280
323
|
* @param {{
|
|
281
324
|
* offerId: string,
|
|
282
325
|
* give: number,
|
|
@@ -284,11 +327,11 @@ const makeBidOffer = (_brands, opts) => {
|
|
|
284
327
|
* }} opts
|
|
285
328
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
286
329
|
*/
|
|
287
|
-
const makeAddCollateralOffer = (
|
|
330
|
+
const makeAddCollateralOffer = ({ brand }, opts) => {
|
|
288
331
|
/** @type {AmountKeywordRecord} */
|
|
289
332
|
const give = {
|
|
290
333
|
Collateral: AmountMath.make(
|
|
291
|
-
|
|
334
|
+
brand[opts.collateralBrandKey],
|
|
292
335
|
scaleDecimals(opts.give),
|
|
293
336
|
),
|
|
294
337
|
};
|
|
@@ -308,7 +351,7 @@ const makeAddCollateralOffer = (brands, opts) => {
|
|
|
308
351
|
|
|
309
352
|
/**
|
|
310
353
|
*
|
|
311
|
-
* @param {
|
|
354
|
+
* @param {unknown} _agoricNames
|
|
312
355
|
* @param {{
|
|
313
356
|
* offerId: string,
|
|
314
357
|
* roundId?: bigint,
|
|
@@ -317,7 +360,7 @@ const makeAddCollateralOffer = (brands, opts) => {
|
|
|
317
360
|
* @param {string} previousOffer
|
|
318
361
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
319
362
|
*/
|
|
320
|
-
const makePushPriceOffer = (
|
|
363
|
+
const makePushPriceOffer = (_agoricNames, opts, previousOffer) => {
|
|
321
364
|
return {
|
|
322
365
|
id: opts.offerId,
|
|
323
366
|
invitationSpec: {
|
|
@@ -332,48 +375,6 @@ const makePushPriceOffer = (_brands, opts, previousOffer) => {
|
|
|
332
375
|
};
|
|
333
376
|
};
|
|
334
377
|
|
|
335
|
-
// TODO DRY with CLI wallet.js
|
|
336
|
-
/**
|
|
337
|
-
* @param {{
|
|
338
|
-
* brand: Record<string, Brand>,
|
|
339
|
-
* vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
|
|
340
|
-
* }} agoricNames
|
|
341
|
-
* @param {(msg: string) => Error} makeError error constructor
|
|
342
|
-
* @returns {(a: string) => Amount<'nat'>}
|
|
343
|
-
*/
|
|
344
|
-
export const makeParseAmount =
|
|
345
|
-
(agoricNames, makeError = msg => RangeError(msg)) =>
|
|
346
|
-
opt => {
|
|
347
|
-
assert.typeof(opt, 'string', 'parseAmount expected string');
|
|
348
|
-
const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
|
|
349
|
-
if (!m || !m.groups) {
|
|
350
|
-
throw makeError(`invalid amount: ${opt}`);
|
|
351
|
-
}
|
|
352
|
-
const anyBrand = agoricNames.brand[m.groups.brand];
|
|
353
|
-
if (!anyBrand) {
|
|
354
|
-
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
355
|
-
}
|
|
356
|
-
const assetDesc = Object.values(agoricNames.vbankAsset).find(
|
|
357
|
-
d => d.brand === anyBrand,
|
|
358
|
-
);
|
|
359
|
-
if (!assetDesc) {
|
|
360
|
-
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
361
|
-
}
|
|
362
|
-
const { displayInfo } = assetDesc;
|
|
363
|
-
if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
|
|
364
|
-
throw makeError(`bad brand: ${displayInfo}`);
|
|
365
|
-
}
|
|
366
|
-
const value = BigInt(
|
|
367
|
-
Number(m.groups.value.replace(/_/g, '')) *
|
|
368
|
-
10 ** displayInfo.decimalPlaces,
|
|
369
|
-
);
|
|
370
|
-
/** @type {Brand<'nat'>} */
|
|
371
|
-
// @ts-expect-error dynamic cast
|
|
372
|
-
const natBrand = anyBrand;
|
|
373
|
-
const amt = { value, brand: natBrand };
|
|
374
|
-
return amt;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
378
|
export const Offers = {
|
|
378
379
|
auction: {
|
|
379
380
|
Bid: makeBidOffer,
|