|
@@ -3,11 +3,13 @@ const { expect } = require('chai');
|
|
|
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
|
|
|
|
|
|
const { packValidationData, UserOperation } = require('../../helpers/erc4337');
|
|
|
+const { deployEntrypoint } = require('../../helpers/erc4337-entrypoint');
|
|
|
const { MAX_UINT48 } = require('../../helpers/constants');
|
|
|
const ADDRESS_ONE = '0x0000000000000000000000000000000000000001';
|
|
|
|
|
|
const fixture = async () => {
|
|
|
- const [authorizer, sender, entrypoint, factory, paymaster] = await ethers.getSigners();
|
|
|
+ const { entrypoint } = await deployEntrypoint();
|
|
|
+ const [authorizer, sender, factory, paymaster] = await ethers.getSigners();
|
|
|
const utils = await ethers.deployContract('$ERC4337Utils');
|
|
|
const SIG_VALIDATION_SUCCESS = await utils.$SIG_VALIDATION_SUCCESS();
|
|
|
const SIG_VALIDATION_FAILED = await utils.$SIG_VALIDATION_FAILED();
|
|
@@ -167,11 +169,19 @@ describe('ERC4337Utils', function () {
|
|
|
describe('hash', function () {
|
|
|
it('returns the operation hash with specified entrypoint and chainId', async function () {
|
|
|
const userOp = new UserOperation({ sender: this.sender, nonce: 1 });
|
|
|
- const chainId = 0xdeadbeef;
|
|
|
+ const chainId = await ethers.provider.getNetwork().then(({ chainId }) => chainId);
|
|
|
+ const otherChainId = 0xdeadbeef;
|
|
|
|
|
|
+ // check that helper matches entrypoint logic
|
|
|
+ expect(this.entrypoint.getUserOpHash(userOp.packed)).to.eventually.equal(userOp.hash(this.entrypoint, chainId));
|
|
|
+
|
|
|
+ // check library against helper
|
|
|
expect(this.utils.$hash(userOp.packed, this.entrypoint, chainId)).to.eventually.equal(
|
|
|
userOp.hash(this.entrypoint, chainId),
|
|
|
);
|
|
|
+ expect(this.utils.$hash(userOp.packed, this.entrypoint, otherChainId)).to.eventually.equal(
|
|
|
+ userOp.hash(this.entrypoint, otherChainId),
|
|
|
+ );
|
|
|
});
|
|
|
});
|
|
|
|