Migrate ERC20 extensions tests to ethers v6 (#4773)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
@ -1,44 +1,52 @@
|
||||
module.exports = {
|
||||
EIP712Domain: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'version', type: 'string' },
|
||||
{ name: 'chainId', type: 'uint256' },
|
||||
{ name: 'verifyingContract', type: 'address' },
|
||||
{ name: 'salt', type: 'bytes32' },
|
||||
],
|
||||
Permit: [
|
||||
{ name: 'owner', type: 'address' },
|
||||
{ name: 'spender', type: 'address' },
|
||||
{ name: 'value', type: 'uint256' },
|
||||
{ name: 'nonce', type: 'uint256' },
|
||||
{ name: 'deadline', type: 'uint256' },
|
||||
],
|
||||
Ballot: [
|
||||
{ name: 'proposalId', type: 'uint256' },
|
||||
{ name: 'support', type: 'uint8' },
|
||||
{ name: 'voter', type: 'address' },
|
||||
{ name: 'nonce', type: 'uint256' },
|
||||
],
|
||||
ExtendedBallot: [
|
||||
{ name: 'proposalId', type: 'uint256' },
|
||||
{ name: 'support', type: 'uint8' },
|
||||
{ name: 'voter', type: 'address' },
|
||||
{ name: 'nonce', type: 'uint256' },
|
||||
{ name: 'reason', type: 'string' },
|
||||
{ name: 'params', type: 'bytes' },
|
||||
],
|
||||
Delegation: [
|
||||
{ name: 'delegatee', type: 'address' },
|
||||
{ name: 'nonce', type: 'uint256' },
|
||||
{ name: 'expiry', type: 'uint256' },
|
||||
],
|
||||
ForwardRequest: [
|
||||
{ name: 'from', type: 'address' },
|
||||
{ name: 'to', type: 'address' },
|
||||
{ name: 'value', type: 'uint256' },
|
||||
{ name: 'gas', type: 'uint256' },
|
||||
{ name: 'nonce', type: 'uint256' },
|
||||
{ name: 'deadline', type: 'uint48' },
|
||||
{ name: 'data', type: 'bytes' },
|
||||
],
|
||||
};
|
||||
const { mapValues } = require('./iterate');
|
||||
|
||||
const formatType = schema => Object.entries(schema).map(([name, type]) => ({ name, type }));
|
||||
|
||||
module.exports = mapValues(
|
||||
{
|
||||
EIP712Domain: {
|
||||
name: 'string',
|
||||
version: 'string',
|
||||
chainId: 'uint256',
|
||||
verifyingContract: 'address',
|
||||
salt: 'bytes32',
|
||||
},
|
||||
Permit: {
|
||||
owner: 'address',
|
||||
spender: 'address',
|
||||
value: 'uint256',
|
||||
nonce: 'uint256',
|
||||
deadline: 'uint256',
|
||||
},
|
||||
Ballot: {
|
||||
proposalId: 'uint256',
|
||||
support: 'uint8',
|
||||
voter: 'address',
|
||||
nonce: 'uint256',
|
||||
},
|
||||
ExtendedBallot: {
|
||||
proposalId: 'uint256',
|
||||
support: 'uint8',
|
||||
voter: 'address',
|
||||
nonce: 'uint256',
|
||||
reason: 'string',
|
||||
params: 'bytes',
|
||||
},
|
||||
Delegation: {
|
||||
delegatee: 'address',
|
||||
nonce: 'uint256',
|
||||
expiry: 'uint256',
|
||||
},
|
||||
ForwardRequest: {
|
||||
from: 'address',
|
||||
to: 'address',
|
||||
value: 'uint256',
|
||||
gas: 'uint256',
|
||||
nonce: 'uint256',
|
||||
deadline: 'uint48',
|
||||
data: 'bytes',
|
||||
},
|
||||
},
|
||||
formatType,
|
||||
);
|
||||
module.exports.formatType = formatType;
|
||||
|
||||
@ -38,9 +38,9 @@ function hashTypedData(domain, structHash) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
types,
|
||||
getDomain,
|
||||
domainType,
|
||||
domainSeparator: ethers.TypedDataEncoder.hashDomain,
|
||||
hashTypedData,
|
||||
...types,
|
||||
};
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
const { time, mineUpTo } = require('@nomicfoundation/hardhat-network-helpers');
|
||||
|
||||
const mapObject = (obj, fn) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, fn(value)]));
|
||||
const { mapValues } = require('./iterate');
|
||||
|
||||
module.exports = {
|
||||
clock: {
|
||||
@ -22,8 +21,8 @@ module.exports = {
|
||||
|
||||
// TODO: deprecate the old version in favor of this one
|
||||
module.exports.bigint = {
|
||||
clock: mapObject(module.exports.clock, fn => () => fn().then(BigInt)),
|
||||
clockFromReceipt: mapObject(module.exports.clockFromReceipt, fn => receipt => fn(receipt).then(BigInt)),
|
||||
clock: mapValues(module.exports.clock, fn => () => fn().then(BigInt)),
|
||||
clockFromReceipt: mapValues(module.exports.clockFromReceipt, fn => receipt => fn(receipt).then(BigInt)),
|
||||
forward: module.exports.forward,
|
||||
duration: mapObject(module.exports.duration, fn => n => BigInt(fn(n))),
|
||||
duration: mapValues(module.exports.duration, fn => n => BigInt(fn(n))),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user