From b7b4ae62474c3db68b23bf47e26b6f207a3a8cc1 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 15 Mar 2023 08:13:32 -0500 Subject: [PATCH 1/3] chore(vats): avoid importing all of ERTP into tokens.js Use static type check and unit tests rather than runtime import to avoid bundling all of ERTP just to get, for example, Stable.symbol. --- packages/vats/src/tokens.js | 26 ++++++++++++++++---------- packages/vats/test/test-tokens.js | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 packages/vats/test/test-tokens.js diff --git a/packages/vats/src/tokens.js b/packages/vats/src/tokens.js index af5d50a635c..76daf7799db 100644 --- a/packages/vats/src/tokens.js +++ b/packages/vats/src/tokens.js @@ -1,35 +1,41 @@ // @ts-check -import { AssetKind } from '@agoric/ertp'; -import { assertKeywordName } from '@agoric/zoe/src/cleanProposal.js'; - /** @typedef { 'IST' | 'BLD' } TokenKeyword */ +/** + * Use static type check and unit tests rather than runtime import + * to avoid bundling all of ERTP just to get Stable.symbol. + * + * @type {typeof import('@agoric/ertp').AssetKind.NAT} + */ +const NAT = 'nat'; + +/** @typedef {Capitalize} Keyword */ + export const Stable = harden( /** @type {const } */ ({ + /** @type {Keyword} */ symbol: 'IST', denom: 'uist', proposedName: 'Agoric stable local currency', - assetKind: AssetKind.NAT, + assetKind: NAT, displayInfo: { decimalPlaces: 6, - assetKind: AssetKind.NAT, + assetKind: NAT, }, }), ); export const Stake = harden( /** @type {const } */ ({ + /** @type {Keyword} */ symbol: 'BLD', denom: 'ubld', proposedName: 'Agoric staking token', - assetKind: AssetKind.NAT, + assetKind: NAT, displayInfo: { decimalPlaces: 6, - assetKind: AssetKind.NAT, + assetKind: NAT, }, }), ); - -assertKeywordName(Stable.symbol); -assertKeywordName(Stake.symbol); diff --git a/packages/vats/test/test-tokens.js b/packages/vats/test/test-tokens.js new file mode 100644 index 00000000000..59238e38b72 --- /dev/null +++ b/packages/vats/test/test-tokens.js @@ -0,0 +1,18 @@ +// @ts-check +import '@endo/init'; +import test from 'ava'; + +import { assertKeywordName } from '@agoric/zoe/src/cleanProposal.js'; + +import { AssetKind } from '@agoric/ertp'; +import { Stable, Stake } from '../src/tokens.js'; + +test('token symbols are keywords', t => { + t.notThrows(() => assertKeywordName(Stable.symbol)); + t.notThrows(() => assertKeywordName(Stake.symbol)); +}); + +test('token assetKind matches ERTP', t => { + t.is(Stable.assetKind, AssetKind.NAT); + t.is(Stake.assetKind, AssetKind.NAT); +}); From 279be57f81f4707a94b7488f395aab5d51b782d2 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 15 Mar 2023 08:25:52 -0500 Subject: [PATCH 2/3] chore(inter-protocol): avoid bundling voteCounter in vaultFactory --- packages/governance/src/index.js | 2 -- packages/governance/test/unitTests/test-binaryballotCount.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/governance/src/index.js b/packages/governance/src/index.js index 80d20ce6214..26a2767f08b 100644 --- a/packages/governance/src/index.js +++ b/packages/governance/src/index.js @@ -44,5 +44,3 @@ export { } from './validators.js'; export { ParamTypes } from './constants.js'; - -export { makeBinaryVoteCounter } from './binaryVoteCounter.js'; diff --git a/packages/governance/test/unitTests/test-binaryballotCount.js b/packages/governance/test/unitTests/test-binaryballotCount.js index 227b8ee76d5..e8923461121 100644 --- a/packages/governance/test/unitTests/test-binaryballotCount.js +++ b/packages/governance/test/unitTests/test-binaryballotCount.js @@ -12,13 +12,13 @@ import { import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; import { - makeBinaryVoteCounter, ChoiceMethod, ElectionType, QuorumRule, coerceQuestionSpec, makeParamChangePositions, } from '../../src/index.js'; +import { makeBinaryVoteCounter } from '../../src/binaryVoteCounter.js'; const SIMPLE_ISSUE = harden({ text: 'Fish or cut bait?' }); const FISH = harden({ text: 'Fish' }); From 6e9cf19d0aa635b32196a8d7bc5f0d5a1fb81b9b Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 15 Mar 2023 08:56:06 -0500 Subject: [PATCH 3/3] fixup! chore(vats): avoid importing all of ERTP into tokens.js --- packages/vats/src/tokens.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/vats/src/tokens.js b/packages/vats/src/tokens.js index 76daf7799db..1dd9d111e05 100644 --- a/packages/vats/src/tokens.js +++ b/packages/vats/src/tokens.js @@ -10,11 +10,8 @@ */ const NAT = 'nat'; -/** @typedef {Capitalize} Keyword */ - export const Stable = harden( /** @type {const } */ ({ - /** @type {Keyword} */ symbol: 'IST', denom: 'uist', proposedName: 'Agoric stable local currency', @@ -28,7 +25,6 @@ export const Stable = harden( export const Stake = harden( /** @type {const } */ ({ - /** @type {Keyword} */ symbol: 'BLD', denom: 'ubld', proposedName: 'Agoric staking token',