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

orch ref docs fixes (WIP) #9768

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
2 changes: 2 additions & 0 deletions packages/orchestration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

export * from './src/types.js';
export * from './src/exos/cosmos-interchain-service.js';
export * from './src/exos/chain-hub-admin.js';
export * from './src/typeGuards.js';
export { withOrchestration } from './src/utils/start-helper.js';
8 changes: 6 additions & 2 deletions packages/orchestration/src/chain-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import {
import fetchedChainInfo from './fetched-chain-info.js'; // Refresh with scripts/refresh-chain-info.ts
import { CosmosAssetInfoShape, CosmosChainInfoShape } from './typeGuards.js';

/** @import {CosmosAssetInfo, CosmosChainInfo, EthChainInfo, IBCConnectionInfo} from './types.js'; */
/** @import {Chain, CosmosAssetInfo, CosmosChainInfo, EthChainInfo, IBCConnectionInfo} from './types.js'; */
/** @import {NameAdmin} from '@agoric/vats'; */

/** @typedef {CosmosChainInfo | EthChainInfo} ChainInfo */
/**
* Info used to build a {@link Chain} object - naming, connections, etc.
*
* @typedef {CosmosChainInfo | EthChainInfo} ChainInfo
*/

const knownChains = /** @satisfies {Record<string, ChainInfo>} */ (
harden({
Expand Down
27 changes: 27 additions & 0 deletions packages/orchestration/src/cosmos-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export type CosmosChainInfo = Readonly<{
stakingTokens?: Readonly<Array<{ denom: string }>>;
}>;

/**
* Queries for the staking properties of an account.
*
* @see {@link https://docs.cosmos.network/main/build/modules/staking#messages x/staking messages}
* {@link https://cosmos.github.io/cosmjs/latest/stargate/interfaces/StakingExtension.html StakingExtension} in cosmjs
*/
export interface StakingAccountQueries {
/**
* @returns all active delegations from the account to any validator (or [] if none)
Expand Down Expand Up @@ -137,6 +143,13 @@ export interface StakingAccountQueries {
*/
getReward: (validator: CosmosValidatorAddress) => Promise<DenomAmount[]>;
}

/**
* Transactions for doing staking operations on an individual account.
*
* @see {@link https://docs.cosmos.network/main/build/modules/staking#messages x/staking messages}
* {@link https://cosmos.github.io/cosmjs/latest/stargate/interfaces/StakingExtension.html StakingExtension} in cosmjs
*/
export interface StakingAccountActions {
/**
* Delegate an amount to a validator. The promise settles when the delegation is complete.
Expand Down Expand Up @@ -248,12 +261,26 @@ export type LocalAccountMethods = {
monitorTransfers: (tap: TargetApp) => Promise<TargetRegistration>;
};

/**
* Options for {@link OrchestrationAccountI} `transfer` method.
*
* @see {@link https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures ICS 20 Data Structures}
*/
export type IBCMsgTransferOptions = {
timeoutHeight?: MsgTransfer['timeoutHeight'];
timeoutTimestamp?: MsgTransfer['timeoutTimestamp'];
memo?: string;
};

/**
* Cosmos-specific methods to extend `OrchestrationAccountI`, parameterized
* by `CosmosChainInfo`.
*
* In particular, if the chain info includes a staking token, `StakingAccountActions`
* are available.
*
* @see {OrchestrationAccountI}
*/
export type CosmosChainAccountMethods<CCI extends CosmosChainInfo> =
(CCI extends {
icaEnabled: true;
Expand Down
13 changes: 9 additions & 4 deletions packages/orchestration/src/exos/chain-hub-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
*/

/**
*

Check warning on line 14 in packages/orchestration/src/exos/chain-hub-admin.js

View workflow job for this annotation

GitHub Actions / lint-rest

Delete `⏎·*·`
* For use with async-flow contracts: can be used as a creator facet that allows
* developers to add new chain configurations to a local chainHub, in the event
* the information is not available widely in `agoricNames`.
*
* @example

Check warning on line 19 in packages/orchestration/src/exos/chain-hub-admin.js

View workflow job for this annotation

GitHub Actions / lint-rest

Delete `⏎·*·`
* const chainHubAdmin = prepareChainHubAdmin(zone, chainHub);
* chainHubAdmin.initChain('hotNewChain', hotNewChainInfo, agoricTohotNewChainConnectionInfo);

Check warning on line 21 in packages/orchestration/src/exos/chain-hub-admin.js

View workflow job for this annotation

GitHub Actions / lint-rest

Insert `⏎·*`
*

Check warning on line 22 in packages/orchestration/src/exos/chain-hub-admin.js

View workflow job for this annotation

GitHub Actions / lint-rest

Delete `·`
* @param {Zone} zone
* @param {ChainHub} chainHub
*/
Expand All @@ -31,9 +36,11 @@
}),
{
/**
* @param {string} chainName
* Register information for a chain
*
* @param {string} chainName - must not exist in chainHub
* @param {CosmosChainInfo} chainInfo
* @param {IBCConnectionInfo} connectionInfo
* @param {IBCConnectionInfo} connectionInfo - from Agoric chain
*/
async initChain(chainName, chainInfo, connectionInfo) {
// when() because chainHub methods return vows. If this were inside
Expand All @@ -52,5 +59,3 @@
);
return makeCreatorFacet;
};

/** @typedef {ReturnType<prepareChainHubAdmin>} ChainHubAdmin */
9 changes: 5 additions & 4 deletions packages/orchestration/src/exos/chain-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,16 @@
});

/**
* Make a new ChainHub in the zone (or in the heap if no zone is provided).
* Make a new ChainHub in the heap zone.
*
* The resulting object is an Exo singleton. It has no precious state. It's only
* The resulting object is an Exo singleton. It has no precious state. Its only
* state is a cache of queries to agoricNames and whatever info was provided in
* registration calls. When you need a newer version you can simply make a hub
* hub and repeat the registrations.
* registration calls. When you need a newer version you can simply make a ChainHub

Check warning on line 178 in packages/orchestration/src/exos/chain-hub.js

View workflow job for this annotation

GitHub Actions / lint-rest

Replace `·ChainHub⏎·*` with `⏎·*·ChainHub`
* and repeat the registrations.
*
* @param {Remote<NameHub>} agoricNames
* @param {VowTools} vowTools
* @internal @see {withOrchestration}

Check warning on line 183 in packages/orchestration/src/exos/chain-hub.js

View workflow job for this annotation

GitHub Actions / lint-rest

@internal should be empty
*/
export const makeChainHub = (agoricNames, vowTools) => {
const zone = makeHeapZone();
Expand Down
13 changes: 12 additions & 1 deletion packages/orchestration/src/exos/cosmos-interchain-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import {

const { Vow$ } = NetworkShape; // TODO #9611
/**
* This is the greatest thing since sliced bread.
*
* TODO: private
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://typedoc.org/tags/private/ says it shouldn't be used. I think we want @internal

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've struggled to get @internal to work. @mitdralla suggested @private, so I tried that. Also didn't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I think we should assume we can get it working. Even when it's not omitted it has an INTERNAL tag which is better than nothing. #9808 (comment)

*
* @typedef {object} OrchestrationPowers
* @property {Remote<PortAllocator>} portAllocator
* @property {undefined} reserved reserve a state key for future use. can hold
Expand Down Expand Up @@ -270,4 +274,11 @@ export const prepareCosmosInterchainService = (zone, vowTools) => {
harden(prepareCosmosInterchainService);

/** @typedef {ReturnType<typeof prepareCosmosInterchainService>} MakeCosmosInterchainService */
/** @typedef {ReturnType<MakeCosmosInterchainService>} CosmosInterchainService */
/**
* Authority to make an interchain account or an interchain query connection.
*
* - UNTIL #9765
* - UNTIL #9766
*
* @typedef {ReturnType<MakeCosmosInterchainService>} CosmosInterchainService
*/
13 changes: 13 additions & 0 deletions packages/orchestration/src/orchestration-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,21 @@ export type TransferMsg = {
data?: object;
};

/**
* TODO: document how Osmosis ibc hooks work
*/
export type AfterAction = { destChain: string; destAddress: ChainAddress };
/**
* Detail for an exact swap on Osmosis.
*
* @see {@link https://docs.osmosis.zone/osmosis-core/modules/pool-manager/ Osmosis pool-manager module}
*/
export type SwapExact = { amountIn: Amount; amountOut: Amount };
/**
* Detail for a max-slippage swap on Osmosis.
*
* @see {@link https://docs.osmosis.zone/osmosis-core/modules/pool-manager/ Osmosis pool-manager module}
*/
export type SwapMaxSlippage = {
amountIn: Amount;
brandOut: Brand;
Expand Down
12 changes: 11 additions & 1 deletion packages/orchestration/src/typeGuards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ import { VowShape } from '@agoric/vow';
import { M } from '@endo/patterns';

/**
* @import {TypedPattern} from '@agoric/internal';
* @import {TypedPattern as TPInternal} from '@agoric/internal';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename this? If TypedPattern is to be internal (which I support) it should simply have the @internal tag. For that matter, I suppose everything in @agoric/internal should.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was: The docs showed DelegationShape: TypedPattern<Delegation> but TypedPattern wasn't linked, because it was from the internal package.

So this is an alias in the orchestration so that it gets linked. For example, see:
https://dc-orch-ref-docs.agoric-sdk.pages.dev/variables/_agoric_orchestration.DelegationShape

Moving TypedPattern to @endo/patterns might be a better way to fix this, but I'm not sure how to test that quickly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we leave it unlinked? if Delegation is linked, that seems enough to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delegation is also unlinked... it's from @agoric/cosmic-proto... I wonder if it's straightforward to address that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we leave it (TypedPattern) unlinked?

I'm making a separate issue about it; we can decide to close it without action:

* @import {ChainAddress, CosmosAssetInfo, ChainInfo, CosmosChainInfo, DenomAmount, DenomDetail} from './types.js';
* @import {Delegation} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
*/

/**
* @template T
* @typedef {TPInternal<T>} TypedPattern a pattern that recognizes an object
* with the static type T
* @see {M}
*
* TODO: caveat about static types that express more than patterns can.
* TODO: push TypedPattern down into @endo/patterns
*/

/**
* Used for IBC Channel Connections that only send outgoing transactions. If
* your channel expects incoming transactions, please extend this interface to
Expand Down
5 changes: 5 additions & 0 deletions packages/orchestration/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @file Rollup of all type definitions in the package, for local import and external export */

import { prepareChainHubAdmin } from './exos/chain-hub-admin.js';

export type * from './chain-info.js';
export type * from './cosmos-api.js';
export type * from './ethereum-api.js';
Expand All @@ -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 ChainHubAdmin = ReturnType<typeof prepareChainHubAdmin>;
7 changes: 7 additions & 0 deletions packages/orchestration/src/utils/start-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ harden(provideOrchestration);
* Simplifies contract functions for Orchestration by wrapping a simpler
* function with all the tools it needs in order to use Orchestration.
*
* @example
*
* ```js
* const contract = (zcf, privateArgs, zone, tools) => { ... };
* export const start = withOrchestration(contract);
* ```
*
* @template {Record<string, unknown>} CT
* @template {OrchestrationPowers & {
* marshaller: Marshaller;
Expand Down
Loading