-
Notifications
You must be signed in to change notification settings - Fork 219
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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({ | ||||||
auctionedAssets: sellerProposal.give.Asset, | ||||||
minimumBid: sellerProposal.want.Ask, | ||||||
winnerPriceOption, | ||||||
closesAfter, | ||||||
bidDuration, | ||||||
timeAuthority, | ||||||
timeAuthority: await timeAuthority, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
bids: getCurrentBids(), | ||||||
}); | ||||||
}; | ||||||
|
||||||
const makeBidInvitation = () => { | ||||||
const makeBidInvitation = async () => { | ||||||
/** @type {OfferHandler} */ | ||||||
const performBid = seat => { | ||||||
assert(!isClosed, X`Auction session is closed, no more bidding`); | ||||||
|
@@ -133,7 +133,7 @@ const start = zcf => { | |||||
return defaultAcceptanceMsg; | ||||||
}; | ||||||
|
||||||
const customProperties = getSessionDetails(); | ||||||
const customProperties = await getSessionDetails(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is good. |
||||||
return zcf.makeInvitation(performBid, 'bid', customProperties); | ||||||
}; | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the purpose of this. Why wrap the |
||
bidDuration: 1n, | ||
}; | ||
const adminP = E(zoe).startInstance( | ||
installation, | ||
issuerKeywordRecord, | ||
|
@@ -274,7 +277,10 @@ test('zoe - secondPriceAuction - alice tries to exit', async t => { | |
Ask: simoleanR.issuer, | ||
}); | ||
const timer = buildManualTimer(console.log); | ||
const terms = harden({ timeAuthority: timer, bidDuration: 1n }); | ||
const terms = harden({ | ||
timeAuthority: Promise.resolve(timer), | ||
bidDuration: 1n, | ||
}); | ||
const { creatorInvitation: aliceInvitation } = await E(zoe).startInstance( | ||
installation, | ||
issuerKeywordRecord, | ||
|
@@ -424,7 +430,10 @@ test('zoe - secondPriceAuction - all bidders try to exit', async t => { | |
Ask: simoleanR.issuer, | ||
}); | ||
const timer = buildManualTimer(console.log); | ||
const terms = harden({ timeAuthority: timer, bidDuration: 1n }); | ||
const terms = harden({ | ||
timeAuthority: Promise.resolve(timer), | ||
bidDuration: 1n, | ||
}); | ||
const { creatorInvitation: aliceInvitation } = await E(zoe).startInstance( | ||
installation, | ||
issuerKeywordRecord, | ||
|
@@ -568,7 +577,10 @@ test('zoe - secondPriceAuction non-fungible asset', async t => { | |
Ask: moolaIssuer, | ||
}); | ||
const timer = buildManualTimer(console.log); | ||
const terms = harden({ timeAuthority: timer, bidDuration: 1n }); | ||
const terms = harden({ | ||
timeAuthority: Promise.resolve(timer), | ||
bidDuration: 1n, | ||
}); | ||
const { creatorInvitation: aliceInvitation } = await E(zoe).startInstance( | ||
installation, | ||
issuerKeywordRecord, | ||
|
@@ -840,7 +852,7 @@ test('zoe - firstPriceAuction w/ 3 bids', async t => { | |
Ask: simoleanKit.issuer, | ||
}); | ||
const terms = { | ||
timeAuthority: timer, | ||
timeAuthority: Promise.resolve(timer), | ||
bidDuration: 1n, | ||
winnerPriceOption: 'first-price', | ||
}; | ||
|
There was a problem hiding this comment.
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 ourawait
design rule. This code is a good example of why. Looking at this code, is it clear whethersellerProposal.want.Ask
andgetCurrentBids()
are evaluated before or after theawait
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.