From 73cdf3ea4f96e8328e45c6a5bbbc2b5e8acdbf96 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 16 Jan 2023 10:49:10 -0800 Subject: [PATCH 1/2] chore: suppress no-nested-await in demo proposal --- packages/inter-protocol/src/proposals/demoIssuers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/inter-protocol/src/proposals/demoIssuers.js b/packages/inter-protocol/src/proposals/demoIssuers.js index 8763fb5eca6..e54c0aa5873 100644 --- a/packages/inter-protocol/src/proposals/demoIssuers.js +++ b/packages/inter-protocol/src/proposals/demoIssuers.js @@ -1,3 +1,4 @@ +/* eslint-disable @jessie.js/no-nested-await -- demo file */ import { AmountMath, AssetKind } from '@agoric/ertp'; import { objectMap } from '@agoric/internal'; import { From 9721eb8d854d6938d0cb19252177b04ae16bb9ae Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 16 Jan 2023 10:48:03 -0800 Subject: [PATCH 2/2] chore: handle floating promises --- .../scripts/add-initial-liquidity.js | 2 +- .../src/price/priceAggregatorChainlink.js | 21 +++++++++++-------- .../src/proposals/price-feed-proposal.js | 6 +++--- .../src/vaultFactory/liquidation.js | 2 +- packages/inter-protocol/test/psm/test-psm.js | 10 +++++---- .../smartWallet/test-oracle-integration.js | 4 ++-- .../test/smartWallet/test-psm-integration.js | 2 +- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/packages/inter-protocol/scripts/add-initial-liquidity.js b/packages/inter-protocol/scripts/add-initial-liquidity.js index 238cae67fb7..dcdc3226e7c 100644 --- a/packages/inter-protocol/scripts/add-initial-liquidity.js +++ b/packages/inter-protocol/scripts/add-initial-liquidity.js @@ -165,7 +165,7 @@ const addInitialLiquidity = async (homeP, { now = () => Date.now() }) => { const payouts = await E(seat).getPayouts(); console.log('initialLiquidityPayouts', keys(payouts)); - E(scratch).set('initialLiquidityPayouts', payouts); + await E(scratch).set('initialLiquidityPayouts', payouts); }; console.log( diff --git a/packages/inter-protocol/src/price/priceAggregatorChainlink.js b/packages/inter-protocol/src/price/priceAggregatorChainlink.js index 75b2dd81308..144a759152f 100644 --- a/packages/inter-protocol/src/price/priceAggregatorChainlink.js +++ b/packages/inter-protocol/src/price/priceAggregatorChainlink.js @@ -183,16 +183,19 @@ export const start = async (zcf, privateArgs, baggage) => { }); // for each new quote from the priceAuthority, publish it to off-chain storage - observeNotifier(priceAuthority.makeQuoteNotifier(unitAmountIn, brandOut), { - updateState: quote => - pricePublisher.publish(priceDescriptionFromQuote(quote)), - fail: reason => { - throw Error(`priceAuthority observer failed: ${reason}`); + void observeNotifier( + priceAuthority.makeQuoteNotifier(unitAmountIn, brandOut), + { + updateState: quote => + pricePublisher.publish(priceDescriptionFromQuote(quote)), + fail: reason => { + throw Error(`priceAuthority observer failed: ${reason}`); + }, + finish: done => { + throw Error(`priceAuthority observer died: ${done}`); + }, }, - finish: done => { - throw Error(`priceAuthority observer died: ${done}`); - }, - }); + ); const creatorFacet = Far('PriceAggregatorChainlinkCreatorFacet', { /** diff --git a/packages/inter-protocol/src/proposals/price-feed-proposal.js b/packages/inter-protocol/src/proposals/price-feed-proposal.js index c9e9b27ebf7..898d91f791b 100644 --- a/packages/inter-protocol/src/proposals/price-feed-proposal.js +++ b/packages/inter-protocol/src/proposals/price-feed-proposal.js @@ -122,7 +122,7 @@ export const createPriceFeed = async ( // Default to an empty Map and home.priceAuthority. produceAggregators.resolve(new Map()); - E(client).assignBundle([_addr => ({ priceAuthority })]); + void E(client).assignBundle([_addr => ({ priceAuthority })]); const timer = await chainTimerService; @@ -168,7 +168,7 @@ export const createPriceFeed = async ( marshaller, }, ); - E(aggregators).set(terms, { aggregator }); + await E(aggregators).set(terms, { aggregator }); E(E(agoricNamesAdmin).lookupAdmin('instance')).update( AGORIC_INSTANCE_NAME, @@ -177,7 +177,7 @@ export const createPriceFeed = async ( // Publish price feed in home.priceAuthority. const forceReplace = true; - E(priceAuthorityAdmin) + void E(priceAuthorityAdmin) .registerPriceAuthority( E(aggregator.publicFacet).getPriceAuthority(), brandIn, diff --git a/packages/inter-protocol/src/vaultFactory/liquidation.js b/packages/inter-protocol/src/vaultFactory/liquidation.js index 0e86096010c..feb9722f87c 100644 --- a/packages/inter-protocol/src/vaultFactory/liquidation.js +++ b/packages/inter-protocol/src/vaultFactory/liquidation.js @@ -44,7 +44,7 @@ const makeQuote = (priceAuthority, highestDebtRatio, liquidationMargin) => { * @param {Ratio} liquidationMargin */ const updateQuote = (quote, highestDebtRatio, liquidationMargin) => { - E(quote).updateLevel( + void E(quote).updateLevel( highestDebtRatio.denominator, // collateral liquidationThreshold(highestDebtRatio, liquidationMargin), ); diff --git a/packages/inter-protocol/test/psm/test-psm.js b/packages/inter-protocol/test/psm/test-psm.js index 325ac9ac164..5d7f2bf24a1 100644 --- a/packages/inter-protocol/test/psm/test-psm.js +++ b/packages/inter-protocol/test/psm/test-psm.js @@ -342,7 +342,7 @@ test('limit', async t => { const actualAnchor = await E(anchor.issuer).getAmountOf(anchorReturn); t.deepEqual(actualAnchor, give); // The pool should be unchanged - driver.assertPoolBalance(initialPool); + await driver.assertPoolBalance(initialPool); }); test('limit is for minted', async t => { @@ -354,7 +354,7 @@ test('limit is for minted', async t => { trace('test going over limit'); const giveTooMuch = anchor.make(MINT_LIMIT); const seat1 = await driver.swapAnchorForMintedSeat(giveTooMuch); - t.throwsAsync( + await t.throwsAsync( () => E(seat1).getOfferResult(), { message: 'Request would exceed mint limit', @@ -482,7 +482,7 @@ test('anchor is 2x minted', async t => { const actualRun = await E(minted.issuer).getAmountOf(runPayouts.Out); t.deepEqual(actualRun, expectedRun); - driver.assertPoolBalance(giveAnchor); + await driver.assertPoolBalance(giveAnchor); const giveRun = AmountMath.make(minted.brand, scale6(100)); trace('get minted ratio', { giveRun, expectedRun, actualRun }); @@ -497,7 +497,9 @@ test('anchor is 2x minted', async t => { anchorPerMinted, ); t.deepEqual(actualAnchor, expectedAnchor); - driver.assertPoolBalance(AmountMath.subtract(giveAnchor, expectedAnchor)); + await driver.assertPoolBalance( + AmountMath.subtract(giveAnchor, expectedAnchor), + ); trace('get anchor', { runGive: giveRun, expectedRun, actualAnchor }); }); diff --git a/packages/inter-protocol/test/smartWallet/test-oracle-integration.js b/packages/inter-protocol/test/smartWallet/test-oracle-integration.js index eb72a47f629..466df951352 100644 --- a/packages/inter-protocol/test/smartWallet/test-oracle-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-oracle-integration.js @@ -41,7 +41,7 @@ const makeTestSpace = async log => { }, psmParams, ); - psmVatRoot.bootstrap(...mockPsmBootstrapArgs(log)); + void psmVatRoot.bootstrap(...mockPsmBootstrapArgs(log)); // TODO mimic the proposals and manifest of price-feed-proposal and price-feed-core // calling ensureOracleBrands and createPriceFeed @@ -237,7 +237,7 @@ test.serial('admin price', async t => { t.context.consume.chainTimerService ); // trigger an aggregation (POLL_INTERVAL=1n in context) - E(manualTimer).tickN(1); + await E(manualTimer).tickN(1); const paPublicFacet = await E(zoe).getPublicFacet(priceAggregator); diff --git a/packages/inter-protocol/test/smartWallet/test-psm-integration.js b/packages/inter-protocol/test/smartWallet/test-psm-integration.js index b1806343982..5b217bc7ee2 100644 --- a/packages/inter-protocol/test/smartWallet/test-psm-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-psm-integration.js @@ -40,7 +40,7 @@ const makePsmTestSpace = async log => { }, psmParams, ); - psmVatRoot.bootstrap(...mockPsmBootstrapArgs(log)); + void psmVatRoot.bootstrap(...mockPsmBootstrapArgs(log)); // @ts-expect-error cast return /** @type {ChainBootstrapSpace} */ (psmVatRoot.getPromiseSpace());