Skip to content

Commit

Permalink
feat(zoe): implement 'home.zoe' and Zoe contract upload
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Oct 15, 2019
1 parent a24124a commit a1a73bd
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/ag-solo/contracts/README-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ This folder contains contracts that are bundled and installed when ag-solo first

Each Zoe contract entrypoint is named `zoe-NAME.js`, where **NAME** is an identifier. These files are ES modules which can import other modules. The direct exports from `zoe-NAME.js` become properties on **NAME**'s installation.

Note that the `makeContract` export accepts a pureFns argument and returns a function that receives a Zoe instance as an argument.
Note that the `makeContract` export accepts a `pureFns` argument and returns a instantiation function that receives a Zoe instance as an argument.

```js
export const makeContract = harden(_pureFns => zoe => { ... });
import harden from '@agoric/harden';

export const makeContract = harden(pureFns => zoe => { ... });
```

The following global variables are available to all modules in your Zoe contract:
Expand All @@ -21,6 +23,8 @@ The following global variables are available to all modules in your Zoe contract
Each contractHost entrypoint is named `contractHost-NAME.js`, where **NAME** is an identifier. These files are ES modules which can import other modules, and whose default export is:

```js
import harden from '@agoric/harden';

// This function is called to instantiate a contract.
export default harden((terms, inviteMaker) => ...);

Expand Down
3 changes: 3 additions & 0 deletions lib/ag-solo/contracts/contractHost-2n.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import harden from '@agoric/harden';
import makePromise from '@agoric/ertp/util/makePromise';

export default harden((_terms, inviteMaker) => {
const result = makePromise();
const seat = harden({
Expand Down
1 change: 1 addition & 0 deletions lib/ag-solo/contracts/contractHost-encouragementBot.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import harden from '@agoric/harden';
import { encourage } from './encourage';

export default harden((_terms, _inviteMaker) => {
Expand Down
4 changes: 3 additions & 1 deletion lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ export default function setup(syscall, state, helpers) {
uploads: await E(vats.uploads).getUploads(),
});
}

function makeBundler(contractHost, vats) {
return harden({
async createDemoBundle(nickname) {
const handoff = await E(vats.handoff).getSharedHandoffService();
const registry = await E(vats.registry).getSharedRegistry();
const pixelBundle = await E(vats.pixel).createPixelBundle(nickname);
const zoe = await E(vats.zoe).getZoe();
return harden({
...pixelBundle,
handoff,
contractHost,
registry,
zoe,
});
},
});
Expand Down
2 changes: 1 addition & 1 deletion lib/ag-solo/vats/vat-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function setup(syscall, state, helpers) {
E =>
harden({
makeHost() {
return harden(makeContractHost(E, evaluate));
return harden(makeContractHost(E, evaluate, { require }));
},
}),
helpers.vatID,
Expand Down
26 changes: 26 additions & 0 deletions lib/ag-solo/vats/vat-zoe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import harden from '@agoric/harden';

import { makeZoe } from '@agoric/ertp/core/zoe/zoe/zoe';

const build = (_E, _log) => {
const zoe = makeZoe({ require });
return harden({
getZoe: () => zoe,
});
};

harden(build);

function setup(syscall, state, helpers) {
function log(...args) {
helpers.log(...args);
console.log(...args);
}
return helpers.makeLiveSlots(
syscall,
state,
E => build(E, log),
helpers.vatID,
);
}
export default harden(setup);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@agoric/ertp": "^0.1.7",
"@agoric/evaluate": "^2.1.2",
"@agoric/eventual-send": "^0.4.2",
"@agoric/harden": "0.0.4",
"@agoric/swingset-vat": "0.0.27",
"@iarna/toml": "^2.2.3",
"bindings": "^1.2.1",
Expand Down

0 comments on commit a1a73bd

Please sign in to comment.