Skip to content

Commit e242143

Browse files
committed
fix: remove unnecessary types
1 parent 20941e6 commit e242143

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

packages/SwingSet/src/vats/network/network.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const ENDPOINT_SEPARATOR = '/';
5656
* @property {(port: Port, l: ListenHandler) => Promise<void>} [onListen] The listener has been registered
5757
* @property {(port: Port, listenAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise<Endpoint>} [onInbound] Return metadata for inbound connection attempt
5858
* @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise<ConnectionHandler>} onAccept A new connection is incoming
59+
* @property {(port: Port, localAddr: Endpoint, remoteAddr: Endpoint, l: ListenHandler) => Promise<void>} onReject The connection was rejected
5960
* @property {(port: Port, rej: any, l: ListenHandler) => Promise<void>} [onError] There was an error while listening
6061
* @property {(port: Port, l: ListenHandler) => Promise<void>} [onRemove] The listener has been removed
6162
*/
@@ -324,7 +325,10 @@ export function makeNetworkProtocol(protocolHandler, E = defaultE) {
324325
if (localAddr.endsWith(ENDPOINT_SEPARATOR)) {
325326
for (;;) {
326327
// eslint-disable-next-line no-await-in-loop
327-
const portID = await E(protocolHandler).generatePortID(localAddr);
328+
const portID = await E(protocolHandler).generatePortID(
329+
localAddr,
330+
protocolHandler,
331+
);
328332
const newAddr = `${localAddr}${portID}`;
329333
if (!boundPorts.has(newAddr)) {
330334
localAddr = newAddr;

packages/cosmic-swingset/lib/ag-solo/vats/bridge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import makeStore from '@agoric/store';
2828
/**
2929
* Create a handler that demuxes/muxes the bridge device by its first argument.
3030
*
31-
* @param {<T>(target: T) => T} E The eventual sender
31+
* @param {import('@agoric/eventual-send').EProxy} E The eventual sender
3232
* @param {<T>(target: Device<T>) => T} D The device sender
3333
* @param {Device<BridgeDevice>} bridgeDevice The bridge to manage
3434
* @returns {BridgeManager} admin facet for this handler

packages/cosmic-swingset/lib/ag-solo/vats/ibc.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export function makeIBCProtocolHandler(E, callIBCDevice) {
227227
localAddr,
228228
remoteAddr,
229229
);
230-
const connP = /** @type {Promise<Connection, any>} */ (E.when(conn));
230+
const connP = E.when(conn);
231231
channelKeyToConnP.init(channelKey, connP);
232232
},
233233
onReceive,
@@ -515,14 +515,10 @@ EOF
515515
const remoteAddr = `${ibcHops}/ibc-port/${rPortID}/${order.toLowerCase()}/${rVersion}`;
516516

517517
// See if we allow an inbound attempt for this address pair (without rejecting).
518-
const attemptP =
519-
/** @type {Promise<InboundAttempt>} */
520-
(E(protocolImpl).inbound(localAddr, remoteAddr));
518+
const attemptP = E(protocolImpl).inbound(localAddr, remoteAddr);
521519

522520
// Tell what version string we negotiated.
523-
const attemptedLocal =
524-
/** @type {string} */
525-
(await E(attemptP).getLocalAddress());
521+
const attemptedLocal = await E(attemptP).getLocalAddress();
526522
const match = attemptedLocal.match(
527523
// Match: ... /ORDER/VERSION ...
528524
new RegExp('^(/[^/]+/[^/]+)*/(ordered|unordered)/([^/]+)(/|$)'),
@@ -643,7 +639,6 @@ EOF
643639
E(connP)
644640
.send(data)
645641
.then(ack => {
646-
/** @type {Data} */
647642
const realAck = ack || DEFAULT_ACKNOWLEDGEMENT;
648643
const ack64 = dataToBase64(realAck);
649644
return callIBCDevice('packetExecuted', { packet, ack: ack64 });

packages/eventual-send/src/index.d.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ export const HandledPromise: HandledPromiseConstructor;
3737

3838
/* Types for E proxy calls. */
3939
type ESingleMethod<T> = {
40-
readonly [P in keyof T]: (...args: Parameters<T[P]>) => Promise<ReturnType<T[P]>>;
40+
readonly [P in keyof T]: (...args: Parameters<T[P]>) => Promise<Unpromise<ReturnType<T[P]>>>;
4141
}
4242
type ESingleCall<T> = T extends Function ?
43-
((...args: Parameters<T>) => Promise<ReturnType<T>>) & ESingleMethod<T> :
43+
((...args: Parameters<T>) => Promise<Unpromise<ReturnType<T>>>) & ESingleMethod<T> :
4444
ESingleMethod<T>;
4545
type ESingleGet<T> = {
46-
readonly [P in keyof T]: Promise<T[P]>;
46+
readonly [P in keyof T]: Promise<Unpromise<T[P]>>;
4747
}
4848

4949
/* Same types for send-only. */
@@ -84,12 +84,17 @@ interface EProxy {
8484
*/
8585
readonly G<T>(x: T): ESingleGet<Unpromise<T>>;
8686

87+
/**
88+
* E.when(x) converts x to a promise.
89+
*/
90+
readonly when<T>(x: T): Promise<Unpromise<T>>;
91+
8792
/**
8893
* E.when(x, res, rej) is equivalent to HandledPromise.resolve(x).then(res, rej)
8994
*/
9095
readonly when<T>(
9196
x: T,
92-
onfulfilled?: (value: Unpromise<T>) => any | PromiseLike<any>,
97+
onfulfilled: (value: Unpromise<T>) => any | PromiseLike<any> | undefined,
9398
onrejected?: (reason: any) => PromiseLike<never>,
9499
): Promise<any>;
95100

0 commit comments

Comments
 (0)