Skip to content

Commit

Permalink
Merge branch 'encouragement-bot'
Browse files Browse the repository at this point in the history
closes Agoric#24
  • Loading branch information
warner committed Apr 17, 2019
2 parents dfbb2cb + cb1fdf6 commit 1e0ded8
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 54 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ More docs are in the works. For now, try:
```
$ npm install
$ npm test
$ bin/vat run demo/left-right
$ bin/vat run demo/encouragementBot
```

This repository is still in early development: APIs and features are not
Expand All @@ -25,7 +25,7 @@ expected to stabilize for a while.
## REPL Shell

```
$ bin/vat shell demo/left-right
$ bin/vat shell demo/encouragementBot
vat>
```

Expand Down
34 changes: 34 additions & 0 deletions demo/encouragementBot/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import harden from '@agoric/harden';

console.log(`=> loading bootstrap.js`);

export default function setup(syscall, state, helpers) {
function log(what) {
helpers.log(what);
console.log(what);
}
log(`=> setup called`);
return helpers.makeLiveSlots(
syscall,
state,
E =>
harden({
bootstrap(argv, vats) {
console.log('=> bootstrap() called');
E(vats.user)
.talkToBot(vats.bot, 'encouragementBot')
.then(
r =>
log(
`=> the promise given by the call to user.talkToBot resolved to '${r}'`,
),
err =>
log(
`=> the promise given by the call to user.talkToBot was rejected '${err}''`,
),
);
},
}),
helpers.vatID,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export default function setup(syscall, state, helpers) {
state,
_E =>
harden({
bar(arg2) {
log(`right ${arg2}`);
return 4;
encourageMe(name) {
log(`=> encouragementBot.encourageMe got the name: ${name}`);
return `${name}, you are awesome, keep it up!`;
},
}),
helpers.vatID,
Expand Down
25 changes: 25 additions & 0 deletions demo/encouragementBot/vat-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import harden from '@agoric/harden';

export default function setup(syscall, state, helpers) {
function log(what) {
helpers.log(what);
console.log(what);
}
return helpers.makeLiveSlots(
syscall,
state,
E =>
harden({
talkToBot(bot, botName) {
log(`=> user.talkToBot is called with ${botName}`);
E(bot)
.encourageMe('user')
.then(myEncouragement =>
log(`=> user receives the encouragement: ${myEncouragement}`),
);
return 'Thanks for the setup. I sure hope I get some encouragement...';
},
}),
helpers.vatID,
);
}
25 changes: 0 additions & 25 deletions demo/left-right/bootstrap.js

This file was deleted.

23 changes: 0 additions & 23 deletions demo/left-right/vat-left.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export async function buildVatController(config, withSES = true, argv = []) {
} else if (config.bootstrapIndexJS) {
// we invoke obj[0].bootstrap with an object that contains 'vats' and
// 'argv'.
console.log(`queueing bootstrap()`);
console.log(`=> queueing bootstrap()`);
kernel.callBootstrap('_bootstrap', JSON.stringify(argv));
}

Expand Down

0 comments on commit 1e0ded8

Please sign in to comment.