Skip to content

Commit

Permalink
types: Chain.query() type
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Aug 21, 2024
1 parent 26fb182 commit 1c7ec01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/orchestration/src/cosmos-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyJson, TypedJson } from '@agoric/cosmic-proto';
import type { AnyJson, TypedJson, JsonSafe } from '@agoric/cosmic-proto';
import type {
Delegation,
Redelegation,
Expand All @@ -11,6 +11,10 @@ import type {
Order,
} from '@agoric/cosmic-proto/ibc/core/channel/v1/channel.js';
import type { State as IBCConnectionState } from '@agoric/cosmic-proto/ibc/core/connection/v1/connection.js';
import type {
RequestQuery,
ResponseQuery,
} from '@agoric/cosmic-proto/tendermint/abci/types.js';
import type { Brand, Purse, Payment, Amount } from '@agoric/ertp/src/types.js';
import type { Port } from '@agoric/network';
import type { IBCChannelID, IBCConnectionID } from '@agoric/vats';
Expand Down Expand Up @@ -265,3 +269,7 @@ export type CosmosChainAccountMethods<CCI extends CosmosChainInfo> =
}
? StakingAccountActions
: {};

export type ICQQueryFunction = (
msgs: JsonSafe<RequestQuery>[],
) => Promise<JsonSafe<ResponseQuery>[]>;
1 change: 0 additions & 1 deletion packages/orchestration/src/examples/basic-flows.flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const sendQuery = async (orch, _ctx, seat, { chainName, msgs }) => {
mustMatch(chainName, M.string());
if (chainName === 'agoric') throw Fail`ICQ not supported on local chain`;
const remoteChain = await orch.getChain(chainName);
// @ts-expect-error FIXME implement Chain.query
const queryResponse = await remoteChain.query(msgs);
console.debug('sendQuery response:', queryResponse);
return queryResponse;
Expand Down
3 changes: 3 additions & 0 deletions packages/orchestration/src/orchestration-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
IBCMsgTransferOptions,
KnownChains,
LocalAccountMethods,
ICQQueryFunction,
} from './types.js';
import type { ResolvedContinuingOfferResult } from './utils/zoe-tools.js';

Expand Down Expand Up @@ -88,6 +89,8 @@ export interface Chain<CI extends ChainInfo> {
makeAccount: () => Promise<OrchestrationAccount<CI>>;
// FUTURE supply optional port object; also fetch port object

query: CI extends { icqEnabled: true } ? ICQQueryFunction : never;

// TODO provide a way to get the local denom/brand/whatever for this chain
}

Expand Down

0 comments on commit 1c7ec01

Please sign in to comment.