Skip to content

Commit

Permalink
fix: deprecate getMathHelpersName for getMathHelperName (#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
erights authored Aug 10, 2020
1 parent aec2c99 commit 2375b28
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 24 deletions.
2 changes: 2 additions & 0 deletions packages/ERTP/src/amountMath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
7 changes: 6 additions & 1 deletion packages/ERTP/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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<boolean>} isLive
* Return true if the payment continues to exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('natMathHelpers', t => {
try {
const {
getBrand,
getMathHelpersName,
getMathHelperName,
make,
coerce,
getValue,
Expand All @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const runSetMathHelpersTests = (t, [a, b, c], a2 = undefined) => {

const {
getBrand,
getMathHelpersName,
getMathHelperName,
make,
coerce,
getValue,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('strSetMathHelpers', t => {
try {
const {
getBrand,
getMathHelpersName,
getMathHelperName,
make,
coerce,
getValue,
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions packages/ERTP/test/unitTests/test-issuerObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-svelte-wallet/api/src/lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-svelte-wallet/api/test/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-runner/demo/exchangeBenchmark/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-runner/demo/zoeTests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contractSupport/zoeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/swingsetTests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 2375b28

Please sign in to comment.