Skip to content

Commit

Permalink
chore: use chainHub in orch example contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Jun 10, 2024
1 parent 4f376ca commit 2165de7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
10 changes: 2 additions & 8 deletions packages/orchestration/src/examples/stakeBld.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { E } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { M } from '@endo/patterns';
import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';
import { makeChainHub } from '../utils/chainHub.js';

/**
* @import {NameHub} from '@agoric/vats';
Expand Down Expand Up @@ -44,19 +45,12 @@ export const start = async (zcf, privateArgs, baggage) => {
privateArgs.marshaller,
);

// FIXME in a second incarnation we can't make a remote call before defining all kinds
// UNTIL https://github.com/Agoric/agoric-sdk/issues/8879
const agoricChainInfo = await E(privateArgs.agoricNames).lookup(
'chain',
'agoric',
);

const makeLocalChainAccountKit = prepareLocalChainAccountKit(
zone,
makeRecorderKit,
zcf,
privateArgs.timerService,
agoricChainInfo,
makeChainHub(privateArgs.agoricNames),
);

async function makeLocalAccountKit() {
Expand Down
19 changes: 18 additions & 1 deletion packages/orchestration/src/examples/swapExample.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { makeDurableZone } from '@agoric/zone/durable.js';
import { Far } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { M, objectMap } from '@endo/patterns';
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
import { makeOrchestrationFacade } from '../facade.js';
import { orcUtils } from '../utils/orc.js';
import { makeChainHub } from '../utils/chainHub.js';
import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';

/**
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
Expand All @@ -25,6 +28,7 @@ export const meta = {
localchain: M.remotable('localchain'),
orchestrationService: M.or(M.remotable('orchestration'), null),
storageNode: StorageNodeShape,
marshaller: M.remotable('marshaller'),
timerService: M.or(TimerServiceShape, null),
},
upgradability: 'canUpgrade',
Expand All @@ -48,6 +52,7 @@ export const makeNatAmountShape = (brand, min) =>
* orchestrationService: Remote<OrchestrationService>;
* storageNode: Remote<StorageNode>;
* timerService: Remote<TimerService>;
* marshaller: Marshaller;
* }} privateArgs
* @param {Baggage} baggage
*/
Expand All @@ -62,16 +67,28 @@ export const start = async (zcf, privateArgs, baggage) => {
orchestrationService,
storageNode,
timerService,
marshaller,
} = privateArgs;

const chainHub = makeChainHub(agoricNames);
const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
const makeLocalChainAccountKit = prepareLocalChainAccountKit(
zone,
makeRecorderKit,
zcf,
timerService,
chainHub,
);

const { orchestrate } = makeOrchestrationFacade({
agoricNames,
localchain,
orchestrationService,
storageNode,
timerService,
zcf,
zone,
chainHub,
makeLocalChainAccountKit,
});

/** deprecated historical example */
Expand Down
17 changes: 16 additions & 1 deletion packages/orchestration/src/examples/unbondExample.contract.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { makeDurableZone } from '@agoric/zone/durable.js';
import { Far } from '@endo/far';
import { M } from '@endo/patterns';
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
import { makeOrchestrationFacade } from '../facade.js';
import { makeChainHub } from '../utils/chainHub.js';
import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';

/**
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
Expand All @@ -20,6 +23,7 @@ import { makeOrchestrationFacade } from '../facade.js';
* localchain: Remote<LocalChain>;
* orchestrationService: Remote<OrchestrationService>;
* storageNode: Remote<StorageNode>;
* marshaller: Marshaller;
* timerService: Remote<TimerService>;
* }} privateArgs
* @param {Baggage} baggage
Expand All @@ -30,18 +34,29 @@ export const start = async (zcf, privateArgs, baggage) => {
localchain,
orchestrationService,
storageNode,
marshaller,
timerService,
} = privateArgs;
const zone = makeDurableZone(baggage);

const chainHub = makeChainHub(agoricNames);
const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
const makeLocalChainAccountKit = prepareLocalChainAccountKit(
zone,
makeRecorderKit,
zcf,
privateArgs.timerService,
chainHub,
);
const { orchestrate } = makeOrchestrationFacade({
agoricNames,
localchain,
orchestrationService,
storageNode,
timerService,
zcf,
zone,
chainHub: makeChainHub(agoricNames),
makeLocalChainAccountKit,
});

/** @type {OfferHandler} */
Expand Down

0 comments on commit 2165de7

Please sign in to comment.