From c388febde5c0087718a59d4730468a34e8c74730 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Jul 2024 16:04:54 -0400 Subject: [PATCH 1/5] feat: export withOrchestration --- packages/orchestration/index.js | 1 + packages/orchestration/src/utils/start-helper.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/orchestration/index.js b/packages/orchestration/index.js index 09afecb813d..25858eba64a 100644 --- a/packages/orchestration/index.js +++ b/packages/orchestration/index.js @@ -5,3 +5,4 @@ export * from './src/types.js'; export * from './src/exos/cosmos-interchain-service.js'; export * from './src/typeGuards.js'; +export * from './src/utils/start-helper.js'; diff --git a/packages/orchestration/src/utils/start-helper.js b/packages/orchestration/src/utils/start-helper.js index f065e3097ae..acdf5e41c08 100644 --- a/packages/orchestration/src/utils/start-helper.js +++ b/packages/orchestration/src/utils/start-helper.js @@ -43,6 +43,7 @@ import { makeZoeTools } from './zoe-tools.js'; * @param {Baggage} baggage * @param {OrchestrationPowers} remotePowers * @param {Marshaller} marshaller + * @internal */ export const provideOrchestration = ( zcf, From c3a6fa3672b93580c43c80eb23839bb3dc782ec0 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Jul 2024 16:29:59 -0400 Subject: [PATCH 2/5] refactor(types): CosmosInterchainService from top --- packages/orchestration/src/examples/sendAnywhere.contract.js | 2 +- packages/orchestration/src/examples/swapExample.contract.js | 2 +- packages/orchestration/src/examples/unbondExample.contract.js | 2 +- packages/orchestration/src/exos/local-chain-facade.js | 2 +- packages/orchestration/src/exos/orchestrator.js | 2 +- packages/orchestration/src/exos/remote-chain-facade.js | 2 +- packages/orchestration/src/facade.js | 2 +- packages/orchestration/src/proposals/orchestration-proposal.js | 1 - packages/orchestration/src/utils/start-helper.js | 2 +- 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/orchestration/src/examples/sendAnywhere.contract.js b/packages/orchestration/src/examples/sendAnywhere.contract.js index cbe1e573e74..e8123fe7c31 100644 --- a/packages/orchestration/src/examples/sendAnywhere.contract.js +++ b/packages/orchestration/src/examples/sendAnywhere.contract.js @@ -15,7 +15,7 @@ import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js'; * @import {Remote, Vow} from '@agoric/vow'; * @import {Zone} from '@agoric/zone'; * @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js'; - * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; * @import {OrchestrationTools} from '../utils/start-helper.js'; */ diff --git a/packages/orchestration/src/examples/swapExample.contract.js b/packages/orchestration/src/examples/swapExample.contract.js index 8d75dd41087..f83772eb15d 100644 --- a/packages/orchestration/src/examples/swapExample.contract.js +++ b/packages/orchestration/src/examples/swapExample.contract.js @@ -10,7 +10,7 @@ import { withOrchestration } from '../utils/start-helper.js'; * @import {TimerService} from '@agoric/time'; * @import {LocalChain} from '@agoric/vats/src/localchain.js'; * @import {Remote} from '@agoric/internal'; - * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; * @import {NameHub} from '@agoric/vats'; * @import {Zone} from '@agoric/zone'; * @import {OrchestrationTools} from '../utils/start-helper.js'; diff --git a/packages/orchestration/src/examples/unbondExample.contract.js b/packages/orchestration/src/examples/unbondExample.contract.js index 8752dc1ff4e..db715408015 100644 --- a/packages/orchestration/src/examples/unbondExample.contract.js +++ b/packages/orchestration/src/examples/unbondExample.contract.js @@ -8,7 +8,7 @@ import { withOrchestration } from '../utils/start-helper.js'; * @import {NameHub} from '@agoric/vats'; * @import {Remote} from '@agoric/internal'; * @import {Zone} from '@agoric/zone'; - * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; * @import {OrchestrationTools} from '../utils/start-helper.js'; */ diff --git a/packages/orchestration/src/exos/local-chain-facade.js b/packages/orchestration/src/exos/local-chain-facade.js index f00eb5e418e..ad0d3d07acc 100644 --- a/packages/orchestration/src/exos/local-chain-facade.js +++ b/packages/orchestration/src/exos/local-chain-facade.js @@ -14,7 +14,7 @@ import { ChainFacadeI } from '../typeGuards.js'; * @import {Remote} from '@agoric/internal'; * @import {LocalChain, LocalChainAccount} from '@agoric/vats/src/localchain.js'; * @import {Vow, VowTools} from '@agoric/vow'; - * @import {CosmosInterchainService} from './cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; * @import {LocalOrchestrationAccountKit, MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js'; * @import {ChainAddress, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount} from '../types.js'; */ diff --git a/packages/orchestration/src/exos/orchestrator.js b/packages/orchestration/src/exos/orchestrator.js index 393cb5b024a..1eede42cdcc 100644 --- a/packages/orchestration/src/exos/orchestrator.js +++ b/packages/orchestration/src/exos/orchestrator.js @@ -23,7 +23,7 @@ import { * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'. * @import {Remote} from '@agoric/internal'; * @import {PickFacet} from '@agoric/swingset-liveslots'; - * @import {CosmosInterchainService} from './cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; * @import {MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js'; * @import {MakeLocalChainFacade} from './local-chain-facade.js'; * @import {MakeRemoteChainFacade} from './remote-chain-facade.js'; diff --git a/packages/orchestration/src/exos/remote-chain-facade.js b/packages/orchestration/src/exos/remote-chain-facade.js index e33f14b6ae2..4acb010ec9e 100644 --- a/packages/orchestration/src/exos/remote-chain-facade.js +++ b/packages/orchestration/src/exos/remote-chain-facade.js @@ -12,7 +12,7 @@ import { ChainAddressShape, ChainFacadeI } from '../typeGuards.js'; * @import {TimerService} from '@agoric/time'; * @import {Remote} from '@agoric/internal'; * @import {Vow, VowTools} from '@agoric/vow'; - * @import {CosmosInterchainService} from './cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; * @import {prepareCosmosOrchestrationAccount} from './cosmos-orchestration-account.js'; * @import {ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, ChainAddress, IcaAccount, Denom, Chain} from '../types.js'; */ diff --git a/packages/orchestration/src/facade.js b/packages/orchestration/src/facade.js index f366b411369..d09eb860ddf 100644 --- a/packages/orchestration/src/facade.js +++ b/packages/orchestration/src/facade.js @@ -10,7 +10,7 @@ import { assertAllDefined } from '@agoric/internal'; * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'. * @import {HostOrchestrator} from './exos/orchestrator.js'; * @import {Remote} from '@agoric/internal'; - * @import {CosmosInterchainService} from './exos/cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from './types.js'; * @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, OrchestrationFlow, Orchestrator} from './types.js'; */ diff --git a/packages/orchestration/src/proposals/orchestration-proposal.js b/packages/orchestration/src/proposals/orchestration-proposal.js index a8a3de2f976..1f38c512f0c 100644 --- a/packages/orchestration/src/proposals/orchestration-proposal.js +++ b/packages/orchestration/src/proposals/orchestration-proposal.js @@ -9,7 +9,6 @@ const trace = makeTracer('CoreEvalOrchestration', true); /** * @import {PortAllocator} from '@agoric/network'; - * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js' */ /** diff --git a/packages/orchestration/src/utils/start-helper.js b/packages/orchestration/src/utils/start-helper.js index acdf5e41c08..3348211b297 100644 --- a/packages/orchestration/src/utils/start-helper.js +++ b/packages/orchestration/src/utils/start-helper.js @@ -20,7 +20,7 @@ import { makeZoeTools } from './zoe-tools.js'; * @import {NameHub} from '@agoric/vats'; * @import {Remote} from '@agoric/vow'; * @import {Zone} from '@agoric/zone'; - * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js'; + * @import {CosmosInterchainService} from '../types.js'; */ /** From f924f606b1ac8cdc6cd5cc4657133f4ebf355dd6 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Jul 2024 16:30:32 -0400 Subject: [PATCH 3/5] feat(types): Exo kind as Interface --- packages/orchestration/src/exos/cosmos-interchain-service.js | 1 - packages/orchestration/src/types.ts | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/orchestration/src/exos/cosmos-interchain-service.js b/packages/orchestration/src/exos/cosmos-interchain-service.js index 82acebd8f13..bb649be0814 100644 --- a/packages/orchestration/src/exos/cosmos-interchain-service.js +++ b/packages/orchestration/src/exos/cosmos-interchain-service.js @@ -259,4 +259,3 @@ export const prepareCosmosInterchainService = (zone, vowTools) => { harden(prepareCosmosInterchainService); /** @typedef {ReturnType} MakeCosmosInterchainService */ -/** @typedef {ReturnType} CosmosInterchainService */ diff --git a/packages/orchestration/src/types.ts b/packages/orchestration/src/types.ts index 9297dee237e..d6df78c14f1 100644 --- a/packages/orchestration/src/types.ts +++ b/packages/orchestration/src/types.ts @@ -1,5 +1,7 @@ /** @file Rollup of all type definitions in the package, for local import and external export */ +import type { MakeCosmosInterchainService } from './exos/cosmos-interchain-service.js'; + export type * from './chain-info.js'; export type * from './cosmos-api.js'; export type * from './ethereum-api.js'; @@ -9,3 +11,6 @@ export type * from './orchestration-api.js'; export type * from './exos/cosmos-interchain-service.js'; export type * from './exos/chain-hub.js'; export type * from './vat-orchestration.js'; + +/** @interface */ +export type CosmosInterchainService = ReturnType; From 3417099e2631a660d11359d8eb2a7103022b6a55 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Jul 2024 16:40:12 -0400 Subject: [PATCH 4/5] chore(types): dedupe OrchestrationPowers --- .../src/examples/auto-stake-it.contract.js | 12 +----------- .../src/examples/sendAnywhere.contract.js | 12 +----------- .../src/exos/cosmos-interchain-service.js | 17 ++++++++++------- packages/orchestration/src/vat-orchestration.js | 4 ++-- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/packages/orchestration/src/examples/auto-stake-it.contract.js b/packages/orchestration/src/examples/auto-stake-it.contract.js index 3cf05d4485c..3d84434b76f 100644 --- a/packages/orchestration/src/examples/auto-stake-it.contract.js +++ b/packages/orchestration/src/examples/auto-stake-it.contract.js @@ -16,17 +16,7 @@ import * as flows from './auto-stake-it.flows.js'; * @import {Remote} from '@agoric/vow'; * @import {Zone} from '@agoric/zone'; * @import {CosmosInterchainService} from '@agoric/orchestration'; - * @import {OrchestrationTools} from '../utils/start-helper.js'; - */ - -/** - * @typedef {{ - * localchain: Remote; - * orchestrationService: Remote; - * storageNode: Remote; - * timerService: Remote; - * agoricNames: Remote; - * }} OrchestrationPowers + * @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js'; */ /** diff --git a/packages/orchestration/src/examples/sendAnywhere.contract.js b/packages/orchestration/src/examples/sendAnywhere.contract.js index e8123fe7c31..9f79022264d 100644 --- a/packages/orchestration/src/examples/sendAnywhere.contract.js +++ b/packages/orchestration/src/examples/sendAnywhere.contract.js @@ -16,17 +16,7 @@ import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js'; * @import {Zone} from '@agoric/zone'; * @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js'; * @import {CosmosInterchainService} from '../types.js'; - * @import {OrchestrationTools} from '../utils/start-helper.js'; - */ - -/** - * @typedef {{ - * localchain: Remote; - * orchestrationService: Remote; - * storageNode: Remote; - * timerService: Remote; - * agoricNames: Remote; - * }} OrchestrationPowers + * @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js'; */ export const SingleAmountRecord = M.and( diff --git a/packages/orchestration/src/exos/cosmos-interchain-service.js b/packages/orchestration/src/exos/cosmos-interchain-service.js index bb649be0814..f76412201c1 100644 --- a/packages/orchestration/src/exos/cosmos-interchain-service.js +++ b/packages/orchestration/src/exos/cosmos-interchain-service.js @@ -23,7 +23,7 @@ import { const { Vow$ } = NetworkShape; // TODO #9611 /** - * @typedef {object} OrchestrationPowers + * @typedef {object} CosmosInterchainPowers * @property {Remote} portAllocator */ @@ -33,8 +33,8 @@ const { Vow$ } = NetworkShape; // TODO #9611 * state migrations. * * @typedef {MapStore< - * keyof OrchestrationPowers, - * OrchestrationPowers[keyof OrchestrationPowers] + * keyof CosmosInterchainPowers, + * CosmosInterchainPowers[keyof CosmosInterchainPowers] * >} PowerStore */ @@ -43,13 +43,13 @@ const { Vow$ } = NetworkShape; // TODO #9611 /** @typedef {ChainAccountKit | ICQConnectionKit} ConnectionKit */ /** - * @template {keyof OrchestrationPowers} K + * @template {keyof CosmosInterchainPowers} K * @param {PowerStore} powers * @param {K} name */ const getPower = (powers, name) => { powers.has(name) || Fail`need powers.${b(name)} for this method`; - return /** @type {OrchestrationPowers[K]} */ (powers.get(name)); + return /** @type {CosmosInterchainPowers[K]} */ (powers.get(name)); }; /** @typedef {{ powers: PowerStore; icqConnections: ICQConnectionStore }} OrchestrationState */ @@ -101,13 +101,16 @@ const prepareCosmosOrchestrationServiceKit = ( ), }), }, - /** @param {Partial} [initialPowers] */ + /** @param {Partial} [initialPowers] */ initialPowers => { /** @type {PowerStore} */ const powers = zone.detached().mapStore('PowerStore'); if (initialPowers) { for (const [name, power] of Object.entries(initialPowers)) { - powers.init(/** @type {keyof OrchestrationPowers} */ (name), power); + powers.init( + /** @type {keyof CosmosInterchainPowers} */ (name), + power, + ); } } const icqConnections = zone.detached().mapStore('ICQConnections'); diff --git a/packages/orchestration/src/vat-orchestration.js b/packages/orchestration/src/vat-orchestration.js index 357ecb24eb4..e7ab2c564f8 100644 --- a/packages/orchestration/src/vat-orchestration.js +++ b/packages/orchestration/src/vat-orchestration.js @@ -3,7 +3,7 @@ import { prepareSwingsetVowTools } from '@agoric/vow/vat.js'; import { makeDurableZone } from '@agoric/zone/durable.js'; import { prepareCosmosInterchainService } from './exos/cosmos-interchain-service.js'; -/** @import {OrchestrationPowers} from './exos/cosmos-interchain-service.js' */ +/** @import {CosmosInterchainPowers} from './exos/cosmos-interchain-service.js' */ export const buildRootObject = (_vatPowers, _args, baggage) => { const zone = makeDurableZone(baggage); @@ -14,7 +14,7 @@ export const buildRootObject = (_vatPowers, _args, baggage) => { ); return Far('OrchestrationVat', { - /** @param {Partial} [initialPowers] */ + /** @param {Partial} [initialPowers] */ makeCosmosInterchainService(initialPowers = {}) { return makeCosmosInterchainService(initialPowers); }, From d343ba153be9bee9c65bfcda8b81723e2fb71aaf Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 30 Jul 2024 16:42:09 -0400 Subject: [PATCH 5/5] chore(types): import from orchestration package --- packages/orchestration/src/examples/auto-stake-it.contract.js | 3 +-- packages/orchestration/src/examples/basic-flows.contract.js | 3 +-- packages/orchestration/src/examples/basic-flows.flows.js | 3 --- packages/orchestration/src/examples/sendAnywhere.contract.js | 3 +-- packages/orchestration/src/examples/swapExample.contract.js | 2 +- packages/orchestration/src/examples/unbondExample.contract.js | 2 +- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/orchestration/src/examples/auto-stake-it.contract.js b/packages/orchestration/src/examples/auto-stake-it.contract.js index 3d84434b76f..b026cc61544 100644 --- a/packages/orchestration/src/examples/auto-stake-it.contract.js +++ b/packages/orchestration/src/examples/auto-stake-it.contract.js @@ -15,8 +15,7 @@ import * as flows from './auto-stake-it.flows.js'; * @import {NameHub} from '@agoric/vats'; * @import {Remote} from '@agoric/vow'; * @import {Zone} from '@agoric/zone'; - * @import {CosmosInterchainService} from '@agoric/orchestration'; - * @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js'; + * @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration'; */ /** diff --git a/packages/orchestration/src/examples/basic-flows.contract.js b/packages/orchestration/src/examples/basic-flows.contract.js index a430dc240c7..0472ad49f15 100644 --- a/packages/orchestration/src/examples/basic-flows.contract.js +++ b/packages/orchestration/src/examples/basic-flows.contract.js @@ -10,8 +10,7 @@ import * as flows from './basic-flows.flows.js'; /** * @import {Zone} from '@agoric/zone'; - * @import {OrchestrationPowers} from '../utils/start-helper.js'; - * @import {OrchestrationTools} from '../utils/start-helper.js'; + * @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration'; */ /** diff --git a/packages/orchestration/src/examples/basic-flows.flows.js b/packages/orchestration/src/examples/basic-flows.flows.js index d735e44d1e4..7bd31eb788c 100644 --- a/packages/orchestration/src/examples/basic-flows.flows.js +++ b/packages/orchestration/src/examples/basic-flows.flows.js @@ -5,12 +5,9 @@ import { M, mustMatch } from '@endo/patterns'; /** - * @import {Zone} from '@agoric/zone'; * @import {OrchestrationAccount, OrchestrationFlow, Orchestrator} from '@agoric/orchestration'; * @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js'; - * @import {OrchestrationPowers} from '../utils/start-helper.js'; * @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js'; - * @import {OrchestrationTools} from '../utils/start-helper.js'; */ /** diff --git a/packages/orchestration/src/examples/sendAnywhere.contract.js b/packages/orchestration/src/examples/sendAnywhere.contract.js index 9f79022264d..da0266e9117 100644 --- a/packages/orchestration/src/examples/sendAnywhere.contract.js +++ b/packages/orchestration/src/examples/sendAnywhere.contract.js @@ -15,8 +15,7 @@ import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js'; * @import {Remote, Vow} from '@agoric/vow'; * @import {Zone} from '@agoric/zone'; * @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js'; - * @import {CosmosInterchainService} from '../types.js'; - * @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js'; + * @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration'; */ export const SingleAmountRecord = M.and( diff --git a/packages/orchestration/src/examples/swapExample.contract.js b/packages/orchestration/src/examples/swapExample.contract.js index f83772eb15d..d1f376a598a 100644 --- a/packages/orchestration/src/examples/swapExample.contract.js +++ b/packages/orchestration/src/examples/swapExample.contract.js @@ -13,7 +13,7 @@ import { withOrchestration } from '../utils/start-helper.js'; * @import {CosmosInterchainService} from '../types.js'; * @import {NameHub} from '@agoric/vats'; * @import {Zone} from '@agoric/zone'; - * @import {OrchestrationTools} from '../utils/start-helper.js'; + * @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration'; */ /** diff --git a/packages/orchestration/src/examples/unbondExample.contract.js b/packages/orchestration/src/examples/unbondExample.contract.js index db715408015..6559b7ac6b3 100644 --- a/packages/orchestration/src/examples/unbondExample.contract.js +++ b/packages/orchestration/src/examples/unbondExample.contract.js @@ -2,6 +2,7 @@ import { M } from '@endo/patterns'; import { withOrchestration } from '../utils/start-helper.js'; /** + * @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration'; * @import {Orchestrator, OrchestrationFlow} from '../types.js' * @import {TimerService} from '@agoric/time'; * @import {LocalChain} from '@agoric/vats/src/localchain.js'; @@ -9,7 +10,6 @@ import { withOrchestration } from '../utils/start-helper.js'; * @import {Remote} from '@agoric/internal'; * @import {Zone} from '@agoric/zone'; * @import {CosmosInterchainService} from '../types.js'; - * @import {OrchestrationTools} from '../utils/start-helper.js'; */ /**