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

[Zoe] Zoe Release v0.3.0 #685

Merged
merged 3 commits into from
Mar 25, 2020
Merged

[Zoe] Zoe Release v0.3.0 #685

merged 3 commits into from
Mar 25, 2020

Conversation

katelynsills
Copy link
Contributor

@katelynsills katelynsills commented Mar 13, 2020

This is the release PR for "Zoe Keywords" (Release v0.3.0).

"OfferRules", or the declarative statement portion of an offer, have
been renamed to "proposal". The structure of a proposal has changed to:

{
  give: { Asset: moola(4 )},
  want: { Price: simoleans(15) },
  exit: { afterDeadline: {
    timer,
    deadline: 100,
  }}
}

(* moola is an alias for moolaAmountMath.make, and likewise for
simoleans.)

There are no longer any keys such as 'payoutRules' or 'exitRule'. Most
importantly, we no longer rely on the specific order of payoutRules
arrays and payment/payout arrays to be the same. In fact, we can even
make a partial proposal that will be filled in.

Asset and Price in the above example are called "keywords". Each
contract has its own specific keywords. For instance, an auction
might have "Asset" and "Bid". Keywords are unique identifiers per
contract, that tie together the proposal, payments to be escrowed, and
payouts to the user.

Users should submit their payments using keywords:

const payments = { Asset: moolaPayment };

And, users will receive their payouts with keywords as the keys of a
payout object:

moolaPurse.deposit(payout.Asset);

In summary, the arrays that were part of the previous API have been
replaced with records keyed by keywords.

Below is a summary of the changes:

Changes to the Zoe Service (User-facing) API:

  • makeInstance now takes in three arguments: installationHandle,
    issuerKeywordRecord, and terms. issuerKeywordRecord should have strings
    as keys (called keywords), and issuers as values (called args).
    For instance, {Asset: moolaIssuer, Price: simoleanIssuer }. Terms
    no longer needs an issuers property. Instead, terms should be used for
    any contract-specific parameters, such as the number of bids an
    auction should wait for before closing.
  • OfferRules (now proposal) have the new structure mentioned above
  • Payments to be escrowed must be an object keyed by keywords rather
    than an array
  • Payouts from Zoe will be in the form of a promise that resolves to a
    object keyed by keywords where the values are promises for
    payments
  • We have added three new methods to the Zoe Service API: getOffer,
    getOffers, and isOfferActive. Note that getOffer and
    getOffers will throw if the offer is not found, whereas
    isOfferActive is safe to check whether an offer is still active or
    not.

Changes to the Contract Facet API and contract helpers:

  • The userFlow helpers have been renamed to zoeHelpers
  • hasValidPayoutRules is no longer a helper function due to the
    change in the proposal structure
  • Instead, we have three new helpers: assertKeywords which can be
    used to make sure that the keywords on instantiation match what
    the contract expects, rejectIfNotProposal which rejects an
    offer if the proposal have the wrong structure, and
    checkIfProposal which checks if the proposal match the
    expected structure and returns true or false.
  • getAmountMathForIssuers and getBrandsForIssuers no longer exist
  • getAmountMaths is added. It takes in a issuerKeywordRecord
    record that maps keywords to issuers.
  • getInstanceRecord is added. It allows the contracts to get access
    to their keywords, issuers and other "instanceRecord" information from
    Zoe.
  • The instanceRecord now has properties: issuerKeywordRecord (a record with
    keyword keys and issuer values) and keywords (an array of
    strings). The keywords in issuerKeywordRecord and the keywords array
    are the same.
  • In the offerRecord, amounts are no longer an array. Instead they are
    an amountKeywordRecord, an object with keywords as keys and amount
    values.
  • Reallocate now takes an array of offerHandles/inviteHandles and an
    array of the above amountKeywordRecords keyed on keywords.
  • AddNewIssuer now requires a keyword to be provided alongside the issuer.

Closes #97
Closes #392
Closes #469
Closes #564
Closes #677
Closes #686

@katelynsills katelynsills added the Zoe package: Zoe label Mar 13, 2020
@katelynsills katelynsills mentioned this pull request Mar 13, 2020
18 tasks
@katelynsills katelynsills linked an issue Mar 13, 2020 that may be closed by this pull request
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

Some early comments to give Kate a head start on anything that needs to be added. More comments coming. Most of my requests are about documentation or testing, which shouldn't be too surprising.

