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:
@ -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 () {
|
||||
|
||||
@ -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 {
|
||||
|
||||
1
test/bin/EntryPoint080.abi
Normal file
1
test/bin/EntryPoint080.abi
Normal file
File diff suppressed because one or more lines are too long
BIN
test/bin/EntryPoint080.bytecode
Normal file
BIN
test/bin/EntryPoint080.bytecode
Normal file
Binary file not shown.
1
test/bin/SenderCreator080.abi
Normal file
1
test/bin/SenderCreator080.abi
Normal file
@ -0,0 +1 @@
|
||||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"opIndex","type":"uint256"},{"internalType":"string","name":"reason","type":"string"},{"internalType":"bytes","name":"inner","type":"bytes"}],"name":"FailedOpWithRevert","type":"error"},{"inputs":[{"internalType":"bytes","name":"initCode","type":"bytes"}],"name":"createSender","outputs":[{"internalType":"address","name":"sender","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"entryPoint","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bytes","name":"initCallData","type":"bytes"}],"name":"initEip7702Sender","outputs":[],"stateMutability":"nonpayable","type":"function"}]
|
||||
BIN
test/bin/SenderCreator080.bytecode
Normal file
BIN
test/bin/SenderCreator080.bytecode
Normal file
Binary file not shown.
@ -78,26 +78,8 @@ class UserOperation {
|
||||
};
|
||||
}
|
||||
|
||||
hash(entrypoint, chainId) {
|
||||
const p = this.packed;
|
||||
const h = ethers.keccak256(
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(
|
||||
['address', 'uint256', 'bytes32', 'bytes32', 'uint256', 'uint256', 'uint256', 'uint256'],
|
||||
[
|
||||
p.sender,
|
||||
p.nonce,
|
||||
ethers.keccak256(p.initCode),
|
||||
ethers.keccak256(p.callData),
|
||||
p.accountGasLimits,
|
||||
p.preVerificationGas,
|
||||
p.gasFees,
|
||||
ethers.keccak256(p.paymasterAndData),
|
||||
],
|
||||
),
|
||||
);
|
||||
return ethers.keccak256(
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(['bytes32', 'address', 'uint256'], [h, getAddress(entrypoint), chainId]),
|
||||
);
|
||||
hash(entrypoint) {
|
||||
return entrypoint.getUserOpHash(this.packed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user