Vendor entrypoint bytecode (#5362)
This commit is contained in:
@ -8,6 +8,7 @@ out = 'out'
|
||||
libs = ['node_modules', 'lib']
|
||||
test = 'test'
|
||||
cache_path = 'cache_forge'
|
||||
fs_permissions = [{ access = "read", path = "./test/bin" }]
|
||||
|
||||
[fuzz]
|
||||
runs = 5000
|
||||
|
||||
@ -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),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
1
test/bin/EntryPoint070.abi
Normal file
1
test/bin/EntryPoint070.abi
Normal file
File diff suppressed because one or more lines are too long
BIN
test/bin/EntryPoint070.bytecode
Normal file
BIN
test/bin/EntryPoint070.bytecode
Normal file
Binary file not shown.
1
test/bin/SenderCreator070.abi
Normal file
1
test/bin/SenderCreator070.abi
Normal file
@ -0,0 +1 @@
|
||||
[{"inputs":[{"internalType":"bytes","name":"initCode","type":"bytes"}],"name":"createSender","outputs":[{"internalType":"address","name":"sender","type":"address"}],"stateMutability":"nonpayable","type":"function"}]
|
||||
BIN
test/bin/SenderCreator070.bytecode
Normal file
BIN
test/bin/SenderCreator070.bytecode
Normal file
Binary file not shown.
31
test/helpers/erc4337-entrypoint.js
Normal file
31
test/helpers/erc4337-entrypoint.js
Normal file
@ -0,0 +1,31 @@
|
||||
const { ethers } = require('hardhat');
|
||||
const { setCode } = require('@nomicfoundation/hardhat-network-helpers');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const INSTANCES = {
|
||||
entrypoint: {
|
||||
address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',
|
||||
abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../bin/EntryPoint070.abi'), 'utf-8')),
|
||||
bytecode: fs.readFileSync(path.resolve(__dirname, '../bin/EntryPoint070.bytecode'), 'hex'),
|
||||
},
|
||||
sendercreator: {
|
||||
address: '0xEFC2c1444eBCC4Db75e7613d20C6a62fF67A167C',
|
||||
abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../bin/SenderCreator070.abi'), 'utf-8')),
|
||||
bytecode: fs.readFileSync(path.resolve(__dirname, '../bin/SenderCreator070.bytecode'), 'hex'),
|
||||
},
|
||||
};
|
||||
|
||||
function deployEntrypoint() {
|
||||
return Promise.all(
|
||||
Object.entries(INSTANCES).map(([name, { address, abi, bytecode }]) =>
|
||||
setCode(address, '0x' + bytecode.replace(/0x/, ''))
|
||||
.then(() => ethers.getContractAt(abi, address))
|
||||
.then(instance => ({ [name]: instance })),
|
||||
),
|
||||
).then(namedInstances => Object.assign(...namedInstances));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
deployEntrypoint,
|
||||
};
|
||||
Reference in New Issue
Block a user