diff --git a/typescript/infra/config/environments/mainnet3/warp/addresses.json b/typescript/infra/config/environments/mainnet3/warp/addresses.json index c0f9371c34..f1fb96eec3 100644 --- a/typescript/infra/config/environments/mainnet3/warp/addresses.json +++ b/typescript/infra/config/environments/mainnet3/warp/addresses.json @@ -7,3 +7,12 @@ "router": "0x26f32245fCF5Ad53159E875d5Cae62aEcf19c2d4" } } + +// { +// "injective": [{, +// "type": "sythetic", +// "standard": "ERC20", +// "name": "USDC", +// "router": "inj1mv9tjvkaw7x8w8y9vds8pkfq46g2vcfkjehc6k" +// }], +// } diff --git a/typescript/infra/scripts/deploy.ts b/typescript/infra/scripts/deploy.ts index e1545c5879..7d13636d65 100644 --- a/typescript/infra/scripts/deploy.ts +++ b/typescript/infra/scripts/deploy.ts @@ -23,7 +23,6 @@ import { import { objMap } from '@hyperlane-xyz/utils'; import { Contexts } from '../config/contexts'; -import { safes } from '../config/environments/mainnet3/owners'; import { deployEnvToSdkEnv } from '../src/config/environment'; import { deployWithArtifacts } from '../src/deployment/deploy'; import { TestQuerySenderDeployer } from '../src/deployment/testcontracts/testquerysender'; @@ -121,19 +120,17 @@ async function main() { multiProvider, ); const routerConfig = core.getRouterConfig(envConfig.owners); - const inevm = { - ...routerConfig.inevm, + const plumetestnet = { + ...routerConfig.plumetestnet, type: TokenType.native, - interchainSecurityModule: ethers.constants.AddressZero, - owner: safes.inevm, }; - const injective = { - ...routerConfig.injective, + const sepolia = { + ...routerConfig.sepolia, type: TokenType.native, }; config = { - inevm, - injective, + plumetestnet, + sepolia, }; deployer = new HypERC20Deployer( multiProvider, diff --git a/typescript/infra/src/deployment/deploy.ts b/typescript/infra/src/deployment/deploy.ts index 5c2f4c1a8d..3325be15dd 100644 --- a/typescript/infra/src/deployment/deploy.ts +++ b/typescript/infra/src/deployment/deploy.ts @@ -16,7 +16,6 @@ import { DeployEnvironment } from '../config'; import { readJSONAtPath, writeJsonAtPath, - writeMergedJSON, writeMergedJSONAtPath, } from '../utils/utils'; diff --git a/typescript/sdk/src/providers/MultiProvider.ts b/typescript/sdk/src/providers/MultiProvider.ts index cca39a7ae8..85e04c06e6 100644 --- a/typescript/sdk/src/providers/MultiProvider.ts +++ b/typescript/sdk/src/providers/MultiProvider.ts @@ -292,7 +292,7 @@ export class MultiProvider extends ChainMetadataManager { // setup contract factory const overrides = this.getTransactionOverrides(chainNameOrId); const signer = this.getSigner(chainNameOrId); - const contractFactory = factory.connect(signer); + const contractFactory = await factory.connect(signer); // estimate gas const deployTx = contractFactory.getDeployTransaction(...params, overrides); diff --git a/typescript/sdk/src/token/config.ts b/typescript/sdk/src/token/config.ts index 5d89509dc6..5e6aaee727 100644 --- a/typescript/sdk/src/token/config.ts +++ b/typescript/sdk/src/token/config.ts @@ -2,6 +2,8 @@ import { ethers } from 'ethers'; import { GasRouterConfig } from '../router/types'; +import { TokenStandard } from './TokenStandard'; + export enum TokenType { synthetic = 'synthetic', fastSynthetic = 'fastSynthetic', @@ -10,11 +12,7 @@ export enum TokenType { fastCollateral = 'fastCollateral', collateralUri = 'collateralUri', native = 'native', -} - -export enum TokenStandard { - ERC20 = 'ERC20', - ERC721 = 'ERC721', + nativeScaled = 'nativeScaled', } // this is for getting a unique artifact key; to differentiate between ERC20/ERC721 diff --git a/typescript/sdk/src/token/contracts.ts b/typescript/sdk/src/token/contracts.ts index ab5327f2f6..fef14c9e52 100644 --- a/typescript/sdk/src/token/contracts.ts +++ b/typescript/sdk/src/token/contracts.ts @@ -11,32 +11,23 @@ import { HypNative__factory, } from '@hyperlane-xyz/core'; -import { TokenStandard, TokenType, getTokenType } from './config'; +import { TokenType } from './config'; export const hypERC20factories = { - [getTokenType(TokenType.fastCollateral, TokenStandard.ERC20)]: - new FastHypERC20Collateral__factory(), - [getTokenType(TokenType.fastSynthetic, TokenStandard.ERC20)]: - new FastHypERC20__factory(), - [getTokenType(TokenType.synthetic, TokenStandard.ERC20)]: - new HypERC20__factory(), - [getTokenType(TokenType.collateral, TokenStandard.ERC20)]: - new HypERC20Collateral__factory(), - [getTokenType(TokenType.native, TokenStandard.ERC20)]: - new HypNative__factory(), - nativescaledERC20: new HypNativeScaled__factory(), + [TokenType.fastCollateral]: new FastHypERC20Collateral__factory(), + [TokenType.fastSynthetic]: new FastHypERC20__factory(), + [TokenType.synthetic]: new HypERC20__factory(), + [TokenType.collateral]: new HypERC20Collateral__factory(), + [TokenType.native]: new HypNative__factory(), + [TokenType.nativeScaled]: new HypNativeScaled__factory(), }; export type HypERC20Factories = typeof hypERC20factories; export const hypERC721factories = { - [getTokenType(TokenType.collateralUri, TokenStandard.ERC721)]: - new HypERC721URICollateral__factory(), - [getTokenType(TokenType.collateral, TokenStandard.ERC721)]: - new HypERC721Collateral__factory(), - [getTokenType(TokenType.syntheticUri, TokenStandard.ERC721)]: - new HypERC721URIStorage__factory(), - [getTokenType(TokenType.synthetic, TokenStandard.ERC721)]: - new HypERC721__factory(), + [TokenType.collateralUri]: new HypERC721URICollateral__factory(), + [TokenType.collateral]: new HypERC721Collateral__factory(), + [TokenType.syntheticUri]: new HypERC721URIStorage__factory(), + [TokenType.synthetic]: new HypERC721__factory(), }; export type HypERC721Factories = typeof hypERC721factories; diff --git a/typescript/sdk/src/token/deploy.ts b/typescript/sdk/src/token/deploy.ts index 5977f4101a..fc56d6d7c6 100644 --- a/typescript/sdk/src/token/deploy.ts +++ b/typescript/sdk/src/token/deploy.ts @@ -33,13 +33,14 @@ import { HypNativeConfig, TokenConfig, TokenMetadata, - TokenStandard, - getTokenType, + TokenType, isCollateralConfig, isErc20Metadata, + isFastConfig, isNativeConfig, isSyntheticConfig, isTokenMetadata, + isUriConfig, } from './config'; import { HypERC20Factories, @@ -134,42 +135,57 @@ export class HypERC20Deployer extends GasRouterDeployer< chain: ChainName, config: HypERC20CollateralConfig, ): Promise { - return (await this.deployContract( - chain, - getTokenType(config.type, TokenStandard.ERC20), - [config.token, config.mailbox], - )) as HypERC20Collateral; + const isFast = isFastConfig(config); + if (isFast) { + return this.deployContract( + chain, + TokenType.fastCollateral, + [config.token, config.mailbox], + ); + } else { + return this.deployContract( + chain, + TokenType.collateral, + [config.token, config.mailbox], + ); + } } protected async deployNative( chain: ChainName, config: HypNativeConfig, ): Promise { - let router: HypNative; if (config.scale) { - router = (await this.deployContract(chain, 'nativescaledERC20', [ - config.scale, - config.mailbox, - ])) as HypNative; - } else { - router = (await this.deployContract( + return this.deployContract( chain, - getTokenType(config.type, TokenStandard.ERC20), - [config.mailbox], - )) as HypNative; + TokenType.nativeScaled, + [config.scale, config.mailbox], + ); + } else { + return this.deployContract(chain, TokenType.native, [ + config.mailbox, + ]); } - return router; } protected async deploySynthetic( chain: ChainName, config: HypERC20Config, ): Promise { - const router = (await this.deployContract( - chain, - getTokenType(config.type, TokenStandard.ERC20), - [config.decimals, config.mailbox], - )) as HypERC20; + let router: HypERC20; + if (isFastConfig(config)) { + router = await this.deployContract( + chain, + TokenType.fastSynthetic, + [config.decimals, config.mailbox], + ); + } else { + router = await this.deployContract( + chain, + TokenType.synthetic, + [config.decimals, config.mailbox], + ); + } try { await this.multiProvider.handleTx( @@ -180,9 +196,7 @@ export class HypERC20Deployer extends GasRouterDeployer< if (!e.message.includes('already initialized')) { throw e; } - this.logger( - `${getTokenType(config.type, TokenStandard.ERC20)} already initialized`, - ); + this.logger(`${config.type} already initialized`); } return router; } @@ -208,7 +222,7 @@ export class HypERC20Deployer extends GasRouterDeployer< throw new Error('Invalid ERC20 token router config'); } await this.configureClient(chain, router, config); - return { [getTokenType(config.type, TokenStandard.ERC20)]: router } as any; + return { [config.type]: router } as any; } async buildTokenMetadata( @@ -319,22 +333,38 @@ export class HypERC721Deployer extends GasRouterDeployer< chain: ChainName, config: HypERC721CollateralConfig, ): Promise { - return (await this.deployContract( - chain, - getTokenType(config.type, TokenStandard.ERC721), - [config.token, config.mailbox], - )) as HypERC721Collateral; + if (isUriConfig(config)) { + return this.deployContract( + chain, + TokenType.collateralUri, + [config.token, config.mailbox], + ); + } else { + return this.deployContract( + chain, + TokenType.collateral, + [config.token, config.mailbox], + ); + } } protected async deploySynthetic( chain: ChainName, config: HypERC721Config, ): Promise { - return (await this.deployContract( - chain, - getTokenType(config.type, TokenStandard.ERC721), - [config.mailbox], - )) as HypERC721; + if (isUriConfig(config)) { + return this.deployContract( + chain, + TokenType.syntheticUri, + [config.mailbox], + ); + } else { + return this.deployContract( + chain, + TokenType.synthetic, + [config.mailbox], + ); + } } router(contracts: HyperlaneContracts) { @@ -355,7 +385,7 @@ export class HypERC721Deployer extends GasRouterDeployer< } else { throw new Error('Invalid ERC721 token router config'); } - return { [getTokenType(config.type, TokenStandard.ERC721)]: router } as any; + return { [config.type]: router } as any; } async buildTokenMetadata(