Skip to content

Commit

Permalink
fix(agoric-cli): changes to make agoric --sdk basically work again (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig authored Jan 27, 2020
1 parent ad24880 commit 1dc046a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/agoric-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ integration-test/transform-tests/output
# generated Sphinx/ReadTheDocs files
/docs/build/
/demo
t[0-9]*
12 changes: 7 additions & 5 deletions packages/agoric-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you have cloned and installed the Agoric SDK as described by its [README](/Ag
alias agoric="/PATH/TO/agoric-sdk/packages/agoric-cli/bin/agoric --sdk"
```

If you want to modify the `template` directory used by Agoric SDK, you can `cd` to it and skip the `agoric init` stage below. Then, create a PR from your changes.
If you want to modify the `template` directory used by Agoric SDK, you can `cd template` and skip to the `agoric install` stage below. Then, iterate on editing the template and, when you're finished, create a PR from your changes.
</details>

## Your first Agoric dApp
Expand All @@ -46,9 +46,11 @@ agoric init demo
cd demo
# Install Javascript dependencies.
agoric install
# Run the local vat machine.
agoric start
# Install your smart contract and web api (can be done separately)
# Run the local vat machine, resetting to factory defaults.
# Leave off `--reset` if you want to resume where you left off.
agoric start --reset
# Now you can navigate to http://localhost:8000/

# Install your smart contract and web api
agoric deploy ./contract/deploy.js ./api/deploy.js
# Navigate to http://localhost:8000/
```
4 changes: 2 additions & 2 deletions packages/agoric-cli/lib/deploy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-await-in-loop */
import parseArgs from 'minimist';
import { evaluateProgram } from '@agoric/evaluate';
import { E, makeCapTP } from '@agoric/captp';
import { E, HandledPromise, makeCapTP } from '@agoric/captp';

import bundleSource from '@agoric/bundle-source';

Expand Down Expand Up @@ -74,7 +74,7 @@ export default async function deployMain(progname, rawArgs, priv) {
const { source, sourceMap } = await bundleSource(moduleFile);

const actualSource = `(${source}\n)\n${sourceMap}`;
const mainNS = evaluateProgram(actualSource, { require })();
const mainNS = evaluateProgram(actualSource, { require, HandledPromise })();
const main = mainNS.default;
if (typeof main !== 'function') {
console.error(
Expand Down
8 changes: 6 additions & 2 deletions packages/agoric-cli/lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ export default async function initMain(progname, rawArgs, priv) {
console.log(`mkdir ${DIR}${stem}`);
await mkdir(`${DIR}${stem}`);
}
}),
);
await recursiveTemplate(templateDir, `${stem}`);
} else {
console.log(`write ${DIR}${stem}`);
await writeTemplate(stem);
}
}));
};
await recursiveTemplate(templateDir);

Expand Down
6 changes: 3 additions & 3 deletions packages/agoric-cli/lib/install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import parseArgs from 'minimist';
import chalk from 'chalk';

export default async function installMain(progname, rawArgs, priv) {
export default async function installMain(progname, rawArgs, priv, opts) {
const { console, error, spawn } = priv;
const { _: args } = parseArgs(rawArgs);

Expand All @@ -13,8 +13,8 @@ export default async function installMain(progname, rawArgs, priv) {
});

// Install via Yarn.
if (await pspawn('yarn', ['install'], { stdio: 'inherit'})) {
error('Cannot install');
if (!opts.sdk && await pspawn('yarn', ['install'], { stdio: 'inherit'})) {
error('Cannot yarn install');
return 1;
};
console.log(chalk.bold.green('Done installing'));
Expand Down
2 changes: 0 additions & 2 deletions packages/agoric-cli/template/api/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Agoric Dapp api deployment script
import fs from 'fs';
import harden from '@agoric/harden';

export default async function deployApi(homeP, { bundleSource, pathResolve }) {
const { source, moduleFormat } = await bundleSource('./handler.js');
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-source/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agoric/bundle-source",
"version": "1.0.4",
"version": "1.0.5",
"description": "Create source bundles from ES Modules",
"main": "src/index.js",
"scripts": {
Expand Down
12 changes: 8 additions & 4 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function build(E, D) {
if (ROLES.client) {
const conns = new Map();
const forward = method => obj => {
const dispatch = conns.get(obj.connectionID);
if (!dispatch || !dispatch(obj)) {
const dispatchAbort = conns.get(obj.connectionID);
if (!dispatchAbort || !(1, dispatchAbort[0])(obj)) {
console.log(
`Could not find CapTP handler ${method}`,
obj.connectionID,
Expand All @@ -91,14 +91,18 @@ function build(E, D) {
o.connectionID = obj.connectionID;
D(commandDevice).sendBroadcast(o);
};
const { dispatch } = makeCapTP(obj.connectionID, sendObj, () =>
const { dispatch, abort } = makeCapTP(obj.connectionID, sendObj, () =>
// Harden only our exported objects.
harden(exportedToCapTP),
);
conns.set(obj.connectionID, dispatch);
conns.set(obj.connectionID, [dispatch, abort]);
},
CTP_CLOSE(obj) {
console.log(`Finishing CapTP`, obj.connectionID);
const dispatchAbort = conns.get(obj.connectionID);
if (dispatchAbort) {
(1, dispatchAbort[1])();
}
conns.delete(obj.connectionID);
},
CTP_ERROR(obj) {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4214,7 +4214,7 @@ eslint-plugin-react-hooks@^1.6.1:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04"
integrity sha512-iXTCFcOmlWvw4+TOE8CLWj6yX1GwzT0Y6cUfHHZqWnSk144VmVIRcVGtUAzrLES7C798lmvnt02C7rxaOX1HNA==

eslint-plugin-react-hooks@^2.2.0, eslint-plugin-react-hooks@^2.3.0:
eslint-plugin-react-hooks@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-2.3.0.tgz#53e073961f1f5ccf8dd19558036c1fac8c29d99a"
integrity sha512-gLKCa52G4ee7uXzdLiorca7JIQZPPXRAQDXV83J4bUEeUuc5pIEyZYAZ45Xnxe5IuupxEqHS+hUhSLIimK1EMw==
Expand All @@ -4234,7 +4234,7 @@ [email protected]:
prop-types "^15.7.2"
resolve "^1.12.0"

eslint-plugin-react@^7.15.1, eslint-plugin-react@^7.18.0:
eslint-plugin-react@^7.15.1:
version "7.18.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.18.0.tgz#2317831284d005b30aff8afb7c4e906f13fa8e7e"
integrity sha512-p+PGoGeV4SaZRDsXqdj9OWcOrOpZn8gXoGPcIQTzo2IDMbAKhNDnME9myZWqO3Ic4R3YmwAZ1lDjWl2R2hMUVQ==
Expand Down

0 comments on commit 1dc046a

Please sign in to comment.