Skip to content

Commit

Permalink
fix(ct): export all chugsplash predeploy addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Nov 9, 2022
1 parent a536675 commit c08a950
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-badgers-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chugsplash/contracts': patch
---

Export ChugSplash predeploy contracts
8 changes: 4 additions & 4 deletions packages/contracts/contracts/ChugSplashManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,10 @@ contract ChugSplashManager is OwnableUpgradeable, ReentrancyGuardUpgradeable {
* @param _proxy Address of the proxy.
* @param _adapter Address of the adapter to use for the proxy.
*/
function _getProxyImplementation(address payable _proxy, address _adapter)
internal
returns (address)
{
function _getProxyImplementation(
address payable _proxy,
address _adapter
) internal returns (address) {
(bool success, bytes memory implementationBytes) = _adapter.delegatecall(
abi.encodeCall(IProxyAdapter.getProxyImplementation, (_proxy))
);
Expand Down
10 changes: 4 additions & 6 deletions packages/contracts/contracts/libraries/Proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ contract Proxy {
* @param _implementation Address of the implementation contract.
* @param _data Calldata to delegatecall the new implementation with.
*/
function upgradeToAndCall(address _implementation, bytes calldata _data)
external
payable
proxyCallIfNotAdmin
returns (bytes memory)
{
function upgradeToAndCall(
address _implementation,
bytes calldata _data
) external payable proxyCallIfNotAdmin returns (bytes memory) {
_setImplementation(_implementation);
(bool success, bytes memory returndata) = _implementation.delegatecall(_data);
require(success, "Proxy: delegatecall to new implementation contract failed");
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"build": "yarn build:contracts && yarn build:ts",
"build:ts": "tsc -p ./tsconfig.json",
"build:contracts": "hardhat compile",
"build:contracts": "hardhat clean && hardhat compile",
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo",
"test:coverage": "echo 'no tests'",
"lint": "yarn lint:fix && yarn lint:check",
Expand Down
89 changes: 43 additions & 46 deletions packages/contracts/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ProxyArtifact,
DefaultAdapterArtifact,
ProxyUpdaterArtifact,
// ChugSplashRegistryArtifact,
ChugSplashBootLoaderArtifact,
ChugSplashRegistryArtifact,
ChugSplashManagerArtifact,
Expand Down Expand Up @@ -48,7 +47,6 @@ export const CHUGSPLASH_BOOTLOADER_ADDRESS = ethers.utils.getCreate2Address(

export const PROXY_UPDATER_ADDRESS = ethers.utils.getCreate2Address(
CHUGSPLASH_BOOTLOADER_ADDRESS,
// ethers.utils.solidityKeccak256(['string'], ['ProxyUpdater']),
ethers.constants.HashZero,
ethers.utils.solidityKeccak256(['bytes'], [ProxyUpdaterArtifact.bytecode])
)
Expand All @@ -75,50 +73,21 @@ export const CHUGSPLASH_REGISTRY_PROXY_ADDRESS = ethers.utils.getCreate2Address(
)
)

// export const ROOT_CHUGSPLASH_MANAGER_PROXY_ADDRESS =
// ethers.utils.getCreate2Address(
// CHUGSPLASH_BOOTLOADER_ADDRESS,
// ethers.constants.HashZero,
// ethers.utils.solidityKeccak256(
// ['bytes', 'bytes'],
// [
// ChugSplashManagerProxyArtifact.bytecode,
// ethers.utils.defaultAbiCoder.encode(
// ['address', 'address', 'address', 'bytes'],
// [
// CHUGSPLASH_REGISTRY_PROXY_ADDRESS,
// CHUGSPLASH_BOOTLOADER_ADDRESS, wrong
// ]
// ),
// ]
// )
// )

// export const CHUGSPLASH_REGISTRY_ADDRESS = ethers.utils.getCreate2Address(
// DETERMINISTIC_DEPLOYMENT_PROXY_ADDRESS,
// ethers.utils.solidityKeccak256(['string'], ['ChugSplashRegistry']),
// ethers.utils.solidityKeccak256(
// ['bytes', 'bytes'],
// [
// ChugSplashRegistryArtifact.bytecode,
// ethers.utils.defaultAbiCoder.encode(
// ['address', 'uint256', 'uint256', 'uint256'],
// [
// PROXY_UPDATER_ADDRESS,
// OWNER_BOND_AMOUNT,
// EXECUTOR_BOND_AMOUNT,
// EXECUTION_LOCK_TIME,
// ]
// ),
// ]
// )
// )

export const DEFAULT_ADAPTER_ADDRESS = ethers.utils.getCreate2Address(
DETERMINISTIC_DEPLOYMENT_PROXY_ADDRESS,
ethers.utils.solidityKeccak256(['string'], ['DefaultAdapter']),
ethers.utils.solidityKeccak256(['bytes'], [DefaultAdapterArtifact.bytecode])
)
export const ROOT_CHUGSPLASH_MANAGER_PROXY_ADDRESS =
ethers.utils.getCreate2Address(
CHUGSPLASH_BOOTLOADER_ADDRESS,
ethers.constants.HashZero,
ethers.utils.solidityKeccak256(
['bytes', 'bytes'],
[
ChugSplashManagerProxyArtifact.bytecode,
ethers.utils.defaultAbiCoder.encode(
['address', 'address'],
[CHUGSPLASH_REGISTRY_PROXY_ADDRESS, CHUGSPLASH_BOOTLOADER_ADDRESS]
),
]
)
)

const chugsplashManagerConstructorArgValues = [
CHUGSPLASH_REGISTRY_PROXY_ADDRESS,
Expand Down Expand Up @@ -146,6 +115,34 @@ export const CHUGSPLASH_MANAGER_ADDRESS = ethers.utils.getCreate2Address(
)
)

export const CHUGSPLASH_REGISTRY_ADDRESS = ethers.utils.getCreate2Address(
CHUGSPLASH_BOOTLOADER_ADDRESS,
ethers.constants.HashZero,
ethers.utils.solidityKeccak256(
['bytes', 'bytes'],
[
ChugSplashRegistryArtifact.bytecode,
ethers.utils.defaultAbiCoder.encode(
['address', 'uint256', 'uint256', 'uint256', 'uint256', 'address'],
[
PROXY_UPDATER_ADDRESS,
OWNER_BOND_AMOUNT,
EXECUTOR_BOND_AMOUNT,
EXECUTION_LOCK_TIME,
EXECUTOR_PAYMENT_PERCENTAGE,
CHUGSPLASH_MANAGER_ADDRESS,
]
),
]
)
)

export const DEFAULT_ADAPTER_ADDRESS = ethers.utils.getCreate2Address(
DETERMINISTIC_DEPLOYMENT_PROXY_ADDRESS,
ethers.utils.solidityKeccak256(['string'], ['DefaultAdapter']),
ethers.utils.solidityKeccak256(['bytes'], [DefaultAdapterArtifact.bytecode])
)

export const CHUGSPLASH_CONSTRUCTOR_ARGS = {}
CHUGSPLASH_CONSTRUCTOR_ARGS[chugsplashRegistrySourceName] = [
PROXY_UPDATER_ADDRESS,
Expand Down

0 comments on commit c08a950

Please sign in to comment.