Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6000 remove zoe floating promises #9458

Merged
merged 9 commits into from
Jun 7, 2024
4 changes: 2 additions & 2 deletions packages/zoe/src/contractFacet/zcfMint.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const prepareZcMint = (
// committed atomically, but it is not a disaster if they are
// not. If we minted only, no one would ever get those
// invisibly-minted assets.
E(zoeMint).mintAndEscrow(totalToMint);
void E(zoeMint).mintAndEscrow(totalToMint);
reallocator.reallocate(zcfSeat, allocationPlusGains);
return zcfSeat;
},
Expand Down Expand Up @@ -143,7 +143,7 @@ export const prepareZcMint = (
// not. If we only commit the allocationMinusLosses no one would
// ever get the unburned assets.
reallocator.reallocate(zcfSeat, allocationMinusLosses);
E(zoeMint).withdrawAndBurn(totalToBurn);
void E(zoeMint).withdrawAndBurn(totalToBurn);
},
},
);
Expand Down
7 changes: 5 additions & 2 deletions packages/zoe/src/contractFacet/zcfSeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@
assertActive(self);
assertNoStagedAllocation(self);
doExitSeat(self);
E(zoeInstanceAdmin).exitSeat(zcfSeatToSeatHandle.get(self), completion);
void E(zoeInstanceAdmin).exitSeat(
zcfSeatToSeatHandle.get(self),
completion,
);
zcfSeatToSeatHandle.delete(self);
},
fail(
Expand All @@ -185,7 +188,7 @@
}
if (!hasExited(self)) {
doExitSeat(self);
E(zoeInstanceAdmin).failSeat(
void E(zoeInstanceAdmin).failSeat(
zcfSeatToSeatHandle.get(self),
harden(reason),
);
Expand Down Expand Up @@ -410,8 +413,8 @@
}
},
reallocate(/** @type {ZCFSeat[]} */ ...seats) {
seats.forEach(assertActive);

Check warning on line 416 in packages/zoe/src/contractFacet/zcfSeat.js

View workflow job for this annotation

GitHub Actions / lint-primary

Prefer for...of instead of Array.forEach
seats.forEach(assertStagedAllocation);

Check warning on line 417 in packages/zoe/src/contractFacet/zcfSeat.js

View workflow job for this annotation

GitHub Actions / lint-primary

Prefer for...of instead of Array.forEach

// Ensure that rights are conserved overall.
const flattenAllocations = allocations =>
Expand Down Expand Up @@ -456,7 +459,7 @@
// for each of the seats) and inform Zoe of the
// newAllocation.

seats.forEach(commitStagedAllocation);

Check warning on line 462 in packages/zoe/src/contractFacet/zcfSeat.js

View workflow job for this annotation

GitHub Actions / lint-primary

Prefer for...of instead of Array.forEach

const seatHandleAllocations = seats.map(seat => {
const seatHandle = zcfSeatToSeatHandle.get(seat);
Expand Down
6 changes: 3 additions & 3 deletions packages/zoe/src/contractFacet/zcfZygote.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const makeZCFZygote = async (

/** @type {import('@agoric/swingset-vat').ShutdownWithFailure} */
const shutdownWithFailure = reason => {
E(zoeInstanceAdmin).failAllSeats(reason);
void E(zoeInstanceAdmin).failAllSeats(reason);
seatManager.dropAllReferences();
// https://github.com/Agoric/agoric-sdk/issues/3239
powers.exitVatWithFailure(reason);
Expand Down Expand Up @@ -114,7 +114,7 @@ export const makeZCFZygote = async (
const zcfSeat = seatManager.makeZCFSeat(seatData);

const exiter = makeExiter(seatData.proposal, zcfSeat);
E(zoeInstanceAdmin)
void E(zoeInstanceAdmin)
.makeNoEscrowSeat(initialAllocation, proposal, exiter, seatHandle)
.then(userSeat => userSeatPromiseKit.resolve(userSeat));

Expand Down Expand Up @@ -326,7 +326,7 @@ export const makeZCFZygote = async (
},
// Shutdown the entire vat and give payouts
shutdown: completion => {
E(zoeInstanceAdmin).exitAllSeats(completion);
void E(zoeInstanceAdmin).exitAllSeats(completion);
seatManager.dropAllReferences();
powers.exitVat(completion);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contractSupport/priceAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const makeOnewayPriceAuthorityKit = opts => {
);
amountIn = coercedAmountIn;
amountOutLimit = coercedAmountOutLimit;
fireTriggers(createQuote);
void fireTriggers(createQuote);
},
getPromise: () => triggerPK.promise,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const makeInitialTransform = (
assert.equal(bOut, brandOut);

const quoteP = E(priceAuthority).quoteGiven(amountIn, brandOut);
quoteP.then(() => (initialMode = false));
void quoteP.then(() => (initialMode = false));
return initialMode
? mintCurrentQuote(amountIn, multiplyBy(amountIn, priceOutPerIn))
: quoteP;
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 @@ -137,7 +137,7 @@
!Array.isArray(expected) || Fail`Expected must be an non-array object`;
const assertValuesNull = e => {
if (e !== undefined) {
Object.values(e).forEach(

Check warning on line 140 in packages/zoe/src/contractSupport/zoeHelpers.js

View workflow job for this annotation

GitHub Actions / lint-primary

Prefer for...of instead of Array.forEach
value =>
value === null ||
Fail`The value of the expected record must be null but was ${value}`,
Expand Down Expand Up @@ -365,7 +365,7 @@
depositedPromiseKit.resolve(mappedAmounts);
};

E(userSeatPromise).getPayouts().then(doDeposit);
void E(userSeatPromise).getPayouts().then(doDeposit);

// TODO rename return key; userSeatPromise is a remote UserSeat
return harden({ userSeatPromise, deposited: depositedPromiseKit.promise });
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/src/contracts/auction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ const start = zcf => {
});
assertBidSeat(zcf, sellSeat, seat);

// XXX await make function hanging
startWakeupTimerIfNeeded();
void startWakeupTimerIfNeeded();

bidSeats.push(seat);
return defaultAcceptanceMsg;
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contracts/callSpread/payoffHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function makePayoffHandler(zcf, seatPromiseKits, collateralSeat) {
}

function reallocateToSeat(seatPromise, seatPortion) {
E.when(seatPromise, seat => {
void E.when(seatPromise, seat => {
atomicTransfer(zcf, collateralSeat, seat, { Collateral: seatPortion });
seat.exit();
seatsExited += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const start = zcf => {
'strikePrice2 must be greater than strikePrice1',
);

zcf.saveIssuer(zcf.getInvitationIssuer(), 'Options');
void zcf.saveIssuer(zcf.getInvitationIssuer(), 'Options');

// We will create the two options early and allocate them to this seat.
const { zcfSeat: collateralSeat } = zcf.makeEmptySeatKit();
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contracts/loan/scheduleLiquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const scheduleLiquidation = (zcf, configWithBorrower) => {
const currentCollateral = collateralSeat.getAmountAllocated('Collateral');
if (AmountMath.isEqual(amountIn, currentCollateral)) {
liquidationPromiseKit.resolve(priceQuote);
liquidate(zcf, configWithBorrower);
void liquidate(zcf, configWithBorrower);
}
})
.catch(err => {
Expand Down
6 changes: 3 additions & 3 deletions packages/zoe/src/contracts/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const start = async zcf => {
Fail`Oracle required a fee but the query had none`;
return reply;
} catch (e) {
E(handler).onError(query, e);
void E(handler).onError(query, e);
throw e;
}
},
Expand All @@ -91,10 +91,10 @@ const start = async zcf => {
atomicTransfer(zcf, querySeat, feeSeat, { Fee: requiredFee });
}
querySeat.exit();
E(handler).onReply(query, reply, requiredFee);
void E(handler).onReply(query, reply, requiredFee);
return reply;
} catch (e) {
E(handler).onError(query, e);
void E(handler).onError(query, e);
throw e;
}
};
Expand Down
31 changes: 17 additions & 14 deletions packages/zoe/src/contracts/priceAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const start = async (zcf, privateArgs) => {
await Promise.all(querierPs).catch(console.error);
},
});
E(repeaterP).schedule(waker);
void E(repeaterP).schedule(waker);

/**
* @param {object} param0
Expand Down Expand Up @@ -231,17 +231,20 @@ const start = async (zcf, privateArgs) => {
});

// for each new quote from the priceAuthority, publish it to off-chain storage
observeNotifier(priceAuthority.makeQuoteNotifier(unitAmountIn, brandOut), {
updateState: quote => {
publisher.publish(priceDescriptionFromQuote(quote));
},
fail: reason => {
throw Error(`priceAuthority observer failed: ${reason}`);
},
finish: done => {
throw Error(`priceAuthority observer died: ${done}`);
void observeNotifier(
priceAuthority.makeQuoteNotifier(unitAmountIn, brandOut),
{
updateState: quote => {
publisher.publish(priceDescriptionFromQuote(quote));
},
fail: reason => {
throw Error(`priceAuthority observer failed: ${reason}`);
},
finish: done => {
throw Error(`priceAuthority observer died: ${done}`);
},
},
});
);

/**
* @param {Ratio} r
Expand Down Expand Up @@ -388,7 +391,7 @@ const start = async (zcf, privateArgs) => {
return;
}
// Queue the next update.
E(oracleNotifier).getUpdateSince(updateCount).then(recurse);
void E(oracleNotifier).getUpdateSince(updateCount).then(recurse);

// See if we have associated parameters or just a raw value.
/** @type {Ratio | undefined} */
Expand Down Expand Up @@ -424,7 +427,7 @@ const start = async (zcf, privateArgs) => {
};

// Start the notifier.
E(oracleNotifier).getUpdateSince().then(recurse);
void E(oracleNotifier).getUpdateSince().then(recurse);
};

const creatorFacet = Far('PriceAggregatorCreatorFacet', {
Expand Down Expand Up @@ -463,7 +466,7 @@ const start = async (zcf, privateArgs) => {
assertParsableNumber(price);
return zcf.makeInvitation(cSeat => {
cSeat.exit();
admin.pushResult(price);
void admin.pushResult(price);
}, 'PushPrice');
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contracts/sellItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const start = zcf => {
const sell = seat => {
sellerSeat = seat;

observeIteration(
void observeIteration(
subscribeLatest(sellerSeat.getSubscriber()),
harden({
updateState: sellerSeatAllocation =>
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/zoeService/instanceAdminStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const makeInstanceAdminBehavior = (zoeBaggage, makeZoeSeatAdminKit) => {

state.zoeSeatAdmins.add(zoeSeatAdmin);
state.handleOfferObj || Fail`incomplete setup of zoe seat`;
E.when(
void E.when(
E(state.handleOfferObj).handleOffer(invitationHandle, seatData),
/** @param {HandleOfferResult} result */
result => zoeSeatAdmin.resolveExitAndResult(result),
Expand Down
4 changes: 2 additions & 2 deletions packages/zoe/src/zoeService/originalZoeSeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const declareOldZoeSeatAdminKind = (baggage, makeDurablePublishKit) => {
assertHasNotExited(this, 'Cannot exit seat. Seat has already exited');

state.exiting = true;
E.when(
void E.when(
doExit(
facets.zoeSeatAdmin,
state.currentAllocation,
Expand All @@ -190,7 +190,7 @@ export const declareOldZoeSeatAdminKind = (baggage, makeDurablePublishKit) => {
assertHasNotExited(this, 'Cannot fail seat. Seat has already exited');

state.exiting = true;
E.when(
void E.when(
doExit(
facets.zoeSeatAdmin,
state.currentAllocation,
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/zoeService/zoeSeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const makeZoeSeatAdminFactory = baggage => {
);

state.exiting = true;
E.when(
void E.when(
doExit(
facets.zoeSeatAdmin,
state.currentAllocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const throwInAPILog = [
'=> alice is set up',
'=> alice.doThrowInApiCall called',
'counter: 3',
'Swap outcome is an invitation (true).',
'throwingAPI should throw Error: someException',
'counter: 5',
'counter: 6',
'Swap outcome is an invitation (true).',
'newCounter: 2',
'counter: 7',
'outcome correctly resolves: "The offer has been accepted. Once the contract has been completed, please check your payout"',
Expand Down
25 changes: 12 additions & 13 deletions packages/zoe/test/swingsetTests/brokenContracts/vat-alice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck
/* eslint @typescript-eslint/no-floating-promises: "warn" */

import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
Expand Down Expand Up @@ -42,7 +41,7 @@ const build = async (log, zoe, issuers, payments, installations) => {
});
const alicePayments = { Asset: moolaPayment };

logCounter(log, publicFacet);
await logCounter(log, publicFacet);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably ok if these stayed void but good to have the confident now of what the order is

const invitation = await E(publicFacet).makeThrowingInvitation();
const seat = await E(zoe).offer(invitation, proposal, alicePayments);

Expand All @@ -52,15 +51,15 @@ const build = async (log, zoe, issuers, payments, installations) => {
() => assert(false, ' expected outcome to fail'),
e => log(`outcome correctly resolves to broken: ${e}`),
);
logCounter(log, publicFacet);
await logCounter(log, publicFacet);
const moolaPayout = await E(seat).getPayout('Asset');
const simoleanPayout = await E(seat).getPayout('Price');

await E(moolaPurseP).deposit(moolaPayout);
await E(simoleanPurseP).deposit(simoleanPayout);
await showPurseBalance(moolaPurseP, 'aliceMoolaPurse', log);
await showPurseBalance(simoleanPurseP, 'aliceSimoleanPurse', log);
logCounter(log, publicFacet);
await logCounter(log, publicFacet);

// zoe should still be able to make new vats.
const { publicFacet: publicFacet2 } = await E(zoe).startInstance(
Expand All @@ -87,9 +86,9 @@ const build = async (log, zoe, issuers, payments, installations) => {
E(newPurse).deposit(swapMoolaPayout);
E(simoleanPurseP).deposit(swapSimoleanPayout);

showPurseBalance(newPurse, 'new Purse', log);
showPurseBalance(simoleanPurseP, 'aliceSimoleanPurse', log);
logCounter(log, publicFacet);
await showPurseBalance(newPurse, 'new Purse', log);
await showPurseBalance(simoleanPurseP, 'aliceSimoleanPurse', log);
await logCounter(log, publicFacet);
};

const doThrowInApiCall = async () => {
Expand Down Expand Up @@ -124,7 +123,7 @@ const build = async (log, zoe, issuers, payments, installations) => {
.getOfferResult()
.then(
o => {
E(invitationIssuer)
return E(invitationIssuer)
.isLive(o)
.then(val => {
swapInvitationTwo = o;
Expand All @@ -133,18 +132,18 @@ const build = async (log, zoe, issuers, payments, installations) => {
},
e => assert(false, X`expected outcome not to resolve yet ${e}`),
);
logCounter(log, publicFacet);
await logCounter(log, publicFacet);

E(publicFacet)
.throwSomething()
.then(
() => assert(false, 'expecting this to throw'),
e => log(`throwingAPI should throw ${e}`),
);
logCounter(log, publicFacet);
await logCounter(log, publicFacet);

// These should not resolve at this point, the funds are still escrowed
E(swapSeat)
void E(swapSeat)
.getPayouts()
.then(async swapPayout => {
const moolaSwapPayout = await swapPayout.Asset;
Expand All @@ -157,7 +156,7 @@ const build = async (log, zoe, issuers, payments, installations) => {
});

// show that the contract is still responsive.
logCounter(log, publicFacet);
await logCounter(log, publicFacet);

// zoe should still be able to make new vats.
const { publicFacet: publicFacet2 } = await E(zoe).startInstance(
Expand All @@ -178,7 +177,7 @@ const build = async (log, zoe, issuers, payments, installations) => {
swapTwoProposal,
aliceSwapTwoPayments,
);
logCounter(log, publicFacet);
await logCounter(log, publicFacet);

E(swapSeatTwo)
.getOfferResult()
Expand Down
5 changes: 2 additions & 3 deletions packages/zoe/test/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint @typescript-eslint/no-floating-promises: "warn" */
/**
* @file uses .ts syntax to be able to declare types (e.g. of kit.creatorFacet as {})
* because "there is no JavaScript syntax for passing a a type argument"
Expand Down Expand Up @@ -93,15 +92,15 @@ const mock = null as any;

// XXX remote method requires E()
const pf1 = await zoe.getPublicFacet(instance);
pf1.getPriceAuthority();
void pf1.getPriceAuthority();
// @ts-expect-error
pf1.notInPublicFacet;

const rf: RemoteFunctions<typeof zoe> = mock;
rf.getPublicFacet;

const pf2 = await E(zoe).getPublicFacet(instance);
pf2.getPriceAuthority();
void pf2.getPriceAuthority();
// @ts-expect-error
pf2.notInPublicFacet;
}
Loading
Loading