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

fix(zoe): fix auction makeBidInvitation #4899

Closed
wants to merge 1 commit into from
Closed

Conversation

samsiegart
Copy link
Contributor

@@ -102,20 +102,20 @@ const start = zcf => {
return bidSeats.map(seat => seat.getAmountAllocated('Bid', bidBrand));
};

const getSessionDetails = () => {
const getSessionDetails = async () => {
const sellerProposal = sellSeat.getProposal();
return harden({
Copy link
Member

Choose a reason for hiding this comment

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

Your use of await nested within an expression violates our await design rule. This code is a good example of why. Looking at this code, is it clear whether sellerProposal.want.Ask and getCurrentBids() are evaluated before or after the await point?

Instead, if you want to use await here, I suggest you rename the variable that might hold a promise for a time authority to something else, and then await it at function top level to obtain the non-promise time authority variable.

Suggested change
return harden({
const timeAuthority = await timeAuthorityP;
return harden({

const sellerProposal = sellSeat.getProposal();
return harden({
auctionedAssets: sellerProposal.give.Asset,
minimumBid: sellerProposal.want.Ask,
winnerPriceOption,
closesAfter,
bidDuration,
timeAuthority,
timeAuthority: await timeAuthority,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
timeAuthority: await timeAuthority,
timeAuthority,

@@ -133,7 +133,7 @@ const start = zcf => {
return defaultAcceptanceMsg;
};

const customProperties = getSessionDetails();
const customProperties = await getSessionDetails();
Copy link
Member

Choose a reason for hiding this comment

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

This one is good.

@@ -40,7 +40,10 @@ test('zoe - secondPriceAuction w/ 3 bids', async t => {
Asset: moolaKit.issuer,
Ask: simoleanKit.issuer,
});
const terms = { timeAuthority: timer, bidDuration: 1n };
const terms = {
timeAuthority: Promise.resolve(timer),
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the purpose of this. Why wrap the timer in a promise? I'm equally confused by the other examples below.

@samsiegart
Copy link
Contributor Author

@erights Thanks for reviewing. Your feedback about the await design rule was helpful. I was wrapping the timer in a promise in the tests to mirror the fact that it was being passed in as a promise in production (causing the contract to break). That way, the tests fail without the fixes to the contract in this PR.

However, I think I'd like to close this PR in favor of Agoric/dapp-card-store#51 since it's simpler.

@samsiegart samsiegart closed this Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot Bid On A Card
2 participants