Skip to content

Commit

Permalink
refactor: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
iomekam committed Apr 26, 2024
1 parent fce3edb commit 96b8508
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/network/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@
* Create an outbound connection
*/

/** @typedef {ReturnType<ReturnType<typeof preparePortAllocator>>} PortAllocator */
/** @typedef {ReturnType<ReturnType<typeof import('@agoric/network').preparePortAllocator>>} PortAllocator */
4 changes: 2 additions & 2 deletions packages/network/test/test-network-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const prepareProtocolHandler = (
},
async generatePortID() {
this.state.nonce += 1;
return `${this.state.nonce}`;
return `port-${this.state.nonce}`;
},
async onBind(port, localAddr) {
t.assert(port, `port is supplied to onBind`);
Expand Down Expand Up @@ -187,7 +187,7 @@ test('verify port allocation', async t => {
const portAllocator = makePortAllocator({ protocol });

const ibcPort = await when(portAllocator.allocateIBCPort());
t.is(ibcPort.getLocalAddress(), '/ibc-port/1');
t.is(ibcPort.getLocalAddress(), '/ibc-port/port-1');

const icaControllerPort1 = await when(
portAllocator.allocateICAControllerPort(),
Expand Down
17 changes: 4 additions & 13 deletions packages/orchestration/src/proposals/orchestration-proposal.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// @ts-check
import { V as E } from '@agoric/vat-data/vow.js';
import { Far } from '@endo/far';

/**
* @import { AttenuatedPortAllocator } from '../types'
* @import { OrchestrationService } from '../service.js'
* @import { OrchestrationVat } from '../vat-orchestration.js'
*/
Expand All @@ -12,7 +10,7 @@ import { Far } from '@endo/far';
* @param {BootstrapPowers & {
* consume: {
* loadCriticalVat: VatLoader<any>;
* portAllocator: AttenuatedPortAllocator;
* portAllocator: PortAllocator;
* };
* produce: {
* orchestration: Producer<any>;
Expand All @@ -29,7 +27,7 @@ import { Far } from '@endo/far';
*/
export const setupOrchestrationVat = async (
{
consume: { loadCriticalVat, portAllocator },
consume: { loadCriticalVat, portAllocator: portAllocatorP },
produce: {
orchestrationVat,
orchestration,
Expand All @@ -49,17 +47,10 @@ export const setupOrchestrationVat = async (
orchestrationVat.reset();
orchestrationVat.resolve(vats.orchestration);

await portAllocator;

/** @type {AttenuatedPortAllocator} */
const allocator = Far('PortAllocator', {
async allocateICAControllerPort() {
return E(portAllocator).allocateICAControllerPort();
},
});
const portAllocator = await portAllocatorP;

const newOrchestrationKit = await E(vats.orchestration).makeOrchestration({
portAllocator: allocator,
portAllocator,
});

orchestration.reset();
Expand Down
5 changes: 3 additions & 2 deletions packages/orchestration/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import { makeICAConnectionAddress, parseAddress } from './utils/address.js';
import { makeTxPacket, parsePacketAck } from './utils/tx.js';

/**
* @import { AttenuatedPortAllocator, ChainAccount, ChainAddress } from './types.js';
* @import { ChainAccount, ChainAddress } from './types.js';
* @import { IBCConnectionID } from '@agoric/vats';
* @import { Zone } from '@agoric/base-zone';
* @import { TxBody } from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
*
*/

const { Fail, bare } = assert;
Expand All @@ -24,7 +25,7 @@ const trace = makeTracer('Orchestration');

/**
* @typedef {object} OrchestrationPowers
* @property {ERef<AttenuatedPortAllocator>} portAllocator
* @property {ERef<PortAllocator>} portAllocator
*/

/**
Expand Down
6 changes: 0 additions & 6 deletions packages/orchestration/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import type {
Redelegation,
UnbondingDelegation,
} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
import type { PortAllocator } from '@agoric/network/src/network';

export type AttenuatedPortAllocator = Pick<
PortAllocator,
'allocateICAControllerPort'
>;

/**
* static declaration of known chain types will allow type support for
Expand Down

0 comments on commit 96b8508

Please sign in to comment.