Skip to content

Commit

Permalink
feat: export DenomDetailShape
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Nov 26, 2024
1 parent 4aca5c5 commit 176069b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 8 deletions.
22 changes: 22 additions & 0 deletions packages/builders/test/snapshots/orchestration-imports.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,28 @@ Generated by [AVA](https://avajs.dev).
payload: [],
},
},
DenomDetailShape: Object @match:splitRecord {
payload: [
{
baseDenom: Object @match:string {
payload: [],
},
baseName: Object @match:string {
payload: [],
},
chainName: Object @match:string {
payload: [],
},
},
{
brand: Object @match:remotable {
payload: {
label: 'Brand',
},
},
},
],
},
DenomInfoShape: {
base: Object @match:remotable {
payload: {
Expand Down
Binary file modified packages/builders/test/snapshots/orchestration-imports.test.js.snap
Binary file not shown.
3 changes: 1 addition & 2 deletions packages/orchestration/src/exos/chain-hub-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/* eslint-disable no-restricted-syntax */
import { heapVowE } from '@agoric/vow/vat.js';
import { M } from '@endo/patterns';
import { CosmosChainInfoShape } from '../typeGuards.js';
import { DenomDetailShape } from './chain-hub.js';
import { CosmosChainInfoShape, DenomDetailShape } from '../typeGuards.js';

/**
* @import {Zone} from '@agoric/zone';
Expand Down
7 changes: 1 addition & 6 deletions packages/orchestration/src/exos/chain-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { VowShape } from '@agoric/vow';
import {
ChainAddressShape,
CosmosChainInfoShape,
DenomDetailShape,
IBCConnectionInfoShape,
} from '../typeGuards.js';
import { getBech32Prefix } from '../utils/address.js';
Expand All @@ -19,7 +20,6 @@ import { getBech32Prefix } from '../utils/address.js';
* @import {ChainInfo, KnownChains} from '../chain-info.js';
* @import {ChainAddress, Denom} from '../orchestration-api.js';
* @import {Remote} from '@agoric/internal';
* @import {TypedPattern} from '@agoric/internal';
*/

/**
Expand All @@ -40,11 +40,6 @@ import { getBech32Prefix } from '../utils/address.js';
* @property {Brand<'nat'>} [brand] - vbank brand, if registered
* @see {ChainHub} `registerAsset` method
*/
/** @type {TypedPattern<DenomDetail>} */
export const DenomDetailShape = M.splitRecord(
{ chainName: M.string(), baseName: M.string(), baseDenom: M.string() },
{ brand: BrandShape },
);

/**
* @enum {(typeof HubName)[keyof typeof HubName]}
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 @@ -102,6 +102,9 @@ export interface Chain<CI extends ChainInfo> {
// TODO provide a way to get the local denom/brand/whatever for this chain
}

/**
* Used with `orch.getDenomInfo('ibc/1234')`. See {@link Orchestrator.getDenomInfo}
*/
export interface DenomInfo<
HoldingChain extends keyof KnownChains,
IssuingChain extends keyof KnownChains,
Expand Down
9 changes: 9 additions & 0 deletions packages/orchestration/src/typeGuards.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BrandShape } from '@agoric/ertp/src/typeGuards.js';
import { VowShape } from '@agoric/vow';
import { M } from '@endo/patterns';

Expand All @@ -7,6 +8,7 @@ import { M } from '@endo/patterns';
* @import {Any as Proto3Msg} from '@agoric/cosmic-proto/google/protobuf/any.js';
* @import {TxBody} from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
* @import {TypedJson} from '@agoric/cosmic-proto';
* @import {DenomDetail} from './exos/chain-hub.js';
*/

/**
Expand Down Expand Up @@ -119,6 +121,13 @@ export const DenomInfoShape = {
};
harden(DenomInfoShape);

/** @type {TypedPattern<DenomDetail>} */
export const DenomDetailShape = M.splitRecord(
{ chainName: M.string(), baseName: M.string(), baseDenom: M.string() },
{ brand: BrandShape },
);
harden(DenomDetailShape);

/** @type {TypedPattern<DenomAmount>} */
export const DenomAmountShape = { denom: DenomShape, value: M.nat() };
harden(DenomAmountShape);
Expand Down
1 change: 1 addition & 0 deletions packages/orchestration/test/snapshots/exports.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Generated by [AVA](https://avajs.dev).
'CosmosChainInfoShape',
'DelegationShape',
'DenomAmountShape',
'DenomDetailShape',
'DenomInfoShape',
'DenomShape',
'IBCChannelIDShape',
Expand Down
Binary file modified packages/orchestration/test/snapshots/exports.test.ts.snap
Binary file not shown.

0 comments on commit 176069b

Please sign in to comment.