@ensuro/account-abstraction 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
- "_format": "hh-sol-artifact-1",
2
+ "_format": "hh3-artifact-1",
3
3
  "contractName": "ERC20With2771",
4
4
  "sourceName": "contracts/mock/ERC20With2771.sol",
5
5
  "abi": [
@@ -375,8 +375,32 @@
375
375
  "type": "function"
376
376
  }
377
377
  ],
378
- "bytecode": "0x60c060405234801561000f575f5ffd5b50604051610d6c380380610d6c83398101604081905261002e91610274565b808585600361003d838261039d565b50600461004a828261039d565b5050506001600160a01b031660805260ff821660a05261006a3384610074565b505050505061047c565b6001600160a01b0382166100a25760405163ec442f0560e01b81525f60048201526024015b60405180910390fd5b6100ad5f83836100b1565b5050565b6001600160a01b0383166100db578060025f8282546100d09190610457565b9091555061014b9050565b6001600160a01b0383165f908152602081905260409020548181101561012d5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610099565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661016757600280548290039055610185565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516101ca91815260200190565b60405180910390a3505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126101fa575f5ffd5b81516001600160401b03811115610213576102136101d7565b604051601f8201601f19908116603f011681016001600160401b0381118282101715610241576102416101d7565b604052818152838201602001851015610258575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b5f5f5f5f5f60a08688031215610288575f5ffd5b85516001600160401b0381111561029d575f5ffd5b6102a9888289016101eb565b602088015190965090506001600160401b038111156102c6575f5ffd5b6102d2888289016101eb565b94505060408601519250606086015160ff811681146102ef575f5ffd5b60808701519092506001600160a01b038116811461030b575f5ffd5b809150509295509295909350565b600181811c9082168061032d57607f821691505b60208210810361034b57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561039857805f5260205f20601f840160051c810160208510156103765750805b601f840160051c820191505b81811015610395575f8155600101610382565b50505b505050565b81516001600160401b038111156103b6576103b66101d7565b6103ca816103c48454610319565b84610351565b6020601f8211600181146103fc575f83156103e55750848201515b5f19600385901b1c1916600184901b178455610395565b5f84815260208120601f198516915b8281101561042b578785015182556020948501946001909201910161040b565b508482101561044857868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b8082018082111561047657634e487b7160e01b5f52601160045260245ffd5b92915050565b60805160a0516108c16104ab5f395f61011701525f8181610151015281816101b6015261044601526108c15ff3fe608060405234801561000f575f5ffd5b50600436106100a6575f3560e01c8063572b6c051161006e578063572b6c051461014157806370a08231146101815780637da0a877146101a957806395d89b41146101e0578063a9059cbb146101e8578063dd62ed3e146101fb575f5ffd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f5ffd5b6100b2610233565b6040516100bf91906106a2565b60405180910390f35b6100db6100d63660046106f2565b6102c3565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b36600461071a565b6102e6565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100db61014f366004610754565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6100ef61018f366004610754565b6001600160a01b03165f9081526020819052604090205490565b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100b2610313565b6100db6101f63660046106f2565b610322565b6100ef610209366004610774565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b606060038054610242906107a5565b80601f016020809104026020016040519081016040528092919081815260200182805461026e906107a5565b80156102b95780601f10610290576101008083540402835291602001916102b9565b820191905f5260205f20905b81548152906001019060200180831161029c57829003601f168201915b5050505050905090565b5f5f6102cd610339565b90506102da818585610347565b60019150505b92915050565b5f5f6102f0610339565b90506102fd858285610359565b6103088585856103da565b506001949350505050565b606060048054610242906107a5565b5f5f61032c610339565b90506102da8185856103da565b5f610342610437565b905090565b61035483838360016104aa565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198110156103d457818110156103c657604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6103d484848484035f6104aa565b50505050565b6001600160a01b03831661040357604051634b637e8f60e11b81525f60048201526024016103bd565b6001600160a01b03821661042c5760405163ec442f0560e01b81525f60048201526024016103bd565b61035483838361057c565b5f366014336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156104735750808210155b156104a2575f3661048483856107f1565b61048f928290610804565b6104989161082b565b60601c9250505090565b339250505090565b6001600160a01b0384166104d35760405163e602df0560e01b81525f60048201526024016103bd565b6001600160a01b0383166104fc57604051634a1406b160e11b81525f60048201526024016103bd565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156103d457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161056e91815260200190565b60405180910390a350505050565b6001600160a01b0383166105a6578060025f82825461059b9190610878565b909155506106169050565b6001600160a01b0383165f90815260208190526040902054818110156105f85760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661063257600280548290039055610650565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161069591815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b03811681146106ed575f5ffd5b919050565b5f5f60408385031215610703575f5ffd5b61070c836106d7565b946020939093013593505050565b5f5f5f6060848603121561072c575f5ffd5b610735846106d7565b9250610743602085016106d7565b929592945050506040919091013590565b5f60208284031215610764575f5ffd5b61076d826106d7565b9392505050565b5f5f60408385031215610785575f5ffd5b61078e836106d7565b915061079c602084016106d7565b90509250929050565b600181811c908216806107b957607f821691505b6020821081036107d757634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156102e0576102e06107dd565b5f5f85851115610812575f5ffd5b8386111561081e575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff198116906014841015610871576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b808201808211156102e0576102e06107dd56fea26469706673582212202d6a63924519f9803257fc7190bf1d1c3b5e564671d83f842ae58ec2cc7b6a7864736f6c634300081c0033",
379
- "deployedBytecode": "0x608060405234801561000f575f5ffd5b50600436106100a6575f3560e01c8063572b6c051161006e578063572b6c051461014157806370a08231146101815780637da0a877146101a957806395d89b41146101e0578063a9059cbb146101e8578063dd62ed3e146101fb575f5ffd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f5ffd5b6100b2610233565b6040516100bf91906106a2565b60405180910390f35b6100db6100d63660046106f2565b6102c3565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b36600461071a565b6102e6565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100db61014f366004610754565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6100ef61018f366004610754565b6001600160a01b03165f9081526020819052604090205490565b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100b2610313565b6100db6101f63660046106f2565b610322565b6100ef610209366004610774565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b606060038054610242906107a5565b80601f016020809104026020016040519081016040528092919081815260200182805461026e906107a5565b80156102b95780601f10610290576101008083540402835291602001916102b9565b820191905f5260205f20905b81548152906001019060200180831161029c57829003601f168201915b5050505050905090565b5f5f6102cd610339565b90506102da818585610347565b60019150505b92915050565b5f5f6102f0610339565b90506102fd858285610359565b6103088585856103da565b506001949350505050565b606060048054610242906107a5565b5f5f61032c610339565b90506102da8185856103da565b5f610342610437565b905090565b61035483838360016104aa565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198110156103d457818110156103c657604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6103d484848484035f6104aa565b50505050565b6001600160a01b03831661040357604051634b637e8f60e11b81525f60048201526024016103bd565b6001600160a01b03821661042c5760405163ec442f0560e01b81525f60048201526024016103bd565b61035483838361057c565b5f366014336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156104735750808210155b156104a2575f3661048483856107f1565b61048f928290610804565b6104989161082b565b60601c9250505090565b339250505090565b6001600160a01b0384166104d35760405163e602df0560e01b81525f60048201526024016103bd565b6001600160a01b0383166104fc57604051634a1406b160e11b81525f60048201526024016103bd565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156103d457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161056e91815260200190565b60405180910390a350505050565b6001600160a01b0383166105a6578060025f82825461059b9190610878565b909155506106169050565b6001600160a01b0383165f90815260208190526040902054818110156105f85760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661063257600280548290039055610650565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161069591815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b03811681146106ed575f5ffd5b919050565b5f5f60408385031215610703575f5ffd5b61070c836106d7565b946020939093013593505050565b5f5f5f6060848603121561072c575f5ffd5b610735846106d7565b9250610743602085016106d7565b929592945050506040919091013590565b5f60208284031215610764575f5ffd5b61076d826106d7565b9392505050565b5f5f60408385031215610785575f5ffd5b61078e836106d7565b915061079c602084016106d7565b90509250929050565b600181811c908216806107b957607f821691505b6020821081036107d757634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156102e0576102e06107dd565b5f5f85851115610812575f5ffd5b8386111561081e575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff198116906014841015610871576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b808201808211156102e0576102e06107dd56fea26469706673582212202d6a63924519f9803257fc7190bf1d1c3b5e564671d83f842ae58ec2cc7b6a7864736f6c634300081c0033",
378
+ "bytecode": "0x60c060405234801561000f575f5ffd5b50604051610d48380380610d4883398101604081905261002e91610274565b808585600361003d838261039d565b50600461004a828261039d565b5050506001600160a01b031660805260ff821660a05261006a3384610074565b505050505061047c565b6001600160a01b0382166100a25760405163ec442f0560e01b81525f60048201526024015b60405180910390fd5b6100ad5f83836100b1565b5050565b6001600160a01b0383166100db578060025f8282546100d09190610457565b9091555061014b9050565b6001600160a01b0383165f908152602081905260409020548181101561012d5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610099565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661016757600280548290039055610185565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516101ca91815260200190565b60405180910390a3505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126101fa575f5ffd5b81516001600160401b03811115610213576102136101d7565b604051601f8201601f19908116603f011681016001600160401b0381118282101715610241576102416101d7565b604052818152838201602001851015610258575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b5f5f5f5f5f60a08688031215610288575f5ffd5b85516001600160401b0381111561029d575f5ffd5b6102a9888289016101eb565b602088015190965090506001600160401b038111156102c6575f5ffd5b6102d2888289016101eb565b94505060408601519250606086015160ff811681146102ef575f5ffd5b60808701519092506001600160a01b038116811461030b575f5ffd5b809150509295509295909350565b600181811c9082168061032d57607f821691505b60208210810361034b57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561039857805f5260205f20601f840160051c810160208510156103765750805b601f840160051c820191505b81811015610395575f8155600101610382565b50505b505050565b81516001600160401b038111156103b6576103b66101d7565b6103ca816103c48454610319565b84610351565b6020601f8211600181146103fc575f83156103e55750848201515b5f19600385901b1c1916600184901b178455610395565b5f84815260208120601f198516915b8281101561042b578785015182556020948501946001909201910161040b565b508482101561044857868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b8082018082111561047657634e487b7160e01b5f52601160045260245ffd5b92915050565b60805160a05161089d6104ab5f395f61011701525f8181610151015281816101b60152610448015261089d5ff3fe608060405234801561000f575f5ffd5b50600436106100a6575f3560e01c8063572b6c051161006e578063572b6c051461014157806370a08231146101815780637da0a877146101a957806395d89b41146101e0578063a9059cbb146101e8578063dd62ed3e146101fb575f5ffd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f5ffd5b6100b2610233565b6040516100bf9190610699565b60405180910390f35b6100db6100d63660046106e9565b6102c3565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b366004610711565b6102e6565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100db61014f36600461074b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6100ef61018f36600461074b565b6001600160a01b03165f9081526020819052604090205490565b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100b2610313565b6100db6101f63660046106e9565b610322565b6100ef61020936600461076b565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6060600380546102429061079c565b80601f016020809104026020016040519081016040528092919081815260200182805461026e9061079c565b80156102b95780601f10610290576101008083540402835291602001916102b9565b820191905f5260205f20905b81548152906001019060200180831161029c57829003601f168201915b5050505050905090565b5f5f6102cd610339565b90506102da818585610347565b60019150505b92915050565b5f5f6102f0610339565b90506102fd858285610359565b6103088585856103da565b506001949350505050565b6060600480546102429061079c565b5f5f61032c610339565b90506102da8185856103da565b5f610342610437565b905090565b61035483838360016104a1565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198110156103d457818110156103c657604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6103d484848484035f6104a1565b50505050565b6001600160a01b03831661040357604051634b637e8f60e11b81525f60048201526024016103bd565b6001600160a01b03821661042c5760405163ec442f0560e01b81525f60048201526024016103bd565b610354838383610573565b5f36601480821080159061047357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633145b156104995761048636828403815f6107d4565b61048f916107fb565b60601c9250505090565b339250505090565b6001600160a01b0384166104ca5760405163e602df0560e01b81525f60048201526024016103bd565b6001600160a01b0383166104f357604051634a1406b160e11b81525f60048201526024016103bd565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156103d457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161056591815260200190565b60405180910390a350505050565b6001600160a01b03831661059d578060025f8282546105929190610848565b9091555061060d9050565b6001600160a01b0383165f90815260208190526040902054818110156105ef5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661062957600280548290039055610647565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161068c91815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b03811681146106e4575f5ffd5b919050565b5f5f604083850312156106fa575f5ffd5b610703836106ce565b946020939093013593505050565b5f5f5f60608486031215610723575f5ffd5b61072c846106ce565b925061073a602085016106ce565b929592945050506040919091013590565b5f6020828403121561075b575f5ffd5b610764826106ce565b9392505050565b5f5f6040838503121561077c575f5ffd5b610785836106ce565b9150610793602084016106ce565b90509250929050565b600181811c908216806107b057607f821691505b6020821081036107ce57634e487b7160e01b5f52602260045260245ffd5b50919050565b5f5f858511156107e2575f5ffd5b838611156107ee575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff198116906014841015610841576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b808201808211156102e057634e487b7160e01b5f52601160045260245ffdfea26469706673582212209052ca3b7d16208877574fb8688288b972afaa142be43385402a72663c099d9564736f6c634300081e0033",
379
+ "deployedBytecode": "0x608060405234801561000f575f5ffd5b50600436106100a6575f3560e01c8063572b6c051161006e578063572b6c051461014157806370a08231146101815780637da0a877146101a957806395d89b41146101e0578063a9059cbb146101e8578063dd62ed3e146101fb575f5ffd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f5ffd5b6100b2610233565b6040516100bf9190610699565b60405180910390f35b6100db6100d63660046106e9565b6102c3565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b366004610711565b6102e6565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100db61014f36600461074b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6100ef61018f36600461074b565b6001600160a01b03165f9081526020819052604090205490565b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100b2610313565b6100db6101f63660046106e9565b610322565b6100ef61020936600461076b565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6060600380546102429061079c565b80601f016020809104026020016040519081016040528092919081815260200182805461026e9061079c565b80156102b95780601f10610290576101008083540402835291602001916102b9565b820191905f5260205f20905b81548152906001019060200180831161029c57829003601f168201915b5050505050905090565b5f5f6102cd610339565b90506102da818585610347565b60019150505b92915050565b5f5f6102f0610339565b90506102fd858285610359565b6103088585856103da565b506001949350505050565b6060600480546102429061079c565b5f5f61032c610339565b90506102da8185856103da565b5f610342610437565b905090565b61035483838360016104a1565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198110156103d457818110156103c657604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6103d484848484035f6104a1565b50505050565b6001600160a01b03831661040357604051634b637e8f60e11b81525f60048201526024016103bd565b6001600160a01b03821661042c5760405163ec442f0560e01b81525f60048201526024016103bd565b610354838383610573565b5f36601480821080159061047357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633145b156104995761048636828403815f6107d4565b61048f916107fb565b60601c9250505090565b339250505090565b6001600160a01b0384166104ca5760405163e602df0560e01b81525f60048201526024016103bd565b6001600160a01b0383166104f357604051634a1406b160e11b81525f60048201526024016103bd565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156103d457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161056591815260200190565b60405180910390a350505050565b6001600160a01b03831661059d578060025f8282546105929190610848565b9091555061060d9050565b6001600160a01b0383165f90815260208190526040902054818110156105ef5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661062957600280548290039055610647565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161068c91815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b03811681146106e4575f5ffd5b919050565b5f5f604083850312156106fa575f5ffd5b610703836106ce565b946020939093013593505050565b5f5f5f60608486031215610723575f5ffd5b61072c846106ce565b925061073a602085016106ce565b929592945050506040919091013590565b5f6020828403121561075b575f5ffd5b610764826106ce565b9392505050565b5f5f6040838503121561077c575f5ffd5b610785836106ce565b9150610793602084016106ce565b90509250929050565b600181811c908216806107b057607f821691505b6020821081036107ce57634e487b7160e01b5f52602260045260245ffd5b50919050565b5f5f858511156107e2575f5ffd5b838611156107ee575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff198116906014841015610841576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b808201808211156102e057634e487b7160e01b5f52601160045260245ffdfea26469706673582212209052ca3b7d16208877574fb8688288b972afaa142be43385402a72663c099d9564736f6c634300081e0033",
380
380
  "linkReferences": {},