packages/zoe/src/cleanOfferRules.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/autoswap.js Show resolved Hide resolved
packages/zoe/src/contracts/helpers/zoeHelpers.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/helpers/zoeHelpers.js Outdated Show resolved Hide resolved
packages/zoe/src/isOfferSafe.js Outdated Show resolved Hide resolved
packages/zoe/src/isOfferSafe.js Outdated Show resolved Hide resolved
packages/zoe/src/roleConversion.js Outdated Show resolved Hide resolved
packages/zoe/src/state.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

Most suggestions at #700

packages/zoe/src/contracts/automaticRefund.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
packages/zoe/src/contracts/publicAuction.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/myFirstDapp.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/simpleExchange.js Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
@katelynsills katelynsills added this to the Zoe 0.3.0 milestone Mar 18, 2020
@katelynsills katelynsills linked an issue Mar 18, 2020 that may be closed by this pull request
@katelynsills katelynsills self-assigned this Mar 19, 2020
@katelynsills katelynsills force-pushed the zoe-release-0.3.0 branch 2 times, most recently from aac6689 to ee7533b Compare March 19, 2020 18:26
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Show resolved Hide resolved
@erights
Copy link
Member

erights commented Mar 19, 2020

The difference LGTM so you can now squash as you wish.

Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

Note that my review skips

chainmail file
most tests
the wrong myFirstDapp that should be deleted anyway

The review is not yet done. But zoe.js is done, which is the most important part. More soon.

packages/zoe/src/cleanOfferRules.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/coveredCall.js Show resolved Hide resolved
packages/zoe/src/contracts/helpers/zoeHelpers.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/myFirstDapp.js Outdated Show resolved Hide resolved
packages/zoe/src/isOfferSafe.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.js Outdated Show resolved Hide resolved
@erights
Copy link
Member

erights commented Mar 20, 2020

Both differential commits LGTM. Squash when you wish.

I'm glad you deleted myFirstDapp despite my misunderstanding. If we can, please leave it deleted.

@erights
Copy link
Member

erights commented Mar 20, 2020

(I don't know why, once I've started a review, I can't comment in place on review comments like #685 (comment) )

At #685 (comment) @katelynsills writes:

Sure, I think we can coerce each amount by the corresponding amountMath. What kind of validation can we do of the exit condition structure for afterDeadline? For onDemand and waived we can check the value is null.

Well, at least that the timer and deadline properties exist. Yeah, when I wrote my review comment I hadn't realized how little we can say in general about timer and deadline being well formed. This makes sense though, because the well formedness of a given deadline is only wrt the timer that would understand that deadline.

Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

Everything reviewed except for the exclusions already mentioned + autoswap and bondingCurves. I'm done for the night, busy a whole day tomorrow, and autoSwap is hard. @dtribble what's your feeling about merging this before I review those two, and then doing post-merge review and fixing-if-needed?

packages/zoe/src/isOfferSafe.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.js Outdated Show resolved Hide resolved
packages/zoe/src/rightsConservation.js Show resolved Hide resolved
packages/zoe/src/state.js Outdated Show resolved Hide resolved
packages/zoe/src/zoe.chainmail Outdated Show resolved Hide resolved
packages/zoe/src/state.js Outdated Show resolved Hide resolved
packages/zoe/src/state.js Outdated Show resolved Hide resolved
Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

Still looking at autoswap. All else reviewed.

As of your tenth commit, I've also done all the differential review, so squash at will.

packages/zoe/src/cleanProposal.js Show resolved Hide resolved
packages/zoe/src/cleanProposal.js Outdated Show resolved Hide resolved
packages/zoe/src/cleanProposal.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/helpers/bondingCurves.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/helpers/bondingCurves.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/helpers/bondingCurves.js Outdated Show resolved Hide resolved
Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

Review done.

packages/zoe/src/contracts/autoswap.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/autoswap.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/autoswap.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/autoswap.js Show resolved Hide resolved
packages/zoe/src/contracts/autoswap.js Outdated Show resolved Hide resolved
Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

LGTM

@Chris-Hibbert
Copy link
Contributor

I'm okay with the merge/refactoring of redeem. Now to look at the tests...

@katelynsills
Copy link
Contributor Author

We decided I'm going to add back in any t.plan that existed in Chris's earlier PR that got merged into master.

Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

That was scary!

I did happen to have in my local git the last zoe.js that I approved. Comparing it with the current merged one was easy. Took less than a minute. Reviewing the diff below would have taken hours more.

LGTM

@katelynsills katelynsills merged commit 0f050cc into master Mar 25, 2020
@katelynsills katelynsills deleted the zoe-release-0.3.0 branch April 10, 2020 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment