Add ERC20 Permit (EIP-2612) (#2237)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Co-authored-by: Santiago Palladino <spalladino@gmail.com>
This commit is contained in:
Nicolás Venturo
2020-12-11 13:34:02 -03:00
committed by GitHub
parent 03d51c5677
commit ecc66719bd
12 changed files with 1615 additions and 164 deletions

21
test/helpers/eip712.js Normal file
View File

@ -0,0 +1,21 @@
const ethSigUtil = require('eth-sig-util');
const EIP712Domain = [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
];
async function domainSeparator (name, version, chainId, verifyingContract) {
return '0x' + ethSigUtil.TypedDataUtils.hashStruct(
'EIP712Domain',
{ name, version, chainId, verifyingContract },
{ EIP712Domain },
).toString('hex');
}
module.exports = {
EIP712Domain,
domainSeparator,
};