Include EIP-5267 discovery in EIP-712 (#3969)
Co-authored-by: Francisco <frangio.1@gmail.com> Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
const ethSigUtil = require('eth-sig-util');
|
||||
const Wallet = require('ethereumjs-wallet').default;
|
||||
|
||||
const { EIP712Domain, domainSeparator, hashTypedData } = require('../../helpers/eip712');
|
||||
const { getDomain, domainType, domainSeparator, hashTypedData } = require('../../helpers/eip712');
|
||||
const { getChainId } = require('../../helpers/chainid');
|
||||
const { mapValues } = require('../../helpers/map-values');
|
||||
|
||||
const EIP712Verifier = artifacts.require('$EIP712Verifier');
|
||||
|
||||
@ -21,19 +22,25 @@ contract('EIP712', function (accounts) {
|
||||
chainId: await getChainId(),
|
||||
verifyingContract: this.eip712.address,
|
||||
};
|
||||
this.domainType = domainType(this.domain);
|
||||
});
|
||||
|
||||
it('domain separator', async function () {
|
||||
const expected = await domainSeparator(this.domain);
|
||||
describe('domain separator', function () {
|
||||
it('is internally available', async function () {
|
||||
const expected = await domainSeparator(this.domain);
|
||||
|
||||
expect(await this.eip712.$_domainSeparatorV4()).to.equal(expected);
|
||||
expect(await this.eip712.$_domainSeparatorV4()).to.equal(expected);
|
||||
});
|
||||
|
||||
it("can be rebuilt using EIP-5267's eip712Domain", async function () {
|
||||
const rebuildDomain = await getDomain(this.eip712);
|
||||
expect(mapValues(rebuildDomain, String)).to.be.deep.equal(mapValues(this.domain, String));
|
||||
});
|
||||
});
|
||||
|
||||
it('hash digest', async function () {
|
||||
const structhash = web3.utils.randomHex(32);
|
||||
const expected = await hashTypedData(this.domain, structhash);
|
||||
|
||||
expect(await this.eip712.$_hashTypedDataV4(structhash)).to.be.equal(expected);
|
||||
expect(await this.eip712.$_hashTypedDataV4(structhash)).to.be.equal(hashTypedData(this.domain, structhash));
|
||||
});
|
||||
|
||||
it('digest', async function () {
|
||||
@ -44,7 +51,7 @@ contract('EIP712', function (accounts) {
|
||||
|
||||
const data = {
|
||||
types: {
|
||||
EIP712Domain,
|
||||
EIP712Domain: this.domainType,
|
||||
Mail: [
|
||||
{ name: 'to', type: 'address' },
|
||||
{ name: 'contents', type: 'string' },
|
||||
|
||||
Reference in New Issue
Block a user