From 3f261f4611fcf67de546f57758ee31d407e62fc8 Mon Sep 17 00:00:00 2001 From: Kate Sills Date: Tue, 26 Oct 2021 13:29:44 -0700 Subject: [PATCH] chore: update to latest ERTP. Linting doesn't pass, but it looks like it was not passing previously --- api/src/priceAuthority/linear.js | 6 +++--- api/src/priceAuthority/single.js | 19 +++++++++++-------- api/test/test-fakePriceAuthority.js | 22 +++++++++++----------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/api/src/priceAuthority/linear.js b/api/src/priceAuthority/linear.js index 0d92349..668bb4f 100644 --- a/api/src/priceAuthority/linear.js +++ b/api/src/priceAuthority/linear.js @@ -10,9 +10,9 @@ import '@agoric/zoe/exported'; * Create a price authority which uses linear-scaled latest quotes from the * underlying quote stream to answer queries. * - * So, if the quote stream produces `[moola(2), simolean(3)]`, and the caller - * asks what it would get if it sold `moola(6)`, then we'll return - * `simoleans(4)`. + * So, if the quote stream produces `[moola(2n), simolean(3n)]`, and the caller + * asks what it would get if it sold `moola(6n)`, then we'll return + * `simoleans(4n)`. * * @param {BasePriceAuthorityOptions} options * @returns {Promise} diff --git a/api/src/priceAuthority/single.js b/api/src/priceAuthority/single.js index e6deaa2..8e3ef0f 100644 --- a/api/src/priceAuthority/single.js +++ b/api/src/priceAuthority/single.js @@ -92,14 +92,17 @@ export async function makeSinglePriceAuthority(options) { * @returns {PriceQuote} */ const makeQuote = (amountIn, amountOut, quoteTime) => { - const quoteAmount = AmountMath.make(quoteBrand, [ - { - amountIn, - amountOut, - timer, - timestamp: quoteTime, - }, - ]); + const quoteAmount = AmountMath.make( + quoteBrand, + harden([ + { + amountIn, + amountOut, + timer, + timestamp: quoteTime, + }, + ]), + ); const quote = harden({ quotePayment: E(quoteMint).mintPayment(quoteAmount), quoteAmount, diff --git a/api/test/test-fakePriceAuthority.js b/api/test/test-fakePriceAuthority.js index 070204b..ecc02d8 100644 --- a/api/test/test-fakePriceAuthority.js +++ b/api/test/test-fakePriceAuthority.js @@ -37,14 +37,14 @@ test('priceAuthority quoteAtTime', async t => { }); const done = E(priceAuthority) - .quoteAtTime(3n, moola(5), bucksBrand) + .quoteAtTime(3n, moola(5n), bucksBrand) .then(async quote => { t.deepEqual( - moola(5), + moola(5n), quote.quoteAmount.value[0].amountIn, 'amountIn match', ); - t.deepEqual(bucks(55 * 5), quote.quoteAmount.value[0].amountOut); + t.deepEqual(bucks(55n * 5n), quote.quoteAmount.value[0].amountOut); t.is(3n, quote.quoteAmount.value[0].timestamp); }); @@ -66,7 +66,7 @@ test('priceAuthority quoteGiven', async t => { }); await E(manualTimer).tick(); - const quote = await E(priceAuthority).quoteGiven(moola(37), bucksBrand); + const quote = await E(priceAuthority).quoteGiven(moola(37n), bucksBrand); const quoteAmount = quote.quoteAmount.value[0]; t.is(1n, quoteAmount.timestamp); t.deepEqual(bucks(37n * 20n), quoteAmount.amountOut); @@ -83,7 +83,7 @@ test('priceAuthority quoteWanted', async t => { }); await E(manualTimer).tick(); - const quote = await E(priceAuthority).quoteWanted(moolaBrand, bucks(400)); + const quote = await E(priceAuthority).quoteWanted(moolaBrand, bucks(400n)); const quoteAmount = quote.quoteAmount.value[0]; t.is(1n, quoteAmount.timestamp); t.deepEqual(bucks(400n), quoteAmount.amountOut); @@ -129,13 +129,13 @@ test('priceAuthority quoteWhenGTE', async t => { }); const expected = E(priceAuthority) - .quoteWhenGTE(moola(1), bucks(40)) + .quoteWhenGTE(moola(1n), bucks(40n)) .then(quote => { const quoteInAmount = quote.quoteAmount.value[0]; t.is(4n, manualTimer.getCurrentTimestamp()); t.is(4n, quoteInAmount.timestamp); - t.deepEqual(bucks(40), quoteInAmount.amountOut); - t.deepEqual(moola(1), quoteInAmount.amountIn); + t.deepEqual(bucks(40n), quoteInAmount.amountOut); + t.deepEqual(moola(1n), quoteInAmount.amountIn); }); await E(manualTimer).tick(); @@ -155,13 +155,13 @@ test('priceAuthority quoteWhenLT', async t => { }); const expected = E(priceAuthority) - .quoteWhenLT(moola(1), bucks(30)) + .quoteWhenLT(moola(1n), bucks(30n)) .then(quote => { const quoteInAmount = quote.quoteAmount.value[0]; t.is(3n, manualTimer.getCurrentTimestamp()); t.is(3n, quoteInAmount.timestamp); - t.deepEqual(bucks(29), quoteInAmount.amountOut); - t.deepEqual(moola(1), quoteInAmount.amountIn); + t.deepEqual(bucks(29n), quoteInAmount.amountOut); + t.deepEqual(moola(1n), quoteInAmount.amountIn); }); await E(manualTimer).tick();