Cherrypick 0a77e54c30 onto release-v5.3 (#5605)

Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: ernestognw <ernestognw@gmail.com>
Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>
This commit is contained in:
Hadrien Croubois
2025-03-26 09:36:37 +01:00
committed by GitHub
parent 39f5a0284e
commit bc3b02ff52
10 changed files with 131 additions and 91 deletions

View File

@ -22,7 +22,11 @@ describe('ERC4337Utils', function () {
describe('entrypoint', function () {
it('v0.7.0', async function () {
await expect(this.utils.$ENTRYPOINT_V07()).to.eventually.equal(entrypoint);
await expect(this.utils.$ENTRYPOINT_V07()).to.eventually.equal(entrypoint.v07);
});
it('v0.8.0', async function () {
await expect(this.utils.$ENTRYPOINT_V08()).to.eventually.equal(entrypoint.v08);
});
});
@ -172,22 +176,14 @@ 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 = await ethers.provider.getNetwork().then(({ chainId }) => chainId);
const otherChainId = 0xdeadbeef;
for (const [version, instance] of Object.entries(entrypoint)) {
it(`returns the operation hash for entrypoint ${version}`, async function () {
const userOp = new UserOperation({ sender: this.sender, nonce: 1 });
const expected = await userOp.hash(instance);
// check that helper matches entrypoint logic
await expect(entrypoint.getUserOpHash(userOp.packed)).to.eventually.equal(userOp.hash(entrypoint, chainId));
// check library against helper
await expect(this.utils.$hash(userOp.packed, entrypoint, chainId)).to.eventually.equal(
userOp.hash(entrypoint, chainId),
);
await expect(this.utils.$hash(userOp.packed, entrypoint, otherChainId)).to.eventually.equal(
userOp.hash(entrypoint, otherChainId),
);
});
await expect(this.utils.$hash(userOp.packed, instance)).to.eventually.equal(expected);
});
}
});
describe('userOp values', function () {

View File

@ -375,7 +375,7 @@ contract ERC7579UtilsTest is Test {
}
function hashUserOperation(PackedUserOperation calldata useroperation) public view returns (bytes32) {
return useroperation.hash(address(ERC4337Utils.ENTRYPOINT_V07), block.chainid);
return useroperation.hash(address(ERC4337Utils.ENTRYPOINT_V07));
}
function _collectAndPrintLogs(bool includeTotalValue) internal {