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:
21
test/helpers/eip712.js
Normal file
21
test/helpers/eip712.js
Normal 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,
|
||||
};
|
||||
Reference in New Issue
Block a user