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

document contract; rename to avoid "game" #38

Closed
wants to merge 2 commits into from
Closed

Conversation

dckc
Copy link
Member

@dckc dckc commented Jan 4, 2024

TODO:

  • update ui/
  • test deployment in a running chain
  • rename package(s)

fixes #22

cc @0xpatrickdev

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
Comment on lines +23 to +35
// #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

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.

Copy link
Member Author

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.

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();

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?

Copy link
Member Author

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

@dckc
Copy link
Member Author

dckc commented Jan 23, 2024

oops! this PR doesn't actually work. I broke it into two pieces:

@dckc dckc closed this Jan 23, 2024
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.

dapp-offer-up still calls itself "game" in various places
3 participants