Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orchestration typedoc: portfolio holder #10217

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import { getMethodNames } from '@agoric/internal';
// TODO use a helper from Endo https://github.com/endojs/endo/issues/2448
/**
* Takes two or more InvitationMaker exos and combines them into a new one.
* Combine with `publicTopics` to form a {@link ContinuingOfferResult} that can
* be returned to a smart-wallet client.
*
* Useful for writing your own invitationMakers while preserving
* platform-provided ones like `Delegate`, `Transfer`, `Send`.
*
* @param {Zone} zone
* @param {import('@endo/patterns').InterfaceGuard[]} interfaceGuards
Expand Down Expand Up @@ -51,3 +56,4 @@ export const prepareCombineInvitationMakers = (zone, ...interfaceGuards) => {
};

/** @typedef {ReturnType<typeof prepareCombineInvitationMakers>} MakeCombineInvitationMakers */
/** @typedef {ReturnType<MakeCombineInvitationMakers>} CombinedInvitationMakers */
63 changes: 60 additions & 3 deletions packages/orchestration/src/exos/portfolio-holder-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { fromEntries } = Object;
* @import {VowTools} from '@agoric/vow';
* @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
* @import {Zone} from '@agoric/zone';
* @import {OrchestrationAccount, OrchestrationAccountI} from '@agoric/orchestration';
* @import {OrchestrationAccount, OrchestrationAccountI, MakeCombineInvitationMakers} from '@agoric/orchestration';
*/

/**
Expand Down Expand Up @@ -156,8 +156,65 @@ const preparePortfolioHolderKit = (zone, { asVow, when }) => {
* A portfolio holder stores two or more OrchestrationAccounts and combines
* ContinuingOfferResult's from each into a single result.
*
* XXX consider an interface for extending the exo maker with additional
* invitation makers.
* The invitationMakers can be accessed via the `Proxy` invitationMaker, which
* calls out to other invitationMakers.
*
* See {@link MakeCombineInvitationMakers} for an exo that allows a developer to
* define extra invitationMakers to combine with platform-provided ones.
*
* @example
*
* ```js
* // in contract start/prepare
* const makePortfolioHolder = preparePortfolioHolder(
* rootZone.subZone('portfolio'),
* vowTools,
* );
*
* // in a flow
* const accounts = {
* cosmoshub: await cosmosChain.makeAccount(),
* agoric: await agoricChain.makeAccount(),
* };
* const accountEntries = harden(Object.entries(accounts));
* const publicTopicEntries = harden(
* await Promise.all(
* Object.entries(accounts).map(async ([chainName, holder]) => {
* const { account } = await E(holder).getPublicTopics();
* return [chainName, account];
* }),
* ),
* );
* const holder = makePortfolioHolder(accountEntries, publicTopicEntries);
*
* // return ContinuingOfferResult to client
* return E(holder).asContinuingOffer();
*
* const { invitationMakers } = await E(holder).asContinuingOffer();
*
* // with invitationArgs
* const delegateInv = await E(invitationMakers).Proxying(
* 'cosmoshub',
* 'Delegate',
* [
* {
* value: 'cosmos1valoper',
* chainId: 'cosmoshub-99',
* encoding: 'bech32',
* },
* {
* denom: 'uatom',
* value: 10n,
* },
* ],
* );
*
* // without invitationArgs
* const transferInv = await E(invitationMakers).Proxying(
* 'cosmoshub',
* 'Transfer',
* );
* ```
*
* @param {Zone} zone
* @param {VowTools} vowTools
Expand Down
10 changes: 6 additions & 4 deletions packages/orchestration/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
export type * from './chain-info.js';
export type * from './cosmos-api.js';
export type * from './ethereum-api.js';
export type * from './exos/chain-hub.js';
export type * from './exos/combine-invitation-makers.js';
export type * from './exos/cosmos-interchain-service.js';
export type * from './exos/exo-interfaces.js';
export type * from './exos/ica-account-kit.js';
export type * from './exos/local-chain-facade.js';
export type * from './exos/icq-connection-kit.js';
export type * from './exos/exo-interfaces.js';
export type * from './exos/local-chain-facade.js';
export type * from './exos/portfolio-holder-kit.js';
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';

/**
Expand Down
Loading