Skip to content

Commit

Permalink
BREAKING CHANGE: getBrandInfo -> getDenomInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 29, 2024
1 parent ae9cd2d commit 52ebb4a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions packages/orchestration/src/exos/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Fail, q } from '@endo/errors';
import { E } from '@endo/far';
import { M } from '@endo/patterns';
import {
BrandInfoShape,
DenomInfoShape,
ChainInfoShape,
DenomAmountShape,
DenomShape,
Expand Down Expand Up @@ -37,7 +37,7 @@ const trace = makeTracer('Orchestrator');
export const OrchestratorI = M.interface('Orchestrator', {
getChain: M.call(M.string()).returns(Vow$(ChainInfoShape)),
makeLocalAccount: M.call().returns(Vow$(LocalChainAccountShape)),
getBrandInfo: M.call(DenomShape).returns(BrandInfoShape),
getDenomInfo: M.call(DenomShape).returns(DenomInfoShape),
asAmount: M.call(DenomAmountShape).returns(AmountShape),
});

Expand Down Expand Up @@ -140,15 +140,15 @@ const prepareOrchestratorKit = (
makeLocalAccount() {
return watch(E(localchain).makeAccount());
},
/** @type {HostOf<Orchestrator['getBrandInfo']>} */
getBrandInfo(denom) {
/** @type {HostOf<Orchestrator['getDenomInfo']>} */
getDenomInfo(denom) {
const { chainName, baseName, baseDenom, brand } =
chainHub.lookupAsset(denom);
chainByName.has(chainName) ||
Fail`use getChain(${q(chainName)}) before getBrandInfo(${q(denom)})`;
Fail`use getChain(${q(chainName)}) before getDenomInfo(${q(denom)})`;
const chain = chainByName.get(chainName);
chainByName.has(baseName) ||
Fail`use getChain(${q(baseName)}) before getBrandInfo(${q(denom)})`;
Fail`use getChain(${q(baseName)}) before getDenomInfo(${q(denom)})`;
const base = chainByName.get(baseName);
return harden({ chain, base, brand, baseDenom });
},
Expand Down
6 changes: 3 additions & 3 deletions packages/orchestration/src/orchestration-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface Chain<CI extends ChainInfo> {
// TODO provide a way to get the local denom/brand/whatever for this chain
}

export interface BrandInfo<
export interface DenomInfo<
HoldingChain extends keyof KnownChains,
IssuingChain extends keyof KnownChains,
> {
Expand Down Expand Up @@ -133,12 +133,12 @@ export interface Orchestrator {
* issues the corresponding asset.
* @param denom
*/
getBrandInfo: <
getDenomInfo: <
HoldingChain extends keyof KnownChains,
IssuingChain extends keyof KnownChains,
>(
denom: Denom,
) => BrandInfo<HoldingChain, IssuingChain>;
) => DenomInfo<HoldingChain, IssuingChain>;
// TODO preload the mapping so this can be synchronous
/**
* Convert an amount described in native data to a local, structured Amount.
Expand Down
6 changes: 3 additions & 3 deletions packages/orchestration/src/typeGuards.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { M } from '@endo/patterns';

/**
* @import {TypedPattern} from '@agoric/internal';
* @import {ChainAddress, CosmosAssetInfo, Chain, ChainInfo, CosmosChainInfo, DenomAmount, DenomDetail, BrandInfo} from './types.js';
* @import {ChainAddress, CosmosAssetInfo, Chain, ChainInfo, CosmosChainInfo, DenomAmount, DenomDetail, DenomInfo} from './types.js';
* @import {Delegation} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
* @import {TxBody} from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
* @import {TypedJson} from '@agoric/cosmic-proto';
Expand Down Expand Up @@ -112,8 +112,8 @@ export const ChainInfoShape = M.splitRecord({
export const LocalChainAccountShape = M.remotable('LocalChainAccount');
export const DenomShape = M.string();

/** @type {TypedPattern<BrandInfo<any, any>>} */
export const BrandInfoShape = {
/** @type {TypedPattern<DenomInfo<any, any>>} */
export const DenomInfoShape = {
chain: M.remotable('Chain'),
base: M.remotable('Chain'),
brand: M.or(M.remotable('Brand'), M.undefined()),
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/test/exos/chain-hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ test.serial('getConnectionInfo', async t => {
t.deepEqual(await vt.when(chainHub.getConnectionInfo(b, a)), ba);
});

test('getBrandInfo support', async t => {
test('getDenomInfo support', async t => {
const { chainHub } = setup();

const denom = 'utok1';
Expand Down
8 changes: 4 additions & 4 deletions packages/orchestration/test/facade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test.serial('asset / denom info', async t => {
const c1 = await orc.getChain(mockChainInfo.chainId);

{
const actual = orc.getBrandInfo('utoken1');
const actual = orc.getDenomInfo('utoken1');
console.log('actual', actual);
const info = await actual.chain.getChainInfo();
t.deepEqual(info, mockChainInfo);
Expand All @@ -200,7 +200,7 @@ test.serial('asset / denom info', async t => {

const ag = await orc.getChain('agoric');
{
const actual = orc.getBrandInfo(agDenom);
const actual = orc.getDenomInfo(agDenom);

t.deepEqual(actual, {
chain: ag,
Expand All @@ -223,11 +223,11 @@ test.serial('asset / denom info', async t => {
});

const missingGetChain = orchestrate('missing getChain', {}, async orc => {
const actual = orc.getBrandInfo('utoken2');
const actual = orc.getDenomInfo('utoken2');
});

await t.throwsAsync(vt.when(missingGetChain()), {
message: 'use getChain("anotherChain") before getBrandInfo("utoken2")',
message: 'use getChain("anotherChain") before getDenomInfo("utoken2")',
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/orchestration/test/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ expectNotType<CosmosValidatorAddress>(chainAddr);
// Negative test
expectNotType<() => Promise<number>>(vowFn);

const getBrandInfo: HostOf<Orchestrator['getBrandInfo']> = null as any;
const chainHostOf = getBrandInfo('uatom').chain;
const getDenomInfo: HostOf<Orchestrator['getDenomInfo']> = null as any;
const chainHostOf = getDenomInfo('uatom').chain;
expectType<Vow<any>>(chainHostOf.getChainInfo());
}

Expand Down

0 comments on commit 52ebb4a

Please sign in to comment.