Skip to content

Commit

Permalink
fix(network): use new ERef and FarRef
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jun 14, 2024
1 parent 90e062c commit 3027adf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 9 additions & 2 deletions packages/boot/test/bootstrapTests/ibcClientMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Far } from '@endo/far';
import { V as E } from '@agoric/vow/vat.js';

/**
* @import {ListenHandler, PortAllocator} from '@agoric/network';
* @import {Connection, PortAllocator} from '@agoric/network';
* @import {FarRef, ERef} from '@agoric/vow';
*/

/**
* @param {ZCF} zcf
* @param {{
* portAllocator: ERef<PortAllocator>;
* portAllocator: FarRef<PortAllocator>;
* }} privateArgs
* @param {import('@agoric/vat-data').Baggage} _baggage
*/
Expand All @@ -20,7 +21,13 @@ export const start = async (zcf, privateArgs, _baggage) => {
const myPort = await E(portAllocator).allocateCustomIBCPort();

const { log } = console;
/**
* @type {FarRef<Connection>}
*/
let connP;
/**
* @type {ERef<string>}
*/
let ackP;

const creatorFacet = Far('CF', {
Expand Down
1 change: 1 addition & 0 deletions packages/internal/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type Remote<Primary, Local = DataOnly<Primary>> =
| Primary
| RemotableBrand<Local, Primary>;

// TODO: Add type tests for FarRef and Remote.
/**
* Potentially remote promises or settled references.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/network/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ export const preparePortAllocator = (zone, { watch }) =>
*/
({ protocol }) => ({ protocol, lastICAPortNum: 0n, lastICQPortNum: 0n }),
{
allocateCustomIBCPort(specifiedName = '') {
async allocateCustomIBCPort(specifiedName = '') {
const { state } = this;
let localAddr = `/ibc-port/`;

Expand All @@ -1488,7 +1488,7 @@ export const preparePortAllocator = (zone, { watch }) =>
// Allocate an IBC port with a unique generated name.
return watch(E(state.protocol).bindPort(localAddr));
},
allocateICAControllerPort() {
async allocateICAControllerPort() {
const { state } = this;
state.lastICAPortNum += 1n;
return watch(
Expand All @@ -1497,7 +1497,7 @@ export const preparePortAllocator = (zone, { watch }) =>
),
);
},
allocateICQControllerPort() {
async allocateICQControllerPort() {
const { state } = this;
state.lastICQPortNum += 1n;
return watch(
Expand All @@ -1506,7 +1506,7 @@ export const preparePortAllocator = (zone, { watch }) =>
),
);
},
allocateCustomLocalPort(specifiedName = '') {
async allocateCustomLocalPort(specifiedName = '') {
const { state } = this;

let localAddr = `/local/`;
Expand Down

0 comments on commit 3027adf

Please sign in to comment.