Skip to content

Commit

Permalink
Update extend to output new artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
ltyu committed Jul 9, 2024
1 parent db6426f commit dcab26c
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions typescript/cli/src/deploy/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import {
WarpRouteDeployConfigSchema,
attachContractsMap,
getTokenConnectionId,
hypERC20factories,
isTokenMetadata,
serializeContracts,
} from '@hyperlane-xyz/sdk';
import {
ProtocolType,
assert,
objFilter,
objMap,
promiseObjAll,
} from '@hyperlane-xyz/utils';
Expand Down Expand Up @@ -364,45 +366,41 @@ export async function runWarpRouteApply(params: ApplyParams) {
const warpCoreChains = Object.keys(warpCoreByChain);
if (warpDeployChains.length > warpCoreChains.length) {
logGray('Extending deployed Warp configs');
// Only chains that have not been deployed
const chainsToDeploy = warpDeployChains.filter(
(chain) => !warpCoreChains.includes(chain),
// Deploy with the additional config
const additionalConfig = objFilter(
warpDeployConfig,
(chain, _config): _config is any => !warpCoreChains.includes(chain),
);

const newWarpDeployConfig = chainsToDeploy.reduce<WarpRouteDeployConfig>(
(result, chain) => {
result[chain] = warpDeployConfig[chain];
return result;
},
{},
);
// @TODO handle synthetic addition because it needs to derive from one of the collateral

// Deploys
const newDeployedContracts = await executeDeploy({
context,
warpDeployConfig: newWarpDeployConfig,
warpDeployConfig: additionalConfig,
});

// TODO Enroll with existing chains
// @TODO Enroll with existing chains

// Merge with existing artifacts
const mergedDeployParams = {
...params,
warpDeployConfig: { ...warpDeployConfig, ...newWarpDeployConfig },
};

const mergedContracts = {
...attachContractsMap(),
...newDeployedContracts,
};
console.log('mergedDeployParams', mergedDeployParams);
const warpCoreConfig = await getWarpCoreConfig(
mergedDeployParams,
mergedContracts,
// Get existing contracts from config to merge with newly deployed ones
const deployedConfig = objFilter(
warpDeployConfig,
(chain, _config): _config is any => warpCoreChains.includes(chain),
);
const existingDeployedAddresses = objMap(
deployedConfig,
(chain, config) => {
return {
[config.type]: warpCoreByChain[chain].addressOrDenom!,
};
},
);
console.log('warpCoreConfig', warpCoreConfig);

// await writeDeploymentArtifacts(warpCoreConfig, context);
const updatedWarpCoreConfig = await getWarpCoreConfig(params, {
...attachContractsMap(existingDeployedAddresses, hypERC20factories),
...newDeployedContracts,
});
WarpCoreConfigSchema.parse(updatedWarpCoreConfig);
await writeDeploymentArtifacts(updatedWarpCoreConfig, context);
} else if (warpDeployChains.length === warpCoreChains.length) {
// Attempt to update Warp Routes
// Can update existing or deploy new contracts
Expand Down

0 comments on commit dcab26c

Please sign in to comment.