diff --git a/packages/boot/test/bootstrapTests/vat-orchestration.test.ts b/packages/boot/test/bootstrapTests/vat-orchestration.test.ts
index fed0336a3c9..da8ba3187a3 100644
--- a/packages/boot/test/bootstrapTests/vat-orchestration.test.ts
+++ b/packages/boot/test/bootstrapTests/vat-orchestration.test.ts
@@ -11,7 +11,7 @@ import {
MsgDelegate,
MsgDelegateResponse,
} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js';
-import type { OrchestrationService } from '@agoric/orchestration';
+import type { CosmosInterchainService } from '@agoric/orchestration';
import { decodeBase64 } from '@endo/base64';
import { M, matches } from '@endo/patterns';
import {
@@ -187,7 +187,7 @@ test.skip('Query connection can be created', async t => {
runUtils: { EV },
} = t.context;
- type Powers = { orchestration: OrchestrationService };
+ type Powers = { orchestration: CosmosInterchainService };
const contract = async ({ orchestration }) => {
const connection =
await EV(orchestration).provideICQConnection('connection-0');
@@ -201,7 +201,7 @@ test.skip('Query connection can be created', async t => {
// core eval context
{
- const orchestration: OrchestrationService =
+ const orchestration: CosmosInterchainService =
await EV.vat('bootstrap').consumeItem('orchestration');
await contract({ orchestration });
}
@@ -213,7 +213,7 @@ test.skip('Query connection can send a query', async t => {
runUtils: { EV },
} = t.context;
- type Powers = { orchestration: OrchestrationService };
+ type Powers = { orchestration: CosmosInterchainService };
const contract = async ({ orchestration }) => {
const queryConnection =
await EV(orchestration).provideICQConnection('connection-0');
@@ -255,7 +255,7 @@ test.skip('Query connection can send a query', async t => {
// core eval context
{
- const orchestration: OrchestrationService =
+ const orchestration: CosmosInterchainService =
await EV.vat('bootstrap').consumeItem('orchestration');
await contract({ orchestration });
}
diff --git a/packages/orchestration/index.js b/packages/orchestration/index.js
index c5ba4292ecb..09afecb813d 100644
--- a/packages/orchestration/index.js
+++ b/packages/orchestration/index.js
@@ -3,5 +3,5 @@
///
export * from './src/types.js';
-export * from './src/service.js';
+export * from './src/exos/cosmos-interchain-service.js';
export * from './src/typeGuards.js';
diff --git a/packages/orchestration/src/examples/sendAnywhere.contract.js b/packages/orchestration/src/examples/sendAnywhere.contract.js
index ef0dfd7e6f9..ac8cde3b6f0 100644
--- a/packages/orchestration/src/examples/sendAnywhere.contract.js
+++ b/packages/orchestration/src/examples/sendAnywhere.contract.js
@@ -1,32 +1,33 @@
+import { makeStateRecord } from '@agoric/async-flow';
+import { AmountShape } from '@agoric/ertp';
+import { heapVowE } from '@agoric/vow/vat.js';
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
-import { M, mustMatch } from '@endo/patterns';
import { E } from '@endo/far';
-import { heapVowE } from '@agoric/vow/vat.js';
-import { makeStateRecord } from '@agoric/async-flow';
-import { AmountShape } from '@agoric/ertp';
-import { CosmosChainInfoShape } from '../typeGuards.js';
-import { provideOrchestration } from '../utils/start-helper.js';
+import { M, mustMatch } from '@endo/patterns';
import { makeResumableAgoricNamesHack } from '../exos/agoric-names-tools.js';
+import { CosmosChainInfoShape } from '../typeGuards.js';
+import { withOrchestration } from '../utils/start-helper.js';
const { entries } = Object;
/**
- * @import {Baggage} from '@agoric/vat-data';
* @import {TimerService} from '@agoric/time';
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
* @import {NameHub} from '@agoric/vats';
* @import {Remote} from '@agoric/vow';
+ * @import {Zone} from '@agoric/zone';
* @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
- * @import {OrchestrationService} from '../service.js';
+ * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
* @import {Orchestrator} from '../types.js'
+ * @import {OrchestrationTools} from '../utils/start-helper.js';
* @import {OrchestrationAccount} from '../orchestration-api.js'
*/
/**
* @typedef {{
* localchain: Remote;
- * orchestrationService: Remote;
+ * orchestrationService: Remote;
* storageNode: Remote;
* timerService: Remote;
* agoricNames: Remote;
@@ -89,19 +90,21 @@ export const SingleAmountRecord = M.and(
);
/**
+ * Orchestration contract to be wrapped by withOrchestration for Zoe
+ *
* @param {ZCF} zcf
* @param {OrchestrationPowers & {
* marshaller: Marshaller;
* }} privateArgs
- * @param {Baggage} baggage
+ * @param {Zone} zone
+ * @param {OrchestrationTools} tools
*/
-export const start = async (zcf, privateArgs, baggage) => {
- const { chainHub, orchestrate, vowTools, zone } = provideOrchestration(
- zcf,
- baggage,
- privateArgs,
- privateArgs.marshaller,
- );
+const contract = async (
+ zcf,
+ privateArgs,
+ zone,
+ { chainHub, orchestrate, vowTools },
+) => {
const agoricNamesTools = makeResumableAgoricNamesHack(zone, {
agoricNames: privateArgs.agoricNames,
vowTools,
@@ -171,3 +174,5 @@ export const start = async (zcf, privateArgs, baggage) => {
return { publicFacet, creatorFacet };
};
+
+export const start = withOrchestration(contract);
diff --git a/packages/orchestration/src/examples/stakeIca.contract.js b/packages/orchestration/src/examples/stakeIca.contract.js
index 846326b1bae..e40485d93ae 100644
--- a/packages/orchestration/src/examples/stakeIca.contract.js
+++ b/packages/orchestration/src/examples/stakeIca.contract.js
@@ -17,7 +17,7 @@ const trace = makeTracer('StakeIca');
* @import {Baggage} from '@agoric/vat-data';
* @import {IBCConnectionID} from '@agoric/vats';
* @import {TimerService} from '@agoric/time';
- * @import {ICQConnection, OrchestrationService} from '../types.js';
+ * @import {ICQConnection, CosmosInterchainService} from '../types.js';
*/
/** @type {ContractMeta} */
@@ -30,7 +30,7 @@ export const meta = harden({
icqEnabled: M.boolean(),
},
privateArgsShape: {
- orchestration: M.remotable('orchestration'),
+ cosmosInterchainService: M.remotable('cosmosInterchainService'),
storageNode: StorageNodeShape,
marshaller: M.remotable('marshaller'),
timer: TimerServiceShape,
@@ -51,7 +51,7 @@ export const privateArgsShape = meta.privateArgsShape;
/**
* @param {ZCF} zcf
* @param {{
- * orchestration: OrchestrationService;
+ * cosmosInterchainService: CosmosInterchainService;
* storageNode: StorageNode;
* marshaller: Marshaller;
* timer: TimerService;
@@ -66,7 +66,12 @@ export const start = async (zcf, privateArgs, baggage) => {
bondDenom,
icqEnabled,
} = zcf.getTerms();
- const { orchestration, marshaller, storageNode, timer } = privateArgs;
+ const {
+ cosmosInterchainService: orchestration,
+ marshaller,
+ storageNode,
+ timer,
+ } = privateArgs;
const zone = makeDurableZone(baggage);
diff --git a/packages/orchestration/src/examples/swapExample.contract.js b/packages/orchestration/src/examples/swapExample.contract.js
index d822cece896..eb3a93da608 100644
--- a/packages/orchestration/src/examples/swapExample.contract.js
+++ b/packages/orchestration/src/examples/swapExample.contract.js
@@ -1,20 +1,20 @@
import { StorageNodeShape } from '@agoric/internal';
import { TimerServiceShape } from '@agoric/time';
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
-import { Far } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { M, objectMap } from '@endo/patterns';
import { orcUtils } from '../utils/orc.js';
-import { provideOrchestration } from '../utils/start-helper.js';
+import { withOrchestration } from '../utils/start-helper.js';
/**
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
* @import {TimerService} from '@agoric/time';
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
* @import {Remote} from '@agoric/internal';
- * @import {OrchestrationService} from '../service.js';
- * @import {Baggage} from '@agoric/vat-data'
+ * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
* @import {NameHub} from '@agoric/vats';
+ * @import {Zone} from '@agoric/zone';
+ * @import {OrchestrationTools} from '../utils/start-helper.js';
*/
/**
@@ -90,40 +90,21 @@ export const makeNatAmountShape = (brand, min) =>
harden({ brand, value: min ? M.gte(min) : M.nat() });
/**
+ * Orchestration contract to be wrapped by withOrchestration for Zoe
+ *
* @param {ZCF} zcf
* @param {{
* agoricNames: Remote;
* localchain: Remote;
- * orchestrationService: Remote;
+ * orchestrationService: Remote;
* storageNode: Remote;
* timerService: Remote;
* marshaller: Marshaller;
* }} privateArgs
- * @param {Baggage} baggage
+ * @param {Zone} zone
+ * @param {OrchestrationTools} tools
*/
-export const start = async (zcf, privateArgs, baggage) => {
- const {
- agoricNames,
- localchain,
- orchestrationService,
- storageNode,
- timerService,
- marshaller,
- } = privateArgs;
-
- const { orchestrate } = provideOrchestration(
- zcf,
- baggage,
- {
- agoricNames,
- localchain,
- orchestrationService,
- storageNode,
- timerService,
- },
- marshaller,
- );
-
+const contract = async (zcf, privateArgs, zone, { orchestrate }) => {
const { brands } = zcf.getTerms();
/** deprecated historical example */
@@ -135,21 +116,22 @@ export const start = async (zcf, privateArgs, baggage) => {
*/
const swapAndStakeHandler = orchestrate('LSTTia', { zcf }, stackAndSwapFn);
- const makeSwapAndStakeInvitation = () =>
- zcf.makeInvitation(
- swapAndStakeHandler,
- 'Swap for TIA and stake',
- undefined,
- harden({
- give: { Stable: makeNatAmountShape(brands.Stable, 1n) },
- want: {}, // XXX ChainAccount Ownable?
- exit: M.any(),
- }),
- );
-
- const publicFacet = Far('SwapAndStake Public Facet', {
- makeSwapAndStakeInvitation,
+ const publicFacet = zone.exo('publicFacet', undefined, {
+ makeSwapAndStakeInvitation() {
+ return zcf.makeInvitation(
+ swapAndStakeHandler,
+ 'Swap for TIA and stake',
+ undefined,
+ harden({
+ give: { Stable: makeNatAmountShape(brands.Stable, 1n) },
+ want: {}, // XXX ChainAccount Ownable?
+ exit: M.any(),
+ }),
+ );
+ },
});
return harden({ publicFacet });
};
+
+export const start = withOrchestration(contract);
diff --git a/packages/orchestration/src/examples/unbondExample.contract.js b/packages/orchestration/src/examples/unbondExample.contract.js
index d403b53489c..0b0beac9bf3 100644
--- a/packages/orchestration/src/examples/unbondExample.contract.js
+++ b/packages/orchestration/src/examples/unbondExample.contract.js
@@ -1,6 +1,5 @@
-import { Far } from '@endo/far';
import { M } from '@endo/patterns';
-import { provideOrchestration } from '../utils/start-helper.js';
+import { withOrchestration } from '../utils/start-helper.js';
/**
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
@@ -9,7 +8,9 @@ import { provideOrchestration } from '../utils/start-helper.js';
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
* @import {NameHub} from '@agoric/vats';
* @import {Remote} from '@agoric/internal';
- * @import {OrchestrationService} from '../service.js';
+ * @import {Zone} from '@agoric/zone';
+ * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
+ * @import {OrchestrationTools} from '../utils/start-helper.js';
*/
/**
@@ -43,40 +44,21 @@ const unbondAndLiquidStakeFn = async (orch, { zcf }, _seat, _offerArgs) => {
};
/**
+ * Orchestration contract to be wrapped by withOrchestration for Zoe
+ *
* @param {ZCF} zcf
* @param {{
* agoricNames: Remote;
* localchain: Remote;
- * orchestrationService: Remote;
+ * orchestrationService: Remote;
* storageNode: Remote;
* marshaller: Marshaller;
* timerService: Remote;
* }} privateArgs
- * @param {Baggage} baggage
+ * @param {Zone} zone
+ * @param {OrchestrationTools} tools
*/
-export const start = async (zcf, privateArgs, baggage) => {
- const {
- agoricNames,
- localchain,
- orchestrationService,
- storageNode,
- marshaller,
- timerService,
- } = privateArgs;
-
- const { orchestrate } = provideOrchestration(
- zcf,
- baggage,
- {
- agoricNames,
- localchain,
- orchestrationService,
- storageNode,
- timerService,
- },
- marshaller,
- );
-
+const contract = async (zcf, privateArgs, zone, { orchestrate }) => {
/** @type {OfferHandler} */
const unbondAndLiquidStake = orchestrate(
'LSTTia',
@@ -84,22 +66,23 @@ export const start = async (zcf, privateArgs, baggage) => {
unbondAndLiquidStakeFn,
);
- const makeUnbondAndLiquidStakeInvitation = () =>
- zcf.makeInvitation(
- unbondAndLiquidStake,
- 'Unbond and liquid stake',
- undefined,
- harden({
- // Nothing to give; the funds come from undelegating
- give: {},
- want: {}, // XXX ChainAccount Ownable?
- exit: M.any(),
- }),
- );
-
- const publicFacet = Far('SwapAndStake Public Facet', {
- makeUnbondAndLiquidStakeInvitation,
+ const publicFacet = zone.exo('publicFacet', undefined, {
+ makeUnbondAndLiquidStakeInvitation() {
+ return zcf.makeInvitation(
+ unbondAndLiquidStake,
+ 'Unbond and liquid stake',
+ undefined,
+ harden({
+ // Nothing to give; the funds come from undelegating
+ give: {},
+ want: {}, // XXX ChainAccount Ownable?
+ exit: M.any(),
+ }),
+ );
+ },
});
return harden({ publicFacet });
};
+
+export const start = withOrchestration(contract);
diff --git a/packages/orchestration/src/service.js b/packages/orchestration/src/exos/cosmos-interchain-service.js
similarity index 90%
rename from packages/orchestration/src/service.js
rename to packages/orchestration/src/exos/cosmos-interchain-service.js
index 93cbf1ab7ce..82acebd8f13 100644
--- a/packages/orchestration/src/service.js
+++ b/packages/orchestration/src/exos/cosmos-interchain-service.js
@@ -4,12 +4,12 @@ import { Fail, b } from '@endo/errors';
import { E } from '@endo/far';
import { M } from '@endo/patterns';
import { Shape as NetworkShape } from '@agoric/network';
-import { prepareChainAccountKit } from './exos/chain-account-kit.js';
-import { prepareICQConnectionKit } from './exos/icq-connection-kit.js';
+import { prepareChainAccountKit } from './chain-account-kit.js';
+import { prepareICQConnectionKit } from './icq-connection-kit.js';
import {
makeICAChannelAddress,
makeICQChannelAddress,
-} from './utils/address.js';
+} from '../utils/address.js';
/**
* @import {Zone} from '@agoric/base-zone';
@@ -18,7 +18,7 @@ import {
* @import {IBCConnectionID} from '@agoric/vats';
* @import {RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
* @import {Vow, VowTools} from '@agoric/vow';
- * @import {ICQConnection, IcaAccount, ICQConnectionKit, ChainAccountKit} from './types.js';
+ * @import {ICQConnection, IcaAccount, ICQConnectionKit, ChainAccountKit} from '../types.js';
*/
const { Vow$ } = NetworkShape; // TODO #9611
@@ -60,7 +60,7 @@ const getPower = (powers, name) => {
* @param {ReturnType} makeChainAccountKit
* @param {ReturnType} makeICQConnectionKit
*/
-const prepareOrchestrationKit = (
+const prepareCosmosOrchestrationServiceKit = (
zone,
{ watch },
makeChainAccountKit,
@@ -92,7 +92,7 @@ const prepareOrchestrationKit = (
)
.returns(M.remotable('ConnectionKit Holder facet')),
}),
- public: M.interface('OrchestrationService', {
+ public: M.interface('CosmosInterchainService', {
makeAccount: M.call(M.string(), M.string(), M.string()).returns(
Vow$(M.remotable('ChainAccountKit')),
),
@@ -240,20 +240,23 @@ const prepareOrchestrationKit = (
* @param {Zone} zone
* @param {VowTools} vowTools
*/
-export const prepareOrchestrationTools = (zone, vowTools) => {
+export const prepareCosmosInterchainService = (zone, vowTools) => {
const makeChainAccountKit = prepareChainAccountKit(zone, vowTools);
const makeICQConnectionKit = prepareICQConnectionKit(zone, vowTools);
- const makeOrchestrationKit = prepareOrchestrationKit(
- zone,
- vowTools,
- makeChainAccountKit,
- makeICQConnectionKit,
- );
+ const makeCosmosOrchestrationServiceKit =
+ prepareCosmosOrchestrationServiceKit(
+ zone,
+ vowTools,
+ makeChainAccountKit,
+ makeICQConnectionKit,
+ );
+
+ const makeCosmosInterchainService = initialPowers =>
+ makeCosmosOrchestrationServiceKit(initialPowers).public;
- return harden({ makeOrchestrationKit });
+ return makeCosmosInterchainService;
};
-harden(prepareOrchestrationTools);
+harden(prepareCosmosInterchainService);
-/** @typedef {ReturnType} OrchestrationTools */
-/** @typedef {ReturnType} OrchestrationKit */
-/** @typedef {OrchestrationKit['public']} OrchestrationService */
+/** @typedef {ReturnType} MakeCosmosInterchainService */
+/** @typedef {ReturnType} CosmosInterchainService */
diff --git a/packages/orchestration/src/exos/local-chain-facade.js b/packages/orchestration/src/exos/local-chain-facade.js
index 251551a7cbe..ddada8f15f4 100644
--- a/packages/orchestration/src/exos/local-chain-facade.js
+++ b/packages/orchestration/src/exos/local-chain-facade.js
@@ -11,7 +11,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 {OrchestrationService} from '../service.js';
+ * @import {CosmosInterchainService} from './cosmos-interchain-service.js';
* @import {MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js';
* @import {ChainAddress, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, PromiseToVow} from '../types.js';
*/
@@ -19,7 +19,7 @@ import { ChainFacadeI } from '../typeGuards.js';
/**
* @typedef {{
* makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
- * orchestration: Remote;
+ * orchestration: Remote;
* storageNode: Remote;
* timer: Remote;
* localchain: Remote;
diff --git a/packages/orchestration/src/exos/orchestrator.js b/packages/orchestration/src/exos/orchestrator.js
index 8703f6aaf04..97fca59363d 100644
--- a/packages/orchestration/src/exos/orchestrator.js
+++ b/packages/orchestration/src/exos/orchestrator.js
@@ -22,7 +22,7 @@ import {
* @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
* @import {Remote} from '@agoric/internal';
* @import {PickFacet} from '@agoric/swingset-liveslots';
- * @import {OrchestrationService} from '../service.js';
+ * @import {CosmosInterchainService} from './cosmos-interchain-service.js';
* @import {MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js';
* @import {MakeLocalChainFacade} from './local-chain-facade.js';
* @import {MakeRemoteChainFacade} from './remote-chain-facade.js';
@@ -50,7 +50,7 @@ export const OrchestratorI = M.interface('Orchestrator', {
* makeRecorderKit: MakeRecorderKit;
* makeLocalChainFacade: MakeLocalChainFacade;
* makeRemoteChainFacade: MakeRemoteChainFacade;
- * orchestrationService: Remote;
+ * orchestrationService: Remote;
* storageNode: Remote;
* timerService: Remote;
* vowTools: VowTools;
diff --git a/packages/orchestration/src/exos/remote-chain-facade.js b/packages/orchestration/src/exos/remote-chain-facade.js
index a88d903d60c..3b87240c39d 100644
--- a/packages/orchestration/src/exos/remote-chain-facade.js
+++ b/packages/orchestration/src/exos/remote-chain-facade.js
@@ -11,7 +11,7 @@ import { ChainFacadeI } from '../typeGuards.js';
* @import {TimerService} from '@agoric/time';
* @import {Remote} from '@agoric/internal';
* @import {Vow, VowTools} from '@agoric/vow';
- * @import {OrchestrationService} from '../service.js';
+ * @import {CosmosInterchainService} from './cosmos-interchain-service.js';
* @import {prepareCosmosOrchestrationAccount} from './cosmos-orchestration-account.js';
* @import {ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, ChainAddress, IcaAccount, PromiseToVow, Denom} from '../types.js';
*/
@@ -27,7 +27,7 @@ const anyVal = null;
* makeCosmosOrchestrationAccount: ReturnType<
* typeof prepareCosmosOrchestrationAccount
* >;
- * orchestration: Remote;
+ * orchestration: Remote;
* storageNode: Remote;
* timer: Remote;
* vowTools: VowTools;
diff --git a/packages/orchestration/src/facade.js b/packages/orchestration/src/facade.js
index 53cdd699f00..f9cb821140c 100644
--- a/packages/orchestration/src/facade.js
+++ b/packages/orchestration/src/facade.js
@@ -13,7 +13,7 @@ import { prepareOrchestratorKit } from './exos/orchestrator.js';
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
* @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
* @import {Remote} from '@agoric/internal';
- * @import {OrchestrationService} from './service.js';
+ * @import {CosmosInterchainService} from './exos/cosmos-interchain-service.js';
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator} from './types.js';
* @import {MakeLocalChainFacade} from './exos/local-chain-facade.js';
* @import {MakeRemoteChainFacade} from './exos/remote-chain-facade.js';
@@ -26,7 +26,7 @@ import { prepareOrchestratorKit } from './exos/orchestrator.js';
* timerService: Remote;
* zcf: ZCF;
* storageNode: Remote;
- * orchestrationService: Remote;
+ * orchestrationService: Remote;
* localchain: Remote;
* chainHub: import('./exos/chain-hub.js').ChainHub;
* makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
diff --git a/packages/orchestration/src/proposals/orchestration-proposal.js b/packages/orchestration/src/proposals/orchestration-proposal.js
index 815e3bc7aad..8094b830ddb 100644
--- a/packages/orchestration/src/proposals/orchestration-proposal.js
+++ b/packages/orchestration/src/proposals/orchestration-proposal.js
@@ -9,8 +9,7 @@ const trace = makeTracer('CoreEvalOrchestration', true);
/**
* @import {PortAllocator} from '@agoric/network';
- * @import {OrchestrationService} from '../service.js'
- * @import {OrchestrationVat} from '../vat-orchestration.js'
+ * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js'
*/
/**
@@ -19,8 +18,6 @@ const trace = makeTracer('CoreEvalOrchestration', true);
* portAllocator: PortAllocator;
* };
* produce: {
- * orchestration: Producer;
- * orchestrationKit: Producer;
* orchestrationVat: Producer;
* };
* }} powers
@@ -29,11 +26,7 @@ const trace = makeTracer('CoreEvalOrchestration', true);
export const setupOrchestrationVat = async (
{
consume: { loadCriticalVat, portAllocator: portAllocatorP },
- produce: {
- orchestrationVat,
- orchestration,
- orchestrationKit: orchestrationKitP,
- },
+ produce: { orchestrationVat, ...produce },
},
options,
) => {
@@ -49,14 +42,14 @@ export const setupOrchestrationVat = async (
const portAllocator = await portAllocatorP;
- const newOrchestrationKit = await E(vats.orchestration).makeOrchestrationKit({
+ const cosmosInterchainService = await E(
+ vats.orchestration,
+ ).makeCosmosInterchainService({
portAllocator,
});
- orchestration.reset();
- orchestration.resolve(newOrchestrationKit.public);
- orchestrationKitP.reset();
- orchestrationKitP.resolve(newOrchestrationKit);
+ produce.cosmosInterchainService.reset();
+ produce.cosmosInterchainService.resolve(cosmosInterchainService);
};
/**
@@ -138,21 +131,6 @@ export const initChainInfo = async ({
};
harden(initChainInfo);
-/**
- * @param {BootstrapPowers & {
- * consume: {
- * orchestration: OrchestrationService;
- * };
- * }} powers
- * @param {object} _options
- */
-export const addOrchestrationToClient = async (
- { consume: { client, orchestration } },
- _options,
-) => {
- return E(client).assignBundle([_a => ({ orchestration })]);
-};
-
export const getManifestForOrchestration = (_powers, { orchestrationRef }) => ({
manifest: {
[setupOrchestrationVat.name]: {
@@ -161,8 +139,7 @@ export const getManifestForOrchestration = (_powers, { orchestrationRef }) => ({
portAllocator: 'portAllocator',
},
produce: {
- orchestration: 'orchestration',
- orchestrationKit: 'orchestrationKit',
+ cosmosInterchainService: 'cosmosInterchainService',
orchestrationVat: 'orchestrationVat',
},
},
diff --git a/packages/orchestration/src/proposals/start-stakeAtom.js b/packages/orchestration/src/proposals/start-stakeAtom.js
index ee63de7c612..96bc316e5c5 100644
--- a/packages/orchestration/src/proposals/start-stakeAtom.js
+++ b/packages/orchestration/src/proposals/start-stakeAtom.js
@@ -29,7 +29,7 @@ export const startStakeAtom = async ({
board,
chainStorage,
chainTimerService,
- orchestration,
+ cosmosInterchainService,
startUpgradable,
},
installation: {
@@ -65,7 +65,7 @@ export const startStakeAtom = async ({
icqEnabled: cosmoshub.icqEnabled,
},
privateArgs: {
- orchestration: await orchestration,
+ cosmosInterchainService: await cosmosInterchainService,
storageNode,
marshaller,
timer: await chainTimerService,
@@ -89,7 +89,7 @@ export const getManifestForStakeAtom = (
board: true,
chainStorage: true,
chainTimerService: true,
- orchestration: true,
+ cosmosInterchainService: true,
startUpgradable: true,
},
installation: {
diff --git a/packages/orchestration/src/proposals/start-stakeOsmo.js b/packages/orchestration/src/proposals/start-stakeOsmo.js
index fc3b3118096..6fcfde82d5a 100644
--- a/packages/orchestration/src/proposals/start-stakeOsmo.js
+++ b/packages/orchestration/src/proposals/start-stakeOsmo.js
@@ -29,7 +29,7 @@ export const startStakeOsmo = async ({
board,
chainStorage,
chainTimerService,
- orchestration,
+ cosmosInterchainService,
startUpgradable,
},
installation: {
@@ -66,7 +66,7 @@ export const startStakeOsmo = async ({
icqEnabled: osmosis.icqEnabled,
},
privateArgs: {
- orchestration: await orchestration,
+ cosmosInterchainService: await cosmosInterchainService,
storageNode,
marshaller,
timer: await chainTimerService,
@@ -90,7 +90,7 @@ export const getManifestForStakeOsmo = (
board: true,
chainStorage: true,
chainTimerService: true,
- orchestration: true,
+ cosmosInterchainService: true,
startUpgradable: true,
},
installation: {
diff --git a/packages/orchestration/src/types.ts b/packages/orchestration/src/types.ts
index a9a17cc8905..6ee257b930e 100644
--- a/packages/orchestration/src/types.ts
+++ b/packages/orchestration/src/types.ts
@@ -7,5 +7,5 @@ export type * from './exos/chain-account-kit.js';
export type * from './exos/icq-connection-kit.js';
export type * from './internal.js';
export type * from './orchestration-api.js';
-export type * from './service.js';
+export type * from './exos/cosmos-interchain-service.js';
export type * from './vat-orchestration.js';
diff --git a/packages/orchestration/src/utils/start-helper.js b/packages/orchestration/src/utils/start-helper.js
index e96fedabb8f..a25de447666 100644
--- a/packages/orchestration/src/utils/start-helper.js
+++ b/packages/orchestration/src/utils/start-helper.js
@@ -16,13 +16,14 @@ import { prepareLocalChainFacade } from '../exos/local-chain-facade.js';
* @import {Baggage} from '@agoric/vat-data';
* @import {NameHub} from '@agoric/vats';
* @import {Remote} from '@agoric/vow';
- * @import {OrchestrationService} from '../service.js';
+ * @import {Zone} from '@agoric/zone';
+ * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
*/
/**
* @typedef {{
* localchain: Remote;
- * orchestrationService: Remote;
+ * orchestrationService: Remote;
* storageNode: Remote;
* timerService: Remote;
* agoricNames: Remote;
@@ -48,16 +49,27 @@ export const provideOrchestration = (
baggage,
}));
- const zone = makeDurableZone(baggage);
+ // separate zones
+ const zones = (() => {
+ const zone = makeDurableZone(baggage);
+ return {
+ asyncFlow: zone.subZone('asyncFlow'),
+ /** for contract-provided names */
+ contract: zone.subZone('contract'),
+ orchestration: zone.subZone('orchestration'),
+ vows: zone.subZone('vows'),
+ };
+ })();
+
const { agoricNames, timerService } = remotePowers;
- const vowTools = prepareVowTools(zone.subZone('vows'));
+ const vowTools = prepareVowTools(zones.vows);
const chainHub = makeChainHub(agoricNames, vowTools);
const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
- zone,
+ zones.orchestration,
makeRecorderKit,
zcf,
timerService,
@@ -65,19 +77,18 @@ export const provideOrchestration = (
chainHub,
);
- const asyncFlowTools = prepareAsyncFlowTools(zone.subZone('asyncFlow'), {
+ const asyncFlowTools = prepareAsyncFlowTools(zones.asyncFlow, {
vowTools,
});
const makeCosmosOrchestrationAccount = prepareCosmosOrchestrationAccount(
- // FIXME what zone?
- zone,
+ zones.orchestration,
makeRecorderKit,
vowTools,
zcf,
);
- const makeRemoteChainFacade = prepareRemoteChainFacade(zone, {
+ const makeRemoteChainFacade = prepareRemoteChainFacade(zones.orchestration, {
makeCosmosOrchestrationAccount,
orchestration: remotePowers.orchestrationService,
storageNode: remotePowers.storageNode,
@@ -85,7 +96,7 @@ export const provideOrchestration = (
vowTools,
});
- const makeLocalChainFacade = prepareLocalChainFacade(zone, {
+ const makeLocalChainFacade = prepareLocalChainFacade(zones.orchestration, {
makeLocalOrchestrationAccountKit,
localchain: remotePowers.localchain,
// FIXME what path?
@@ -97,7 +108,7 @@ export const provideOrchestration = (
const facade = makeOrchestrationFacade({
zcf,
- zone,
+ zone: zones.orchestration,
chainHub,
makeLocalOrchestrationAccountKit,
makeRecorderKit,
@@ -108,6 +119,38 @@ export const provideOrchestration = (
vowTools,
...remotePowers,
});
- return { ...facade, chainHub, vowTools, zone };
+ return { ...facade, chainHub, vowTools, zone: zones.contract };
};
harden(provideOrchestration);
+
+/** @typedef {Omit, 'zone'>} OrchestrationTools */
+
+/**
+ * Simplifies contract functions for Orchestration by wrapping a simpler
+ * function with all the tools it needs in order to use Orchestration.
+ *
+ * @template {Record} CT
+ * @template {OrchestrationPowers & {
+ * marshaller: Marshaller;
+ * }} PA
+ * @template R
+ * @param {(
+ * zcf: ZCF,
+ * privateArgs: PA,
+ * zone: Zone,
+ * tools: OrchestrationTools,
+ * ) => Promise} contractFn
+ * @returns {(zcf: ZCF, privateArgs: PA, baggage: Baggage) => Promise} a
+ * Zoe start function
+ */
+export const withOrchestration =
+ contractFn => async (zcf, privateArgs, baggage) => {
+ const { zone, ...tools } = provideOrchestration(
+ zcf,
+ baggage,
+ privateArgs,
+ privateArgs.marshaller,
+ );
+ return contractFn(zcf, privateArgs, zone, tools);
+ };
+harden(withOrchestration);
diff --git a/packages/orchestration/src/vat-orchestration.js b/packages/orchestration/src/vat-orchestration.js
index 8f3de0b1cc2..357ecb24eb4 100644
--- a/packages/orchestration/src/vat-orchestration.js
+++ b/packages/orchestration/src/vat-orchestration.js
@@ -1,22 +1,22 @@
import { Far } from '@endo/far';
-import { prepareVowTools } from '@agoric/vow/vat.js';
+import { prepareSwingsetVowTools } from '@agoric/vow/vat.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
-import { prepareOrchestrationTools } from './service.js';
+import { prepareCosmosInterchainService } from './exos/cosmos-interchain-service.js';
-/** @import {OrchestrationPowers} from './service.js' */
+/** @import {OrchestrationPowers} from './exos/cosmos-interchain-service.js' */
export const buildRootObject = (_vatPowers, _args, baggage) => {
const zone = makeDurableZone(baggage);
- const vowTools = prepareVowTools(zone.subZone('VowTools'));
- const { makeOrchestrationKit } = prepareOrchestrationTools(
+ const vowTools = prepareSwingsetVowTools(zone.subZone('VowTools'));
+ const makeCosmosInterchainService = prepareCosmosInterchainService(
zone.subZone('orchestration'),
vowTools,
);
return Far('OrchestrationVat', {
/** @param {Partial} [initialPowers] */
- makeOrchestrationKit(initialPowers = {}) {
- return makeOrchestrationKit(initialPowers);
+ makeCosmosInterchainService(initialPowers = {}) {
+ return makeCosmosInterchainService(initialPowers);
},
});
};
diff --git a/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.md b/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.md
index 5bee6c1c222..b26f76cdb5a 100644
--- a/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.md
+++ b/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.md
@@ -10,17 +10,7 @@ Generated by [AVA](https://avajs.dev).
{
'Durable Publish Kit_kindHandle': 'Alleged: kind',
- 'Local Orchestration Account Kit_kindHandle': 'Alleged: kind',
- LocalChainFacade_kindHandle: 'Alleged: kind',
- Orchestrator_kindHandle: 'Alleged: kind',
Recorder_kindHandle: 'Alleged: kind',
- RemoteChainFacade_kindHandle: 'Alleged: kind',
- ResumableAgoricNamesHack_kindHandle: 'Alleged: kind',
- 'Send CF_kindHandle': 'Alleged: kind',
- 'Send CF_singleton': 'Alleged: Send CF',
- 'Send PF_kindHandle': 'Alleged: kind',
- 'Send PF_singleton': 'Alleged: Send PF',
- 'Staking Account Holder_kindHandle': 'Alleged: kind',
asyncFlow: {
AdminAsyncFlow_kindHandle: 'Alleged: kind',
AdminAsyncFlow_singleton: 'Alleged: AdminAsyncFlow',
@@ -34,16 +24,30 @@ Generated by [AVA](https://avajs.dev).
flowForOutcomeVow: {},
unwrapMap: 'Alleged: weakMapStore',
},
- sendIt: {
- asyncFlow_kindHandle: 'Alleged: kind',
- endowments: {
- 1: {
- contractState_kindHandle: 'Alleged: kind',
- contractState_singleton: 'Alleged: contractState',
+ contract: {
+ ResumableAgoricNamesHack_kindHandle: 'Alleged: kind',
+ 'Send CF_kindHandle': 'Alleged: kind',
+ 'Send CF_singleton': 'Alleged: Send CF',
+ 'Send PF_kindHandle': 'Alleged: kind',
+ 'Send PF_singleton': 'Alleged: Send PF',
+ vbankAssetsByBrand: {},
+ },
+ orchestration: {
+ 'Local Orchestration Account Kit_kindHandle': 'Alleged: kind',
+ LocalChainFacade_kindHandle: 'Alleged: kind',
+ Orchestrator_kindHandle: 'Alleged: kind',
+ RemoteChainFacade_kindHandle: 'Alleged: kind',
+ 'Staking Account Holder_kindHandle': 'Alleged: kind',
+ sendIt: {
+ asyncFlow_kindHandle: 'Alleged: kind',
+ endowments: {
+ 1: {
+ contractState_kindHandle: 'Alleged: kind',
+ contractState_singleton: 'Alleged: contractState',
+ },
},
},
},
- vbankAssetsByBrand: {},
vows: {
PromiseWatcher_kindHandle: 'Alleged: kind',
VowInternalsKit_kindHandle: 'Alleged: kind',
diff --git a/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.snap b/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.snap
index ca1ec68d67d..68b8203f347 100644
Binary files a/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.snap and b/packages/orchestration/test/examples/snapshots/sendAnywhere.test.ts.snap differ
diff --git a/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.md b/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.md
index d219a511421..5a872f186dd 100644
--- a/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.md
+++ b/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.md
@@ -10,15 +10,7 @@ Generated by [AVA](https://avajs.dev).
{
'Durable Publish Kit_kindHandle': 'Alleged: kind',
- LSTTia: {
- asyncFlow_kindHandle: 'Alleged: kind',
- },
- 'Local Orchestration Account Kit_kindHandle': 'Alleged: kind',
- LocalChainFacade_kindHandle: 'Alleged: kind',
- Orchestrator_kindHandle: 'Alleged: kind',
Recorder_kindHandle: 'Alleged: kind',
- RemoteChainFacade_kindHandle: 'Alleged: kind',
- 'Staking Account Holder_kindHandle': 'Alleged: kind',
asyncFlow: {
AdminAsyncFlow_kindHandle: 'Alleged: kind',
AdminAsyncFlow_singleton: 'Alleged: AdminAsyncFlow',
@@ -32,6 +24,20 @@ Generated by [AVA](https://avajs.dev).
flowForOutcomeVow: {},
unwrapMap: 'Alleged: weakMapStore',
},
+ contract: {
+ publicFacet_kindHandle: 'Alleged: kind',
+ publicFacet_singleton: 'Alleged: publicFacet',
+ },
+ orchestration: {
+ LSTTia: {
+ asyncFlow_kindHandle: 'Alleged: kind',
+ },
+ 'Local Orchestration Account Kit_kindHandle': 'Alleged: kind',
+ LocalChainFacade_kindHandle: 'Alleged: kind',
+ Orchestrator_kindHandle: 'Alleged: kind',
+ RemoteChainFacade_kindHandle: 'Alleged: kind',
+ 'Staking Account Holder_kindHandle': 'Alleged: kind',
+ },
vows: {
PromiseWatcher_kindHandle: 'Alleged: kind',
VowInternalsKit_kindHandle: 'Alleged: kind',
diff --git a/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.snap b/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.snap
index f1053d2bfc9..eb1faeb51a1 100644
Binary files a/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.snap and b/packages/orchestration/test/examples/snapshots/unbondExample.test.ts.snap differ
diff --git a/packages/orchestration/test/examples/stake-ica.contract.test.ts b/packages/orchestration/test/examples/stake-ica.contract.test.ts
index a3448d45487..4ce9cf04df5 100644
--- a/packages/orchestration/test/examples/stake-ica.contract.test.ts
+++ b/packages/orchestration/test/examples/stake-ica.contract.test.ts
@@ -51,7 +51,7 @@ const getChainTerms = (
};
const startContract = async ({
- orchestration,
+ cosmosInterchainService,
timer,
marshaller,
storage,
@@ -69,7 +69,7 @@ const startContract = async ({
terms,
{
marshaller,
- orchestration,
+ cosmosInterchainService,
storageNode: storage.rootNode.makeChildNode(storagePath),
timer,
},
diff --git a/packages/orchestration/test/service.test.ts b/packages/orchestration/test/service.test.ts
index 5d27a08e1b8..20996a83ae8 100644
--- a/packages/orchestration/test/service.test.ts
+++ b/packages/orchestration/test/service.test.ts
@@ -18,12 +18,12 @@ import { tryDecodeResponse } from '../src/utils/cosmos.js';
test('makeICQConnection returns an ICQConnection', async t => {
const {
- bootstrap: { orchestration },
+ bootstrap: { cosmosInterchainService },
} = await commonSetup(t);
const CONTROLLER_CONNECTION_ID = 'connection-0';
- const icqConnection = await E(orchestration).provideICQConnection(
+ const icqConnection = await E(cosmosInterchainService).provideICQConnection(
CONTROLLER_CONNECTION_ID,
);
const [localAddr, remoteAddr] = await Promise.all([
@@ -46,7 +46,7 @@ test('makeICQConnection returns an ICQConnection', async t => {
'remote address contains icqhost port, unordered ordering, and icq-1 version string',
);
- const icqConnection2 = await E(orchestration).provideICQConnection(
+ const icqConnection2 = await E(cosmosInterchainService).provideICQConnection(
CONTROLLER_CONNECTION_ID,
);
const localAddr2 = await E(icqConnection2).getLocalAddress();
@@ -68,14 +68,14 @@ test('makeICQConnection returns an ICQConnection', async t => {
test('makeAccount returns a ChainAccount', async t => {
const {
- bootstrap: { orchestration },
+ bootstrap: { cosmosInterchainService },
} = await commonSetup(t);
const CHAIN_ID = 'cosmoshub-99';
const HOST_CONNECTION_ID = 'connection-0';
const CONTROLLER_CONNECTION_ID = 'connection-1';
- const account = await E(orchestration).makeAccount(
+ const account = await E(cosmosInterchainService).makeAccount(
CHAIN_ID,
HOST_CONNECTION_ID,
CONTROLLER_CONNECTION_ID,
diff --git a/packages/orchestration/test/supports.ts b/packages/orchestration/test/supports.ts
index c017a3f07d2..9755d221f0e 100644
--- a/packages/orchestration/test/supports.ts
+++ b/packages/orchestration/test/supports.ts
@@ -22,7 +22,7 @@ import { makeDurableZone } from '@agoric/zone/durable.js';
import { E } from '@endo/far';
import type { ExecutionContext } from 'ava';
import { registerChainNamespace } from '../src/chain-info.js';
-import { prepareOrchestrationTools } from '../src/service.js';
+import { prepareCosmosInterchainService } from '../src/exos/cosmos-interchain-service.js';
import { setupFakeNetwork } from './network-fakes.js';
export {
@@ -113,11 +113,13 @@ export const commonSetup = async (t: ExecutionContext) => {
);
await setupIBCProtocol();
- const { makeOrchestrationKit } = prepareOrchestrationTools(
+ const makeCosmosInterchainService = prepareCosmosInterchainService(
rootZone.subZone('orchestration'),
vowTools,
);
- const { public: orchestration } = makeOrchestrationKit({ portAllocator });
+ const cosmosInterchainService = makeCosmosInterchainService({
+ portAllocator,
+ });
await registerChainNamespace(agoricNamesAdmin, () => {});
@@ -129,7 +131,7 @@ export const commonSetup = async (t: ExecutionContext) => {
timer,
localchain,
marshaller,
- orchestration,
+ cosmosInterchainService,
// TODO remove; bootstrap doesn't have a zone
rootZone: rootZone.subZone('contract'),
storage,
@@ -143,7 +145,7 @@ export const commonSetup = async (t: ExecutionContext) => {
commonPrivateArgs: {
agoricNames,
localchain,
- orchestrationService: orchestration,
+ orchestrationService: cosmosInterchainService,
storageNode: storage.rootNode,
marshaller,
timerService: timer,
@@ -151,7 +153,7 @@ export const commonSetup = async (t: ExecutionContext) => {
facadeServices: {
agoricNames,
localchain,
- orchestrationService: orchestration,
+ orchestrationService: cosmosInterchainService,
timerService: timer,
},
utils: {
diff --git a/packages/vats/src/core/types-ambient.d.ts b/packages/vats/src/core/types-ambient.d.ts
index 74359b00ac7..ee27e97924b 100644
--- a/packages/vats/src/core/types-ambient.d.ts
+++ b/packages/vats/src/core/types-ambient.d.ts
@@ -109,7 +109,9 @@ type Producer = {
};
type VatSourceRef = { bundleName?: string; bundleID?: string };
-type VatLoader = (
+type VatLoader = <
+ N extends Names,
+>(
name: N,
sourceRef?: VatSourceRef,
) => Promise>;
@@ -342,6 +344,7 @@ type ChainBootstrapSpaceT = {
client: ClientManager;
clientCreator: any;
coreEvalBridgeHandler: import('../types.js').BridgeHandler;
+ cosmosInterchainService: import('@agoric/orchestration').CosmosInterchainService;
/** Utilities to support debugging */
diagnostics: {
/**
@@ -368,7 +371,6 @@ type ChainBootstrapSpaceT = {
namesByAddress: import('../types.js').NameHub;
namesByAddressAdmin: import('../types.js').NamesByAddressAdmin;
networkVat: NetworkVat;
- orchestration: import('@agoric/orchestration/src/service.js').OrchestrationService;
pegasusConnections: import('@agoric/vats').NameHubKit;
pegasusConnectionsAdmin: import('@agoric/vats').NameAdmin;
priceAuthorityVat: Awaited;