Deploy consistent Create2Factory, TestRecipient and InterchainAccountRouters (#1123)
* Deploy consistent Create2Factory, TestRecipient and InterchainAccountRouters * .gitignore * PR Reviewpull/1135/head
parent
65e0bfb2e6
commit
68c394a2a8
@ -0,0 +1,114 @@ |
||||
// SPDX-License-Identifier: MIT |
||||
// Copied from https://github.com/axelarnetwork/axelar-utils-solidity/commits/main/contracts/ConstAddressDeployer.sol |
||||
|
||||
pragma solidity ^0.8.0; |
||||
|
||||
contract Create2Factory { |
||||
error EmptyBytecode(); |
||||
error FailedDeploy(); |
||||
error FailedInit(); |
||||
|
||||
event Deployed( |
||||
bytes32 indexed bytecodeHash, |
||||
bytes32 indexed salt, |
||||
address indexed deployedAddress |
||||
); |
||||
|
||||
/** |
||||
* @dev Deploys a contract using `CREATE2`. The address where the contract |
||||
* will be deployed can be known in advance via {deployedAddress}. |
||||
* |
||||
* The bytecode for a contract can be obtained from Solidity with |
||||
* `type(contractName).creationCode`. |
||||
* |
||||
* Requirements: |
||||
* |
||||
* - `bytecode` must not be empty. |
||||
* - `salt` must have not been used for `bytecode` already by the same `msg.sender`. |
||||
*/ |
||||
function deploy(bytes memory bytecode, bytes32 salt) |
||||
external |
||||
returns (address deployedAddress_) |
||||
{ |
||||
deployedAddress_ = _deploy( |
||||
bytecode, |
||||
keccak256(abi.encode(msg.sender, salt)) |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @dev Deploys a contract using `CREATE2` and initialize it. The address where the contract |
||||
* will be deployed can be known in advance via {deployedAddress}. |
||||
* |
||||
* The bytecode for a contract can be obtained from Solidity with |
||||
* `type(contractName).creationCode`. |
||||
* |
||||
* Requirements: |
||||
* |
||||
* - `bytecode` must not be empty. |
||||
* - `salt` must have not been used for `bytecode` already by the same `msg.sender`. |
||||
* - `init` is used to initialize the deployed contract |
||||
* as an option to not have the constructor args affect the address derived by `CREATE2`. |
||||
*/ |
||||
function deployAndInit( |
||||
bytes memory bytecode, |
||||
bytes32 salt, |
||||
bytes calldata init |
||||
) external returns (address deployedAddress_) { |
||||
deployedAddress_ = _deploy( |
||||
bytecode, |
||||
keccak256(abi.encode(msg.sender, salt)) |
||||
); |
||||
|
||||
// solhint-disable-next-line avoid-low-level-calls |
||||
(bool success, ) = deployedAddress_.call(init); |
||||
if (!success) revert FailedInit(); |
||||
} |
||||
|
||||
/** |
||||
* @dev Returns the address where a contract will be stored if deployed via {deploy} or {deployAndInit} by `sender`. |
||||
* Any change in the `bytecode`, `sender`, or `salt` will result in a new destination address. |
||||
*/ |
||||
function deployedAddress( |
||||
bytes calldata bytecode, |
||||
address sender, |
||||
bytes32 salt |
||||
) external view returns (address deployedAddress_) { |
||||
bytes32 newSalt = keccak256(abi.encode(sender, salt)); |
||||
deployedAddress_ = address( |
||||
uint160( |
||||
uint256( |
||||
keccak256( |
||||
abi.encodePacked( |
||||
hex"ff", |
||||
address(this), |
||||
newSalt, |
||||
keccak256(bytecode) // init code hash |
||||
) |
||||
) |
||||
) |
||||
) |
||||
); |
||||
} |
||||
|
||||
function _deploy(bytes memory bytecode, bytes32 salt) |
||||
internal |
||||
returns (address deployedAddress_) |
||||
{ |
||||
if (bytecode.length == 0) revert EmptyBytecode(); |
||||
|
||||
// solhint-disable-next-line no-inline-assembly |
||||
assembly { |
||||
deployedAddress_ := create2( |
||||
0, |
||||
add(bytecode, 32), |
||||
mload(bytecode), |
||||
salt |
||||
) |
||||
} |
||||
|
||||
if (deployedAddress_ == address(0)) revert FailedDeploy(); |
||||
|
||||
emit Deployed(keccak256(bytecode), salt, deployedAddress_); |
||||
} |
||||
} |
@ -0,0 +1,23 @@ |
||||
{ |
||||
"bsc": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"avalanche": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"polygon": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"celo": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"arbitrum": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"optimism": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"ethereum": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
{ |
||||
"bsc": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"avalanche": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"polygon": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"celo": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"arbitrum": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"optimism": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"ethereum": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,23 @@ |
||||
{ |
||||
"bsc": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"avalanche": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"polygon": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"celo": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"arbitrum": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"optimism": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"ethereum": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
{ |
||||
"bsc": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"avalanche": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"polygon": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"celo": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"arbitrum": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"optimism": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"ethereum": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,23 @@ |
||||
{ |
||||
"bsc": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"avalanche": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"polygon": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"celo": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"arbitrum": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"optimism": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"ethereum": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
{ |
||||
"bsc": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"avalanche": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"polygon": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"celo": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"arbitrum": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"optimism": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"ethereum": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,29 @@ |
||||
{ |
||||
"alfajores": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"kovan": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"fuji": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"mumbai": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"bsctestnet": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"arbitrumrinkeby": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"optimismkovan": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"goerli": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
}, |
||||
"moonbasealpha": { |
||||
"Create2Factory": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a" |
||||
} |
||||
} |
@ -0,0 +1,74 @@ |
||||
{ |
||||
"alfajores": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"kovan": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"fuji": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"mumbai": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"bsctestnet": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"arbitrumrinkeby": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"optimismkovan": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"goerli": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
], |
||||
"moonbasealpha": [ |
||||
{ |
||||
"name": "Create2Factory", |
||||
"address": "0xc97D8e6f57b0d64971453dDc6EB8483fec9d163a", |
||||
"constructorArguments": "", |
||||
"isProxy": false |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,29 @@ |
||||
{ |
||||
"alfajores": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"kovan": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"fuji": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"mumbai": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"bsctestnet": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"optimismkovan": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"goerli": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"moonbasealpha": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
}, |
||||
"arbitrumrinkeby": { |
||||
"router": "0x28DB114018576cF6c9A523C17903455A161d18C4" |
||||
} |
||||
} |
@ -0,0 +1,74 @@ |
||||
{ |
||||
"alfajores": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"kovan": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"fuji": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"mumbai": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"bsctestnet": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"arbitrumrinkeby": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"optimismkovan": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"goerli": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"moonbasealpha": [ |
||||
{ |
||||
"name": "InterchainAccountRouter", |
||||
"address": "0x28DB114018576cF6c9A523C17903455A161d18C4", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,29 @@ |
||||
{ |
||||
"alfajores": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"kovan": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"fuji": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"mumbai": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"bsctestnet": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"arbitrumrinkeby": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"optimismkovan": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"goerli": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
}, |
||||
"moonbasealpha": { |
||||
"TestRecipient": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE" |
||||
} |
||||
} |
@ -0,0 +1,74 @@ |
||||
{ |
||||
"alfajores": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"kovan": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"fuji": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"mumbai": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"bsctestnet": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"arbitrumrinkeby": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"optimismkovan": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"goerli": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
], |
||||
"moonbasealpha": [ |
||||
{ |
||||
"name": "TestRecipient", |
||||
"address": "0xBC3cFeca7Df5A45d61BC60E7898E63670e1654aE", |
||||
"isProxy": false, |
||||
"constructorArguments": "" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,29 @@ |
||||
import path from 'path'; |
||||
|
||||
import { Contexts } from '../../config/contexts'; |
||||
import { KEY_ROLE_ENUM } from '../../src/agents/roles'; |
||||
import { Create2FactoryDeployer, factories } from '../../src/create2'; |
||||
import { deployWithArtifacts } from '../../src/deploy'; |
||||
import { |
||||
getCoreEnvironmentConfig, |
||||
getEnvironment, |
||||
getEnvironmentDirectory, |
||||
} from '../utils'; |
||||
|
||||
async function main() { |
||||
const environment = await getEnvironment(); |
||||
const coreConfig = getCoreEnvironmentConfig(environment); |
||||
const multiProvider = await coreConfig.getMultiProvider( |
||||
Contexts.Abacus, |
||||
KEY_ROLE_ENUM.Create2Deployer, |
||||
); |
||||
|
||||
const deployer = new Create2FactoryDeployer(multiProvider); |
||||
const dir = path.join(getEnvironmentDirectory(environment), 'create2'); |
||||
|
||||
await deployWithArtifacts(dir, factories, deployer); |
||||
} |
||||
|
||||
main() |
||||
.then(() => console.info('Deployment complete')) |
||||
.catch(console.error); |
@ -0,0 +1,24 @@ |
||||
import path from 'path'; |
||||
|
||||
import { deployWithArtifacts } from '../../src/deploy'; |
||||
import { TestRecipientDeployer, factories } from '../../src/testrecipient'; |
||||
import { |
||||
getCoreEnvironmentConfig, |
||||
getEnvironment, |
||||
getEnvironmentDirectory, |
||||
} from '../utils'; |
||||
|
||||
async function main() { |
||||
const environment = await getEnvironment(); |
||||
const coreConfig = getCoreEnvironmentConfig(environment); |
||||
const multiProvider = await coreConfig.getMultiProvider(); |
||||
|
||||
const deployer = new TestRecipientDeployer(multiProvider); |
||||
const dir = path.join(getEnvironmentDirectory(environment), 'testrecipient'); |
||||
|
||||
await deployWithArtifacts(dir, factories, deployer); |
||||
} |
||||
|
||||
main() |
||||
.then(() => console.info('Deployment complete')) |
||||
.catch(console.error); |
@ -0,0 +1,36 @@ |
||||
import { Create2Factory, Create2Factory__factory } from '@hyperlane-xyz/core'; |
||||
import { |
||||
ChainName, |
||||
HyperlaneDeployer, |
||||
MultiProvider, |
||||
} from '@hyperlane-xyz/sdk'; |
||||
|
||||
export const factories = { |
||||
Create2Factory: new Create2Factory__factory(), |
||||
}; |
||||
|
||||
type Contracts = { |
||||
Create2Factory: Create2Factory; |
||||
}; |
||||
|
||||
export class Create2FactoryDeployer< |
||||
Chain extends ChainName, |
||||
> extends HyperlaneDeployer<Chain, any, Contracts, typeof factories> { |
||||
constructor(multiProvider: MultiProvider<Chain>) { |
||||
super( |
||||
multiProvider, |
||||
multiProvider.map(() => ({})), |
||||
factories, |
||||
); |
||||
} |
||||
async deployContracts(chain: Chain) { |
||||
const Create2Factory = await this.deployContract( |
||||
chain, |
||||
'Create2Factory', |
||||
[], |
||||
); |
||||
return { |
||||
Create2Factory, |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,33 @@ |
||||
import { |
||||
ChainMap, |
||||
HyperlaneContracts, |
||||
HyperlaneDeployer, |
||||
HyperlaneFactories, |
||||
buildContracts, |
||||
serializeContracts, |
||||
} from '@hyperlane-xyz/sdk'; |
||||
|
||||
import { readJSON, writeJSON } from './utils/utils'; |
||||
|
||||
export async function deployWithArtifacts<T extends HyperlaneFactories>( |
||||
dir: string, |
||||
factories: T, |
||||
deployer: HyperlaneDeployer<any, any, any, T>, |
||||
) { |
||||
let contracts: ChainMap<any, HyperlaneContracts> = {}; |
||||
try { |
||||
const addresses = readJSON(dir, 'addresses.json'); |
||||
contracts = buildContracts(addresses, factories) as any; |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
|
||||
try { |
||||
contracts = await deployer.deploy(contracts); |
||||
} catch (e) { |
||||
console.error(e); |
||||
contracts = deployer.deployedContracts as any; |
||||
} |
||||
writeJSON(dir, 'verification.json', deployer.verificationInputs); |
||||
writeJSON(dir, 'addresses.json', serializeContracts(contracts)); |
||||
} |
@ -0,0 +1,37 @@ |
||||
import { TestRecipient, TestRecipient__factory } from '@hyperlane-xyz/core'; |
||||
import { |
||||
ChainName, |
||||
HyperlaneDeployer, |
||||
MultiProvider, |
||||
} from '@hyperlane-xyz/sdk'; |
||||
|
||||
export const factories = { |
||||
TestRecipient: new TestRecipient__factory(), |
||||
}; |
||||
|
||||
type Contracts = { |
||||
TestRecipient: TestRecipient; |
||||
}; |
||||
|
||||
export class TestRecipientDeployer< |
||||
Chain extends ChainName, |
||||
> extends HyperlaneDeployer<Chain, any, Contracts, typeof factories> { |
||||
constructor(multiProvider: MultiProvider<Chain>) { |
||||
super( |
||||
multiProvider, |
||||
multiProvider.map(() => ({})), |
||||
factories, |
||||
); |
||||
} |
||||
async deployContracts(chain: Chain) { |
||||
const TestRecipient = await this.deployContract( |
||||
chain, |
||||
'TestRecipient', |
||||
[], |
||||
{ create2Salt: 'testtest32' }, |
||||
); |
||||
return { |
||||
TestRecipient, |
||||
}; |
||||
} |
||||
} |
Loading…
Reference in new issue