diff --git a/packages/SwingSet/src/vats/network/network.js b/packages/SwingSet/src/vats/network/network.js index 1b50a15b654..67e0185b9af 100644 --- a/packages/SwingSet/src/vats/network/network.js +++ b/packages/SwingSet/src/vats/network/network.js @@ -56,6 +56,7 @@ export const ENDPOINT_SEPARATOR = '/'; * @property {(port: Port, l: ListenHandler) => Promise} [onListen] The listener has been registered * @property {(port: Port, listenAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise} [onInbound] Return metadata for inbound connection attempt * @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise} onAccept A new connection is incoming + * @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise} onReject The connection was rejected * @property {(port: Port, rej: any, l: ListenHandler) => Promise} [onError] There was an error while listening * @property {(port: Port, l: ListenHandler) => Promise} [onRemove] The listener has been removed */ @@ -324,7 +325,10 @@ export function makeNetworkProtocol(protocolHandler, E = defaultE) { if (localAddr.endsWith(ENDPOINT_SEPARATOR)) { for (;;) { // eslint-disable-next-line no-await-in-loop - const portID = await E(protocolHandler).generatePortID(localAddr); + const portID = await E(protocolHandler).generatePortID( + localAddr, + protocolHandler, + ); const newAddr = `${localAddr}${portID}`; if (!boundPorts.has(newAddr)) { localAddr = newAddr; diff --git a/packages/cosmic-swingset/lib/ag-solo/vats/bridge.js b/packages/cosmic-swingset/lib/ag-solo/vats/bridge.js index e779b4954f0..da1e7d593aa 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/bridge.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/bridge.js @@ -28,7 +28,7 @@ import makeStore from '@agoric/store'; /** * Create a handler that demuxes/muxes the bridge device by its first argument. * - * @param {(target: T) => T} E The eventual sender + * @param {import('@agoric/eventual-send').EProxy} E The eventual sender * @param {(target: Device) => T} D The device sender * @param {Device} bridgeDevice The bridge to manage * @returns {BridgeManager} admin facet for this handler diff --git a/packages/cosmic-swingset/lib/ag-solo/vats/ibc.js b/packages/cosmic-swingset/lib/ag-solo/vats/ibc.js index 9607e34fc32..509797c7a57 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/ibc.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/ibc.js @@ -227,7 +227,7 @@ export function makeIBCProtocolHandler(E, callIBCDevice) { localAddr, remoteAddr, ); - const connP = /** @type {Promise} */ (E.when(conn)); + const connP = E.when(conn); channelKeyToConnP.init(channelKey, connP); }, onReceive, @@ -515,14 +515,10 @@ EOF const remoteAddr = `${ibcHops}/ibc-port/${rPortID}/${order.toLowerCase()}/${rVersion}`; // See if we allow an inbound attempt for this address pair (without rejecting). - const attemptP = - /** @type {Promise} */ - (E(protocolImpl).inbound(localAddr, remoteAddr)); + const attemptP = E(protocolImpl).inbound(localAddr, remoteAddr); // Tell what version string we negotiated. - const attemptedLocal = - /** @type {string} */ - (await E(attemptP).getLocalAddress()); + const attemptedLocal = await E(attemptP).getLocalAddress(); const match = attemptedLocal.match( // Match: ... /ORDER/VERSION ... new RegExp('^(/[^/]+/[^/]+)*/(ordered|unordered)/([^/]+)(/|$)'), @@ -643,7 +639,6 @@ EOF E(connP) .send(data) .then(ack => { - /** @type {Data} */ const realAck = ack || DEFAULT_ACKNOWLEDGEMENT; const ack64 = dataToBase64(realAck); return callIBCDevice('packetExecuted', { packet, ack: ack64 }); diff --git a/packages/eventual-send/src/index.d.ts b/packages/eventual-send/src/index.d.ts index 6d08c6167c7..22cfc2fb31e 100644 --- a/packages/eventual-send/src/index.d.ts +++ b/packages/eventual-send/src/index.d.ts @@ -37,13 +37,13 @@ export const HandledPromise: HandledPromiseConstructor; /* Types for E proxy calls. */ type ESingleMethod = { - readonly [P in keyof T]: (...args: Parameters) => Promise>; + readonly [P in keyof T]: (...args: Parameters) => Promise>>; } type ESingleCall = T extends Function ? - ((...args: Parameters) => Promise>) & ESingleMethod : + ((...args: Parameters) => Promise>>) & ESingleMethod : ESingleMethod; type ESingleGet = { - readonly [P in keyof T]: Promise; + readonly [P in keyof T]: Promise>; } /* Same types for send-only. */ @@ -84,12 +84,17 @@ interface EProxy { */ readonly G(x: T): ESingleGet>; + /** + * E.when(x) converts x to a promise. + */ + readonly when(x: T): Promise>; + /** * E.when(x, res, rej) is equivalent to HandledPromise.resolve(x).then(res, rej) */ readonly when( x: T, - onfulfilled?: (value: Unpromise) => any | PromiseLike, + onfulfilled: (value: Unpromise) => any | PromiseLike | undefined, onrejected?: (reason: any) => PromiseLike, ): Promise;