Skip to content

Commit

Permalink
feat: parse warp route artifacts with token-specific key names
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-savu committed Mar 14, 2024
1 parent ae0990a commit 9061c84
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
17 changes: 14 additions & 3 deletions typescript/infra/config/environments/mainnet3/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {
GasPaymentEnforcementConfig,
routerMatchingList,
warpRouteMatchingList,
} from '../../../src/config/agent/relayer';
import { ALL_KEY_ROLES, Role } from '../../../src/roles';
import { Contexts } from '../../contexts';
Expand All @@ -22,7 +23,9 @@ import { environment, supportedChainNames } from './chains';
import { helloWorld } from './helloworld';
import { validatorChainConfig } from './validators';
import arbitrumTIAAddresses from './warp/arbitrum-TIA-addresses.json';
import injectiveInevmAddresses from './warp/injective-inevm-addresses.json';
import injectiveInevmUsdcAddresses from './warp/inevm-USDC-addresses.json';
import injectiveInevmUsdtAddresses from './warp/inevm-USDT-addresses.json';
import injectiveInevmInjAddresses from './warp/injective-inevm-addresses.json';
import mantaTIAAddresses from './warp/manta-TIA-addresses.json';

const releaseCandidateHelloworldMatchingList = routerMatchingList(
Expand Down Expand Up @@ -138,7 +141,7 @@ const hyperlane: RootAgentConfig = {
// we saw some issues with IGP indexing.
{
type: GasPaymentEnforcementPolicyType.None,
matchingList: routerMatchingList(injectiveInevmAddresses),
matchingList: routerMatchingList(injectiveInevmInjAddresses),
},
...gasPaymentEnforcement,
],
Expand All @@ -151,7 +154,15 @@ const hyperlane: RootAgentConfig = {
},
{
name: 'injective_inevm_inj',
matchingList: routerMatchingList(injectiveInevmAddresses),
matchingList: routerMatchingList(injectiveInevmInjAddresses),
},
{
name: 'injective_inevm_usdc',
matchingList: warpRouteMatchingList(injectiveInevmUsdcAddresses),
},
{
name: 'injective_inevm_usdt',
matchingList: warpRouteMatchingList(injectiveInevmUsdtAddresses),
},
],
},
Expand Down
27 changes: 27 additions & 0 deletions typescript/infra/src/config/agent/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,30 @@ export function routerMatchingList(

return matchingList;
}

type HypErc20Address = { HypERC20: string };
type HypERC20CollateralAddress = { HypERC20Collateral: string };
type HypErc721Address = { HypERC721: string };
type HypErc721CollateralAddress = { HypERC721Collateral: string };
type HypNativeAddress = { HypNativeAddress: string };

type WarpRoute =
| HypErc20Address
| HypERC20CollateralAddress
| HypErc721Address
| HypErc721CollateralAddress
| HypNativeAddress;

// Create a matching list for the given warp route addresses
export function warpRouteMatchingList(
routers: ChainMap<WarpRoute>,
): MatchingList {
let standardizedRouters: ChainMap<{ router: string }> = {};
Object.entries(routers).forEach(([chain, route]) => {
let routerAddress = Object.values(route);
// Due to duck typing there could be more than one value in the route object,
// but the line below assumes there is only one.
standardizedRouters[chain] = { router: routerAddress[0] };
});
return routerMatchingList(standardizedRouters);
}

0 comments on commit 9061c84

Please sign in to comment.