fix: warp route deployment verification (#3494)

snapshot-igp-config
Paul Balaji 8 months ago committed by GitHub
parent 4e7a43be6a
commit a9881dc128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      typescript/cli/src/deploy/warp.ts
  2. 41
      typescript/sdk/src/deploy/HyperlaneDeployer.ts
  3. 10
      typescript/sdk/src/deploy/verify/ContractVerifier.ts
  4. 16
      typescript/sdk/src/token/contracts.ts
  5. 61
      typescript/sdk/src/token/deploy.ts

@ -267,7 +267,7 @@ async function executeDeploy(params: DeployParams) {
log('Writing deployment artifacts'); log('Writing deployment artifacts');
writeTokenDeploymentArtifacts(contractsFilePath, deployedContracts, params); writeTokenDeploymentArtifacts(contractsFilePath, deployedContracts, params);
writeWarpUiTokenConfig(tokenConfigPath, deployedContracts, params); writeWarpConfig(tokenConfigPath, deployedContracts, params);
logBlue('Deployment is complete!'); logBlue('Deployment is complete!');
logBlue(`Contract address artifacts are in ${contractsFilePath}`); logBlue(`Contract address artifacts are in ${contractsFilePath}`);
@ -330,7 +330,7 @@ function writeTokenDeploymentArtifacts(
writeJson(filePath, artifacts); writeJson(filePath, artifacts);
} }
function writeWarpUiTokenConfig( function writeWarpConfig(
filePath: string, filePath: string,
contracts: HyperlaneContractsMap<TokenFactories>, contracts: HyperlaneContractsMap<TokenFactories>,
{ configMap, metadata }: DeployParams, { configMap, metadata }: DeployParams,

@ -384,9 +384,23 @@ export abstract class HyperlaneDeployer<
return contract; return contract;
} }
async deployContract<K extends keyof Factories>( /**
* Deploys a contract with a specified name.
*
* This is a generic function capable of deploying any contract type, defined within the `Factories` type, to a specified chain.
*
* @param {ChainName} chain - The name of the chain on which the contract is to be deployed.
* @param {K} contractKey - The key identifying the factory to use for deployment.
* @param {string} contractName - The name of the contract to deploy. This must match the contract source code.
* @param {Parameters<Factories[K]['deploy']>} constructorArgs - Arguments for the contract's constructor.
* @param {Parameters<Awaited<ReturnType<Factories[K]['deploy']>>['initialize']>?} initializeArgs - Optional arguments for the contract's initialization function.
* @param {boolean} shouldRecover - Flag indicating whether to attempt recovery if deployment fails.
* @returns {Promise<HyperlaneContracts<Factories>[K]>} A promise that resolves to the deployed contract instance.
*/
async deployContractWithName<K extends keyof Factories>(
chain: ChainName, chain: ChainName,
contractName: K, contractKey: K,
contractName: string,
constructorArgs: Parameters<Factories[K]['deploy']>, constructorArgs: Parameters<Factories[K]['deploy']>,
initializeArgs?: Parameters< initializeArgs?: Parameters<
Awaited<ReturnType<Factories[K]['deploy']>>['initialize'] Awaited<ReturnType<Factories[K]['deploy']>>['initialize']
@ -395,8 +409,8 @@ export abstract class HyperlaneDeployer<
): Promise<HyperlaneContracts<Factories>[K]> { ): Promise<HyperlaneContracts<Factories>[K]> {
const contract = await this.deployContractFromFactory( const contract = await this.deployContractFromFactory(
chain, chain,
this.factories[contractName], this.factories[contractKey],
contractName.toString(), contractName,
constructorArgs, constructorArgs,
initializeArgs, initializeArgs,
shouldRecover, shouldRecover,
@ -405,6 +419,25 @@ export abstract class HyperlaneDeployer<
return contract; return contract;
} }
async deployContract<K extends keyof Factories>(
chain: ChainName,
contractKey: K,
constructorArgs: Parameters<Factories[K]['deploy']>,
initializeArgs?: Parameters<
Awaited<ReturnType<Factories[K]['deploy']>>['initialize']
>,
shouldRecover = true,
): Promise<HyperlaneContracts<Factories>[K]> {
return this.deployContractWithName(
chain,
contractKey,
contractKey.toString(),
constructorArgs,
initializeArgs,
shouldRecover,
);
}
protected async changeAdmin( protected async changeAdmin(
chain: ChainName, chain: ChainName,
proxy: ITransparentUpgradeableProxy, proxy: ITransparentUpgradeableProxy,

@ -73,7 +73,11 @@ export class ContractVerifier {
verificationLogger: Logger, verificationLogger: Logger,
options?: FormOptions<typeof action>, options?: FormOptions<typeof action>,
): Promise<any> { ): Promise<any> {
const { apiUrl, family } = this.multiProvider.getExplorerApi(chain); const {
apiUrl,
family,
apiKey = this.apiKeys[chain],
} = this.multiProvider.getExplorerApi(chain);
const params = new URLSearchParams(); const params = new URLSearchParams();
params.set('module', 'contract'); params.set('module', 'contract');
params.set('action', action); params.set('action', action);
@ -84,8 +88,8 @@ export class ContractVerifier {
} }
// only include apikey if provided & not blockscout // only include apikey if provided & not blockscout
if (family !== ExplorerFamily.Blockscout && this.apiKeys[chain]) { if (family !== ExplorerFamily.Blockscout && apiKey) {
params.set('apikey', this.apiKeys[chain]); params.set('apikey', apiKey);
} }
const url = new URL(apiUrl); const url = new URL(apiUrl);

@ -14,6 +14,15 @@ import {
import { TokenType } from './config'; import { TokenType } from './config';
export const hypERC20contracts = {
[TokenType.fastCollateral]: 'FastHypERC20Collateral',
[TokenType.fastSynthetic]: 'FastHypERC20',
[TokenType.synthetic]: 'HypERC20',
[TokenType.collateral]: 'HypERC20Collateral',
[TokenType.collateralVault]: 'HypERC20CollateralVaultDeposit',
[TokenType.native]: 'HypNative',
[TokenType.nativeScaled]: 'HypNativeScaled',
};
export const hypERC20factories = { export const hypERC20factories = {
[TokenType.fastCollateral]: new FastHypERC20Collateral__factory(), [TokenType.fastCollateral]: new FastHypERC20Collateral__factory(),
[TokenType.fastSynthetic]: new FastHypERC20__factory(), [TokenType.fastSynthetic]: new FastHypERC20__factory(),
@ -25,13 +34,18 @@ export const hypERC20factories = {
}; };
export type HypERC20Factories = typeof hypERC20factories; export type HypERC20Factories = typeof hypERC20factories;
export const hypERC721contracts = {
[TokenType.collateralUri]: 'HypERC721URICollateral',
[TokenType.collateral]: 'HypERC721Collateral',
[TokenType.syntheticUri]: 'HypERC721URIStorage',
[TokenType.synthetic]: 'HypERC721',
};
export const hypERC721factories = { export const hypERC721factories = {
[TokenType.collateralUri]: new HypERC721URICollateral__factory(), [TokenType.collateralUri]: new HypERC721URICollateral__factory(),
[TokenType.collateral]: new HypERC721Collateral__factory(), [TokenType.collateral]: new HypERC721Collateral__factory(),
[TokenType.syntheticUri]: new HypERC721URIStorage__factory(), [TokenType.syntheticUri]: new HypERC721URIStorage__factory(),
[TokenType.synthetic]: new HypERC721__factory(), [TokenType.synthetic]: new HypERC721__factory(),
}; };
export type HypERC721Factories = typeof hypERC721factories; export type HypERC721Factories = typeof hypERC721factories;
export type TokenFactories = HypERC20Factories | HypERC721Factories; export type TokenFactories = HypERC20Factories | HypERC721Factories;

@ -44,7 +44,9 @@ import {
import { import {
HypERC20Factories, HypERC20Factories,
HypERC721Factories, HypERC721Factories,
hypERC20contracts,
hypERC20factories, hypERC20factories,
hypERC721contracts,
hypERC721factories, hypERC721factories,
} from './contracts'; } from './contracts';
@ -134,27 +136,29 @@ export class HypERC20Deployer extends GasRouterDeployer<
chain: ChainName, chain: ChainName,
config: HypERC20CollateralConfig, config: HypERC20CollateralConfig,
): Promise<HypERC20Collateral> { ): Promise<HypERC20Collateral> {
let contractName: let tokenType:
| TokenType.fastCollateral | TokenType.fastCollateral
| TokenType.collateral | TokenType.collateral
| TokenType.collateralVault; | TokenType.collateralVault;
switch (config.type) { switch (config.type) {
case TokenType.fastSynthetic || TokenType.fastCollateral: case TokenType.fastSynthetic || TokenType.fastCollateral:
contractName = TokenType.fastCollateral; tokenType = TokenType.fastCollateral;
break; break;
case TokenType.collateral: case TokenType.collateral:
contractName = TokenType.collateral; tokenType = TokenType.collateral;
break; break;
case TokenType.collateralVault: case TokenType.collateralVault:
contractName = TokenType.collateralVault; tokenType = TokenType.collateralVault;
break; break;
default: default:
throw new Error(`Unknown collateral type ${config.type}`); throw new Error(`Unknown collateral type ${config.type}`);
} }
return this.deployContract(chain, contractName, [ return this.deployContractWithName(
config.token, chain,
config.mailbox, tokenType,
]); hypERC20contracts[tokenType],
[config.token, config.mailbox],
);
} }
protected async deployNative( protected async deployNative(
@ -162,12 +166,19 @@ export class HypERC20Deployer extends GasRouterDeployer<
config: HypNativeConfig, config: HypNativeConfig,
): Promise<HypNative> { ): Promise<HypNative> {
if (config.scale) { if (config.scale) {
return this.deployContract(chain, TokenType.nativeScaled, [ return this.deployContractWithName(
config.scale, chain,
config.mailbox, TokenType.nativeScaled,
]); hypERC20contracts[TokenType.nativeScaled],
[config.scale, config.mailbox],
);
} else { } else {
return this.deployContract(chain, TokenType.native, [config.mailbox]); return this.deployContractWithName(
chain,
TokenType.native,
hypERC20contracts[TokenType.native],
[config.mailbox],
);
} }
} }
@ -175,9 +186,13 @@ export class HypERC20Deployer extends GasRouterDeployer<
chain: ChainName, chain: ChainName,
config: HypERC20Config, config: HypERC20Config,
): Promise<HypERC20> { ): Promise<HypERC20> {
const router: HypERC20 = await this.deployContract( const tokenType = isFastConfig(config)
? TokenType.fastSynthetic
: TokenType.synthetic;
const router: HypERC20 = await this.deployContractWithName(
chain, chain,
isFastConfig(config) ? TokenType.fastSynthetic : TokenType.synthetic, tokenType,
hypERC20contracts[tokenType],
[config.decimals, config.mailbox], [config.decimals, config.mailbox],
); );
try { try {
@ -326,9 +341,13 @@ export class HypERC721Deployer extends GasRouterDeployer<
chain: ChainName, chain: ChainName,
config: HypERC721CollateralConfig, config: HypERC721CollateralConfig,
): Promise<HypERC721Collateral> { ): Promise<HypERC721Collateral> {
return this.deployContract( const tokenType = isUriConfig(config)
? TokenType.collateralUri
: TokenType.collateral;
return this.deployContractWithName(
chain, chain,
isUriConfig(config) ? TokenType.collateralUri : TokenType.collateral, tokenType,
hypERC721contracts[tokenType],
[config.token, config.mailbox], [config.token, config.mailbox],
); );
} }
@ -337,9 +356,13 @@ export class HypERC721Deployer extends GasRouterDeployer<
chain: ChainName, chain: ChainName,
config: HypERC721Config, config: HypERC721Config,
): Promise<HypERC721> { ): Promise<HypERC721> {
const router = await this.deployContract( const tokenType = isUriConfig(config)
? TokenType.syntheticUri
: TokenType.synthetic;
const router = await this.deployContractWithName(
chain, chain,
isUriConfig(config) ? TokenType.syntheticUri : TokenType.synthetic, tokenType,
hypERC721contracts[tokenType],
[config.mailbox], [config.mailbox],
); );
await this.multiProvider.handleTx( await this.multiProvider.handleTx(

Loading…
Cancel
Save