From c7ae7d735a4e36d403e0b8d867c92ad2257d516d Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Thu, 3 Aug 2023 18:14:48 -0600 Subject: [PATCH] chore: enact new `@agoric/network` location --- .github/workflows/test-all-packages.yml | 3 + packages/SwingSet/docs/networking.md | 3 + packages/agoric-cli/package.json | 1 + packages/agoric-cli/src/init.js | 2 +- packages/agoric-cli/src/sdk-package-names.js | 1 + packages/governance/package.json | 1 + packages/governance/src/index.js | 2 +- packages/network/exported.js | 1 + packages/network/jsconfig.build.json | 6 ++ packages/network/jsconfig.json | 13 ++++ packages/network/package.json | 63 +++++++++++++++++++ packages/network/src/index.js | 2 +- packages/network/test/test-network-misc.js | 21 +++---- packages/pegasus/package.json | 1 + packages/pegasus/src/ibc-trace.js | 2 +- packages/pegasus/src/pegasus.js | 3 +- packages/pegasus/test/test-peg.js | 4 +- packages/vats/package.json | 3 +- packages/vats/src/ibc.js | 11 ++-- .../vats/src/proposals/network-proposal.js | 4 +- packages/vats/src/vat-network.js | 2 +- 21 files changed, 116 insertions(+), 33 deletions(-) create mode 100644 packages/SwingSet/docs/networking.md create mode 100644 packages/network/exported.js create mode 100644 packages/network/jsconfig.build.json create mode 100644 packages/network/jsconfig.json create mode 100644 packages/network/package.json diff --git a/.github/workflows/test-all-packages.yml b/.github/workflows/test-all-packages.yml index 79b1245e5c5..8630acd3206 100644 --- a/.github/workflows/test-all-packages.yml +++ b/.github/workflows/test-all-packages.yml @@ -214,6 +214,9 @@ jobs: - name: yarn test (internal) if: (success() || failure()) run: cd packages/internal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT + - name: yarn test (network) + if: (success() || failure()) + run: cd packages/network && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT - name: yarn test (pegasus) if: (success() || failure()) run: cd packages/pegasus && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT diff --git a/packages/SwingSet/docs/networking.md b/packages/SwingSet/docs/networking.md new file mode 100644 index 00000000000..a92a7d47c13 --- /dev/null +++ b/packages/SwingSet/docs/networking.md @@ -0,0 +1,3 @@ +# Network API + +This documentation has been relocated to https://github.com/Agoric/agoric-sdk/tree/master/packages/network#readme diff --git a/packages/agoric-cli/package.json b/packages/agoric-cli/package.json index ca718f835e1..8ec7e9aabb5 100644 --- a/packages/agoric-cli/package.json +++ b/packages/agoric-cli/package.json @@ -41,6 +41,7 @@ "@agoric/ertp": "^0.16.2", "@agoric/inter-protocol": "^0.16.1", "@agoric/internal": "^0.3.2", + "@agoric/network": "^0.1.0", "@agoric/smart-wallet": "^0.5.3", "@agoric/store": "^0.9.2", "@agoric/swingset-vat": "^0.32.2", diff --git a/packages/agoric-cli/src/init.js b/packages/agoric-cli/src/init.js index 5c3aa2c977d..54ce67dcc76 100644 --- a/packages/agoric-cli/src/init.js +++ b/packages/agoric-cli/src/init.js @@ -5,7 +5,7 @@ import { makePspawn } from './helpers.js'; // https://github.com/Agoric/agoric-sdk/issues/6512 import '@endo/captp/src/types.js'; import '@agoric/swingset-vat/exported.js'; -import '@agoric/swingset-vat/src/vats/network/types.js'; +import '@agoric/network/exported.js'; // Use either an absolute template URL, or find it relative to DAPP_URL_BASE. const gitURL = (relativeOrAbsoluteURL, base) => { diff --git a/packages/agoric-cli/src/sdk-package-names.js b/packages/agoric-cli/src/sdk-package-names.js index 164911a98df..31e019cedae 100644 --- a/packages/agoric-cli/src/sdk-package-names.js +++ b/packages/agoric-cli/src/sdk-package-names.js @@ -18,6 +18,7 @@ export default [ "@agoric/import-manager", "@agoric/inter-protocol", "@agoric/internal", + "@agoric/network", "@agoric/notifier", "@agoric/pegasus", "@agoric/same-structure", diff --git a/packages/governance/package.json b/packages/governance/package.json index 282d44909d3..d5d6a4ff738 100644 --- a/packages/governance/package.json +++ b/packages/governance/package.json @@ -34,6 +34,7 @@ "@agoric/assert": "^0.6.0", "@agoric/ertp": "^0.16.2", "@agoric/internal": "^0.3.2", + "@agoric/network": "^0.1.0", "@agoric/notifier": "^0.6.2", "@agoric/store": "^0.9.2", "@agoric/swingset-vat": "^0.32.2", diff --git a/packages/governance/src/index.js b/packages/governance/src/index.js index 26a2767f08b..6943c34c9c4 100644 --- a/packages/governance/src/index.js +++ b/packages/governance/src/index.js @@ -1,5 +1,5 @@ // Ambient types. https://github.com/Agoric/agoric-sdk/issues/6512 -import '@agoric/swingset-vat/src/vats/network/types.js'; +import '@agoric/network/exported.js'; import '@agoric/ertp/exported.js'; import '@agoric/zoe/exported.js'; diff --git a/packages/network/exported.js b/packages/network/exported.js new file mode 100644 index 00000000000..f4cba017ea1 --- /dev/null +++ b/packages/network/exported.js @@ -0,0 +1 @@ +import './src/types.js'; diff --git a/packages/network/jsconfig.build.json b/packages/network/jsconfig.build.json new file mode 100644 index 00000000000..b674676c8fe --- /dev/null +++ b/packages/network/jsconfig.build.json @@ -0,0 +1,6 @@ +{ + "extends": [ + "./jsconfig.json", + "../../tsconfig-build-options.json" + ] +} diff --git a/packages/network/jsconfig.json b/packages/network/jsconfig.json new file mode 100644 index 00000000000..369a34eb383 --- /dev/null +++ b/packages/network/jsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "checkJs": false, + }, + "include": [ + "*.js", + "scripts/**/*.js", + "src/**/*.js", + "test/**/*.js", + "tools/**/*.js", + ], +} diff --git a/packages/network/package.json b/packages/network/package.json new file mode 100644 index 00000000000..4958000f9ed --- /dev/null +++ b/packages/network/package.json @@ -0,0 +1,63 @@ +{ + "name": "@agoric/network", + "version": "0.1.0", + "description": "Agoric's network protocol API", + "type": "module", + "main": "./src/index.js", + "repository": "https://github.com/Agoric/agoric-sdk", + "scripts": { + "build": "exit 0", + "prepack": "tsc --build jsconfig.build.json", + "postpack": "git clean -f '*.d.ts*'", + "test": "ava", + "test:c8": "c8 $C8_OPTIONS ava", + "test:xs": "exit 0", + "lint-fix": "yarn lint:eslint --fix", + "lint": "run-s --continue-on-error lint:*", + "lint:types": "tsc -p jsconfig.json", + "lint:eslint": "eslint ." + }, + "keywords": [], + "author": "Agoric", + "license": "Apache-2.0", + "dependencies": { + "@agoric/assert": "^0.6.0", + "@agoric/internal": "^0.3.2", + "@agoric/store": "^0.9.2", + "@agoric/swingset-vat": "^0.32.2", + "@endo/base64": "^0.2.32", + "@endo/far": "^0.2.19", + "@endo/promise-kit": "^0.2.57" + }, + "devDependencies": { + "@endo/bundle-source": "^2.5.2", + "ava": "^5.3.0", + "c8": "^7.13.0" + }, + "exports": { + ".": "./src/index.js", + "./exported.js": "./exported.js" + }, + "files": [ + "CHANGELOG.md", + "src/", + "scripts/", + "tools/", + "*.json", + "globals.d.ts", + "exported.js" + ], + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=14.15.0" + }, + "ava": { + "files": [ + "test/**/test-*.js" + ], + "timeout": "20m", + "workerThreads": false + } +} diff --git a/packages/network/src/index.js b/packages/network/src/index.js index 8411dc0139e..b35f7581eec 100644 --- a/packages/network/src/index.js +++ b/packages/network/src/index.js @@ -1,4 +1,4 @@ export * from './network.js'; -export { default as makeRouter } from './router.js'; +export { default as makeRouter, makeRouterProtocol } from './router.js'; export * from './multiaddr.js'; export * from './bytes.js'; diff --git a/packages/network/test/test-network-misc.js b/packages/network/test/test-network-misc.js index c99d7b94958..410b70d3769 100644 --- a/packages/network/test/test-network-misc.js +++ b/packages/network/test/test-network-misc.js @@ -1,6 +1,5 @@ -// @ts-nocheck // eslint-disable-next-line import/order -import { test } from '../tools/prepare-test-env-ava.js'; +import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js'; import { makePromiseKit } from '@endo/promise-kit'; import { Far } from '@endo/far'; @@ -12,19 +11,17 @@ import { makeLoopbackProtocolHandler, makeNetworkProtocol, makeRouter, -} from '../src/vats/network/index.js'; +} from '../src/index.js'; // eslint-disable-next-line no-constant-condition const log = false ? console.log : () => {}; /** - * @param {*} t - * @returns {import('../src/vats/network').ProtocolHandler} A testing handler + * @param {any} t + * @returns {import('../src').ProtocolHandler} A testing handler */ const makeProtocolHandler = t => { - /** - * @type {import('../src/vats/network').ListenHandler} - */ + /** @type {import('../src').ListenHandler} */ let l; let lp; let nonce = 0; @@ -112,9 +109,7 @@ test('protocol connection listen', async t => { const port = await protocol.bind('/net/ordered/ordered/some-portname'); - /** - * @type {import('../src/vats/network').ListenHandler} - */ + /** @type {import('../src').ListenHandler} */ const listener = Far('listener', { async onListen(p, listenHandler) { t.is(p, port, `port is tracked in onListen`); @@ -198,9 +193,7 @@ test('loopback protocol', async t => { const port = await protocol.bind('/loopback/foo'); - /** - * @type {import('../src/vats/network').ListenHandler} - */ + /** @type {import('../src').ListenHandler} */ const listener = Far('listener', { async onAccept(_p, _localAddr, _remoteAddr, _listenHandler) { return harden({ diff --git a/packages/pegasus/package.json b/packages/pegasus/package.json index 0adc12f73b6..f5a842b7926 100644 --- a/packages/pegasus/package.json +++ b/packages/pegasus/package.json @@ -32,6 +32,7 @@ "@agoric/assert": "^0.6.0", "@agoric/ertp": "^0.16.2", "@agoric/internal": "^0.3.2", + "@agoric/network": "^0.1.0", "@agoric/notifier": "^0.6.2", "@agoric/store": "^0.9.2", "@agoric/swingset-vat": "^0.32.2", diff --git a/packages/pegasus/src/ibc-trace.js b/packages/pegasus/src/ibc-trace.js index a446e654516..1a075156c33 100644 --- a/packages/pegasus/src/ibc-trace.js +++ b/packages/pegasus/src/ibc-trace.js @@ -2,7 +2,7 @@ import { Far } from '@endo/far'; import { Fail } from '@agoric/assert'; -import { parse } from '@agoric/swingset-vat/src/vats/network/multiaddr.js'; +import { parse } from '@agoric/network'; /** * Return a source-prefixed version of the denomination, as specified in diff --git a/packages/pegasus/src/pegasus.js b/packages/pegasus/src/pegasus.js index 4f074f0b11e..3f67a3223ae 100644 --- a/packages/pegasus/src/pegasus.js +++ b/packages/pegasus/src/pegasus.js @@ -9,8 +9,7 @@ import { } from '@agoric/zoe/src/contractSupport/index.js'; import { makeSubscriptionKit } from '@agoric/notifier'; -import '@agoric/vats/exported.js'; -import '@agoric/swingset-vat/src/vats/network/types.js'; +import '@agoric/network/exported.js'; import '@agoric/zoe/exported.js'; import '../exported.js'; diff --git a/packages/pegasus/test/test-peg.js b/packages/pegasus/test/test-peg.js index 5ad3940cb2f..a52971c670e 100644 --- a/packages/pegasus/test/test-peg.js +++ b/packages/pegasus/test/test-peg.js @@ -5,7 +5,7 @@ import { E, Far } from '@endo/far'; import { makeNetworkProtocol, makeLoopbackProtocolHandler, -} from '@agoric/swingset-vat/src/vats/network/index.js'; +} from '@agoric/network'; import bundleSource from '@endo/bundle-source'; import { AmountMath } from '@agoric/ertp'; @@ -83,7 +83,7 @@ async function testRemotePeg(t) { /** * Pretend we're Gaia. * - * @type {import('@agoric/swingset-vat/src/vats/network').Connection?} + * @type {import('@agoric/network/src').Connection?} */ let gaiaConnection; E(portP).addListener( diff --git a/packages/vats/package.json b/packages/vats/package.json index fe975b81e71..502e2289597 100644 --- a/packages/vats/package.json +++ b/packages/vats/package.json @@ -29,6 +29,7 @@ "@agoric/governance": "^0.10.3", "@agoric/inter-protocol": "^0.16.1", "@agoric/internal": "^0.3.2", + "@agoric/network": "^0.1.0", "@agoric/notifier": "^0.6.2", "@agoric/store": "^0.9.2", "@agoric/swingset-vat": "^0.32.2", @@ -38,7 +39,6 @@ "@agoric/zone": "^0.2.2", "@endo/far": "^0.2.19", "@endo/import-bundle": "^0.3.5", - "@endo/init": "^0.5.57", "@endo/marshal": "^0.8.6", "@endo/nat": "^4.1.28", "@endo/promise-kit": "^0.2.57", @@ -50,6 +50,7 @@ "@agoric/smart-wallet": "^0.5.3", "@agoric/swingset-liveslots": "^0.10.2", "@endo/bundle-source": "^2.5.2", + "@endo/init": "^0.5.57", "ava": "^5.3.0", "c8": "^7.13.0" }, diff --git a/packages/vats/src/ibc.js b/packages/vats/src/ibc.js index 2d5fe64e318..66f52db991c 100644 --- a/packages/vats/src/ibc.js +++ b/packages/vats/src/ibc.js @@ -1,18 +1,15 @@ // @ts-check -import { - dataToBase64, - base64ToBytes, -} from '@agoric/swingset-vat/src/vats/network/index.js'; import { makeScalarMapStore, makeLegacyMap } from '@agoric/store'; import { makePromiseKit } from '@endo/promise-kit'; import { assert, details as X, Fail } from '@agoric/assert'; import { Far } from '@endo/far'; -import '@agoric/store/exported.js'; -import '@agoric/swingset-vat/src/vats/network/types.js'; - import { makeWithQueue } from '@agoric/internal/src/queue.js'; +import { dataToBase64, base64ToBytes } from '@agoric/network'; + +import '@agoric/store/exported.js'; +import '@agoric/network/exported.js'; // CAVEAT: IBC acks cannot be empty, as the Cosmos IAVL tree cannot represent // empty acknowledgements as distinct from unacknowledged packets. diff --git a/packages/vats/src/proposals/network-proposal.js b/packages/vats/src/proposals/network-proposal.js index 9daf0a8cd09..e6d0eb619f8 100644 --- a/packages/vats/src/proposals/network-proposal.js +++ b/packages/vats/src/proposals/network-proposal.js @@ -1,11 +1,11 @@ // @ts-check import { E, Far } from '@endo/far'; +import { BridgeId as BRIDGE_ID } from '@agoric/internal'; import { makeLoopbackProtocolHandler, makeEchoConnectionHandler, makeNonceMaker, -} from '@agoric/swingset-vat/src/vats/network/index.js'; -import { BridgeId as BRIDGE_ID } from '@agoric/internal'; +} from '@agoric/network'; const NUM_IBC_PORTS_PER_CLIENT = 3; const INTERCHAIN_ACCOUNT_CONTROLLER_PORT_PREFIX = 'icacontroller-'; diff --git a/packages/vats/src/vat-network.js b/packages/vats/src/vat-network.js index d942543a921..6f98d761c24 100644 --- a/packages/vats/src/vat-network.js +++ b/packages/vats/src/vat-network.js @@ -1,5 +1,5 @@ // @ts-check -import { makeRouterProtocol } from '@agoric/swingset-vat/src/vats/network/router.js'; +import { makeRouterProtocol } from '@agoric/network'; export function buildRootObject() { return makeRouterProtocol(); // already Far('Router')