Make TransparentUpgradeableProxy deploy its ProxyAdmin and optimize proxy interfaces (#4382)

This commit is contained in:
Francisco Giordano
2023-07-09 16:54:32 -03:00
parent e47b53bce4
commit 8fff875589
24 changed files with 300 additions and 308 deletions

14
test/helpers/account.js Normal file
View File

@ -0,0 +1,14 @@
const { web3 } = require('hardhat');
const { impersonateAccount, setBalance } = require('@nomicfoundation/hardhat-network-helpers');
// Hardhat default balance
const DEFAULT_BALANCE = web3.utils.toBN('10000000000000000000000');
async function impersonate(account, balance = DEFAULT_BALANCE) {
await impersonateAccount(account);
await setBalance(account, balance);
}
module.exports = {
impersonate,
};

23
test/helpers/create.js Normal file
View File

@ -0,0 +1,23 @@
const { rlp } = require('ethereumjs-util');
function computeCreateAddress(deployer, nonce) {
return web3.utils.toChecksumAddress(web3.utils.sha3(rlp.encode([deployer.address ?? deployer, nonce])).slice(-40));
}
function computeCreate2Address(saltHex, bytecode, deployer) {
return web3.utils.toChecksumAddress(
web3.utils
.sha3(
'0x' +
['ff', deployer.address ?? deployer, saltHex, web3.utils.soliditySha3(bytecode)]
.map(x => x.replace(/0x/, ''))
.join(''),
)
.slice(-40),
);
}
module.exports = {
computeCreateAddress,
computeCreate2Address,
};

View File

@ -1,11 +0,0 @@
function computeCreate2Address(saltHex, bytecode, deployer) {
return web3.utils.toChecksumAddress(
`0x${web3.utils
.sha3(`0x${['ff', deployer, saltHex, web3.utils.soliditySha3(bytecode)].map(x => x.replace(/0x/, '')).join('')}`)
.slice(-40)}`,
);
}
module.exports = {
computeCreate2Address,
};