Refactor time helper and remove custom error helper. (#4803)
Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
const {
|
||||
bigint: { MAX_UINT64 },
|
||||
} = require('./constants');
|
||||
const { ethers } = require('hardhat');
|
||||
const { MAX_UINT64 } = require('./constants');
|
||||
const { namespaceSlot } = require('./namespaced-storage');
|
||||
const { bigint: time } = require('./time');
|
||||
const { keccak256, AbiCoder } = require('ethers');
|
||||
|
||||
function buildBaseRoles() {
|
||||
const roles = {
|
||||
@ -54,9 +52,8 @@ const CONSUMING_SCHEDULE_STORAGE_SLOT = namespaceSlot('AccessManaged', 0n);
|
||||
* @requires this.{manager, caller, target, calldata}
|
||||
*/
|
||||
async function prepareOperation(manager, { caller, target, calldata, delay }) {
|
||||
const timestamp = await time.clock.timestamp();
|
||||
const scheduledAt = timestamp + 1n;
|
||||
await time.forward.timestamp(scheduledAt, false); // Fix next block timestamp for predictability
|
||||
const scheduledAt = (await time.clock.timestamp()) + 1n;
|
||||
await time.increaseTo.timestamp(scheduledAt, false); // Fix next block timestamp for predictability
|
||||
|
||||
return {
|
||||
schedule: () => manager.connect(caller).schedule(target, calldata, scheduledAt + delay),
|
||||
@ -68,8 +65,8 @@ async function prepareOperation(manager, { caller, target, calldata, delay }) {
|
||||
const lazyGetAddress = addressable => addressable.address ?? addressable.target ?? addressable;
|
||||
|
||||
const hashOperation = (caller, target, data) =>
|
||||
keccak256(
|
||||
AbiCoder.defaultAbiCoder().encode(
|
||||
ethers.keccak256(
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(
|
||||
['address', 'address', 'bytes'],
|
||||
[lazyGetAddress(caller), lazyGetAddress(target), data],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user