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

Using/Teaching zone.exo instead of Far --wip-- #89

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ videos
!.yarn/sdks
!.yarn/versions

# contract tx
contract/,tx.json
contract/start-offer-up-plan.json
15 changes: 9 additions & 6 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@
"typescript-eslint": "^7.2.0"
},
"dependencies": {
"@agoric/ertp": "^0.16.3-u16.1",
"@agoric/vats": "dev",
"@agoric/zoe": "^0.26.3-u16.1",
"@endo/far": "^1.1.5",
"@endo/marshal": "^1.5.3",
"@endo/patterns": "^1.4.3"
"@agoric/ertp": "^0.16.3-u18.0",
"@agoric/internal": "^0.4.0-u18.0",
"@agoric/vat-data": "0.5.3-u18.1",
"@agoric/vats": "^0.16.0-u18.0",
"@agoric/zoe": "^0.26.3-u18.0",
"@agoric/zone": "^0.3.0-u18.1",
"@endo/far": "^1.1.8",
"@endo/marshal": "^1.6.1",
"@endo/patterns": "^1.4.6"
},
"ava": {
"files": [
Expand Down
26 changes: 11 additions & 15 deletions contract/src/offer-up.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@
*/
// @ts-check

import { Far } from '@endo/far';
// import { Far } from '@endo/far';
import { M, getCopyBagEntries } from '@endo/patterns';
import { AssetKind } from '@agoric/ertp/src/amountMath.js';
import { AmountShape } from '@agoric/ertp/src/typeGuards.js';
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
import '@agoric/zoe/exported.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
amessbee marked this conversation as resolved.
Show resolved Hide resolved

/**
* @import {Amount} from '@agoric/ertp/src/types.js';
* @import {CopyBag} from '@endo/patterns';
*
*/

const { Fail, quote: q } = assert;

// #region bag utilities
Expand Down Expand Up @@ -75,9 +77,12 @@ harden(customTermsShape);
* - handles offers to buy up to `maxItems` items at a time.
*
* @param {ZCF<OfferUpTerms>} zcf
* @param {*} _privateArgs
* @param {import('@agoric/vat-data').Baggage} baggage
*/
export const start = async zcf => {
export const start = async (zcf, _privateArgs, baggage) => {
const { tradePrice, maxItems = 3n } = zcf.getTerms();
const zone = makeDurableZone(baggage);

/**
* a new ERTP mint for items, accessed thru the Zoe Contract Facet.
Expand Down Expand Up @@ -129,19 +134,10 @@ export const start = async zcf => {
return 'trade complete';
};

/**
* Make an invitation to trade for items.
*
* Proposal Keywords used in offers using these invitations:
* - give: `Price`
* - want: `Items`
Comment on lines -133 to -137
Copy link
Member

Choose a reason for hiding this comment

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

any particular reason to drop this bit of documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, don't remember removing them at all, will put them back.

Also, currently there are a lot of type errors in the CI which is bothering me a bit. Let me know if you can find time to help there.

*/
const makeTradeInvitation = () =>
zcf.makeInvitation(tradeHandler, 'buy items', undefined, proposalShape);

// Mark the publicFacet Far, i.e. reachable from outside the contract
const publicFacet = Far('Items Public Facet', {
makeTradeInvitation,
// Use zone.exo to make a publicFacet suitable for use by remote callers.
const publicFacet = zone.exo('Items Public Facet', undefined, {
makeTradeInvitation: () =>
zcf.makeInvitation(tradeHandler, 'buy items', undefined, proposalShape),
amessbee marked this conversation as resolved.
Show resolved Hide resolved
});
return harden({ publicFacet });
};
Expand Down
Loading
Loading