From 91e2b6fdf424d00d194d4e43ad11b85134e5691e Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Fri, 20 Mar 2020 17:16:47 -0600 Subject: [PATCH] feat!: support for proper multicast from HTTP handlers This anticipates support for https://github.com/Agoric/agoric-sdk/issues/748 in the command device. --- packages/agoric-cli/lib/deploy.js | 2 +- packages/agoric-cli/lib/start.js | 2 +- packages/cosmic-swingset/docker/ag-solo | 2 +- .../cosmic-swingset/lib/ag-solo/bundle.js | 2 +- .../cosmic-swingset/lib/ag-solo/html/main.js | 4 +- .../lib/ag-solo/html/wallet-bridge.html | 2 +- .../lib/ag-solo/vats/bootstrap.js | 44 ++++-- .../cosmic-swingset/lib/ag-solo/vats/repl.js | 45 ++++-- .../lib/ag-solo/vats/vat-http.js | 148 +++++++++--------- .../lib/ag-solo/vats/vat-wallet.js | 85 ++++++---- packages/cosmic-swingset/lib/ag-solo/web.js | 139 ++++++++-------- packages/wallet-frontend/src/setupProxy.js | 2 +- .../src/utils/fetch-websocket.js | 36 +++-- 13 files changed, 297 insertions(+), 216 deletions(-) diff --git a/packages/agoric-cli/lib/deploy.js b/packages/agoric-cli/lib/deploy.js index c09ae6183f6..c766482aa24 100644 --- a/packages/agoric-cli/lib/deploy.js +++ b/packages/agoric-cli/lib/deploy.js @@ -30,7 +30,7 @@ export default async function deployMain(progname, rawArgs, powers) { ws.send(JSON.stringify(obj)); }; - const wsurl = `ws://${hostport}/captp`; + const wsurl = `ws://${hostport}/private/captp`; const ws = makeWebSocket(wsurl, { origin: 'http://127.0.0.1' }); const exit = makePromise(); diff --git a/packages/agoric-cli/lib/start.js b/packages/agoric-cli/lib/start.js index 7b9d6847c8e..886d5335d61 100644 --- a/packages/agoric-cli/lib/start.js +++ b/packages/agoric-cli/lib/start.js @@ -75,7 +75,7 @@ export default async function startMain(progname, rawArgs, powers, opts) { } } - const fakeGCI = 'myFakeGCI'; + const fakeGCI = 'fake-chain'; if (!(await exists(agServer))) { log(chalk.yellow(`initializing ${profileName}`)); await pspawn(agSolo, ['init', profileName, '--egresses=fake'], { diff --git a/packages/cosmic-swingset/docker/ag-solo b/packages/cosmic-swingset/docker/ag-solo index c24ab08f264..9001292e7a5 100755 --- a/packages/cosmic-swingset/docker/ag-solo +++ b/packages/cosmic-swingset/docker/ag-solo @@ -17,7 +17,7 @@ if test "$1" = shell; then shift elif test "$1" = upload-contract; then shift - exec `dirname "$0"`/../bin/ag-solo upload-contract --ag-solo=ws://127.0.0.1:$HOST_PORT/captp ${1+"$@"} + exec `dirname "$0"`/../bin/ag-solo upload-contract --ag-solo=ws://127.0.0.1:$HOST_PORT/private/captp ${1+"$@"} exit $? else FLAGS=-p127.0.0.1:$HOST_PORT:$PORT diff --git a/packages/cosmic-swingset/lib/ag-solo/bundle.js b/packages/cosmic-swingset/lib/ag-solo/bundle.js index 6a2f6223261..1db7ac1f97d 100644 --- a/packages/cosmic-swingset/lib/ag-solo/bundle.js +++ b/packages/cosmic-swingset/lib/ag-solo/bundle.js @@ -93,7 +93,7 @@ export default async function bundle(insistIsBasedir, args) { ); for (const conn of JSON.parse(cjson)) { if (conn.type === 'http') { - wsurl = `ws://${conn.host}:${conn.port}/captp`; + wsurl = `ws://${conn.host}:${conn.port}/private/captp`; } } } diff --git a/packages/cosmic-swingset/lib/ag-solo/html/main.js b/packages/cosmic-swingset/lib/ag-solo/html/main.js index a9602c66eec..eaf0c06cc00 100644 --- a/packages/cosmic-swingset/lib/ag-solo/html/main.js +++ b/packages/cosmic-swingset/lib/ag-solo/html/main.js @@ -12,7 +12,7 @@ function run() { let inputHistoryNum = 0; async function call(req) { - const res = await fetch('/vat', { + const res = await fetch('/private/repl', { method: 'POST', body: JSON.stringify(req), headers: { 'Content-Type': 'application/json' }, @@ -26,7 +26,7 @@ function run() { const loc = window.location; const protocol = loc.protocol.replace(/^http/, 'ws'); - const socketEndpoint = `${protocol}//${loc.host}/`; + const socketEndpoint = `${protocol}//${loc.host}/private/repl`; const ws = new WebSocket(socketEndpoint); ws.addEventListener('error', ev => { diff --git a/packages/cosmic-swingset/lib/ag-solo/html/wallet-bridge.html b/packages/cosmic-swingset/lib/ag-solo/html/wallet-bridge.html index c1b0e294d16..e3cc4f83925 100644 --- a/packages/cosmic-swingset/lib/ag-solo/html/wallet-bridge.html +++ b/packages/cosmic-swingset/lib/ag-solo/html/wallet-bridge.html @@ -7,7 +7,7 @@

This bridge is only for dApps to reach your wallet. It contains no user-servicable parts.