Skip to content

Commit

Permalink
feat: asContinuingOffer
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 4, 2024
1 parent 3af2b5c commit 7622490
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
34 changes: 14 additions & 20 deletions packages/orchestration/src/examples/stakeAtom.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport';
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { M } from '@endo/patterns';
import { prepareCosmosOrchestrationAccountKit } from '../exos/cosmosOrchestrationAccount.js';
import { prepareCosmosOrchestrationAccount } from '../exos/cosmosOrchestrationAccount.js';

const trace = makeTracer('StakeAtom');
/**
Expand Down Expand Up @@ -61,8 +61,11 @@ export const start = async (zcf, privateArgs, baggage) => {

const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);

const makeCosmosOrchestrationAccountKit =
prepareCosmosOrchestrationAccountKit(zone, makeRecorderKit, zcf);
const makeCosmosOrchestrationAccount = prepareCosmosOrchestrationAccount(
zone,
makeRecorderKit,
zcf,
);

async function makeAccountKit() {
const account = await E(orchestration).makeAccount(
Expand All @@ -77,21 +80,13 @@ export const start = async (zcf, privateArgs, baggage) => {
);
const accountAddress = await E(account).getAddress();
trace('account address', accountAddress);
const { holder, invitationMakers } = makeCosmosOrchestrationAccountKit(
accountAddress,
bondDenom,
{
account,
storageNode,
icqConnection,
timer,
},
);
return {
publicSubscribers: holder.getPublicTopics(),
invitationMakers,
account: holder,
};
const holder = makeCosmosOrchestrationAccount(accountAddress, bondDenom, {
account,
storageNode,
icqConnection,
timer,
});
return holder;
}

const publicFacet = zone.exo(
Expand All @@ -103,8 +98,7 @@ export const start = async (zcf, privateArgs, baggage) => {
{
async makeAccount() {
trace('makeAccount');
const { account } = await makeAccountKit();
return account;
return makeAccountKit();
},
makeAccountInvitationMaker() {
trace('makeCreateAccountInvitation');
Expand Down
13 changes: 13 additions & 0 deletions packages/orchestration/src/exos/cosmosOrchestrationAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ const { Fail } = assert;

/** @see {OrchestrationAccountI} */
export const IcaAccountHolderI = M.interface('IcaAccountHolder', {
asContinuingOffer: M.call().returns({
publicSubscribers: M.any(),
invitationMakers: M.any(),
holder: M.any(),
}),
getPublicTopics: M.call().returns(TopicsRecordShape),
getAddress: M.call().returns(ChainAddressShape),
getBalance: M.callWhen().optional(M.string()).returns(CoinShape),
Expand Down Expand Up @@ -251,6 +256,14 @@ export const prepareCosmosOrchestrationAccountKit = (
},
},
holder: {
asContinuingOffer() {
const { holder, invitationMakers } = this.facets;
return {
publicSubscribers: holder.getPublicTopics(),
invitationMakers,
holder,
};
},
getPublicTopics() {
const { topicKit } = this.state;
return harden({
Expand Down

0 comments on commit 7622490

Please sign in to comment.