Remove GovernorCompatibilyBravo and add simpler GovernorStorage (#4360)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
Co-authored-by: Francisco Giordano <fg@frang.io>
This commit is contained in:
Hadrien Croubois
2023-08-03 17:51:07 +02:00
committed by GitHub
parent d39df78f6c
commit 21716722ad
27 changed files with 755 additions and 1259 deletions

View File

@ -1,17 +1,16 @@
const { rlp } = require('ethereumjs-util');
const RLP = require('rlp');
function computeCreateAddress(deployer, nonce) {
return web3.utils.toChecksumAddress(web3.utils.sha3(rlp.encode([deployer.address ?? deployer, nonce])).slice(-40));
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(''),
`0x${['ff', deployer.address ?? deployer, saltHex, web3.utils.soliditySha3(bytecode)]
.map(x => x.replace(/0x/, ''))
.join('')}`,
)
.slice(-40),
);