Skip to content

Commit

Permalink
feat(vats): add home.registrar and home.moolah
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Oct 23, 2019
1 parent 3af19e3 commit 4b8ce42
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 45 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
User-visible changes in Cosmic SwingSet:

## Release v0.10.7 (2019-10-23)

* Upgrade to ERTP v0.1.8
- Zoe contracts updated to use ESM format
- exit conditions have been added to Zoe
* Create the `home.moolah` purse with balance 1000 to have some currency to trade
* Create `home.registrar` to publish objects

## Release v0.10.6 (2019-10-16)

* Upgrade to SwingSet v0.1.0
Expand Down
9 changes: 6 additions & 3 deletions lib/ag-solo/contracts/README-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ The following global variables are available to all modules in your contractHost

## Uploading

The upload process installs the contract and registers the installation as `NAME` in the `home.uploads` private scratch pad. This process can be run at any time by using ag-solo's upload-contract functionality:
The upload process installs the contract and registers the installation as `NAME` in the `home.uploads` private scratch pad. This process can be run at any time by using ag-solo's upload-contract functionality. The first part of the `NAME` must be either `zoe-` or `contractHost-`:

```sh
ag-solo upload-contract NAME=ENTRYPOINT.js [NAME=ENTRYPOINT.js...]
```

To access the contract installation object, use `home.uploads~.get(NAME)`.
To access the contract installation object just from your ag-solo, use `home.uploads~.get(NAME)`.

To list all contracts in the uploads scratch pad: `home.uploads~.list()`.
To list all contracts in your private uploads scratch pad: `home.uploads~.list()`.

If you want to permanently publish an object to everybody with access to the chain: `home.registrar~.register(NAME, obj)` which will return an ID.
Then others can get a reference to the object on their own connected ag-solo with `home.registrar~.get(ID)`
6 changes: 4 additions & 2 deletions lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ export default function setup(syscall, state, helpers) {
return harden({
async createDemoBundle(nickname) {
const handoff = await E(vats.handoff).getSharedHandoffService();
const registry = await E(vats.registry).getSharedRegistry();
const registrar = await E(vats.registrar).getSharedRegistrar();
const pixelBundle = await E(vats.pixel).createPixelBundle(nickname);
const moolah = await E(vats.moolah).getSomeMoolah(nickname);
const zoe = await E(vats.zoe).getZoe();
return harden({
...pixelBundle,
handoff,
moolah,
contractHost,
registry,
registrar,
zoe,
});
},
Expand Down
23 changes: 23 additions & 0 deletions lib/ag-solo/vats/vat-moolah.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import harden from '@agoric/harden';
import { makeMint } from '@agoric/ertp/core/mint';

// This vat contains the registrar for the demo.

function build(E, log) {
const sharedMoolahMint = makeMint('moolah');

function getSomeMoolah(nickname) {
return sharedMoolahMint.mint(1000, `${nickname}'s moolah purse`);
}

return harden({ getSomeMoolah });
}

export default function setup(syscall, state, helpers) {
return helpers.makeLiveSlots(
syscall,
state,
E => build(E, helpers.log),
helpers.vatID,
);
}
23 changes: 23 additions & 0 deletions lib/ag-solo/vats/vat-registrar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import harden from '@agoric/harden';
import { makeRegistrar } from '@agoric/ertp/more/registrar/registrar';

// This vat contains the registrar for the demo.

function build(E, log) {
const sharedRegistrar = makeRegistrar();

function getSharedRegistrar() {
return sharedRegistrar;
}

return harden({ getSharedRegistrar });
}

export default function setup(syscall, state, helpers) {
return helpers.makeLiveSlots(
syscall,
state,
E => build(E, helpers.log),
helpers.vatID,
);
}
40 changes: 0 additions & 40 deletions lib/ag-solo/vats/vat-registry.js

This file was deleted.

0 comments on commit 4b8ce42

Please sign in to comment.