Skip to content

Commit

Permalink
chore: enact new @agoric/network location
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 8, 2023
1 parent 1ebfef7 commit c7ae7d7
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/SwingSet/docs/networking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Network API

This documentation has been relocated to https://github.com/Agoric/agoric-sdk/tree/master/packages/network#readme
1 change: 1 addition & 0 deletions packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/src/sdk-package-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default [
"@agoric/import-manager",
"@agoric/inter-protocol",
"@agoric/internal",
"@agoric/network",
"@agoric/notifier",
"@agoric/pegasus",
"@agoric/same-structure",
Expand Down
1 change: 1 addition & 0 deletions packages/governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/index.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
1 change: 1 addition & 0 deletions packages/network/exported.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/types.js';
6 changes: 6 additions & 0 deletions packages/network/jsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"./jsconfig.json",
"../../tsconfig-build-options.json"
]
}
13 changes: 13 additions & 0 deletions packages/network/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"checkJs": false,
},
"include": [
"*.js",
"scripts/**/*.js",
"src/**/*.js",
"test/**/*.js",
"tools/**/*.js",
],
}
63 changes: 63 additions & 0 deletions packages/network/package.json
Original file line number Diff line number Diff line change
@@ -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
}
}
2 changes: 1 addition & 1 deletion packages/network/src/index.js
Original file line number Diff line number Diff line change
@@ -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';
21 changes: 7 additions & 14 deletions packages/network/test/test-network-misc.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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`);
Expand Down Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions packages/pegasus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/pegasus/src/ibc-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions packages/pegasus/src/pegasus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/pegasus/test/test-peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion packages/vats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
},
Expand Down
11 changes: 4 additions & 7 deletions packages/vats/src/ibc.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions packages/vats/src/proposals/network-proposal.js
Original file line number Diff line number Diff line change
@@ -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-';
Expand Down
2 changes: 1 addition & 1 deletion packages/vats/src/vat-network.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit c7ae7d7

Please sign in to comment.