Add deploy script for Flowers (#13)

* Updates for v2

* Add canonical wrapper

* Use v2 connection client

* Fix prettier

* Update 721 for v2

* Use msg lib

* Update deployer with collateral

* Use better union types

* Rename and organize contracts

* Rename TransferRemoteRouter to TokenRouter

* Update deployers

* Fix tests

* Pull in prerelease versions

* Improve test coverage

* Update yarn lock

* Add tests for collateral

* Fix prettier

* Add bridge router skeleton

* Use Create2 deployments

* Refactor CREATE2 logic

* Fix prettier

* Add HypERC721URIStorage

* Add HypERC721URICollateral

* Add deployer and unit tests for URI relay

* Fix prettier

* Remove bridge router

* Add docstrings

* Use enum for type discriminant

* Fix prettier

* Add deploy script for Flowers

* Update scripts/deploy.ts

Co-authored-by: Yorke Rhodes <yorke@hyperlane.xyz>

* Dont pay for gas for now

* Dont pass ism

* Remove console.log

* PR review

* Update base

* Fix prettier

* Fix lint

* Make mods to Erc20 too

* lint

* Prettier

Co-authored-by: Yorke Rhodes <yorke@hyperlane.xyz>
pull/2435/head
Nam Chu Hoai 2 years ago committed by GitHub
parent 5dd421b54e
commit dea4b2a942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .eslintignore
  2. 5
      contracts/HypERC20.sol
  3. 13
      contracts/HypERC20Collateral.sol
  4. 5
      contracts/HypERC721.sol
  5. 13
      contracts/HypERC721Collateral.sol
  6. 61
      scripts/deploy.ts
  7. 8
      src/deploy.ts
  8. 2
      test/erc20.test.ts
  9. 2
      test/erc721.test.ts

@ -1,5 +1,6 @@
node_modules
dist
coverage
src/types
hardhat.config.ts
types
hardhat.config.ts
scripts

@ -15,7 +15,6 @@ contract HypERC20 is ERC20Upgradeable, TokenRouter {
* @notice Initializes the Hyperlane router, ERC20 metadata, and mints initial supply to deployer.
* @param _mailbox The address of the mailbox contract.
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
* @param _interchainSecurityModule The address of the interchain security module contract.
* @param _totalSupply The initial supply of the token.
* @param _name The name of the token.
* @param _symbol The symbol of the token.
@ -23,7 +22,6 @@ contract HypERC20 is ERC20Upgradeable, TokenRouter {
function initialize(
address _mailbox,
address _interchainGasPaymaster,
address _interchainSecurityModule,
uint256 _totalSupply,
string memory _name,
string memory _symbol
@ -31,8 +29,7 @@ contract HypERC20 is ERC20Upgradeable, TokenRouter {
// transfers ownership to `msg.sender`
__HyperlaneConnectionClient_initialize(
_mailbox,
_interchainGasPaymaster,
_interchainSecurityModule
_interchainGasPaymaster
);
// Initialize ERC20 metadata

@ -20,17 +20,14 @@ contract HypERC20Collateral is TokenRouter {
* @notice Initializes the Hyperlane router.
* @param _mailbox The address of the mailbox contract.
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
* @param _interchainSecurityModule The address of the interchain security module contract.
*/
function initialize(
address _mailbox,
address _interchainGasPaymaster,
address _interchainSecurityModule
) external initializer {
function initialize(address _mailbox, address _interchainGasPaymaster)
external
initializer
{
__HyperlaneConnectionClient_initialize(
_mailbox,
_interchainGasPaymaster,
_interchainSecurityModule
_interchainGasPaymaster
);
}

@ -14,7 +14,6 @@ contract HypERC721 is ERC721EnumerableUpgradeable, TokenRouter {
* @notice Initializes the Hyperlane router, ERC721 metadata, and mints initial supply to deployer.
* @param _mailbox The address of the mailbox contract.
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
* @param _interchainSecurityModule The address of the interchain security module contract.
* @param _mintAmount The amount of NFTs to mint to `msg.sender`.
* @param _name The name of the token.
* @param _symbol The symbol of the token.
@ -22,7 +21,6 @@ contract HypERC721 is ERC721EnumerableUpgradeable, TokenRouter {
function initialize(
address _mailbox,
address _interchainGasPaymaster,
address _interchainSecurityModule,
uint256 _mintAmount,
string memory _name,
string memory _symbol
@ -30,8 +28,7 @@ contract HypERC721 is ERC721EnumerableUpgradeable, TokenRouter {
// transfers ownership to `msg.sender`
__HyperlaneConnectionClient_initialize(
_mailbox,
_interchainGasPaymaster,
_interchainSecurityModule
_interchainGasPaymaster
);
__ERC721_init(_name, _symbol);

@ -20,17 +20,14 @@ contract HypERC721Collateral is TokenRouter {
* @notice Initializes the Hyperlane router.
* @param _mailbox The address of the mailbox contract.
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
* @param _interchainSecurityModule The address of the interchain security module contract.
*/
function initialize(
address _mailbox,
address _interchainGasPaymaster,
address _interchainSecurityModule
) external initializer {
function initialize(address _mailbox, address _interchainGasPaymaster)
external
initializer
{
__HyperlaneConnectionClient_initialize(
_mailbox,
_interchainGasPaymaster,
_interchainSecurityModule
_interchainGasPaymaster
);
}

@ -0,0 +1,61 @@
import { ethers, Wallet } from 'ethers';
import {
Chains,
HyperlaneCore,
MultiProvider,
objMap,
} from '@hyperlane-xyz/sdk';
import { RouterConfig, chainConnectionConfigs } from '@hyperlane-xyz/sdk';
import { TokenConfig, TokenType } from '../src/config';
import { HypERC20Deployer } from '../src/deploy';
const connectionConfigs = {
goerli: {
...chainConnectionConfigs.goerli,
provider: new ethers.providers.JsonRpcProvider(
'https://eth-goerli.public.blastapi.io',
5,
),
},
fuji: chainConnectionConfigs.fuji,
alfajores: chainConnectionConfigs.alfajores,
moonbasealpha: chainConnectionConfigs.moonbasealpha,
};
async function deployNFTWrapper() {
console.info('Getting signer');
const signer = new Wallet(
'pkey',
);
const multiProvider = new MultiProvider(connectionConfigs);
multiProvider.rotateSigner(signer)
const core = HyperlaneCore.fromEnvironment('testnet2', multiProvider);
const config = objMap(connectionConfigs, (chain, c) => ({
type: TokenType.synthetic,
name: 'Dai',
symbol: 'DAI',
totalSupply: 0,
owner: signer.address,
mailbox: '0x1d3aAC239538e6F1831C8708803e61A9EA299Eec',
interchainGasPaymaster: core.getContracts(chain)
.interchainGasPaymaster.address,
} as TokenConfig & RouterConfig))
config.goerli = {
type: TokenType.collateral,
token: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6',
owner: signer.address,
mailbox: '0x1d3aAC239538e6F1831C8708803e61A9EA299Eec',
interchainGasPaymaster: core.getContracts(Chains.goerli)
.interchainGasPaymaster.address,
} as TokenConfig & RouterConfig
const deployer = new HypERC20Deployer(multiProvider, config, core);
await deployer.deploy();
}
deployNFTWrapper().then(console.log).catch(console.error);

@ -1,5 +1,3 @@
import { ethers } from 'ethers';
import {
ChainName,
HyperlaneRouterDeployer,
@ -31,7 +29,6 @@ export class HypERC20Deployer<
chain: Chain,
config: HypERC20Config | HypERC20CollateralConfig,
) {
const ism = config.interchainSecurityModule ?? ethers.constants.AddressZero;
const connection = this.multiProvider.getChainConnection(chain);
if (isCollateralConfig(config)) {
const router = await this.deployContractFromFactory(
@ -44,7 +41,6 @@ export class HypERC20Deployer<
router.initialize(
config.mailbox,
config.interchainGasPaymaster,
ism
),
);
return { router };
@ -58,7 +54,6 @@ export class HypERC20Deployer<
await connection.handleTx(router.initialize(
config.mailbox,
config.interchainGasPaymaster,
ism,
config.totalSupply,
config.name,
config.symbol,
@ -81,7 +76,6 @@ export class HypERC721Deployer<
chain: Chain,
config: HypERC721Config | HypERC721CollateralConfig,
) {
const ism = config.interchainSecurityModule ?? ethers.constants.AddressZero;
const connection = this.multiProvider.getChainConnection(chain);
if (isCollateralConfig(config)) {
const router = await this.deployContractFromFactory(
@ -94,7 +88,6 @@ export class HypERC721Deployer<
router.initialize(
config.mailbox,
config.interchainGasPaymaster,
ism
),
);
return { router };
@ -108,7 +101,6 @@ export class HypERC721Deployer<
await connection.handleTx(router.initialize(
config.mailbox,
config.interchainGasPaymaster,
ism,
config.totalSupply,
config.name,
config.symbol,

@ -102,10 +102,8 @@ for (const withCollateral of [true, false]) {
? (local as HypERC20Collateral).initialize(
ethers.constants.AddressZero,
ethers.constants.AddressZero,
ethers.constants.AddressZero,
)
: (local as HypERC20).initialize(
ethers.constants.AddressZero,
ethers.constants.AddressZero,
ethers.constants.AddressZero,
0,

@ -131,10 +131,8 @@ for (const withCollateral of [true, false]) {
? (local as HypERC721Collateral).initialize(
ethers.constants.AddressZero,
ethers.constants.AddressZero,
ethers.constants.AddressZero,
)
: (local as HypERC721).initialize(
ethers.constants.AddressZero,
ethers.constants.AddressZero,
ethers.constants.AddressZero,
0,

Loading…
Cancel
Save