From 2375b28c1aadf8116c3665cec0ef0397e6a91102 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Mon, 10 Aug 2020 11:41:00 -0700 Subject: [PATCH] fix: deprecate getMathHelpersName for getMathHelperName (#1409) --- packages/ERTP/src/amountMath.js | 2 ++ packages/ERTP/src/issuer.js | 2 ++ packages/ERTP/src/types.js | 7 ++++++- .../ERTP/test/unitTests/mathHelpers/test-natMathHelpers.js | 6 +++--- .../ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js | 6 +++--- .../test/unitTests/mathHelpers/test-strSetMathHelpers.js | 6 +++--- packages/ERTP/test/unitTests/test-issuerObj.js | 4 ++-- packages/dapp-svelte-wallet/api/src/lib-wallet.js | 2 +- packages/dapp-svelte-wallet/api/test/test-lib-wallet.js | 2 +- .../spawner/test/swingsetTests/contractHost/bootstrap.js | 2 +- .../spawner/test/swingsetTests/contractHost/vat-alice.js | 2 +- .../spawner/test/swingsetTests/contractHost/vat-bob.js | 2 +- .../spawner/test/swingsetTests/contractHost/vat-fred.js | 2 +- packages/swingset-runner/demo/exchangeBenchmark/helpers.js | 2 +- packages/swingset-runner/demo/zoeTests/helpers.js | 2 +- packages/zoe/src/contractSupport/zoeHelpers.js | 2 +- packages/zoe/src/state.js | 2 +- packages/zoe/test/swingsetTests/helpers.js | 2 +- .../zoe/test/unitTests/contracts/test-multipoolAutoswap.js | 2 +- 19 files changed, 33 insertions(+), 24 deletions(-) diff --git a/packages/ERTP/src/amountMath.js b/packages/ERTP/src/amountMath.js index 1805f2db0cb..5590caa0f16 100644 --- a/packages/ERTP/src/amountMath.js +++ b/packages/ERTP/src/amountMath.js @@ -73,7 +73,9 @@ function makeAmountMath(brand, mathHelpersName) { const amountMath = harden({ getBrand: () => brand, + /** @deprecated Use getMathHelperName */ getMathHelpersName: () => mathHelpersName, + getMathHelperName: () => mathHelpersName, /** * Make an amount from a value by adding the brand. diff --git a/packages/ERTP/src/issuer.js b/packages/ERTP/src/issuer.js index cd293a7d6af..49edaa589f0 100644 --- a/packages/ERTP/src/issuer.js +++ b/packages/ERTP/src/issuer.js @@ -175,7 +175,9 @@ function makeIssuerKit(allegedName, mathHelpersName = 'nat') { getBrand: () => brand, getAllegedName: () => allegedName, getAmountMath: () => amountMath, + /** @deprecated Use getMathHelperName */ getMathHelpersName: () => mathHelpersName, + getMathHelperName: () => mathHelpersName, makeEmptyPurse: () => { const purse = makePurse(); purseLedger.init(purse, amountMath.getEmpty()); diff --git a/packages/ERTP/src/types.js b/packages/ERTP/src/types.js index 79bdb23a467..d66e85e7d60 100644 --- a/packages/ERTP/src/types.js +++ b/packages/ERTP/src/types.js @@ -46,6 +46,8 @@ * * @property {() => Brand} getBrand Return the brand. * @property {() => MathHelpersName} getMathHelpersName + * Deprecated. Use getMathHelperName + * @property {() => MathHelpersName} getMathHelperName * Get the name of the mathHelpers used. This can be used as an * argument to `makeAmountMath` to create local amountMath. * @@ -127,7 +129,10 @@ * * @property {() => string} getAllegedName Get the allegedName for this mint/issuer * @property {() => AmountMath} getAmountMath Get the AmountMath for this Issuer. - * @property {() => MathHelpersName} getMathHelpersName Get the name of the MathHelpers for this Issuer. + * @property {() => MathHelpersName} getMathHelpersName + * Deprecated. Use getMathHelperName + * @property {() => MathHelpersName} getMathHelperName Get the name of the + * MathHelpers for this Issuer. * @property {() => Purse} makeEmptyPurse Make an empty purse of this brand. * @property {(payment: PaymentP) => Promise} isLive * Return true if the payment continues to exist. diff --git a/packages/ERTP/test/unitTests/mathHelpers/test-natMathHelpers.js b/packages/ERTP/test/unitTests/mathHelpers/test-natMathHelpers.js index 08712b28629..5bcb246b2a9 100644 --- a/packages/ERTP/test/unitTests/mathHelpers/test-natMathHelpers.js +++ b/packages/ERTP/test/unitTests/mathHelpers/test-natMathHelpers.js @@ -20,7 +20,7 @@ test('natMathHelpers', t => { try { const { getBrand, - getMathHelpersName, + getMathHelperName, make, coerce, getValue, @@ -35,8 +35,8 @@ test('natMathHelpers', t => { // getBrand t.deepEquals(getBrand(), mockBrand, 'brand is brand'); - // getMathHelpersName - t.deepEquals(getMathHelpersName(), 'nat', 'mathHelpersName is nat'); + // getMathHelperName + t.deepEquals(getMathHelperName(), 'nat', 'mathHelpersName is nat'); // make t.deepEquals(make(4), { brand: mockBrand, value: 4 }); diff --git a/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js b/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js index b849c07b1b6..73f0f14c8ff 100644 --- a/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js +++ b/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js @@ -23,7 +23,7 @@ const runSetMathHelpersTests = (t, [a, b, c], a2 = undefined) => { const { getBrand, - getMathHelpersName, + getMathHelperName, make, coerce, getValue, @@ -38,8 +38,8 @@ const runSetMathHelpersTests = (t, [a, b, c], a2 = undefined) => { // getBrand t.deepEquals(getBrand(), mockBrand, 'brand is brand'); - // getMathHelpersName - t.deepEquals(getMathHelpersName(), 'set', 'mathHelpersName is set'); + // getMathHelperName + t.deepEquals(getMathHelperName(), 'set', 'mathHelpersName is set'); // make t.deepEquals( diff --git a/packages/ERTP/test/unitTests/mathHelpers/test-strSetMathHelpers.js b/packages/ERTP/test/unitTests/mathHelpers/test-strSetMathHelpers.js index 3699a7547ef..8b38b53b721 100644 --- a/packages/ERTP/test/unitTests/mathHelpers/test-strSetMathHelpers.js +++ b/packages/ERTP/test/unitTests/mathHelpers/test-strSetMathHelpers.js @@ -20,7 +20,7 @@ test('strSetMathHelpers', t => { try { const { getBrand, - getMathHelpersName, + getMathHelperName, make, coerce, getValue, @@ -35,8 +35,8 @@ test('strSetMathHelpers', t => { // getBrand t.deepEquals(getBrand(), mockBrand, 'brand is brand'); - // getMathHelpersName - t.deepEquals(getMathHelpersName(), 'strSet', 'mathHelpersName is strSet'); + // getMathHelperName + t.deepEquals(getMathHelperName(), 'strSet', 'mathHelpersName is strSet'); // make t.doesNotThrow( diff --git a/packages/ERTP/test/unitTests/test-issuerObj.js b/packages/ERTP/test/unitTests/test-issuerObj.js index 134d1abf6d8..1ccda5580fc 100644 --- a/packages/ERTP/test/unitTests/test-issuerObj.js +++ b/packages/ERTP/test/unitTests/test-issuerObj.js @@ -44,10 +44,10 @@ test('issuer.getAmountMath', t => { } }); -test('issuer.getMathHelpersName', t => { +test('issuer.getMathHelperName', t => { try { const { issuer } = makeIssuerKit('fungible'); - t.equals(issuer.getMathHelpersName(), 'nat'); + t.equals(issuer.getMathHelperName(), 'nat'); } catch (e) { t.assert(false, e); } finally { diff --git a/packages/dapp-svelte-wallet/api/src/lib-wallet.js b/packages/dapp-svelte-wallet/api/src/lib-wallet.js index 2af8d088384..6d81da827a9 100644 --- a/packages/dapp-svelte-wallet/api/src/lib-wallet.js +++ b/packages/dapp-svelte-wallet/api/src/lib-wallet.js @@ -51,7 +51,7 @@ export async function makeWallet({ } // remote calls which immediately return a promise - const mathHelpersNameP = E(issuer).getMathHelpersName(); + const mathHelpersNameP = E(issuer).getMathHelperName(); const brandP = E(issuer).getBrand(); const issuerBoardIdP = E(board) .has(issuer) diff --git a/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js b/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js index d351a3967cd..7f96d8c5d62 100644 --- a/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js +++ b/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js @@ -792,7 +792,7 @@ test('lib-wallet addOffer for autoswap swap', async t => { const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName), ); diff --git a/packages/spawner/test/swingsetTests/contractHost/bootstrap.js b/packages/spawner/test/swingsetTests/contractHost/bootstrap.js index 2013593355a..2f6f7aad215 100644 --- a/packages/spawner/test/swingsetTests/contractHost/bootstrap.js +++ b/packages/spawner/test/swingsetTests/contractHost/bootstrap.js @@ -37,7 +37,7 @@ export function buildRootObject(vatPowers, vatParameters) { const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName), ); diff --git a/packages/spawner/test/swingsetTests/contractHost/vat-alice.js b/packages/spawner/test/swingsetTests/contractHost/vat-alice.js index f5f97a0161c..d8dbbeb584b 100644 --- a/packages/spawner/test/swingsetTests/contractHost/vat-alice.js +++ b/packages/spawner/test/swingsetTests/contractHost/vat-alice.js @@ -25,7 +25,7 @@ function makeAliceMaker(host, log) { const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName), ); diff --git a/packages/spawner/test/swingsetTests/contractHost/vat-bob.js b/packages/spawner/test/swingsetTests/contractHost/vat-bob.js index 977a330cb27..6f6f4333e05 100644 --- a/packages/spawner/test/swingsetTests/contractHost/vat-bob.js +++ b/packages/spawner/test/swingsetTests/contractHost/vat-bob.js @@ -13,7 +13,7 @@ function makeBobMaker(host, log) { const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName), ); diff --git a/packages/spawner/test/swingsetTests/contractHost/vat-fred.js b/packages/spawner/test/swingsetTests/contractHost/vat-fred.js index e23f69030ab..f86b4e2c29f 100644 --- a/packages/spawner/test/swingsetTests/contractHost/vat-fred.js +++ b/packages/spawner/test/swingsetTests/contractHost/vat-fred.js @@ -14,7 +14,7 @@ function makeFredMaker(host, log) { const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName), ); diff --git a/packages/swingset-runner/demo/exchangeBenchmark/helpers.js b/packages/swingset-runner/demo/exchangeBenchmark/helpers.js index 04aa699ba1f..7bccc338d67 100644 --- a/packages/swingset-runner/demo/exchangeBenchmark/helpers.js +++ b/packages/swingset-runner/demo/exchangeBenchmark/helpers.js @@ -15,7 +15,7 @@ export async function showPurseBalance(purseP, name, log) { export function getLocalAmountMath(issuer) { return Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName)); } diff --git a/packages/swingset-runner/demo/zoeTests/helpers.js b/packages/swingset-runner/demo/zoeTests/helpers.js index 6007e571688..381de682d0f 100644 --- a/packages/swingset-runner/demo/zoeTests/helpers.js +++ b/packages/swingset-runner/demo/zoeTests/helpers.js @@ -15,7 +15,7 @@ export const showPurseBalance = async (purseP, name, log) => { export const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName)); export const setupIssuers = async (zoe, issuers) => { diff --git a/packages/zoe/src/contractSupport/zoeHelpers.js b/packages/zoe/src/contractSupport/zoeHelpers.js index f254bd37c8e..fa3816f4150 100644 --- a/packages/zoe/src/contractSupport/zoeHelpers.js +++ b/packages/zoe/src/contractSupport/zoeHelpers.js @@ -431,7 +431,7 @@ export const makeZoeHelpers = zcf => { assertNatMathHelpers: brand => { const amountMath = zcf.getAmountMath(brand); assert( - amountMath.getMathHelpersName() === 'nat', + amountMath.getMathHelperName() === 'nat', details`issuer must have natMathHelpers`, ); }, diff --git a/packages/zoe/src/state.js b/packages/zoe/src/state.js index 7df8689b48c..d00cdec3868 100644 --- a/packages/zoe/src/state.js +++ b/packages/zoe/src/state.js @@ -204,7 +204,7 @@ const makeIssuerTable = (withPurses = true) => { */ function buildTableEntryAndPlaceHolder(issuer) { // remote calls which immediately return a promise - const mathHelpersNameP = E(issuer).getMathHelpersName(); + const mathHelpersNameP = E(issuer).getMathHelperName(); const brandP = E(issuer).getBrand(); /** diff --git a/packages/zoe/test/swingsetTests/helpers.js b/packages/zoe/test/swingsetTests/helpers.js index a2a673b10d0..c70b47bd209 100644 --- a/packages/zoe/test/swingsetTests/helpers.js +++ b/packages/zoe/test/swingsetTests/helpers.js @@ -13,7 +13,7 @@ export const showPurseBalance = async (purseP, name, log) => { export const getLocalAmountMath = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathHelpersName]) => makeAmountMath(brand, mathHelpersName)); export const setupIssuers = async (zoe, issuers) => { diff --git a/packages/zoe/test/unitTests/contracts/test-multipoolAutoswap.js b/packages/zoe/test/unitTests/contracts/test-multipoolAutoswap.js index ebc66da5130..eaa1e5ca1f0 100644 --- a/packages/zoe/test/unitTests/contracts/test-multipoolAutoswap.js +++ b/packages/zoe/test/unitTests/contracts/test-multipoolAutoswap.js @@ -52,7 +52,7 @@ test('multipoolAutoSwap with valid offers', async t => { const makeAmountMathFromIssuer = issuer => Promise.all([ E(issuer).getBrand(), - E(issuer).getMathHelpersName(), + E(issuer).getMathHelperName(), ]).then(([brand, mathName]) => makeAmountMath(brand, mathName)); const inviteAmountMath = await makeAmountMathFromIssuer(inviteIssuer);