Migrate AccessManager tests to ethers (#4710)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Ernesto García
2023-11-09 15:56:54 +00:00
committed by GitHub
parent cb1ef861e5
commit cf6ff90b6d
10 changed files with 1240 additions and 1447 deletions

View File

@ -1,16 +1,14 @@
const { keccak256, id, toBeHex, MaxUint256 } = require('ethers');
const { artifacts } = require('hardhat');
function namespaceId(contractName) {
return `openzeppelin.storage.${contractName}`;
}
function namespaceLocation(id) {
const hashIdBN = web3.utils.toBN(web3.utils.keccak256(id)).subn(1); // keccak256(id) - 1
const hashIdHex = web3.utils.padLeft(web3.utils.numberToHex(hashIdBN), 64);
const mask = BigInt(web3.utils.padLeft('0x00', 64, 'f')); // ~0xff
return BigInt(web3.utils.keccak256(hashIdHex)) & mask;
function namespaceLocation(value) {
const hashIdBN = BigInt(id(value)) - 1n; // keccak256(id) - 1
const mask = MaxUint256 - 0xffn; // ~0xff
return BigInt(keccak256(toBeHex(hashIdBN, 32))) & mask;
}
function namespaceSlot(contractName, offset) {