381
- "deployedLinkReferences": {}
382
- }
381
+ "deployedLinkReferences": {},
382
+ "immutableReferences": {
383
+ "2301": [
384
+ {
385
+ "length": 32,
386
+ "start": 337
387
+ },
388
+ {
389
+ "length": 32,
390
+ "start": 438
391
+ },
392
+ {
393
+ "length": 32,
394
+ "start": 1096
395
+ }
396
+ ],
397
+ "14976": [
398
+ {
399
+ "length": 32,
400
+ "start": 279
401
+ }
402
+ ]
403
+ },
404
+ "inputSourceName": "project/contracts/mock/ERC20With2771.sol",
405
+ "buildInfoId": "solc-0_8_30-95f43f1788cfd8898b8023be4a1aea1d69744865"
406
+ }
@@ -0,0 +1,27 @@
1
+ // This file was autogenerated by Hardhat, do not edit it.
2
+ // prettier-ignore
3
+ // tslint:disable
4
+ // eslint-disable
5
+ // biome-ignore format: see above
6
+
7
+ export interface ERC20With2771$Type {
8
+ readonly _format: "hh3-artifact-1";
9
+ readonly contractName: "ERC20With2771";
10
+ readonly sourceName: "contracts/mock/ERC20With2771.sol";
11
+ readonly abi: [{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint256","name":"initialSupply","type":"uint256"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"trustedForwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}];
12
+ readonly bytecode: "0x60c060405234801561000f575f5ffd5b50604051610d48380380610d4883398101604081905261002e91610274565b808585600361003d838261039d565b50600461004a828261039d565b5050506001600160a01b031660805260ff821660a05261006a3384610074565b505050505061047c565b6001600160a01b0382166100a25760405163ec442f0560e01b81525f60048201526024015b60405180910390fd5b6100ad5f83836100b1565b5050565b6001600160a01b0383166100db578060025f8282546100d09190610457565b9091555061014b9050565b6001600160a01b0383165f908152602081905260409020548181101561012d5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610099565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661016757600280548290039055610185565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516101ca91815260200190565b60405180910390a3505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126101fa575f5ffd5b81516001600160401b03811115610213576102136101d7565b604051601f8201601f19908116603f011681016001600160401b0381118282101715610241576102416101d7565b604052818152838201602001851015610258575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b5f5f5f5f5f60a08688031215610288575f5ffd5b85516001600160401b0381111561029d575f5ffd5b6102a9888289016101eb565b602088015190965090506001600160401b038111156102c6575f5ffd5b6102d2888289016101eb565b94505060408601519250606086015160ff811681146102ef575f5ffd5b60808701519092506001600160a01b038116811461030b575f5ffd5b809150509295509295909350565b600181811c9082168061032d57607f821691505b60208210810361034b57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561039857805f5260205f20601f840160051c810160208510156103765750805b601f840160051c820191505b81811015610395575f8155600101610382565b50505b505050565b81516001600160401b038111156103b6576103b66101d7565b6103ca816103c48454610319565b84610351565b6020601f8211600181146103fc575f83156103e55750848201515b5f19600385901b1c1916600184901b178455610395565b5f84815260208120601f198516915b8281101561042b578785015182556020948501946001909201910161040b565b508482101561044857868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b8082018082111561047657634e487b7160e01b5f52601160045260245ffd5b92915050565b60805160a05161089d6104ab5f395f61011701525f8181610151015281816101b60152610448015261089d5ff3fe608060405234801561000f575f5ffd5b50600436106100a6575f3560e01c8063572b6c051161006e578063572b6c051461014157806370a08231146101815780637da0a877146101a957806395d89b41146101e0578063a9059cbb146101e8578063dd62ed3e146101fb575f5ffd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f5ffd5b6100b2610233565b6040516100bf9190610699565b60405180910390f35b6100db6100d63660046106e9565b6102c3565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b366004610711565b6102e6565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100db61014f36600461074b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6100ef61018f36600461074b565b6001600160a01b03165f9081526020819052604090205490565b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100b2610313565b6100db6101f63660046106e9565b610322565b6100ef61020936600461076b565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6060600380546102429061079c565b80601f016020809104026020016040519081016040528092919081815260200182805461026e9061079c565b80156102b95780601f10610290576101008083540402835291602001916102b9565b820191905f5260205f20905b81548152906001019060200180831161029c57829003601f168201915b5050505050905090565b5f5f6102cd610339565b90506102da818585610347565b60019150505b92915050565b5f5f6102f0610339565b90506102fd858285610359565b6103088585856103da565b506001949350505050565b6060600480546102429061079c565b5f5f61032c610339565b90506102da8185856103da565b5f610342610437565b905090565b61035483838360016104a1565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198110156103d457818110156103c657604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6103d484848484035f6104a1565b50505050565b6001600160a01b03831661040357604051634b637e8f60e11b81525f60048201526024016103bd565b6001600160a01b03821661042c5760405163ec442f0560e01b81525f60048201526024016103bd565b610354838383610573565b5f36601480821080159061047357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633145b156104995761048636828403815f6107d4565b61048f916107fb565b60601c9250505090565b339250505090565b6001600160a01b0384166104ca5760405163e602df0560e01b81525f60048201526024016103bd565b6001600160a01b0383166104f357604051634a1406b160e11b81525f60048201526024016103bd565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156103d457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161056591815260200190565b60405180910390a350505050565b6001600160a01b03831661059d578060025f8282546105929190610848565b9091555061060d9050565b6001600160a01b0383165f90815260208190526040902054818110156105ef5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661062957600280548290039055610647565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161068c91815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b03811681146106e4575f5ffd5b919050565b5f5f604083850312156106fa575f5ffd5b610703836106ce565b946020939093013593505050565b5f5f5f60608486031215610723575f5ffd5b61072c846106ce565b925061073a602085016106ce565b929592945050506040919091013590565b5f6020828403121561075b575f5ffd5b610764826106ce565b9392505050565b5f5f6040838503121561077c575f5ffd5b610785836106ce565b9150610793602084016106ce565b90509250929050565b600181811c908216806107b057607f821691505b6020821081036107ce57634e487b7160e01b5f52602260045260245ffd5b50919050565b5f5f858511156107e2575f5ffd5b838611156107ee575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff198116906014841015610841576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b808201808211156102e057634e487b7160e01b5f52601160045260245ffdfea26469706673582212209052ca3b7d16208877574fb8688288b972afaa142be43385402a72663c099d9564736f6c634300081e0033";
13
+ readonly deployedBytecode: "0x608060405234801561000f575f5ffd5b50600436106100a6575f3560e01c8063572b6c051161006e578063572b6c051461014157806370a08231146101815780637da0a877146101a957806395d89b41146101e0578063a9059cbb146101e8578063dd62ed3e146101fb575f5ffd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f5ffd5b6100b2610233565b6040516100bf9190610699565b60405180910390f35b6100db6100d63660046106e9565b6102c3565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b366004610711565b6102e6565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100db61014f36600461074b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6100ef61018f36600461074b565b6001600160a01b03165f9081526020819052604090205490565b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020016100bf565b6100b2610313565b6100db6101f63660046106e9565b610322565b6100ef61020936600461076b565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6060600380546102429061079c565b80601f016020809104026020016040519081016040528092919081815260200182805461026e9061079c565b80156102b95780601f10610290576101008083540402835291602001916102b9565b820191905f5260205f20905b81548152906001019060200180831161029c57829003601f168201915b5050505050905090565b5f5f6102cd610339565b90506102da818585610347565b60019150505b92915050565b5f5f6102f0610339565b90506102fd858285610359565b6103088585856103da565b506001949350505050565b6060600480546102429061079c565b5f5f61032c610339565b90506102da8185856103da565b5f610342610437565b905090565b61035483838360016104a1565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198110156103d457818110156103c657604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6103d484848484035f6104a1565b50505050565b6001600160a01b03831661040357604051634b637e8f60e11b81525f60048201526024016103bd565b6001600160a01b03821661042c5760405163ec442f0560e01b81525f60048201526024016103bd565b610354838383610573565b5f36601480821080159061047357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633145b156104995761048636828403815f6107d4565b61048f916107fb565b60601c9250505090565b339250505090565b6001600160a01b0384166104ca5760405163e602df0560e01b81525f60048201526024016103bd565b6001600160a01b0383166104f357604051634a1406b160e11b81525f60048201526024016103bd565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156103d457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161056591815260200190565b60405180910390a350505050565b6001600160a01b03831661059d578060025f8282546105929190610848565b9091555061060d9050565b6001600160a01b0383165f90815260208190526040902054818110156105ef5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661062957600280548290039055610647565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161068c91815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b03811681146106e4575f5ffd5b919050565b5f5f604083850312156106fa575f5ffd5b610703836106ce565b946020939093013593505050565b5f5f5f60608486031215610723575f5ffd5b61072c846106ce565b925061073a602085016106ce565b929592945050506040919091013590565b5f6020828403121561075b575f5ffd5b610764826106ce565b9392505050565b5f5f6040838503121561077c575f5ffd5b610785836106ce565b9150610793602084016106ce565b90509250929050565b600181811c908216806107b057607f821691505b6020821081036107ce57634e487b7160e01b5f52602260045260245ffd5b50919050565b5f5f858511156107e2575f5ffd5b838611156107ee575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff198116906014841015610841576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b808201808211156102e057634e487b7160e01b5f52601160045260245ffdfea26469706673582212209052ca3b7d16208877574fb8688288b972afaa142be43385402a72663c099d9564736f6c634300081e0033";
14
+ readonly linkReferences: {};
15
+ readonly deployedLinkReferences: {};
16
+ readonly immutableReferences: {"2301":[{"length":32,"start":337},{"length":32,"start":438},{"length":32,"start":1096}],"14976":[{"length":32,"start":279}]};
17
+ readonly inputSourceName: "project/contracts/mock/ERC20With2771.sol";
18
+ readonly buildInfoId: "solc-0_8_30-95f43f1788cfd8898b8023be4a1aea1d69744865";
19
+ };
20
+
21
+ import "hardhat/types/artifacts";
22
+ declare module "hardhat/types/artifacts" {
23
+ interface ArtifactMap {
24
+ ["ERC20With2771"]: ERC20With2771$Type;
25
+ ["contracts/mock/ERC20With2771.sol:ERC20With2771"]: ERC20With2771$Type;
26
+ }
27
+ }
@@ -47,7 +47,7 @@ contract AccessControlAccount is AccessControl, BaseAccount {
47
47
  * @param value the value to pass in this call
48
48
  * @param func the calldata to pass in this call
49
49
  */
50
- function execute(address dest, uint256 value, bytes calldata func) external {
50
+ function execute(address dest, uint256 value, bytes calldata func) external override {
51
51
  _requireFromEntryPointOrExecutor();
52
52
  Address.functionCallWithValue(dest, func, value);
53
53
  }
@@ -40,7 +40,7 @@ contract AccessManagerAccount is AccessManager, BaseAccount {
40
40
  * @param value the value to pass in this call
41
41
  * @param func the calldata to pass in this call
42
42
  */
43
- function execute(address dest, uint256 value, bytes calldata func) external {
43
+ function execute(address dest, uint256 value, bytes calldata func) external override {
44
44
  _requireFromEntryPoint();
45
45
  Address.functionCallWithValue(dest, func, value);
46
46
  }
@@ -1,98 +1,127 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.23;
3
3
 
4
- import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
5
4
  import {Address} from "@openzeppelin/contracts/utils/Address.sol";
6
- import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
7
- import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
8
5
  import {BaseAccount} from "@account-abstraction/contracts/core/BaseAccount.sol";
9
- import {SIG_VALIDATION_SUCCESS, SIG_VALIDATION_FAILED} from "@account-abstraction/contracts/core/Helpers.sol";
6
+ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
7
+ import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
8
+ import {IAccountExecute} from "@account-abstraction/contracts/interfaces/IAccountExecute.sol";
10
9
  import {IEntryPoint} from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
10
+ import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
11
11
  import {PackedUserOperation} from "@account-abstraction/contracts/interfaces/PackedUserOperation.sol";
12
- import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
12
+ import {SIG_VALIDATION_SUCCESS, SIG_VALIDATION_FAILED} from "@account-abstraction/contracts/core/Helpers.sol";
13
+ import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
13
14
 
14
15
  /**
15
16
  * @title ERC2771ForwarderAccount
16
17
  *
17
- * @dev Smart Account that acts as an ERC2771 Trusted Forwarder, forwarding calls to other contract(s) where
18
- * the account is the trusted forwarder, on behalf of the signer of the userOp.
18
+ * @dev Smart Account that acts as an ERC2771 Trusted Forwarder, forwarding calls to a pre-defined contract
19
+ * on behalf of the signer of the userOp.
20
+ *
21
+ * Assumes the target contract is designed to work with ERC2771Context and trusts this account as a forwarder.
22
+ *
23
+ * This contract is designed to be used with an AccessManagedProxy for runtime access control management.
19
24
  *
20
25
  * @custom:security-contact security@ensuro.co
21
26
  * @author Ensuro
22
27
  */
23
- contract ERC2771ForwarderAccount is AccessControl, BaseAccount {
24
- bytes32 public constant WITHDRAW_ROLE = keccak256("WITHDRAW_ROLE");
25
- bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
26
-
28
+ contract ERC2771ForwarderAccount is UUPSUpgradeable, BaseAccount, IAccountExecute {
27
29
  IEntryPoint private immutable _entryPoint;
28
- address internal transient _userOpSigner;
30
+
31
+ /// @custom:storage-location erc7201:ensuro.storage.ERC2771ForwarderAccount
32
+ struct ERC2771ForwarderAccountStorage {
33
+ mapping(address => ERC2771Context) targets;
34
+ }
35
+
36
+ // keccak256(abi.encode(uint256(keccak256("ensuro.storage.ERC2771ForwarderAccount")) - 1)) & ~bytes32(uint256(0xff))
37
+ // solhint-disable-next-line const-name-snakecase
38
+ bytes32 internal constant ERC2771ForwarderAccountStorageLocation =
39
+ 0x32800a8a254400b8b55434a22b827759dcb96a572133b419f26b7155e3843000;
40
+
41
+ function _getAccountStorage() internal pure returns (ERC2771ForwarderAccountStorage storage $) {
42
+ // solhint-disable-next-line no-inline-assembly
43
+ assembly {
44
+ $.slot := ERC2771ForwarderAccountStorageLocation
45
+ }
46
+ }
47
+
48
+ event ExecutorAdded(address indexed executor, ERC2771Context indexed target);
49
+ event ExecutorRemoved(address indexed executor);
29
50
 
30
51
  error RequiredEntryPointOrExecutor(address sender);
31
- error UserOpSignerNotSet();
32
- error CanCallOnlyIfTrustedForwarder(address target);
33
- error WrongArrayLength();
52
+ error InvalidTarget(ERC2771Context target, address signer);
53
+ error OnlyExecuteUserOpAllowed();
54
+ error InvalidCall();
34
55
 
35
- /// @inheritdoc BaseAccount
36
- function entryPoint() public view virtual override returns (IEntryPoint) {
37
- return _entryPoint;
56
+ constructor(IEntryPoint anEntryPoint) {
57
+ _entryPoint = anEntryPoint;
38
58
  }
39
59
 
60
+ // solhint-disable-next-line no-empty-blocks
61
+ function _authorizeUpgrade(address newImpl) internal view override {}
62
+
63
+ /**
64
+ * @dev This is a noop, for deployment convenience where an initializer is expected.
65
+ */
66
+ //solhint-disable-next-line no-empty-blocks
67
+ function initialize() external {}
68
+
40
69
  // solhint-disable-next-line no-empty-blocks
41
70
  receive() external payable {}
42
71
 
43
- constructor(IEntryPoint anEntryPoint, address admin, address[] memory executors) {
44
- _entryPoint = anEntryPoint;
45
- _grantRole(DEFAULT_ADMIN_ROLE, admin);
46
- for (uint256 i; i < executors.length; i++) {
47
- _grantRole(EXECUTOR_ROLE, executors[i]);
48
- }
72
+ function executeBatch(Call[] calldata) external virtual override {
73
+ revert OnlyExecuteUserOpAllowed();
49
74
  }
50
75
 
51
- // Require the function call went through EntryPoint or authorized executor
52
- function _requireFromEntryPointOrExecutor() internal returns (address sender) {
53
- if (msg.sender == address(entryPoint())) {
54
- require(_userOpSigner != address(0), UserOpSignerNotSet());
55
- sender = _userOpSigner;
56
- // Since _userOpSigner is only used in `execute` and `executeBatch` methods, when the caller is
57
- // the entryPoint. And since the entryPoint only calls these functions after calling _validateSignature,
58
- // then not cleaning the _userOpSigner (something that might happen if the exec call fails), shouldn't have
59
- // any effect, but I do it anyway, just in case.
60
- _userOpSigner = address(0);
61
- return sender;
76
+ function execute(address, uint256, bytes calldata) external virtual override {
77
+ revert OnlyExecuteUserOpAllowed();
78
+ }
79
+
80
+ function _getSigner(PackedUserOperation calldata userop, bytes32 userOpHash) internal pure returns (address) {
81
+ bytes32 hash = MessageHashUtils.toEthSignedMessageHash(userOpHash);
82
+ return ECDSA.recover(hash, userop.signature);
83
+ }
84
+
85
+ /**
86
+ * @dev Validates that the user operation is well formed and that the destination is correct. Does not validate signature.
87
+ * @return call A Call struct containing the call to be made
88
+ */
89
+ function _validateAndDecodeCall(
90
+ PackedUserOperation calldata userOp,
91
+ bytes32 userOpHash
92
+ ) internal pure returns (Call memory call) {
93
+ require(userOp.callData.length >= 56 && bytes4(userOp.callData[0:4]) == this.executeUserOp.selector, InvalidCall());
94
+ (call.target, call.value, call.data) = abi.decode(userOp.callData[4:], (address, uint256, bytes));
95
+ if (call.target == address(0)) {
96
+ // This is an if and not a require to avoid evaluating the _getSigner call in the happy path
97
+ revert InvalidTarget(ERC2771Context(call.target), _getSigner(userOp, userOpHash));
62
98
  }
63
- require(hasRole(EXECUTOR_ROLE, msg.sender), RequiredEntryPointOrExecutor(msg.sender));
64
- return msg.sender;
99
+ }
100
+
101
+ function _isAuthorized(address signer, address target) internal view returns (bool) {
102
+ ERC2771ForwarderAccountStorage storage $ = _getAccountStorage();
103
+ return $.targets[signer] == ERC2771Context(target);
65
104
  }
66
105
 
67
106
  /**
68
- * execute a transaction (called directly from owner, or by entryPoint)
69
- * @param dest destination address to call
70
- * @param value the value to pass in this call
71
- * @param func the calldata to pass in this call
107
+ * @notice Add an executor and its corresponding target contract.
108
+ * @param executor The executor address to add
109
+ * @param target The ERC2771Context target contract for this executor
72
110
  */
73
- function execute(address dest, uint256 value, bytes calldata func) external {
74
- address sender = _requireFromEntryPointOrExecutor();
75
- require(_isTrustedByTarget(dest), CanCallOnlyIfTrustedForwarder(dest));
76
- Address.functionCallWithValue(dest, abi.encodePacked(func, sender), value);
111
+ function addExecutor(address executor, ERC2771Context target) external {
112
+ ERC2771ForwarderAccountStorage storage $ = _getAccountStorage();
113
+ $.targets[executor] = target;
114
+ emit ExecutorAdded(executor, target);
77
115
  }
78
116
 
79
117
  /**
80
- * execute a sequence of transactions
81
- * @dev to reduce gas consumption for trivial case (no value), use a zero-length array to mean zero value
82
- * @param dest an array of destination addresses
83
- * @param value an array of values to pass to each call. can be zero-length for no-value calls
84
- * @param func an array of calldata to pass to each call
118
+ * @notice Remove an executor by setting its target to the zero address.
119
+ * @param executor The executor address to remove
85
120
  */
86
- function executeBatch(address[] calldata dest, uint256[] calldata value, bytes[] calldata func) external {
87
- address sender = _requireFromEntryPointOrExecutor();
88
- if (dest.length != func.length || (value.length != 0 && value.length != func.length)) revert WrongArrayLength();
89
- for (uint256 i = 0; i < dest.length; i++) {
90
- require(
91
- i == 0 ? _isTrustedByTarget(dest[0]) : (dest[i - 1] == dest[i] || _isTrustedByTarget(dest[i])),
92
- CanCallOnlyIfTrustedForwarder(dest[i])
93
- );
94
- Address.functionCallWithValue(dest[i], abi.encodePacked(func[i], sender), value.length == 0 ? 0 : value[i]);
95
- }
121
+ function removeExecutor(address executor) external {
122
+ ERC2771ForwarderAccountStorage storage $ = _getAccountStorage();
123
+ $.targets[executor] = ERC2771Context(address(0));
124
+ emit ExecutorRemoved(executor);
96
125
  }
97
126
 
98
127
  /// implement template method of BaseAccount
@@ -100,41 +129,32 @@ contract ERC2771ForwarderAccount is AccessControl, BaseAccount {
100
129
  PackedUserOperation calldata userOp,
101
130
  bytes32 userOpHash
102
131
  ) internal virtual override returns (uint256 validationData) {
103
- bytes32 hash = MessageHashUtils.toEthSignedMessageHash(userOpHash);
104
- address recovered = ECDSA.recover(hash, userOp.signature);
105
- if (!hasRole(EXECUTOR_ROLE, recovered)) return SIG_VALIDATION_FAILED;
106
- // Store the _userOpSigner so it can be used as _msgSender by execute and executeBatch
107
- _userOpSigner = recovered;
132
+ Call memory call = _validateAndDecodeCall(userOp, userOpHash);
133
+ address signer = _getSigner(userOp, userOpHash);
134
+ if (!_isAuthorized(signer, call.target)) {
135
+ return SIG_VALIDATION_FAILED;
136
+ }
108
137
  return SIG_VALIDATION_SUCCESS;
109
138
  }
110
139
 
111
140
  /**
112
- * @dev Returns whether the target trusts this forwarder.
113
- *
114
- * This function performs a static call to the target contract calling the
115
- * {ERC2771Context-isTrustedForwarder} function.
141
+ * @dev Executes a user operation by forwarding the call to the target contract with the signer as the msgSender.
142
+ * It re-validates the signature and checks that the signer is authorized. Reverts with InvalidTarget if it isn't.
143
+ * The calldata is expected to contain this function's selector followed by an ABI-encoded Call:
144
+ * - dest (address): the target contract address (must be the same as _target)
145
+ * - value (uint256): the amount of ETH to send with the call
146
+ * - func (bytes): the calldata for the target function
116
147
  *
117
- * Copied from ERC2771Forwarder.sol (OZ-contracts)
148
+ * @param userOp The packed user operation containing the call data and signature.
149
+ * @param userOpHash The hash of the user operation, used for signature verification.
118
150
  */
119
- function _isTrustedByTarget(address target) private view returns (bool) {
120
- bytes memory encodedParams = abi.encodeCall(ERC2771Context.isTrustedForwarder, (address(this)));
151
+ function executeUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external override {
152
+ Call memory call = _validateAndDecodeCall(userOp, userOpHash);
153
+ address signer = _getSigner(userOp, userOpHash);
121
154
 
122
- bool success;
123
- uint256 returnSize;
124
- uint256 returnValue;
125
- // solhint-disable-next-line no-inline-assembly
126
- assembly ("memory-safe") {
127
- // Perform the staticcall and save the result in the scratch space.
128
- // | Location | Content | Content (Hex) |
129
- // |-----------|----------|--------------------------------------------------------------------|
130
- // | | | result ↓ |
131
- // | 0x00:0x1F | selector | 0x0000000000000000000000000000000000000000000000000000000000000001 |
132
- success := staticcall(gas(), target, add(encodedParams, 0x20), mload(encodedParams), 0, 0x20)
133
- returnSize := returndatasize()
134
- returnValue := mload(0)
135
- }
155
+ require(_isAuthorized(signer, call.target), InvalidTarget(ERC2771Context(call.target), signer));
136
156
 
137
- return success && returnSize >= 0x20 && returnValue > 0;
157
+ Address.functionCallWithValue(call.target, abi.encodePacked(call.data, signer), call.value);
138
158
  }
139
159
 
140
160
  /**
@@ -156,7 +176,12 @@ contract ERC2771ForwarderAccount is AccessControl, BaseAccount {
156
176
  * @param withdrawAddress target to send to
157
177
  * @param amount to withdraw
158
178
  */
159
- function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public onlyRole(WITHDRAW_ROLE) {
179
+ function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public {
160
180
  entryPoint().withdrawTo(withdrawAddress, amount);
161
181
  }
182
+
183
+ /// @inheritdoc BaseAccount
184
+ function entryPoint() public view virtual override returns (IEntryPoint) {
185
+ return _entryPoint;
186
+ }
162
187
  }
package/js/userOp.js CHANGED
@@ -1,13 +1,13 @@
1
- const ethers = require("ethers");
1
+ import * as ethers from "ethers";
2
2
  const { ZeroAddress } = ethers;
3
3
 
4
4
  const defaultAbiCoder = ethers.AbiCoder.defaultAbiCoder();
5
5
 
6
- function packAccountGasLimits(verificationGasLimit, callGasLimit) {
6
+ export function packAccountGasLimits(verificationGasLimit, callGasLimit) {
7
7
  return ethers.toBeHex(verificationGasLimit, 16) + ethers.toBeHex(callGasLimit, 16).slice(2);
8
8
  }
9
9
 
10
- function packUserOp(userOp) {
10
+ export function packUserOp(userOp) {
11
11
  const accountGasLimits = packAccountGasLimits(userOp.verificationGasLimit, userOp.callGasLimit);
12
12
  const gasFees = packAccountGasLimits(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas);
13
13
  let paymasterAndData = "0x";
@@ -32,7 +32,7 @@ function packUserOp(userOp) {
32
32
  };
33
33
  }
34
34
 
35
- function packedUserOpAsArray(packedUserOp, includeSignature = true) {
35
+ export function packedUserOpAsArray(packedUserOp, includeSignature = true) {
36
36
  if (includeSignature) {
37
37
  return [
38
38
  packedUserOp.sender,
@@ -59,7 +59,7 @@ function packedUserOpAsArray(packedUserOp, includeSignature = true) {
59
59
  }
60
60
  }
61
61
 
62
- function encodeUserOp(userOp, forSignature = true) {
62
+ export function encodeUserOp(userOp, forSignature = true) {
63
63
  const packedUserOp = packUserOp(userOp);
64
64
  if (forSignature) {
65
65
  return defaultAbiCoder.encode(
@@ -94,47 +94,39 @@ function encodeUserOp(userOp, forSignature = true) {
94
94
  }
95
95
  }
96
96
 
97
- function getUserOpHash(op, entryPoint, chainId) {
97
+ export function getUserOpHash(op, entryPoint, chainId) {
98
98
  const userOpHash = ethers.keccak256(encodeUserOp(op, true));
99
99
  const enc = defaultAbiCoder.encode(["bytes32", "address", "uint256"], [userOpHash, entryPoint, chainId]);
100
100
  return ethers.keccak256(enc);
101
101
  }
102
102
 
103
- const DefaultsForUserOp = {
103
+ export const DefaultsForUserOp = {
104
104
  sender: ZeroAddress,
105
105
  nonce: 0,
106
106
  initCode: "0x",
107
107
  callData: "0x",
108
- callGasLimit: 0,
109
- verificationGasLimit: 150000, // default verification gas. will add create2 cost (3200+200*length) if initCode exists
110
- preVerificationGas: 21000, // should also cover calldata cost.
111
- maxFeePerGas: 0,
108
+ callGasLimit: 0n,
109
+ verificationGasLimit: 150000n, // default verification gas. will add create2 cost (3200+200*length) if initCode exists
110
+ preVerificationGas: 21000n, // should also cover calldata cost.
111
+ maxFeePerGas: 0n,
112
112
  maxPriorityFeePerGas: 1e9,
113
113
  paymaster: ZeroAddress,
114
114
  paymasterData: "0x",
115
- paymasterVerificationGasLimit: 3e5,
115
+ paymasterVerificationGasLimit: 300000n,
116
116
  paymasterPostOpGasLimit: 0,
117
117
  signature: "0x",
118
118
  };
119
119
 
120
- function signUserOp(op, signer, entryPoint, chainId) {
121
- const message = getUserOpHash(op, entryPoint, chainId);
122
- const msg1 = Buffer.concat([
123
- Buffer.from("\x19Ethereum Signed Message:\n32", "ascii"),
124
- Buffer.from(arrayify(message)),
125
- ]);
126
-
127
- const sig = ecsign(keccak256_buffer(msg1), Buffer.from(arrayify(signer.privateKey)));
128
- // that's equivalent of: await signer.signMessage(message);
129
- // (but without "async"
130
- const signedMessage1 = toRpcSig(sig.v, sig.r, sig.s);
120
+ export async function signUserOp(op, signer, entryPoint, chainId) {
121
+ const userOpHash = getUserOpHash(op, entryPoint, chainId);
122
+ const signature = await signer.signMessage(ethers.getBytes(userOpHash));
131
123
  return {
132
124
  ...op,
133
- signature: signedMessage1,
125
+ signature,
134
126
  };
135
127
  }
136
128
 
137
- function fillUserOpDefaults(op, defaults = DefaultsForUserOp) {
129
+ export function fillUserOpDefaults(op, defaults = DefaultsForUserOp) {
138
130
  const partial = { ...op };
139
131
  // we want "item:undefined" to be used from defaults, and not override defaults, so we must explicitly
140
132
  // remove those so "merge" will succeed.
@@ -147,14 +139,3 @@ function fillUserOpDefaults(op, defaults = DefaultsForUserOp) {
147
139
  const filled = { ...defaults, ...partial };
148
140
  return filled;
149
141
  }
150
-
151
- module.exports = {
152
- packAccountGasLimits,
153
- packUserOp,
154
- packedUserOpAsArray,
155
- encodeUserOp,
156
- getUserOpHash,
157
- DefaultsForUserOp,
158
- signUserOp,
159
- fillUserOpDefaults,
160
- };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ensuro/account-abstraction",
3
3
  "description": "ERC-4337 related contracts by the Ensuro Team",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "files": [
6
6
  "**/*.sol",
7
7
  "/build",