Skip to content

Commit

Permalink
chore: normalize chain info
Browse files Browse the repository at this point in the history
- counterParty -> counterparty
- prefer camelCase to snake_case for JS conventions
- prefer flattened counterparty fields (counterpartyConnectionId)
  • Loading branch information
0xpatrickdev committed Sep 18, 2024
1 parent f6ca68a commit 98e4e9b
Show file tree
Hide file tree
Showing 20 changed files with 714 additions and 938 deletions.
6 changes: 3 additions & 3 deletions multichain-testing/tools/ibc-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ export const makeIBCTransferMsg = (
throw Error(
`No connection found between ${sender.chainName} and ${destination.chainName}`,
);
const { counterPartyPortId, counterPartyChannelId } =
const { counterpartyPortId, counterpartyChannelId } =
connection.transferChannel;

const msgTransfer = MsgTransfer.fromPartial({
sender: sender.address,
receiver: destination.address,
token: { denom: amount.denom, amount: String(amount.value) },
sourcePort: counterPartyPortId,
sourceChannel: counterPartyChannelId,
sourcePort: counterpartyPortId,
sourceChannel: counterpartyChannelId,
timeoutHeight,
timeoutTimestamp: timeoutHeight
? undefined
Expand Down
12 changes: 5 additions & 7 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ test.serial('config', async t => {
);
t.like(connection, {
id: 'connection-1',
client_id: '07-tendermint-1',
counterparty: {
client_id: '07-tendermint-2109',
connection_id: 'connection-1649',
},
clientId: '07-tendermint-1',
counterpartyClientId: '07-tendermint-2109',
counterpartyConnectionId: 'connection-1649',
transferChannel: {
counterPartyChannelId: 'channel-320',
counterpartyChannelId: 'channel-320',
channelId: 'channel-1',
},
});
Expand Down Expand Up @@ -278,7 +276,7 @@ test.serial('revise chain info', async t => {
);
t.like(connection, {
id: 'connection-1',
client_id: '07-tendermint-2',
clientId: '07-tendermint-2',
});
});

Expand Down
204 changes: 102 additions & 102 deletions packages/boot/test/bootstrapTests/snapshots/orchestration.test.ts.md

Large diffs are not rendered by default.

Binary file not shown.
12 changes: 5 additions & 7 deletions packages/builders/scripts/testing/append-chain-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ const chainInfo = {
connections: {
'cosmoshub-4': {
id: 'connection-99',
client_id: '07-tendermint-3',
counterparty: {
client_id: '07-tendermint-2',
connection_id: 'connection-1',
},
clientId: '07-tendermint-3',
counterpartyClientId: '07-tendermint-2',
counterpartyConnectionId: 'connection-1',
state: 3 /* IBCConnectionState.STATE_OPEN */,
transferChannel: {
portId: 'transfer',
channelId: 'channel-1',
counterPartyChannelId: 'channel-1',
counterPartyPortId: 'transfer',
counterpartyChannelId: 'channel-1',
counterpartyPortId: 'transfer',
ordering: 1 /* Order.ORDER_UNORDERED */,
state: 3 /* IBCConnectionState.STATE_OPEN */,
version: 'ics20-1',
Expand Down
12 changes: 5 additions & 7 deletions packages/builders/scripts/testing/tweak-chain-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ const chainInfo = {
connections: {
'cosmoshub-4': {
id: 'connection-99',
client_id: '07-tendermint-3',
counterparty: {
client_id: '07-tendermint-2',
connection_id: 'connection-1',
},
clientId: '07-tendermint-3',
counterpartyClientId: '07-tendermint-2',
counterpartyConnectionId: 'connection-1',
state: 3 /* IBCConnectionState.STATE_OPEN */,
transferChannel: {
portId: 'transfer',
channelId: 'channel-1',
counterPartyChannelId: 'channel-1',
counterPartyPortId: 'transfer',
counterpartyChannelId: 'channel-1',
counterpartyPortId: 'transfer',
ordering: 1 /* Order.ORDER_UNORDERED */,
state: 3 /* IBCConnectionState.STATE_OPEN */,
version: 'ics20-1',
Expand Down
22 changes: 10 additions & 12 deletions packages/orchestration/src/cosmos-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ export type CosmosValidatorAddress = ChainAddress & {
/** Represents an IBC Connection between two chains, which can contain multiple Channels. */
export interface IBCConnectionInfo {
id: IBCConnectionID; // e.g. connection-0
client_id: string; // '07-tendermint-0'
clientId: string; // '07-tendermint-0'
state: IBCConnectionState;
counterparty: {
client_id: string;
connection_id: IBCConnectionID;
};
counterpartyClientId: string;
counterpartyConnectionId: IBCConnectionID;
transferChannel: {
portId: string;
channelId: IBCChannelID;
counterPartyPortId: string;
counterPartyChannelId: IBCChannelID;
counterpartyPortId: string;
counterpartyChannelId: IBCChannelID;
ordering: Order;
state: IBCChannelState;
version: string; // e.eg. 'ics20-1'
Expand All @@ -66,16 +64,16 @@ export interface CosmosAssetInfo extends Record<string, unknown> {
name: string;
display: string;
symbol: string;
denom_units: Array<{ denom: Denom; exponent: number }>;
denomUnits: Array<{ denom: Denom; exponent: number }>;
traces?: Array<{
type: 'ibc';
counterparty: {
chain_name: string;
base_denom: Denom;
channel_id: IBCChannelID;
chainName: string;
baseDenom: Denom;
channelId: IBCChannelID;
};
chain: {
channel_id: IBCChannelID;
channelId: IBCChannelID;
path: string;
};
}>;
Expand Down
4 changes: 2 additions & 2 deletions packages/orchestration/src/examples/auto-stake-it.flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const makeAccounts = async (
agoricChainId,
chainId,
);
assert(transferChannel.counterPartyChannelId, 'unable to find sourceChannel');
assert(transferChannel.counterpartyChannelId, 'unable to find sourceChannel');

const localDenom = `ibc/${denomHash({ denom: remoteDenom, channelId: transferChannel.channelId })}`;

Expand All @@ -69,7 +69,7 @@ export const makeAccounts = async (
validator,
localChainAddress,
remoteChainAddress,
sourceChannel: transferChannel.counterPartyChannelId,
sourceChannel: transferChannel.counterpartyChannelId,
remoteDenom,
localDenom,
});
Expand Down
22 changes: 10 additions & 12 deletions packages/orchestration/src/exos/chain-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,17 @@ export const connectionKey = (chainId1, chainId2) => {
const reverseConnInfo = connInfo => {
const { transferChannel } = connInfo;
return {
id: connInfo.counterparty.connection_id,
client_id: connInfo.counterparty.client_id,
counterparty: {
client_id: connInfo.client_id,
connection_id: connInfo.id,
},
id: connInfo.counterpartyConnectionId,
clientId: connInfo.counterpartyClientId,
counterpartyClientId: connInfo.clientId,
counterpartyConnectionId: connInfo.id,
state: connInfo.state,
transferChannel: {
...transferChannel,
channelId: transferChannel.counterPartyChannelId,
counterPartyChannelId: transferChannel.channelId,
portId: transferChannel.counterPartyPortId,
counterPartyPortId: transferChannel.portId,
channelId: transferChannel.counterpartyChannelId,
counterpartyChannelId: transferChannel.channelId,
portId: transferChannel.counterpartyPortId,
counterpartyPortId: transferChannel.portId,
},
};
};
Expand Down Expand Up @@ -434,8 +432,8 @@ export const registerAssets = (chainHub, name, assets) => {
? [name, name, base]
: [
name,
traces[0].counterparty.chain_name,
traces[0].counterparty.base_denom,
traces[0].counterparty.chainName,
traces[0].counterparty.baseDenom,
];
chainHub.registerAsset(base, { chainName, baseName, baseDenom });
}
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/exos/remote-chain-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const prepareRemoteChainFacadeKit = (

const makeAccountV = E(orchestration).makeAccount(
remoteChainInfo.chainId,
connectionInfo.counterparty.connection_id,
connectionInfo.counterpartyConnectionId,
connectionInfo.id,
);

Expand Down
Loading

0 comments on commit 98e4e9b

Please sign in to comment.