Generalize matching list agent config fn (#3458)

### Description

Generalizes `routerMatchingList` to `matchingList` for use with
asymmetric app artifacts

### Drive-by changes

- migrate to `matchingList` for some app context agent config

### Related issues

- Fixes https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/3441

### Backward compatibility

- Yes

### Testing

Unit tests
pull/3466/head
Yorke Rhodes 8 months ago committed by GitHub
parent dcb67e97da
commit 5514ab1deb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      typescript/infra/config/environments/mainnet3/agent.ts
  2. 6
      typescript/infra/config/environments/mainnet3/warp/inevm-USDC-addresses.json
  3. 6
      typescript/infra/config/environments/mainnet3/warp/inevm-USDT-addresses.json
  4. 26
      typescript/infra/src/config/agent/relayer.ts

@ -13,6 +13,7 @@ import {
} from '../../../src/config';
import {
GasPaymentEnforcementConfig,
matchingList,
routerMatchingList,
} from '../../../src/config/agent/relayer';
import { ALL_KEY_ROLES, Role } from '../../../src/roles';
@ -160,11 +161,11 @@ const hyperlane: RootAgentConfig = {
},
{
name: 'inevm_ethereum_usdc',
matchingList: routerMatchingList(inevmEthereumUsdcAddresses),
matchingList: matchingList(inevmEthereumUsdcAddresses),
},
{
name: 'inevm_ethereum_usdt',
matchingList: routerMatchingList(inevmEthereumUsdtAddresses),
matchingList: matchingList(inevmEthereumUsdtAddresses),
},
{
name: 'viction_ethereum_eth',

@ -1,10 +1,8 @@
{
"inevm": {
"router": "0x8358D8291e3bEDb04804975eEa0fe9fe0fAfB147",
"type": "HypERC20"
"synthetic": "0x8358D8291e3bEDb04804975eEa0fe9fe0fAfB147"
},
"ethereum": {
"router": "0xED56728fb977b0bBdacf65bCdD5e17Bb7e84504f",
"type": "HypERC20Collateral"
"collateral": "0xED56728fb977b0bBdacf65bCdD5e17Bb7e84504f"
}
}

@ -1,10 +1,8 @@
{
"inevm": {
"router": "0x97423A68BAe94b5De52d767a17aBCc54c157c0E5",
"type": "HypERC20"
"synthetic": "0x97423A68BAe94b5De52d767a17aBCc54c157c0E5"
},
"ethereum": {
"router": "0xab852e67bf03E74C89aF67C4BA97dd1088D3dA19",
"type": "HypERC20Collateral"
"collateral": "0xab852e67bf03E74C89aF67C4BA97dd1088D3dA19"
}
}

@ -4,12 +4,15 @@ import {
AgentConfig,
ChainMap,
GasPaymentEnforcement,
HyperlaneAddresses,
HyperlaneAddressesMap,
HyperlaneFactories,
MatchingList,
RelayerConfig as RelayerAgentConfig,
chainMetadata,
getDomainId,
} from '@hyperlane-xyz/sdk';
import { ProtocolType, addressToBytes32 } from '@hyperlane-xyz/utils';
import { Address, ProtocolType, addressToBytes32 } from '@hyperlane-xyz/utils';
import { AgentAwsUser } from '../../agents/aws';
import { Role } from '../../roles';
@ -152,11 +155,17 @@ export class RelayerConfigHelper extends AgentConfigHelper<RelayerConfig> {
}
}
// Create a matching list for the given router addresses
export function routerMatchingList(
routers: ChainMap<{ router: string }>,
routers: ChainMap<{ router: Address }>,
): MatchingList {
const chains = Object.keys(routers);
return matchingList(routers);
}
// Create a matching list for the given contract addresses
export function matchingList<F extends HyperlaneFactories>(
addressesMap: HyperlaneAddressesMap<F>,
): MatchingList {
const chains = Object.keys(addressesMap);
// matching list must have at least one element so bypass and check before returning
const matchingList: MatchingList = [];
@ -167,11 +176,16 @@ export function routerMatchingList(
continue;
}
const uniqueAddresses = (addresses: HyperlaneAddresses<F>) =>
Array.from(new Set(Object.values(addresses)).values()).map((s) =>
addressToBytes32(s),
);
matchingList.push({
originDomain: getDomainId(chainMetadata[source]),
senderAddress: addressToBytes32(routers[source].router),
senderAddress: uniqueAddresses(addressesMap[source]),
destinationDomain: getDomainId(chainMetadata[destination]),
recipientAddress: addressToBytes32(routers[destination].router),
recipientAddress: uniqueAddresses(addressesMap[destination]),
});
}
}

Loading…
Cancel
Save