From 0c0380a4c89b92ccba34459150fca993169baaef Mon Sep 17 00:00:00 2001 From: Kate Sills Date: Fri, 12 Apr 2019 18:16:38 -0700 Subject: [PATCH 1/4] functional changes --- demo/left-right/bootstrap.js | 19 ++++++++++++++----- demo/left-right/vat-left.js | 14 ++++++++------ demo/left-right/vat-right.js | 6 +++--- src/controller.js | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/demo/left-right/bootstrap.js b/demo/left-right/bootstrap.js index 482ddd2572b..f8a63cd756f 100644 --- a/demo/left-right/bootstrap.js +++ b/demo/left-right/bootstrap.js @@ -1,23 +1,32 @@ import harden from '@agoric/harden'; -console.log(`loading bootstrap.js`); +console.log(`=> loading bootstrap.js`); export default function setup(syscall, state, helpers) { function log(what) { helpers.log(what); console.log(what); } - log(`setup called`); + log(`=> setup called`); return helpers.makeLiveSlots( syscall, state, E => harden({ bootstrap(argv, vats) { - console.log('bootstrap() called'); + console.log('=> bootstrap() called'); E(vats.left) - .callRight(1, vats.right) - .then(r => log(`b.resolved ${r}`), err => log(`b.rejected ${err}`)); + .talkToBot(vats.right, 'hello') + .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, diff --git a/demo/left-right/vat-left.js b/demo/left-right/vat-left.js index fa23166a370..629bae7a980 100644 --- a/demo/left-right/vat-left.js +++ b/demo/left-right/vat-left.js @@ -10,12 +10,14 @@ export default function setup(syscall, state, helpers) { state, E => harden({ - callRight(arg1, right) { - log(`left.callRight ${arg1}`); - E(right) - .bar(2) - .then(a => log(`left.then ${a}`)); - return 3; + talkToBot(vat, msg) { + log(`=> user's talkToBot method is called with: (right, ${msg})`); + E(vat) + .affirmMe(msg) + .then(myAffirmation => + log(`=> user receives the affirmation: ${myAffirmation}`), + ); + return 'Thanks for the setup. I sure hope I get some affirmation...'; }, }), helpers.vatID, diff --git a/demo/left-right/vat-right.js b/demo/left-right/vat-right.js index e88d2e767fc..8995d90e5d1 100644 --- a/demo/left-right/vat-right.js +++ b/demo/left-right/vat-right.js @@ -11,9 +11,9 @@ export default function setup(syscall, state, helpers) { state, _E => harden({ - bar(arg2) { - log(`right ${arg2}`); - return 4; + affirmMe(msg) { + log(`=> affirmationBot.affirmMe got the message: ${msg}`); + return `${msg}, you are wonderful!`; }, }), helpers.vatID, diff --git a/src/controller.js b/src/controller.js index b3b9e89f0b3..e693db71d4a 100644 --- a/src/controller.js +++ b/src/controller.js @@ -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)); } From fe3286af78102588e318ea36ad60934f66af8d40 Mon Sep 17 00:00:00 2001 From: Kate Sills Date: Fri, 12 Apr 2019 18:18:25 -0700 Subject: [PATCH 2/4] change names only --- README.md | 4 ++-- demo/{left-right => affirmationBot}/bootstrap.js | 4 ++-- .../vat-right.js => affirmationBot/vat-affirmationbot.js} | 0 demo/{left-right/vat-left.js => affirmationBot/vat-user.js} | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) rename demo/{left-right => affirmationBot}/bootstrap.js (91%) rename demo/{left-right/vat-right.js => affirmationBot/vat-affirmationbot.js} (100%) rename demo/{left-right/vat-left.js => affirmationBot/vat-user.js} (83%) diff --git a/README.md b/README.md index 1a89c28b7dc..72aad642b71 100644 --- a/README.md +++ b/README.md @@ -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/affirmationBot ``` This repository is still in early development: APIs and features are not @@ -25,7 +25,7 @@ expected to stabilize for a while. ## REPL Shell ``` -$ bin/vat shell demo/left-right +$ bin/vat shell demo/affirmationBot vat> ``` diff --git a/demo/left-right/bootstrap.js b/demo/affirmationBot/bootstrap.js similarity index 91% rename from demo/left-right/bootstrap.js rename to demo/affirmationBot/bootstrap.js index f8a63cd756f..7ebcd98e4b3 100644 --- a/demo/left-right/bootstrap.js +++ b/demo/affirmationBot/bootstrap.js @@ -15,8 +15,8 @@ export default function setup(syscall, state, helpers) { harden({ bootstrap(argv, vats) { console.log('=> bootstrap() called'); - E(vats.left) - .talkToBot(vats.right, 'hello') + E(vats.user) + .talkToBot(vats.affirmationbot, 'hello') .then( r => log( diff --git a/demo/left-right/vat-right.js b/demo/affirmationBot/vat-affirmationbot.js similarity index 100% rename from demo/left-right/vat-right.js rename to demo/affirmationBot/vat-affirmationbot.js diff --git a/demo/left-right/vat-left.js b/demo/affirmationBot/vat-user.js similarity index 83% rename from demo/left-right/vat-left.js rename to demo/affirmationBot/vat-user.js index 629bae7a980..4c957cb10fc 100644 --- a/demo/left-right/vat-left.js +++ b/demo/affirmationBot/vat-user.js @@ -11,7 +11,9 @@ export default function setup(syscall, state, helpers) { E => harden({ talkToBot(vat, msg) { - log(`=> user's talkToBot method is called with: (right, ${msg})`); + log( + `=> user's talkToBot method is called with: (affirmationBot, ${msg})`, + ); E(vat) .affirmMe(msg) .then(myAffirmation => From df060fe6487bdc29a19b3ca1f9fdeb0c7804da37 Mon Sep 17 00:00:00 2001 From: Kate Sills Date: Fri, 12 Apr 2019 18:35:09 -0700 Subject: [PATCH 3/4] clarify the example --- demo/affirmationBot/bootstrap.js | 2 +- demo/affirmationBot/vat-user.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/demo/affirmationBot/bootstrap.js b/demo/affirmationBot/bootstrap.js index 7ebcd98e4b3..6ac34da2bc5 100644 --- a/demo/affirmationBot/bootstrap.js +++ b/demo/affirmationBot/bootstrap.js @@ -16,7 +16,7 @@ export default function setup(syscall, state, helpers) { bootstrap(argv, vats) { console.log('=> bootstrap() called'); E(vats.user) - .talkToBot(vats.affirmationbot, 'hello') + .talkToBot(vats.affirmationbot, 'affirmationBot') .then( r => log( diff --git a/demo/affirmationBot/vat-user.js b/demo/affirmationBot/vat-user.js index 4c957cb10fc..5f2cd6c8d50 100644 --- a/demo/affirmationBot/vat-user.js +++ b/demo/affirmationBot/vat-user.js @@ -10,12 +10,10 @@ export default function setup(syscall, state, helpers) { state, E => harden({ - talkToBot(vat, msg) { - log( - `=> user's talkToBot method is called with: (affirmationBot, ${msg})`, - ); + talkToBot(vat, botName) { + log(`=> user.talkToBot is called with ${botName}`); E(vat) - .affirmMe(msg) + .affirmMe('hello') .then(myAffirmation => log(`=> user receives the affirmation: ${myAffirmation}`), ); From cb1fdf6af46274e1e3b38e010b6c0753dd8a6941 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 16 Apr 2019 16:18:08 -0700 Subject: [PATCH 4/4] rename to encouragementBot, tweak parameter names --- README.md | 4 ++-- .../bootstrap.js | 2 +- .../vat-bot.js} | 6 +++--- .../{affirmationBot => encouragementBot}/vat-user.js | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) rename demo/{affirmationBot => encouragementBot}/bootstrap.js (92%) rename demo/{affirmationBot/vat-affirmationbot.js => encouragementBot/vat-bot.js} (65%) rename demo/{affirmationBot => encouragementBot}/vat-user.js (57%) diff --git a/README.md b/README.md index 72aad642b71..5724a3c592d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ More docs are in the works. For now, try: ``` $ npm install $ npm test -$ bin/vat run demo/affirmationBot +$ bin/vat run demo/encouragementBot ``` This repository is still in early development: APIs and features are not @@ -25,7 +25,7 @@ expected to stabilize for a while. ## REPL Shell ``` -$ bin/vat shell demo/affirmationBot +$ bin/vat shell demo/encouragementBot vat> ``` diff --git a/demo/affirmationBot/bootstrap.js b/demo/encouragementBot/bootstrap.js similarity index 92% rename from demo/affirmationBot/bootstrap.js rename to demo/encouragementBot/bootstrap.js index 6ac34da2bc5..1a84f5f482a 100644 --- a/demo/affirmationBot/bootstrap.js +++ b/demo/encouragementBot/bootstrap.js @@ -16,7 +16,7 @@ export default function setup(syscall, state, helpers) { bootstrap(argv, vats) { console.log('=> bootstrap() called'); E(vats.user) - .talkToBot(vats.affirmationbot, 'affirmationBot') + .talkToBot(vats.bot, 'encouragementBot') .then( r => log( diff --git a/demo/affirmationBot/vat-affirmationbot.js b/demo/encouragementBot/vat-bot.js similarity index 65% rename from demo/affirmationBot/vat-affirmationbot.js rename to demo/encouragementBot/vat-bot.js index 8995d90e5d1..4e1d9383a8f 100644 --- a/demo/affirmationBot/vat-affirmationbot.js +++ b/demo/encouragementBot/vat-bot.js @@ -11,9 +11,9 @@ export default function setup(syscall, state, helpers) { state, _E => harden({ - affirmMe(msg) { - log(`=> affirmationBot.affirmMe got the message: ${msg}`); - return `${msg}, you are wonderful!`; + encourageMe(name) { + log(`=> encouragementBot.encourageMe got the name: ${name}`); + return `${name}, you are awesome, keep it up!`; }, }), helpers.vatID, diff --git a/demo/affirmationBot/vat-user.js b/demo/encouragementBot/vat-user.js similarity index 57% rename from demo/affirmationBot/vat-user.js rename to demo/encouragementBot/vat-user.js index 5f2cd6c8d50..9b5f5ea932a 100644 --- a/demo/affirmationBot/vat-user.js +++ b/demo/encouragementBot/vat-user.js @@ -10,14 +10,14 @@ export default function setup(syscall, state, helpers) { state, E => harden({ - talkToBot(vat, botName) { + talkToBot(bot, botName) { log(`=> user.talkToBot is called with ${botName}`); - E(vat) - .affirmMe('hello') - .then(myAffirmation => - log(`=> user receives the affirmation: ${myAffirmation}`), + E(bot) + .encourageMe('user') + .then(myEncouragement => + log(`=> user receives the encouragement: ${myEncouragement}`), ); - return 'Thanks for the setup. I sure hope I get some affirmation...'; + return 'Thanks for the setup. I sure hope I get some encouragement...'; }, }), helpers.vatID,