Skip to content

Commit

Permalink
chore: change contract code to use zone.exo
Browse files Browse the repository at this point in the history
  • Loading branch information
amessbee committed Aug 6, 2024
1 parent b4731f4 commit 9abaf3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
},
"dependencies": {
"@agoric/ertp": "^0.16.3-u12.0",
"@agoric/vat-data": "0.5.3-u16.1",
"@agoric/zoe": "^0.26.3-u12.0",
"@agoric/zone": "dev",
"@endo/far": "^0.2.22",
"@endo/marshal": "^0.8.9",
"@endo/patterns": "^0.2.5"
Expand Down
18 changes: 15 additions & 3 deletions contract/src/offer-up.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
*/
// @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';
const { Fail, quote: q } = assert;
import { makeScalarBigMapStore } from '@agoric/vat-data';

// #region bag utilities
/** @type { (xs: bigint[]) => bigint } */
Expand Down Expand Up @@ -72,6 +73,16 @@ export const customTermsShape = meta.customTermsShape;
export const start = async zcf => {
const { tradePrice, maxItems = 3n } = zcf.getTerms();

/**
* TODO: below is somewhat fake way of generating a zone. This should be fixed by passing it as a parameter.
* RN I don't know how to do it.
*/
const baggage = makeScalarBigMapStore('baggage', {
keyShape: M.string(),
durable: true,
});
const zone = makeDurableZone(baggage);

/**
* a new ERTP mint for items, accessed thru the Zoe Contract Facet.
* Note: `makeZCFMint` makes the associated brand and issuer available
Expand Down Expand Up @@ -133,7 +144,8 @@ export const start = async zcf => {
zcf.makeInvitation(tradeHandler, 'buy items', undefined, proposalShape);

// Mark the publicFacet Far, i.e. reachable from outside the contract
const publicFacet = Far('Items Public Facet', {
// const myexo = makeExo('Items Public Facet', undefined);
const publicFacet = zone.exo('Items Public Facet', undefined, {
makeTradeInvitation,
});
return harden({ publicFacet });
Expand Down

0 comments on commit 9abaf3a

Please sign in to comment.