Skip to content

Commit

Permalink
use concurrentMap of 1 to reduce rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
ltyu committed Oct 7, 2024
1 parent c56fad1 commit 7a924b2
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions typescript/cli/src/deploy/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
Address,
ProtocolType,
assert,
concurrentMap,
objFilter,
objKeys,
objMap,
Expand Down Expand Up @@ -624,43 +625,42 @@ async function enrollRemoteRouters(
(_, contracts) => getRouter(contracts).address,
);
const allChains = Object.keys(deployedRouters);
await concurrentMap(1, allChains, async (chain) => {
const contracts = deployedContractsMap[chain];
const router = getRouter(contracts); // Assume deployedContract always has 1 value

// Mutate the config.remoteRouters by setting it to all other routers to update
const warpRouteReader = new EvmERC20WarpRouteReader(multiProvider, chain);
const mutatedWarpRouteConfig = await warpRouteReader.deriveWarpRouteConfig(
router.address,
);
const evmERC20WarpModule = new EvmERC20WarpModule(multiProvider, {
config: mutatedWarpRouteConfig,
chain,
addresses: { deployedTokenRoute: router.address },
});

await promiseObjAll(
objMap(deployedContractsMap, async (chain, contracts) => {
const router = getRouter(contracts); // Assume deployedContract always has 1 value
const otherChains = multiProvider
.getRemoteChains(chain)
.filter((c) => allChains.includes(c));

// Mutate the config.remoteRouters by setting it to all other routers to update
const warpRouteReader = new EvmERC20WarpRouteReader(multiProvider, chain);
const mutatedWarpRouteConfig =
await warpRouteReader.deriveWarpRouteConfig(router.address);
const evmERC20WarpModule = new EvmERC20WarpModule(multiProvider, {
config: mutatedWarpRouteConfig,
chain,
addresses: { deployedTokenRoute: router.address },
});

const otherChains = multiProvider
.getRemoteChains(chain)
.filter((c) => allChains.includes(c));
mutatedWarpRouteConfig.remoteRouters = otherChains.reduce<RemoteRouters>(
(remoteRouters, chain) => {
remoteRouters[multiProvider.getDomainId(chain)] =
deployedRouters[chain];
return remoteRouters;
},
{},
);
const mutatedConfigTxs: AnnotatedEV5Transaction[] =
await evmERC20WarpModule.update(mutatedWarpRouteConfig);

mutatedWarpRouteConfig.remoteRouters = otherChains.reduce<RemoteRouters>(
(remoteRouters, chain) => {
remoteRouters[multiProvider.getDomainId(chain)] =
deployedRouters[chain];
return remoteRouters;
},
{},
if (mutatedConfigTxs.length == 0)
return logGreen(
`Warp config on ${chain} is the same as target. No updates needed.`,
);
const mutatedConfigTxs: AnnotatedEV5Transaction[] =
await evmERC20WarpModule.update(mutatedWarpRouteConfig);

if (mutatedConfigTxs.length == 0)
return logGreen(
`Warp config on ${chain} is the same as target. No updates needed.`,
);
await submitWarpApplyTransactions(chain, params, mutatedConfigTxs);
}),
);
await submitWarpApplyTransactions(chain, params, mutatedConfigTxs);
});
}

function getRouter(contracts: HyperlaneContracts<HypERC20Factories>) {
Expand Down

0 comments on commit 7a924b2

Please sign in to comment.