Skip to content

Commit

Permalink
fix: Agoric SDK integration fixes (merge #1889)
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal authored Dec 11, 2023
2 parents 281e318 + b7f18a7 commit 0886269
Show file tree
Hide file tree
Showing 48 changed files with 259 additions and 233 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ jobs:
- name: build
run: yarn run build

- name: build:types
run: yarn lerna run build:types

- name: pack
# Concurrency is 1 to avoid bizarre cross-package contamination.
run: yarn run lerna exec --concurrency=1 yarn pack
# Cannot use yarn lerna run pack
run: yarn lerna exec yarn pack

- name: clean:types
run: yarn lerna run clean:types
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ https://github.com/endojs/endo/labels/next-release
git checkout -b release-$now
```

* Generate types.

```sh
yarn lerna run build:types
```

We generate types from the bottom up before publishing because this allows
each package to rely on the generated types of its dependencies in the
workspace.

* Create the release CHANGELOGs.

```sh
Expand Down Expand Up @@ -156,6 +166,12 @@ https://github.com/endojs/endo/labels/next-release
git tag -l | egrep -e '@[0-9]+\.[0-9]+\.[0-9]+$' | xargs git push origin
```

* Clean up generated types.

```sh
yarn lerna run clean:types
```

## More information

To get help for the command-line options that will affect these commands, use:
Expand Down
4 changes: 2 additions & 2 deletions packages/base64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/bundle-source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand Down
4 changes: 2 additions & 2 deletions packages/captp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand Down
4 changes: 2 additions & 2 deletions packages/captp/src/atomics.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const splitTransferBuffer = transferBuffer => {
* when the guest iterates over it.
*
* @param {SharedArrayBuffer} transferBuffer
* @returns {TrapHost}
* @returns {import('./types.js').TrapHost}
*/
export const makeAtomicsTrapHost = transferBuffer => {
const { statusbuf, lenbuf, databuf } = splitTransferBuffer(transferBuffer);
Expand Down Expand Up @@ -104,7 +104,7 @@ export const makeAtomicsTrapHost = transferBuffer => {
* then returns it.
*
* @param {SharedArrayBuffer} transferBuffer
* @returns {TrapGuest}
* @returns {import('./types.js').TrapGuest}
*/
export const makeAtomicsTrapGuest = transferBuffer => {
const { statusbuf, lenbuf, databuf } = splitTransferBuffer(transferBuffer);
Expand Down
37 changes: 18 additions & 19 deletions packages/captp/src/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { isPromise, makePromiseKit } from '@endo/promise-kit';

import { makeTrap } from './trap.js';

import './types.js';
import { makeFinalizingMap } from './finalize.js';

export { E };
Expand All @@ -39,8 +38,8 @@ const isThenable = maybeThenable =>
* us, we need to reference just our own slot, not one from their
* side.
*
* @param {CapTPSlot} slot
* @returns {CapTPSlot} slot with direction reversed
* @param {import('./types.js').CapTPSlot} slot
* @returns {import('./types.js').CapTPSlot} slot with direction reversed
*/
const reverseSlot = slot => {
const otherDir = slot[1] === '+' ? '-' : '+';
Expand All @@ -50,15 +49,15 @@ const reverseSlot = slot => {

/**
* @typedef {object} CapTPOptions the options to makeCapTP
* @property {(val: unknown, slot: CapTPSlot) => void} [exportHook]
* @property {(val: unknown, slot: CapTPSlot) => void} [importHook]
* @property {(val: unknown, slot: import('./types.js').CapTPSlot) => void} [exportHook]
* @property {(val: unknown, slot: import('./types.js').CapTPSlot) => void} [importHook]
* @property {(err: any) => void} [onReject]
* @property {number} [epoch] an integer tag to attach to all messages in order to
* assist in ignoring earlier defunct instance's messages
* @property {TrapGuest} [trapGuest] if specified, enable this CapTP (guest) to
* @property {import('./types.js').TrapGuest} [trapGuest] if specified, enable this CapTP (guest) to
* use Trap(target) to block while the recipient (host) resolves and
* communicates the response to the message
* @property {TrapHost} [trapHost] if specified, enable this CapTP (host) to serve
* @property {import('./types.js').TrapHost} [trapHost] if specified, enable this CapTP (host) to serve
* objects marked with makeTrapHandler to synchronous clients (guests)
* @property {boolean} [gcImports] if true, aggressively garbage collect imports
*/
Expand Down Expand Up @@ -164,7 +163,7 @@ export const makeCapTP = (
});
};

/** @type {Map<CapTPSlot, number>} */
/** @type {Map<import('./types.js').CapTPSlot, number>} */
const slotToNumRefs = new Map();

const recvSlot = makeRefCounter(
Expand Down Expand Up @@ -219,13 +218,13 @@ export const makeCapTP = (
},
);

/** @type {WeakMap<any, CapTPSlot>} */
/** @type {WeakMap<any, import('./types.js').CapTPSlot>} */
const valToSlot = new WeakMap(); // exports looked up by val
/** @type {Map<CapTPSlot, any>} */
/** @type {Map<import('./types.js').CapTPSlot, any>} */
const slotToExported = new Map();
const slotToImported = makeFinalizingMap(
/**
* @param {CapTPSlot} slotID
* @param {import('./types.js').CapTPSlot} slotID
*/
slotID => {
// We drop all the references we know about at once, since GC told us we
Expand All @@ -246,7 +245,7 @@ export const makeCapTP = (
// Since we decide the ids for questions, we use this to increment the
// question key

/** @type {Map<CapTPSlot, Settler<unknown>>} */
/** @type {Map<import('./types.js').CapTPSlot, Settler<unknown>>} */
const settlers = new Map();
/** @type {Map<string, any>} */
const answers = new Map(); // chosen by our peer
Expand All @@ -257,14 +256,14 @@ export const makeCapTP = (
* promise listener to inform the other side when the promise is
* fulfilled/broken.
*
* @type {import('@endo/marshal').ConvertValToSlot<CapTPSlot>}
* @type {import('@endo/marshal').ConvertValToSlot<import('./types.js').CapTPSlot>}
*/
function convertValToSlot(val) {
if (!valToSlot.has(val)) {
/**
* new export
*
* @type {CapTPSlot}
* @type {import('./types.js').CapTPSlot}
*/
let slot;
if (isPromise(val)) {
Expand Down Expand Up @@ -327,7 +326,7 @@ export const makeCapTP = (

const IS_REMOTE_PUMPKIN = harden({});
/**
* @type {import('@endo/marshal').ConvertSlotToVal<CapTPSlot>}
* @type {import('@endo/marshal').ConvertSlotToVal<import('./types.js').CapTPSlot>}
*/
const assertValIsLocal = val => {
const slot = valToSlot.get(val);
Expand All @@ -354,7 +353,7 @@ export const makeCapTP = (
* Generate a new question in the questions table and set up a new
* remote handled promise.
*
* @returns {[CapTPSlot, Promise]}
* @returns {[import('./types.js').CapTPSlot, Promise]}
*/
const makeQuestion = () => {
lastPromiseID += 1;
Expand Down Expand Up @@ -464,7 +463,7 @@ export const makeCapTP = (
/**
* Set up import
*
* @type {import('@endo/marshal').ConvertSlotToVal<CapTPSlot>}
* @type {import('@endo/marshal').ConvertSlotToVal<import('./types.js').CapTPSlot>}
*/
function convertSlotToVal(theirSlot, iface = undefined) {
let val;
Expand Down Expand Up @@ -806,7 +805,7 @@ export const makeCapTP = (
serialize,
unserialize,
makeTrapHandler,
Trap: /** @type {Trap | undefined} */ (undefined),
Trap: /** @type {import('./types.js').Trap | undefined} */ (undefined),
};

if (trapGuest) {
Expand Down Expand Up @@ -904,7 +903,7 @@ export const makeCapTP = (
return value;
};

/** @type {TrapImpl} */
/** @type {import('./types.js').TrapImpl} */
const trapImpl = {
applyFunction: makeTrapImpl('applyFunction'),
applyMethod: makeTrapImpl('applyMethod'),
Expand Down
8 changes: 3 additions & 5 deletions packages/captp/src/trap.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Lifted mostly from `@endo/eventual-send/src/E.js`.

import './types.js';

/**
* Default implementation of Trap for near objects.
*
* @type {TrapImpl}
* @type {import('./types.js').TrapImpl}
*/
export const nearTrapImpl = harden({
applyFunction(target, args) {
Expand Down Expand Up @@ -39,7 +37,7 @@ const baseFreezableProxyHandler = {
* A Proxy handler for Trap(x)
*
* @param {any} x Any value passed to Trap(x)
* @param {TrapImpl} trapImpl
* @param {import('./types.js').TrapImpl} trapImpl
* @returns {ProxyHandler}
*/
const TrapProxyHandler = (x, trapImpl) => {
Expand All @@ -59,7 +57,7 @@ const TrapProxyHandler = (x, trapImpl) => {
};

/**
* @param {TrapImpl} trapImpl
* @param {import('./types.js').TrapImpl} trapImpl
* @returns {Trap}
*/
export const makeTrap = trapImpl => {
Expand Down
2 changes: 2 additions & 0 deletions packages/captp/src/types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export {};

/** @typedef {string} CapTPSlot */

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/check-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
"lint:js": "eslint .",
Expand Down
4 changes: 2 additions & 2 deletions packages/cjs-module-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"exports": {},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
"lint:js": "eslint .",
Expand Down
4 changes: 2 additions & 2 deletions packages/compartment-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"cover": "c8 ava",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
Expand Down
4 changes: 2 additions & 2 deletions packages/env-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"lint-fix": "eslint --fix .",
"lint:js": "eslint .",
"lint:types": "tsc",
"postpack": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"test": "ava"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint:eslint": "eslint '**/*.js'",
"lint:types": "tsc",
"postpack": "yarn clean",
"prepack": "tsc --build tsconfig.build.json",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0"
Expand Down
5 changes: 2 additions & 3 deletions packages/evasive-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
"build": "exit 0",
"clean": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "yarn clean",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint": "yarn lint:types && yarn lint:eslint",
Expand Down
2 changes: 1 addition & 1 deletion packages/evasive-transform/src/parse-ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module
*/

import babelParser from '@babel/parser';
import * as babelParser from '@babel/parser';

const { parse: parseBabel } = babelParser;

Expand Down
4 changes: 2 additions & 2 deletions packages/eventual-send/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"test:xs": "exit 0",
"build": "exit 0",
"clean": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "yarn clean",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint": "yarn lint:types && yarn lint:eslint",
Expand Down
4 changes: 2 additions & 2 deletions packages/exo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"scripts": {
"build": "exit 0",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"build:types": "tsc --build tsconfig.build.json",
"clean:types": "git clean -f '*.d.ts*'",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix .",
"lint:js": "eslint .",
Expand Down
2 changes: 1 addition & 1 deletion packages/exo/src/exo-makers.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ harden(defineExoClass);
* @template {Record<FacetName, Methods>} F facet methods
* @param {string} tag
* @param {{ [K in keyof F]:
* InterfaceGuard<{[M in keyof F[K]]: MethodGuard; }>
* import('@endo/patterns').InterfaceGuard<{[M in keyof F[K]]: import('@endo/patterns').MethodGuard; }>
* } | undefined} interfaceGuardKit
* @param {I} init
* @param {F & { [K in keyof F]: ThisType<{ facets: GuardedKit<F>, state: ReturnType<I> }> }} methodsKit
Expand Down
Loading

0 comments on commit 0886269

Please sign in to comment.