Skip to content

Commit

Permalink
refactor!: Zoe Release Candidate (#1414)
Browse files Browse the repository at this point in the history
* refactor: refactor Zoe to use seat objects rather than offerHandles

* refactor: update seat namings, add seats.md to docs with diagrams

* refactor: move up init of instance, instanceAdmin

* fix: minting allocations in zcf (#1382)

* refactor: tests for sellItems and mintAndSellNFT pass - need to be reworked for new synchronous mint still

* refactor: fix jsdoc to recognize makeZCFMint as property

* fix: register the new minty issuer on zcf side (#1392)

* refactor: redirect main in package.json

* refactor: apply zoe renames

- `getInviteIssuer` to `getInvitationIssuer`
- `inviteDesc` to `description`

* fix: solve some easy types

* fix: use local amountMath (#1408)

* fix(swingset): check promise resolution table during comms.inbound

refs #1400

* refactor: multipoolAutoswap

* refactor: remove BrandName parameter from ERTP types

* feat: add the ability for a contract to get a synchronous seat

zcf.addEmptySeat() would return a zcfSeat that the contract could use
to hold allocations.

untested

* refactor: cleanup synchronous ZCF seat creation

drop keyword parameter in addEmptySeat()
extract makeZoeSeatAdminKit, use it for emptySeat, too.
rename zcf seat construction to use 'Kit'

* refactor: use updateFromNotifier from library

* refactor: add types to reveal the wallet changes needed for Zoe

* refactor: post review cleanups; mostly type info

improved type annotations
rename makeEmptySeat to makeOfferlessSeat
don't return the zcfSeatAdmin to the contract

* fix: make Zoe typesafe again

* refactor: bring autoswap up to date on the new Zoe spike branch

Based on the synchronous seat work.

The unit tests for autoswap pass. I haven't yet done the swingset tests.

* fix: update autoswap from addEmptySeat() to makeEmptySeatKit()

* chore: add publicFacet and instance to MakeInstanceResult (#1418)

* chore: fix typing of MakeInstanceResult

* chore: add hasExited, getNotifier to UserSeat

* Update more unit tests (#1422)

* chore: update tests

* chore: finish automaticRefund tests

* chore: update barterExchange and brokenContract tests. Small changes to Zoe and types (#1427)

* fix: make the wallet pass unit tests

* refactor: clear up some more types

* fix(dapp-svelte-wallet): minor cleanups

* fix: always use the published wallet payment facet

* test: invite -> creatorInvitation

* fix: noticed bug in exit code while doing (chore: update coveredCall tests) (#1428)

* chore: update tests for escrowToVote, grifter, multipoolAutoswap, publicAuction, sellTickets, simpleExchange

* chore: make more unit tests pass, linting

* chore: update tests for escrowToVote, grifter, multipoolAutoswap, publicAuction, sellTickets, simpleExchange (#1430)

* fix: minor wallet cleanup

* test: fix all the zoe swingSet tests

* chore: find usages of .getBrand() and make sure that brand and issuer match (#1443)

* refactor: rename makeInstance to startInstance (#1444)

* test(dapp-svelte-wallet): fix test log for determinism

The prior golden test log relied on a race between deposit and
the new purse values.  Correct that ambiguity.

* fix: generate unique petnames, and use them

* fix: only uniquify suffixes for petnames that are actually paths

* chore: fix brokenContracts tests, zoe-metering tests, skip ZoeHelpers tests for now (need to be rewritten entirely, I think using the real ZCF, not a mock) (#1435)

* fix: minor typing issue

* chore: clean up vestiges of encouragement dapp

* chore: remove contract/deploy.js from the wallet spec

* refactor: prevent the same seat being an argument multiple times in reallocate (#1452)

* refactor: remove makeEmptyOffer from zoeHelpers, use zcf.makeEmptySeatKit instead (#1451)

* refactor: move issuerKeywordRecord and brandKeywordRecord to terms (#1459)

* refactor: add issuers, brands, maths to terms

* refactor: rename NonCustomTerms in types

* chore: address PR comments

* refactor: move AmountMath from names to Kinds; easier local creation

Issuer no longer has getAmountMath(), instead exports makeLocalAmountMath();
added an enum for the three kinds of AmountMath
getAmountMathHelpersName replaced with getAmountMathKind
Add MathKind as an enum containing the legal values of AmountKind
Made progress on correct typing

* fix: review suggestions and merge conflicts.

* fix: clear up the types

* chore: export all of ERTP from index.js. Update all imports.

A few other review-suggested cleanups

* refactor: add Zoe methods for getting assured invitation values

The type declarations seem to work.

* refactor: drop unnecessary invitations in the metering tests.

* refactor: review of the following files in the form of code changes (#1475)

* refactor: review of:

packages/zoe/src/contracts/autoswap.js
packages/zoe/src/contracts/barterExchange.js
packages/zoe/src/contracts/simpleExchange.js
packages/zoe/test/swingsetTests/zoe/test-zoe.js
packages/zoe/test/swingsetTests/zoe/vat-alice.js
packages/zoe/test/swingsetTests/zoe/vat-bob.js
packages/zoe/test/swingsetTests/zoe/vat-carol.js
packages/zoe/test/swingsetTests/zoe/vat-dave.js
packages/zoe/test/swingsetTests/zoe/vat-zoe.js
packages/zoe/test/unitTests/contracts/test-autoswap.js
packages/zoe/test/unitTests/contracts/test-barter.js
packages/zoe/test/unitTests/contracts/test-simpleExchange.js
packages/zoe/test/unitTests/installFromSource.js
packages/zoe/test/unitTests/setupBasicMints.js
packages/zoe/test/unitTests/setupMixedMints.js
packages/zoe/test/unitTests/setupNonFungibleMints.js
packages/zoe/test/unitTests/test-cleanProposal.js
packages/zoe/test/unitTests/test-offerSafety.js
packages/zoe/test/unitTests/test-rightsConservation.js
packages/zoe/test/zoeTestHelpers.js

in PR form rather than comments

* fix: fix dapp-svelte-wallet issues

* fix: lint-fix

* fix: fix errors

* chore: review in the form of PR w/ changes (#1484)

* fix: resolve semantic merge conflict

The `@agoric/zoe/src/contractFacet` moved to:
`@agoric/zoe/src/contractFacet/contractFacet.js`.

* refactor: add typings for some sample Zoe contracts

* refactor: loosen unknown typings

* chore: expose '@agoric/zoe/contractFacet'

* docs: address review comments

* test(swingset-runner): update demo/exchangeBenchmark for new Zoe

* chore: follow #1194: take fresh copy of zoeTests from zoe

* fix: don't use monorepo-relative paths to @agoric/zoe

* chore: complete #1194 Problem 1

* fix: zcf is unused, so prepend an underscore

lint fix

* chore: complete #1194 Problem 2b

* chore: complete #1194 Problem 2c

* chore: move global harden declaration to package.json

* fix: undo invalid Zoe change

* fix: minor cleanups

* chore: rename userSeat.exit() to tryExit() (#1493)

* chore: rename userSeat.exit() to tryExit()

* Update packages/zoe/src/objArrayConversion.js

Co-authored-by: Mark S. Miller <erights@users.noreply.github.com>

* chore: address small PR comments

* chore: remove objToArray because unused

* chore: move cleanProposal.js (#1495)

* chore: remove more unused functions

* chore: remove escrowAndAllocateTo

* chore: remove unused type

* chore: rename invite to invitation, forever more. begone!

* Use flatMap

Co-authored-by: Mark S. Miller <erights@users.noreply.github.com>

* chore: change areRightsConserved to assertRightsConserved

* chore: address PR comments

* fix: reintroduce makeZoe's zcfBundleName argument; lost in merge

* Update packages/zoe/src/zoeService/zoeSeat.js

Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com>

* chore: address PR comments

* chore: fix the lint

* chore: address PR comments about kick out messages (#1529)

* chore: address PR comments about exit behavior (#1527)

* chore: address PR comments about exit behavior

* Update packages/zoe/src/zoeService/zoeSeat.js

Co-authored-by: Mark S. Miller <erights@users.noreply.github.com>

* chore: fix lint, slight errors from merge

Co-authored-by: Mark S. Miller <erights@users.noreply.github.com>

Co-authored-by: Mark S. Miller <erights@users.noreply.github.com>
Co-authored-by: Dean Tribble <tribble@agoric.com>
Co-authored-by: Michael FIG <mfig@agoric.com>
Co-authored-by: Brian Warner <warner@lothar.com>
Co-authored-by: Chris Hibbert <hibbert@agoric.com>
Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com>
  • Loading branch information
7 people authored Aug 17, 2020
1 parent a3bf3cd commit 7058a85
Show file tree
Hide file tree
Showing 226 changed files with 7,354 additions and 8,347 deletions.
2 changes: 1 addition & 1 deletion packages/ERTP/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "es2019",
"target": "es2020",

"noEmit": true,
/*
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@agoric/ertp",
"version": "0.6.0",
"description": "Electronic Rights Transfer Protocol (ERTP). A smart contract framework for exchanging electronic rights",
"main": "src/issuer.js",
"main": "src/index.js",
"engines": {
"node": ">=11.0"
},
Expand Down
115 changes: 0 additions & 115 deletions packages/ERTP/src/amountMath.chainmail

This file was deleted.

66 changes: 44 additions & 22 deletions packages/ERTP/src/amountMath.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
import { assert, details } from '@agoric/assert';

import { mustBeComparable } from '@agoric/same-structure';
import mathHelpersLib from './mathHelpersLib';

import './types';
import natMathHelpers from './mathHelpers/natMathHelpers';
import strSetMathHelpers from './mathHelpers/strSetMathHelpers';
import setMathHelpers from './mathHelpers/setMathHelpers';

// We want an enum, but narrowed to the AmountMathKind type.
/**
* Constants for the kinds of amountMath we support.
* @type {{ NAT: 'nat', SET: 'set', STRING_SET: 'strSet' }}
*/
const MathKind = {
NAT: 'nat',
SET: 'set',
STRING_SET: 'strSet',
};
harden(MathKind);
export { MathKind };

/**
* Amounts describe digital assets. From an amount, you can learn the
Expand Down Expand Up @@ -38,48 +53,53 @@ import './types';
* function `coerce` takes an amount and checks it, returning an amount (amount
* -> amount).
*
* `makeAmount` takes in a brand and the name of the particular
* mathHelpers to use.
* `makeAmountMath` takes in a brand and the kind of amountMath to use.
*
* amountMath is unfortunately not pass-by-copy. If you call
* `getAmountMath` on a remote issuer, it will be a remote object and
* each call will incur the costs of calling a remote object. However,
* you can create a local amountMath by importing this module locally
* and calling makeAmountMath(), passing in a brand and a mathHelpers name,
* both of which can be passed-by-copy (since there are no calls to brand
* in this module).
* amountMath is not pass-by-copy, but everything it does can be done
* locally in each vat that needs the functionality. If the operations
* are done against a remote version, they have the same semantics, but
* require an extra messaging round-trip per call. The best way to use
* it is to make a local copy, which can be done by calling
* makeLocalAmountMath(issuer).
*
* AmountMath exports MathKind, which contains constants for the kinds:
* NAT, SET, and STRING_SET.
*
* Each issuer of digital assets has an associated brand in a one-to-one
* mapping. In untrusted contexts, such as in analyzing payments and
* amounts, we can get the brand and find the issuer which matches the
* brand. The issuer and the brand mutually validate each other.
*
* @param {Brand} brand
* @param {MathHelpersName} mathHelpersName
* @param {AmountMathKind} amountMathKind
* @returns {AmountMath}
*/
function makeAmountMath(brand, mathHelpersName) {
function makeAmountMath(brand, amountMathKind) {
mustBeComparable(brand);
assert.typeof(mathHelpersName, 'string');

const helpers = mathHelpersLib[mathHelpersName];
assert.typeof(amountMathKind, 'string');

const mathHelpers = {
nat: natMathHelpers,
strSet: strSetMathHelpers,
set: setMathHelpers,
};
const helpers = mathHelpers[amountMathKind];
assert(
helpers !== undefined,
details`unrecognized mathHelpersName: ${mathHelpersName}`,
details`unrecognized amountMathKind: ${amountMathKind}`,
);

// Cache the amount if we can.
const cache = new WeakSet();

/** @type {AmountMath} */
const amountMath = harden({
getBrand: () => brand,
/** @deprecated Use getMathHelperName */
getMathHelpersName: () => mathHelpersName,
getMathHelperName: () => mathHelpersName,
getAmountMathKind: () => amountMathKind,

/**
* Make an amount from a value by adding the brand.
* @param {any} allegedValue
* @param {Value} allegedValue
* @returns {Amount}
*/
make: allegedValue => {
Expand All @@ -91,7 +111,7 @@ function makeAmountMath(brand, mathHelpersName) {

/**
* Make sure this amount is valid and return it if so, throwing if invalid.
* @param {any} allegedAmount
* @param {Amount} allegedAmount
* @returns {Amount} or throws if invalid
*/
coerce: allegedAmount => {
Expand Down Expand Up @@ -163,4 +183,6 @@ function makeAmountMath(brand, mathHelpersName) {
return amountMath;
}

export default harden(makeAmountMath);
harden(makeAmountMath);

export { makeAmountMath };
3 changes: 3 additions & 0 deletions packages/ERTP/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './amountMath';
export * from './issuer';
export * from './localAmountMath';
Loading

0 comments on commit 7058a85

Please sign in to comment.