-
Notifications
You must be signed in to change notification settings - Fork 5
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
document contract; rename to avoid "game" #38
Conversation
TODO: update ui - rename files etc. to avoid "game" - rename brands, keywords, issuers, ... - migrate from reallocate() to atomicRearrange - constrain brands, bag amount in proposal shape - skip tracer() - refactor bag count utilities for clarity
// #region bag utilities | ||
/** @type { (xs: bigint[]) => bigint } */ | ||
const sum = xs => xs.reduce((acc, x) => acc + x, 0n); | ||
|
||
/** | ||
* @param {import('@endo/patterns').CopyBag} bag | ||
* @returns {bigint[]} | ||
*/ | ||
const bagCounts = bag => { | ||
const entries = getCopyBagEntries(bag); | ||
return entries.map(([_k, ct]) => ct); | ||
}; | ||
// #endregion |
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.
#region doesn't seem helpful in this context. I'd drop the comments or move the code to an import.
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.
feedback from @kbennett2000 was that #region is a well-known idiom from Visual Studio, so it was worthwhile. Do you two want to arm-wrestle and tell me how it comes out? :)
An import is what I might normally do, but that means the contract is no longer one file. That's OK if a walk-thru can assume readers grok sum()
and bagCount()
without looking at them. In fact, it could be a benefit to let folks know that they can split up their work.
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.
Do you two want to arm-wrestle and tell me how it comes out?
I will cede the ground. @kbennett2000 knows more than I do about how developers read code.
* @param {ZCF<ItemTerms>} zcf | ||
*/ | ||
export const start = async zcf => { | ||
const { price, maxItems = 3n } = zcf.getTerms(); |
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.
In the 3n case, is the intent that price
is enough for all three items, or were you expecting it to be price * quantity
?
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.
price is enough for all 3
oops! this PR doesn't actually work. I broke it into two pieces: |
TODO:
fixes #22
cc @0xpatrickdev