@1inch/solidity-utils 3.8.3 → 4.1.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.
- package/README.md +9 -208
- package/contracts/interfaces/ICreate3Deployer.sol +16 -0
- package/contracts/interfaces/IDaiLikePermit.sol +13 -0
- package/contracts/interfaces/IERC20MetadataUppercase.sol +12 -0
- package/contracts/interfaces/IERC7597Permit.sol +13 -0
- package/contracts/interfaces/IPermit2.sol +45 -12
- package/contracts/interfaces/IWETH.sol +17 -0
- package/contracts/libraries/AddressArray.sol +190 -61
- package/contracts/libraries/AddressLib.sol +2 -1
- package/contracts/libraries/AddressSet.sol +82 -18
- package/contracts/libraries/BySigTraits.sol +46 -0
- package/contracts/libraries/BytesMemory.sol +2 -1
- package/contracts/libraries/BytesStorage.sol +2 -1
- package/contracts/libraries/ECDSA.sol +111 -0
- package/contracts/libraries/RevertReasonForwarder.sol +13 -3
- package/contracts/libraries/RevertReasonParser.sol +11 -2
- package/contracts/libraries/SafeERC20.sol +7 -3
- package/contracts/libraries/StringUtil.sol +21 -3
- package/contracts/libraries/UniERC20.sol +57 -12
- package/contracts/mocks/ERC20PermitMock.sol +12 -0
- package/contracts/mocks/SelfdestructEthSenderMock.sol +17 -0
- package/contracts/mocks/TokenCustomDecimalsMock.sol +25 -4
- package/contracts/mocks/TokenMock.sol +19 -0
- package/dist/hardhat-setup/networks.d.ts +23 -0
- package/dist/hardhat-setup/networks.js +22 -0
- package/dist/hardhat-setup/networks.js.map +1 -1
- package/dist/src/expect.d.ts +12 -0
- package/dist/src/expect.js +12 -0
- package/dist/src/expect.js.map +1 -1
- package/dist/src/permit.d.ts +120 -1
- package/dist/src/permit.js +124 -8
- package/dist/src/permit.js.map +1 -1
- package/dist/src/prelude.d.ts +6 -0
- package/dist/src/prelude.js +6 -0
- package/dist/src/prelude.js.map +1 -1
- package/dist/src/profileEVM.d.ts +26 -0
- package/dist/src/profileEVM.js +30 -3
- package/dist/src/profileEVM.js.map +1 -1
- package/dist/src/utils.d.ts +79 -0
- package/dist/src/utils.js +92 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/typechain-types/@openzeppelin/contracts/utils/Address.d.ts +20 -0
- package/dist/typechain-types/@openzeppelin/contracts/utils/Address.js +3 -0
- package/dist/typechain-types/@openzeppelin/contracts/utils/Address.js.map +1 -0
- package/dist/typechain-types/@openzeppelin/contracts/utils/index.d.ts +1 -0
- package/dist/typechain-types/contracts/index.d.ts +2 -3
- package/dist/typechain-types/contracts/interfaces/IERC7597Permit.d.ts +41 -0
- package/dist/typechain-types/contracts/interfaces/IERC7597Permit.js +3 -0
- package/dist/typechain-types/contracts/interfaces/IERC7597Permit.js.map +1 -0
- package/dist/typechain-types/contracts/interfaces/index.d.ts +1 -0
- package/dist/typechain-types/contracts/libraries/BySigTraits.d.ts +20 -0
- package/dist/typechain-types/contracts/libraries/BySigTraits.js +3 -0
- package/dist/typechain-types/contracts/libraries/BySigTraits.js.map +1 -0
- package/dist/typechain-types/contracts/libraries/index.d.ts +1 -0
- package/dist/typechain-types/contracts/mixins/BySig.d.ts +214 -0
- package/dist/typechain-types/contracts/mixins/BySig.js +3 -0
- package/dist/typechain-types/contracts/mixins/BySig.js.map +1 -0
- package/dist/typechain-types/contracts/{EthReceiver.d.ts → mixins/EthReceiver.d.ts} +1 -1
- package/dist/typechain-types/contracts/mixins/EthReceiver.js.map +1 -0
- package/dist/typechain-types/contracts/{OnlyWethReceiver.d.ts → mixins/OnlyWethReceiver.d.ts} +1 -1
- package/dist/typechain-types/contracts/mixins/OnlyWethReceiver.js.map +1 -0
- package/dist/typechain-types/contracts/{PermitAndCall.d.ts → mixins/PermitAndCall.d.ts} +1 -1
- package/dist/typechain-types/contracts/mixins/PermitAndCall.js.map +1 -0
- package/dist/typechain-types/contracts/mixins/SelfdestructEthSender.d.ts +29 -0
- package/dist/typechain-types/contracts/mixins/SelfdestructEthSender.js +3 -0
- package/dist/typechain-types/contracts/mixins/SelfdestructEthSender.js.map +1 -0
- package/dist/typechain-types/contracts/mixins/index.d.ts +5 -0
- package/dist/typechain-types/contracts/mixins/index.js +3 -0
- package/dist/typechain-types/contracts/mixins/index.js.map +1 -0
- package/dist/typechain-types/contracts/mocks/SelfdestructEthSenderMock.d.ts +37 -0
- package/dist/typechain-types/contracts/mocks/SelfdestructEthSenderMock.js +3 -0
- package/dist/typechain-types/contracts/mocks/SelfdestructEthSenderMock.js.map +1 -0
- package/dist/typechain-types/contracts/mocks/TokenCustomDecimalsMock.d.ts +1 -5
- package/dist/typechain-types/contracts/mocks/index.d.ts +1 -0
- package/dist/typechain-types/contracts/tests/mocks/AddressSetMock.d.ts +5 -1
- package/dist/typechain-types/contracts/tests/mocks/BySigTraitsMock.d.ts +47 -0
- package/dist/typechain-types/contracts/tests/mocks/BySigTraitsMock.js +3 -0
- package/dist/typechain-types/contracts/tests/mocks/BySigTraitsMock.js.map +1 -0
- package/dist/typechain-types/contracts/tests/mocks/TokenWithBySig.d.ts +422 -0
- package/dist/typechain-types/contracts/tests/mocks/TokenWithBySig.js +3 -0
- package/dist/typechain-types/contracts/tests/mocks/TokenWithBySig.js.map +1 -0
- package/dist/typechain-types/contracts/tests/mocks/USDCLikePermitMock.d.ts +260 -0
- package/dist/typechain-types/contracts/tests/mocks/USDCLikePermitMock.js +3 -0
- package/dist/typechain-types/contracts/tests/mocks/USDCLikePermitMock.js.map +1 -0
- package/dist/typechain-types/contracts/tests/mocks/index.d.ts +3 -0
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.d.ts +42 -0
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.js +67 -0
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.js.map +1 -0
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/cryptography/ECDSA__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/cryptography/ECDSA__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/index.d.ts +1 -0
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/index.js +3 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/index.js.map +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/math/Math__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/math/Math__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/index.d.ts +1 -3
- package/dist/typechain-types/factories/contracts/index.js +2 -7
- package/dist/typechain-types/factories/contracts/index.js.map +1 -1
- package/dist/typechain-types/factories/contracts/interfaces/IERC7597Permit__factory.d.ts +33 -0
- package/dist/typechain-types/factories/contracts/interfaces/IERC7597Permit__factory.js +53 -0
- package/dist/typechain-types/factories/contracts/interfaces/IERC7597Permit__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/interfaces/index.d.ts +1 -0
- package/dist/typechain-types/factories/contracts/interfaces/index.js +3 -1
- package/dist/typechain-types/factories/contracts/interfaces/index.js.map +1 -1
- package/dist/typechain-types/factories/contracts/libraries/AddressArray__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/AddressArray__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.d.ts +26 -0
- package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.js +45 -0
- package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/libraries/BytesMemory__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesMemory__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesStorage__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesStorage__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/RevertReasonParser__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/RevertReasonParser__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/SafeERC20__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/SafeERC20__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/UniERC20__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/UniERC20__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/index.d.ts +1 -0
- package/dist/typechain-types/factories/contracts/libraries/index.js +3 -1
- package/dist/typechain-types/factories/contracts/libraries/index.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mixins/BySig__factory.d.ts +286 -0
- package/dist/typechain-types/factories/contracts/mixins/BySig__factory.js +385 -0
- package/dist/typechain-types/factories/contracts/mixins/BySig__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/{EthReceiver__factory.d.ts → mixins/EthReceiver__factory.d.ts} +1 -1
- package/dist/typechain-types/factories/contracts/mixins/EthReceiver__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/{OnlyWethReceiver__factory.d.ts → mixins/OnlyWethReceiver__factory.d.ts} +1 -1
- package/dist/typechain-types/factories/contracts/mixins/OnlyWethReceiver__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/{PermitAndCall__factory.d.ts → mixins/PermitAndCall__factory.d.ts} +1 -1
- package/dist/typechain-types/factories/contracts/mixins/PermitAndCall__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/mixins/SelfdestructEthSender__factory.d.ts +17 -0
- package/dist/typechain-types/factories/contracts/mixins/SelfdestructEthSender__factory.js +33 -0
- package/dist/typechain-types/factories/contracts/mixins/SelfdestructEthSender__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/mixins/index.d.ts +5 -0
- package/dist/typechain-types/factories/contracts/mixins/index.js +17 -0
- package/dist/typechain-types/factories/contracts/mixins/index.js.map +1 -0
- package/dist/typechain-types/factories/contracts/mocks/ERC20PermitMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/mocks/ERC20PermitMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/mocks/ERC20PermitMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.d.ts +49 -0
- package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.js +75 -0
- package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/mocks/TokenCustomDecimalsMock__factory.d.ts +1 -11
- package/dist/typechain-types/factories/contracts/mocks/TokenCustomDecimalsMock__factory.js +1 -14
- package/dist/typechain-types/factories/contracts/mocks/TokenCustomDecimalsMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/TokenMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/mocks/TokenMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/mocks/TokenMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/index.d.ts +1 -0
- package/dist/typechain-types/factories/contracts/mocks/index.js +3 -1
- package/dist/typechain-types/factories/contracts/mocks/index.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/ECDSATest__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/ECDSATest__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/ECDSATest__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/RevertReasonParserTest__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/RevertReasonParserTest__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/RevertReasonParserTest__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/StringUtilTest__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/StringUtilTest__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/StringUtilTest__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressArrayMock__factory.d.ts +1 -5
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressArrayMock__factory.js +1 -6
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressArrayMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressLibMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressLibMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressLibMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressSetMock__factory.d.ts +11 -5
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressSetMock__factory.js +14 -6
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressSetMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.d.ts +86 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.js +126 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesMemoryMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesMemoryMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesMemoryMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesStorageMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesStorageMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesStorageMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/DaiLikePermitMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/DaiLikePermitMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/DaiLikePermitMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/ERC1271WalletMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/ERC1271WalletMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/ERC1271WalletMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthReceiverMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthReceiverMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthSenderMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthSenderMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthSenderMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.d.ts +675 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.js +893 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/USDCLikePermitMock__factory.d.ts +481 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/USDCLikePermitMock__factory.js +640 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/USDCLikePermitMock__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WETH__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WETH__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WETH__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WethReceiverMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WethReceiverMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WethReceiverMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/index.d.ts +3 -0
- package/dist/typechain-types/factories/contracts/tests/mocks/index.js +7 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/index.js.map +1 -1
- package/dist/typechain-types/index.d.ts +24 -6
- package/dist/typechain-types/index.js +26 -8
- package/dist/typechain-types/index.js.map +1 -1
- package/package.json +23 -18
- package/utils/README.md +180 -0
- package/utils/docify.utils.js +3 -3
- package/utils/file-dependencies.js +0 -0
- package/utils/test-docgen.js +0 -0
- package/contracts/EthReceiver.sol +0 -16
- package/contracts/OnlyWethReceiver.sol +0 -17
- package/contracts/PermitAndCall.sol +0 -28
- package/dist/typechain-types/contracts/EthReceiver.js.map +0 -1
- package/dist/typechain-types/contracts/OnlyWethReceiver.js.map +0 -1
- package/dist/typechain-types/contracts/PermitAndCall.js.map +0 -1
- package/dist/typechain-types/factories/contracts/EthReceiver__factory.js.map +0 -1
- package/dist/typechain-types/factories/contracts/OnlyWethReceiver__factory.js.map +0 -1
- package/dist/typechain-types/factories/contracts/PermitAndCall__factory.js.map +0 -1
- /package/dist/typechain-types/contracts/{EthReceiver.js → mixins/EthReceiver.js} +0 -0
- /package/dist/typechain-types/contracts/{OnlyWethReceiver.js → mixins/OnlyWethReceiver.js} +0 -0
- /package/dist/typechain-types/contracts/{PermitAndCall.js → mixins/PermitAndCall.js} +0 -0
- /package/dist/typechain-types/factories/contracts/{EthReceiver__factory.js → mixins/EthReceiver__factory.js} +0 -0
- /package/dist/typechain-types/factories/contracts/{OnlyWethReceiver__factory.js → mixins/OnlyWethReceiver__factory.js} +0 -0
- /package/dist/typechain-types/factories/contracts/{PermitAndCall__factory.js → mixins/PermitAndCall__factory.js} +0 -0
|
@@ -4,6 +4,10 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
|
|
5
5
|
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @title ECDSA signature operations
|
|
9
|
+
* @notice Provides functions for recovering addresses from signatures and verifying signatures, including support for EIP-2098 compact signatures.
|
|
10
|
+
*/
|
|
7
11
|
library ECDSA {
|
|
8
12
|
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
|
|
9
13
|
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
|
|
@@ -18,6 +22,15 @@ library ECDSA {
|
|
|
18
22
|
uint256 private constant _COMPACT_S_MASK = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
|
|
19
23
|
uint256 private constant _COMPACT_V_SHIFT = 255;
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @notice Recovers the signer's address from the signature.
|
|
27
|
+
* @dev Recovers the address that has signed a hash with `(v, r, s)` signature.
|
|
28
|
+
* @param hash The keccak256 hash of the data signed.
|
|
29
|
+
* @param v The recovery byte of the signature.
|
|
30
|
+
* @param r The first 32 bytes of the signature.
|
|
31
|
+
* @param s The second 32 bytes of the signature.
|
|
32
|
+
* @return signer The address of the signer.
|
|
33
|
+
*/
|
|
21
34
|
function recover(
|
|
22
35
|
bytes32 hash,
|
|
23
36
|
uint8 v,
|
|
@@ -39,6 +52,14 @@ library ECDSA {
|
|
|
39
52
|
}
|
|
40
53
|
}
|
|
41
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @notice Recovers the signer's address from the signature using `r` and `vs` components.
|
|
57
|
+
* @dev Recovers the address that has signed a hash with `r` and `vs`, where `vs` combines `v` and `s`.
|
|
58
|
+
* @param hash The keccak256 hash of the data signed.
|
|
59
|
+
* @param r The first 32 bytes of the signature.
|
|
60
|
+
* @param vs The combined `v` and `s` values of the signature.
|
|
61
|
+
* @return signer The address of the signer.
|
|
62
|
+
*/
|
|
42
63
|
function recover(
|
|
43
64
|
bytes32 hash,
|
|
44
65
|
bytes32 r,
|
|
@@ -60,6 +81,12 @@ library ECDSA {
|
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @notice Recovers the signer's address from a hash and a signature.
|
|
86
|
+
* @param hash The keccak256 hash of the signed data.
|
|
87
|
+
* @param signature The full signature from which the signer will be recovered.
|
|
88
|
+
* @return signer The address of the signer.
|
|
89
|
+
*/
|
|
63
90
|
/// @dev WARNING!!!
|
|
64
91
|
/// There is a known signature malleability issue with two representations of signatures!
|
|
65
92
|
/// Even though this function is able to verify both standard 65-byte and compact 64-byte EIP-2098 signatures
|
|
@@ -102,6 +129,14 @@ library ECDSA {
|
|
|
102
129
|
}
|
|
103
130
|
}
|
|
104
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @notice Verifies the signature for a hash, either by recovering the signer or using EIP-1271's `isValidSignature` function.
|
|
134
|
+
* @dev Attempts to recover the signer's address from the signature; if the address is non-zero, checks if it's valid according to EIP-1271.
|
|
135
|
+
* @param signer The address to validate the signature against.
|
|
136
|
+
* @param hash The hash of the signed data.
|
|
137
|
+
* @param signature The signature to verify.
|
|
138
|
+
* @return success True if the signature is verified, false otherwise.
|
|
139
|
+
*/
|
|
105
140
|
function recoverOrIsValidSignature(
|
|
106
141
|
address signer,
|
|
107
142
|
bytes32 hash,
|
|
@@ -114,6 +149,16 @@ library ECDSA {
|
|
|
114
149
|
return isValidSignature(signer, hash, signature);
|
|
115
150
|
}
|
|
116
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @notice Verifies the signature for a hash, either by recovering the signer or using EIP-1271's `isValidSignature` function.
|
|
154
|
+
* @dev Attempts to recover the signer's address from the signature; if the address is non-zero, checks if it's valid according to EIP-1271.
|
|
155
|
+
* @param signer The address to validate the signature against.
|
|
156
|
+
* @param hash The hash of the signed data.
|
|
157
|
+
* @param v The recovery byte of the signature.
|
|
158
|
+
* @param r The first 32 bytes of the signature.
|
|
159
|
+
* @param s The second 32 bytes of the signature.
|
|
160
|
+
* @return success True if the signature is verified, false otherwise.
|
|
161
|
+
*/
|
|
117
162
|
function recoverOrIsValidSignature(
|
|
118
163
|
address signer,
|
|
119
164
|
bytes32 hash,
|
|
@@ -128,6 +173,15 @@ library ECDSA {
|
|
|
128
173
|
return isValidSignature(signer, hash, v, r, s);
|
|
129
174
|
}
|
|
130
175
|
|
|
176
|
+
/**
|
|
177
|
+
* @notice Verifies the signature for a hash, either by recovering the signer or using EIP-1271's `isValidSignature` function.
|
|
178
|
+
* @dev Attempts to recover the signer's address from the signature; if the address is non-zero, checks if it's valid according to EIP-1271.
|
|
179
|
+
* @param signer The address to validate the signature against.
|
|
180
|
+
* @param hash The hash of the signed data.
|
|
181
|
+
* @param r The first 32 bytes of the signature.
|
|
182
|
+
* @param vs The combined `v` and `s` values of the signature.
|
|
183
|
+
* @return success True if the signature is verified, false otherwise.
|
|
184
|
+
*/
|
|
131
185
|
function recoverOrIsValidSignature(
|
|
132
186
|
address signer,
|
|
133
187
|
bytes32 hash,
|
|
@@ -141,6 +195,15 @@ library ECDSA {
|
|
|
141
195
|
return isValidSignature(signer, hash, r, vs);
|
|
142
196
|
}
|
|
143
197
|
|
|
198
|
+
/**
|
|
199
|
+
* @notice Verifies the signature for a given hash, attempting to recover the signer's address or validates it using EIP-1271 for 65-byte signatures.
|
|
200
|
+
* @dev Attempts to recover the signer's address from the signature. If the address is a contract, checks if the signature is valid according to EIP-1271.
|
|
201
|
+
* @param signer The expected signer's address.
|
|
202
|
+
* @param hash The keccak256 hash of the signed data.
|
|
203
|
+
* @param r The first 32 bytes of the signature.
|
|
204
|
+
* @param vs The last 32 bytes of the signature, with the last byte being the recovery id.
|
|
205
|
+
* @return success True if the signature is valid, false otherwise.
|
|
206
|
+
*/
|
|
144
207
|
function recoverOrIsValidSignature65(
|
|
145
208
|
address signer,
|
|
146
209
|
bytes32 hash,
|
|
@@ -154,6 +217,14 @@ library ECDSA {
|
|
|
154
217
|
return isValidSignature65(signer, hash, r, vs);
|
|
155
218
|
}
|
|
156
219
|
|
|
220
|
+
/**
|
|
221
|
+
* @notice Validates a signature for a hash using EIP-1271, if `signer` is a contract.
|
|
222
|
+
* @dev Makes a static call to `signer` with `isValidSignature` function selector from EIP-1271.
|
|
223
|
+
* @param signer The address of the signer to validate against, which could be an EOA or a contract.
|
|
224
|
+
* @param hash The hash of the signed data.
|
|
225
|
+
* @param signature The signature to validate.
|
|
226
|
+
* @return success True if the signature is valid according to EIP-1271, false otherwise.
|
|
227
|
+
*/
|
|
157
228
|
function isValidSignature(
|
|
158
229
|
address signer,
|
|
159
230
|
bytes32 hash,
|
|
@@ -176,6 +247,16 @@ library ECDSA {
|
|
|
176
247
|
}
|
|
177
248
|
}
|
|
178
249
|
|
|
250
|
+
/**
|
|
251
|
+
* @notice Validates a signature for a hash using EIP-1271, if `signer` is a contract.
|
|
252
|
+
* @dev Makes a static call to `signer` with `isValidSignature` function selector from EIP-1271.
|
|
253
|
+
* @param signer The address of the signer to validate against, which could be an EOA or a contract.
|
|
254
|
+
* @param hash The hash of the signed data.
|
|
255
|
+
* @param v The recovery byte of the signature.
|
|
256
|
+
* @param r The first 32 bytes of the signature.
|
|
257
|
+
* @param s The second 32 bytes of the signature.
|
|
258
|
+
* @return success True if the signature is valid according to EIP-1271, false otherwise.
|
|
259
|
+
*/
|
|
179
260
|
function isValidSignature(
|
|
180
261
|
address signer,
|
|
181
262
|
bytes32 hash,
|
|
@@ -200,6 +281,15 @@ library ECDSA {
|
|
|
200
281
|
}
|
|
201
282
|
}
|
|
202
283
|
|
|
284
|
+
/**
|
|
285
|
+
* @notice Validates a signature for a hash using EIP-1271, if `signer` is a contract.
|
|
286
|
+
* @dev Makes a static call to `signer` with `isValidSignature` function selector from EIP-1271.
|
|
287
|
+
* @param signer The address of the signer to validate against, which could be an EOA or a contract.
|
|
288
|
+
* @param hash The hash of the signed data.
|
|
289
|
+
* @param r The first 32 bytes of the signature.
|
|
290
|
+
* @param vs The last 32 bytes of the signature, with the last byte being the recovery id.
|
|
291
|
+
* @return success True if the signature is valid according to EIP-1271, false otherwise.
|
|
292
|
+
*/
|
|
203
293
|
function isValidSignature(
|
|
204
294
|
address signer,
|
|
205
295
|
bytes32 hash,
|
|
@@ -224,6 +314,14 @@ library ECDSA {
|
|
|
224
314
|
}
|
|
225
315
|
}
|
|
226
316
|
|
|
317
|
+
/**
|
|
318
|
+
* @notice Verifies if a 65-byte signature is valid for a given hash, according to EIP-1271.
|
|
319
|
+
* @param signer The address of the signer to validate against, which could be an EOA or a contract.
|
|
320
|
+
* @param hash The hash of the signed data.
|
|
321
|
+
* @param r The first 32 bytes of the signature.
|
|
322
|
+
* @param vs The combined `v` (recovery id) and `s` component of the signature, packed into the last 32 bytes.
|
|
323
|
+
* @return success True if the signature is valid according to EIP-1271, false otherwise.
|
|
324
|
+
*/
|
|
227
325
|
function isValidSignature65(
|
|
228
326
|
address signer,
|
|
229
327
|
bytes32 hash,
|
|
@@ -249,6 +347,12 @@ library ECDSA {
|
|
|
249
347
|
}
|
|
250
348
|
}
|
|
251
349
|
|
|
350
|
+
/**
|
|
351
|
+
* @notice Generates a hash compatible with Ethereum's signed message format.
|
|
352
|
+
* @dev Prepends the hash with Ethereum's message prefix before hashing it.
|
|
353
|
+
* @param hash The hash of the data to sign.
|
|
354
|
+
* @return res The Ethereum signed message hash.
|
|
355
|
+
*/
|
|
252
356
|
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 res) {
|
|
253
357
|
// 32 is the length in bytes of hash, enforced by the type signature above
|
|
254
358
|
// return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
|
|
@@ -259,6 +363,13 @@ library ECDSA {
|
|
|
259
363
|
}
|
|
260
364
|
}
|
|
261
365
|
|
|
366
|
+
/**
|
|
367
|
+
* @notice Generates an EIP-712 compliant hash.
|
|
368
|
+
* @dev Encodes the domain separator and the struct hash according to EIP-712.
|
|
369
|
+
* @param domainSeparator The EIP-712 domain separator.
|
|
370
|
+
* @param structHash The EIP-712 struct hash.
|
|
371
|
+
* @return res The EIP-712 compliant hash.
|
|
372
|
+
*/
|
|
262
373
|
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 res) {
|
|
263
374
|
// return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
|
|
264
375
|
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @title RevertReasonForwarder
|
|
7
|
+
* @notice Provides utilities for forwarding and retrieving revert reasons from failed external calls.
|
|
8
|
+
*/
|
|
6
9
|
library RevertReasonForwarder {
|
|
7
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @dev Forwards the revert reason from the latest external call.
|
|
12
|
+
* This method allows propagating the revert reason of a failed external call to the caller.
|
|
13
|
+
*/
|
|
8
14
|
function reRevert() internal pure {
|
|
9
15
|
// bubble up revert reason from latest external call
|
|
10
16
|
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
|
|
@@ -14,7 +20,11 @@ library RevertReasonForwarder {
|
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @dev Retrieves the revert reason from the latest external call.
|
|
25
|
+
* This method enables capturing the revert reason of a failed external call for inspection or processing.
|
|
26
|
+
* @return reason The latest external call revert reason.
|
|
27
|
+
*/
|
|
18
28
|
function reReason() internal pure returns (bytes memory reason) {
|
|
19
29
|
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
|
|
20
30
|
reason := mload(0x40)
|
|
@@ -4,7 +4,9 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
|
|
5
5
|
import "./StringUtil.sol";
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* @title RevertReasonParser
|
|
9
|
+
* @notice Library that allows to parse unsuccessful arbitrary calls revert reasons.
|
|
8
10
|
* See https://solidity.readthedocs.io/en/latest/control-structures.html#revert for details.
|
|
9
11
|
* Note that we assume revert reason being abi-encoded as Error(string) so it may fail to parse reason
|
|
10
12
|
* if structured reverts appear in the future.
|
|
@@ -20,7 +22,14 @@ library RevertReasonParser {
|
|
|
20
22
|
bytes4 private constant _ERROR_SELECTOR = bytes4(keccak256("Error(string)"));
|
|
21
23
|
bytes4 private constant _PANIC_SELECTOR = bytes4(keccak256("Panic(uint256)"));
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @dev Parses revert reason from failed calls, returning it with a `prefix`.
|
|
27
|
+
* Handles standard `Error(string)` and `Panic(uint256)` formats, defaulting to `Unknown(data)` for unrecognized patterns.
|
|
28
|
+
*
|
|
29
|
+
* @param data The revert data to parse.
|
|
30
|
+
* @param prefix String to add before the parsed reason for context.
|
|
31
|
+
* @return The formatted revert reason.
|
|
32
|
+
*/
|
|
24
33
|
function parse(bytes memory data, string memory prefix) internal pure returns (string memory) {
|
|
25
34
|
// https://solidity.readthedocs.io/en/latest/control-structures.html#revert
|
|
26
35
|
// We assume that revert reason is abi-encoded as Error(string)
|
|
@@ -6,6 +6,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
6
6
|
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
|
|
7
7
|
import "../interfaces/IDaiLikePermit.sol";
|
|
8
8
|
import "../interfaces/IPermit2.sol";
|
|
9
|
+
import "../interfaces/IERC7597Permit.sol";
|
|
9
10
|
import "../interfaces/IWETH.sol";
|
|
10
11
|
import "../libraries/RevertReasonForwarder.sol";
|
|
11
12
|
|
|
@@ -301,6 +302,7 @@ library SafeERC20 {
|
|
|
301
302
|
bytes4 permitSelector = IERC20Permit.permit.selector;
|
|
302
303
|
bytes4 daiPermitSelector = IDaiLikePermit.permit.selector;
|
|
303
304
|
bytes4 permit2Selector = IPermit2.permit.selector;
|
|
305
|
+
bytes4 erc7597PermitSelector = IERC7597Permit.permit.selector;
|
|
304
306
|
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
|
|
305
307
|
let ptr := mload(0x40)
|
|
306
308
|
|
|
@@ -389,10 +391,12 @@ library SafeERC20 {
|
|
|
389
391
|
// IPermit2.permit(address owner, PermitSingle calldata permitSingle, bytes calldata signature)
|
|
390
392
|
success := call(gas(), _PERMIT2, 0, ptr, 0x164, 0, 0)
|
|
391
393
|
}
|
|
392
|
-
//
|
|
394
|
+
// Dynamic length
|
|
393
395
|
default {
|
|
394
|
-
mstore(ptr,
|
|
395
|
-
|
|
396
|
+
mstore(ptr, erc7597PermitSelector)
|
|
397
|
+
calldatacopy(add(ptr, 0x04), permit.offset, permit.length) // copy permit calldata
|
|
398
|
+
// IERC7597Permit.permit(address owner, address spender, uint256 value, uint256 deadline, bytes memory signature)
|
|
399
|
+
success := call(gas(), token, 0, ptr, add(permit.length, 4), 0, 0)
|
|
396
400
|
}
|
|
397
401
|
}
|
|
398
402
|
}
|
|
@@ -2,18 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @title StringUtil
|
|
7
|
+
* @dev Library with gas-efficient string operations.
|
|
8
|
+
*/
|
|
6
9
|
library StringUtil {
|
|
10
|
+
/**
|
|
11
|
+
* @notice Converts a uint256 value to its hexadecimal string representation.
|
|
12
|
+
* @param value The uint256 value to convert.
|
|
13
|
+
* @return The hexadecimal string representation of the input value.
|
|
14
|
+
*/
|
|
7
15
|
function toHex(uint256 value) internal pure returns (string memory) {
|
|
8
16
|
return toHex(abi.encodePacked(value));
|
|
9
17
|
}
|
|
10
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @notice Converts an address to its hexadecimal string representation.
|
|
21
|
+
* @param value The address to convert.
|
|
22
|
+
* @return The hexadecimal string representation of the input address.
|
|
23
|
+
*/
|
|
11
24
|
function toHex(address value) internal pure returns (string memory) {
|
|
12
25
|
return toHex(abi.encodePacked(value));
|
|
13
26
|
}
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @dev Converts arbitrary bytes to their hexadecimal string representation.
|
|
30
|
+
* This is an assembly adaptation of highly optimized toHex16 code by Mikhail Vladimirov.
|
|
31
|
+
* Reference: https://stackoverflow.com/a/69266989
|
|
32
|
+
* @param data The bytes to be converted to hexadecimal string.
|
|
33
|
+
* @return result The hexadecimal string representation of the input bytes.
|
|
34
|
+
*/
|
|
17
35
|
function toHex(bytes memory data) internal pure returns (string memory result) {
|
|
18
36
|
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
|
|
19
37
|
function _toHex16(input) -> output {
|
|
@@ -8,7 +8,11 @@ import "../interfaces/IERC20MetadataUppercase.sol";
|
|
|
8
8
|
import "./SafeERC20.sol";
|
|
9
9
|
import "./StringUtil.sol";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @title UniERC20
|
|
13
|
+
* @dev Library to abstract the handling of ETH and ERC20 tokens, enabling unified interaction with both. It allows usage of ETH as ERC20.
|
|
14
|
+
* Utilizes SafeERC20 for ERC20 interactions and provides additional utility functions.
|
|
15
|
+
*/
|
|
12
16
|
library UniERC20 {
|
|
13
17
|
using SafeERC20 for IERC20;
|
|
14
18
|
|
|
@@ -23,12 +27,21 @@ library UniERC20 {
|
|
|
23
27
|
IERC20 private constant _ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
|
|
24
28
|
IERC20 private constant _ZERO_ADDRESS = IERC20(address(0));
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @dev Determines if the specified token is ETH.
|
|
32
|
+
* @param token The token to check.
|
|
33
|
+
* @return bool True if the token is ETH, false otherwise.
|
|
34
|
+
*/
|
|
27
35
|
function isETH(IERC20 token) internal pure returns (bool) {
|
|
28
36
|
return (token == _ZERO_ADDRESS || token == _ETH_ADDRESS);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @dev Retrieves the balance of the specified token for an account.
|
|
41
|
+
* @param token The token to query the balance of.
|
|
42
|
+
* @param account The address of the account.
|
|
43
|
+
* @return uint256 The balance of the token for the specified account.
|
|
44
|
+
*/
|
|
32
45
|
function uniBalanceOf(IERC20 token, address account) internal view returns (uint256) {
|
|
33
46
|
if (isETH(token)) {
|
|
34
47
|
return account.balance;
|
|
@@ -37,8 +50,13 @@ library UniERC20 {
|
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @dev Transfers a specified amount of the token to a given address.
|
|
55
|
+
* Note: Does nothing if the amount is zero.
|
|
56
|
+
* @param token The token to transfer.
|
|
57
|
+
* @param to The address to transfer the token to.
|
|
58
|
+
* @param amount The amount of the token to transfer.
|
|
59
|
+
*/
|
|
42
60
|
function uniTransfer(
|
|
43
61
|
IERC20 token,
|
|
44
62
|
address payable to,
|
|
@@ -56,8 +74,14 @@ library UniERC20 {
|
|
|
56
74
|
}
|
|
57
75
|
}
|
|
58
76
|
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
/**
|
|
78
|
+
* @dev Transfers a specified amount of the token from one address to another.
|
|
79
|
+
* Note: Does nothing if the amount is zero.
|
|
80
|
+
* @param token The token to transfer.
|
|
81
|
+
* @param from The address to transfer the token from.
|
|
82
|
+
* @param to The address to transfer the token to.
|
|
83
|
+
* @param amount The amount of the token to transfer.
|
|
84
|
+
*/
|
|
61
85
|
function uniTransferFrom(
|
|
62
86
|
IERC20 token,
|
|
63
87
|
address payable from,
|
|
@@ -83,17 +107,31 @@ library UniERC20 {
|
|
|
83
107
|
}
|
|
84
108
|
}
|
|
85
109
|
|
|
86
|
-
|
|
110
|
+
/**
|
|
111
|
+
* @dev Retrieves the symbol from ERC20 metadata of the specified token.
|
|
112
|
+
* @param token The token to retrieve the symbol of.
|
|
113
|
+
* @return string The symbol of the token.
|
|
114
|
+
*/
|
|
87
115
|
function uniSymbol(IERC20 token) internal view returns (string memory) {
|
|
88
116
|
return _uniDecode(token, IERC20Metadata.symbol.selector, IERC20MetadataUppercase.SYMBOL.selector);
|
|
89
117
|
}
|
|
90
118
|
|
|
91
|
-
|
|
119
|
+
/**
|
|
120
|
+
* @dev Retrieves the name from ERC20 metadata of the specified token.
|
|
121
|
+
* @param token The token to retrieve the name of.
|
|
122
|
+
* @return string The name of the token.
|
|
123
|
+
*/
|
|
92
124
|
function uniName(IERC20 token) internal view returns (string memory) {
|
|
93
125
|
return _uniDecode(token, IERC20Metadata.name.selector, IERC20MetadataUppercase.NAME.selector);
|
|
94
126
|
}
|
|
95
127
|
|
|
96
|
-
|
|
128
|
+
/**
|
|
129
|
+
* @dev forceApprove the specified amount of the token to a given address.
|
|
130
|
+
* Reverts if the token is ETH.
|
|
131
|
+
* @param token The token to approve.
|
|
132
|
+
* @param to The address to approve the token to.
|
|
133
|
+
* @param amount The amount of the token to approve.
|
|
134
|
+
*/
|
|
97
135
|
function uniApprove(
|
|
98
136
|
IERC20 token,
|
|
99
137
|
address to,
|
|
@@ -104,8 +142,15 @@ library UniERC20 {
|
|
|
104
142
|
token.forceApprove(to, amount);
|
|
105
143
|
}
|
|
106
144
|
|
|
107
|
-
|
|
108
|
-
|
|
145
|
+
/**
|
|
146
|
+
* @dev Internal function to decode token metadata (name or symbol).
|
|
147
|
+
* 20K gas is provided to account for possible implementations of name/symbol
|
|
148
|
+
* (token implementation might be behind proxy or store the value in storage)
|
|
149
|
+
* @param token The token to decode metadata for.
|
|
150
|
+
* @param lowerCaseSelector The selector for the lowercase metadata function.
|
|
151
|
+
* @param upperCaseSelector The selector for the uppercase metadata function.
|
|
152
|
+
* @return result The decoded metadata value.
|
|
153
|
+
*/
|
|
109
154
|
function _uniDecode(
|
|
110
155
|
IERC20 token,
|
|
111
156
|
bytes4 lowerCaseSelector,
|
|
@@ -5,7 +5,19 @@ pragma solidity ^0.8.0;
|
|
|
5
5
|
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
|
|
6
6
|
import "./TokenMock.sol";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @title ERC20PermitMock
|
|
10
|
+
* @dev Extends ERC20Permit and TokenMock for testing purposes, incorporating permit functionality.
|
|
11
|
+
* This contract simplifies the testing of ERC20 tokens with permit capabilities by allowing easy setup of initial states.
|
|
12
|
+
*/
|
|
8
13
|
contract ERC20PermitMock is ERC20Permit, TokenMock {
|
|
14
|
+
/**
|
|
15
|
+
* @dev Creates an instance of `ERC20PermitMock` with specified token details and initial token distribution.
|
|
16
|
+
* @param name Name of the ERC20 token.
|
|
17
|
+
* @param symbol Symbol of the ERC20 token.
|
|
18
|
+
* @param initialAccount Address to receive the initial token supply.
|
|
19
|
+
* @param initialBalance Amount of tokens to mint to the `initialAccount`.
|
|
20
|
+
*/
|
|
9
21
|
constructor(
|
|
10
22
|
string memory name,
|
|
11
23
|
string memory symbol,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.25;
|
|
4
|
+
|
|
5
|
+
import "../mixins/SelfdestructEthSender.sol";
|
|
6
|
+
|
|
7
|
+
contract SelfdestructEthSenderMock is SelfdestructEthSender {
|
|
8
|
+
error ETHTransferFailed();
|
|
9
|
+
|
|
10
|
+
receive() external payable {}
|
|
11
|
+
|
|
12
|
+
function transferBalance(address payable receiver) external payable {
|
|
13
|
+
// solhint-disable-next-line avoid-low-level-calls
|
|
14
|
+
(bool success, ) = receiver.call{value: address(this).balance}("");
|
|
15
|
+
if (!success) revert ETHTransferFailed();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -5,9 +5,20 @@ pragma solidity ^0.8.0;
|
|
|
5
5
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
6
6
|
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @title TokenCustomDecimalsMock
|
|
10
|
+
* @dev Extends ERC20Permit token with custom number of decimals and only owner access to `mint` and `burn` functionality.
|
|
11
|
+
*/
|
|
8
12
|
contract TokenCustomDecimalsMock is ERC20Permit, Ownable {
|
|
9
13
|
uint8 internal immutable _DECIMALS;
|
|
10
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @dev Sets up the ERC20 token with a name, symbol, initial amount to mint, and custom decimals.
|
|
17
|
+
* @param name Name of the token.
|
|
18
|
+
* @param symbol Symbol of the token.
|
|
19
|
+
* @param amount Initial amount of tokens to mint to the owner.
|
|
20
|
+
* @param decimals_ Custom number of decimal places for the token.
|
|
21
|
+
*/
|
|
11
22
|
constructor(
|
|
12
23
|
string memory name,
|
|
13
24
|
string memory symbol,
|
|
@@ -18,19 +29,29 @@ contract TokenCustomDecimalsMock is ERC20Permit, Ownable {
|
|
|
18
29
|
_DECIMALS = decimals_;
|
|
19
30
|
}
|
|
20
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @notice Mints tokens to a specified account, callable only by the owner.
|
|
34
|
+
* @param account The address to mint tokens to.
|
|
35
|
+
* @param amount The amount of tokens to mint.
|
|
36
|
+
*/
|
|
21
37
|
function mint(address account, uint256 amount) external onlyOwner {
|
|
22
38
|
_mint(account, amount);
|
|
23
39
|
}
|
|
24
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @notice Burns tokens from a specified account, callable only by the owner.
|
|
43
|
+
* @param account The address to burn tokens from.
|
|
44
|
+
* @param amount The amount of tokens to burn.
|
|
45
|
+
*/
|
|
25
46
|
function burn(address account, uint256 amount) external onlyOwner {
|
|
26
47
|
_burn(account, amount);
|
|
27
48
|
}
|
|
28
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @dev Returns the number of decimal places of the token.
|
|
52
|
+
* @return Number of decimal places.
|
|
53
|
+
*/
|
|
29
54
|
function decimals() public view virtual override returns (uint8) {
|
|
30
55
|
return _DECIMALS;
|
|
31
56
|
}
|
|
32
|
-
|
|
33
|
-
function getChainId() external view returns (uint256) {
|
|
34
|
-
return block.chainid;
|
|
35
|
-
}
|
|
36
57
|
}
|
|
@@ -5,14 +5,33 @@ pragma solidity ^0.8.0;
|
|
|
5
5
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
6
6
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @title TokenMock
|
|
10
|
+
* @dev Simple ERC20 token mock for testing purposes, with minting and burning capabilities restricted to the owner.
|
|
11
|
+
*/
|
|
8
12
|
contract TokenMock is ERC20, Ownable {
|
|
13
|
+
/**
|
|
14
|
+
* @dev Initializes the contract with token name and symbol, setting the deployer as the owner.
|
|
15
|
+
* @param name Name of the ERC20 token.
|
|
16
|
+
* @param symbol Symbol of the ERC20 token.
|
|
17
|
+
*/
|
|
9
18
|
// solhint-disable-next-line no-empty-blocks
|
|
10
19
|
constructor(string memory name, string memory symbol) ERC20(name, symbol) Ownable(msg.sender) {}
|
|
11
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @notice Mints tokens to a specified account, callable only by the owner.
|
|
23
|
+
* @param account The address to mint tokens to.
|
|
24
|
+
* @param amount The amount of tokens to mint.
|
|
25
|
+
*/
|
|
12
26
|
function mint(address account, uint256 amount) external onlyOwner {
|
|
13
27
|
_mint(account, amount);
|
|
14
28
|
}
|
|
15
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @notice Burns tokens from a specified account, callable only by the owner.
|
|
32
|
+
* @param account The address to burn tokens from.
|
|
33
|
+
* @param amount The amount of tokens to burn.
|
|
34
|
+
*/
|
|
16
35
|
function burn(address account, uint256 amount) external onlyOwner {
|
|
17
36
|
_burn(account, amount);
|
|
18
37
|
}
|
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
import { ChainConfig } from '@nomicfoundation/hardhat-verify/src/types';
|
|
2
2
|
import { Network, NetworksUserConfig } from 'hardhat/types';
|
|
3
|
+
/** @internal */
|
|
3
4
|
export type Etherscan = {
|
|
4
5
|
apiKey: {
|
|
5
6
|
[key: string]: string;
|
|
6
7
|
};
|
|
7
8
|
customChains: ChainConfig[];
|
|
8
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* @category Hardhat-Setup
|
|
12
|
+
* @notice A helper method to get the network name from the command line arguments.
|
|
13
|
+
* @returns The network name.
|
|
14
|
+
*/
|
|
9
15
|
export declare function getNetwork(): string;
|
|
16
|
+
/**
|
|
17
|
+
* @category Hardhat-Setup
|
|
18
|
+
* @notice A helper method to parse RPC configuration strings. Checks that the string is in the expected format.
|
|
19
|
+
* @param envRpc The RPC configuration string to parse.
|
|
20
|
+
* @returns An object containing the RPC URL and optional auth key HTTP header.
|
|
21
|
+
*/
|
|
10
22
|
export declare function parseRpcEnv(envRpc: string): {
|
|
11
23
|
url: string;
|
|
12
24
|
authKeyHttpHeader?: string;
|
|
13
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @category Hardhat-Setup
|
|
28
|
+
* @notice A helper method to reset the Hardhat network to the local network or to a fork.
|
|
29
|
+
* @param network The Hardhat network object.
|
|
30
|
+
* @param networkName The name of the network to reset to.
|
|
31
|
+
*/
|
|
14
32
|
export declare function resetHardhatNetworkFork(network: Network, networkName: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* @category Hardhat-Setup
|
|
35
|
+
* @notice The Network class is a helper class to register networks and Etherscan API keys.
|
|
36
|
+
* See the [README](https://github.com/1inch/solidity-utils/tree/master/hardhat-setup/README.md) for usage.
|
|
37
|
+
*/
|
|
15
38
|
export declare class Networks {
|
|
16
39
|
networks: NetworksUserConfig;
|
|
17
40
|
etherscan: Etherscan;
|
|
@@ -3,11 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Networks = exports.resetHardhatNetworkFork = exports.parseRpcEnv = exports.getNetwork = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const dotenv_1 = tslib_1.__importDefault(require("dotenv"));
|
|
6
|
+
/**
|
|
7
|
+
* @category Hardhat-Setup
|
|
8
|
+
* @notice A helper method to get the network name from the command line arguments.
|
|
9
|
+
* @returns The network name.
|
|
10
|
+
*/
|
|
6
11
|
function getNetwork() {
|
|
7
12
|
const index = process.argv.findIndex((arg) => arg === '--network') + 1;
|
|
8
13
|
return index !== 0 ? process.argv[index] : 'unknown';
|
|
9
14
|
}
|
|
10
15
|
exports.getNetwork = getNetwork;
|
|
16
|
+
/**
|
|
17
|
+
* @category Hardhat-Setup
|
|
18
|
+
* @notice A helper method to parse RPC configuration strings. Checks that the string is in the expected format.
|
|
19
|
+
* @param envRpc The RPC configuration string to parse.
|
|
20
|
+
* @returns An object containing the RPC URL and optional auth key HTTP header.
|
|
21
|
+
*/
|
|
11
22
|
function parseRpcEnv(envRpc) {
|
|
12
23
|
const [url, authKeyHttpHeader, overflow] = envRpc.split('|');
|
|
13
24
|
if (overflow || url === '') {
|
|
@@ -16,6 +27,12 @@ function parseRpcEnv(envRpc) {
|
|
|
16
27
|
return { url, authKeyHttpHeader };
|
|
17
28
|
}
|
|
18
29
|
exports.parseRpcEnv = parseRpcEnv;
|
|
30
|
+
/**
|
|
31
|
+
* @category Hardhat-Setup
|
|
32
|
+
* @notice A helper method to reset the Hardhat network to the local network or to a fork.
|
|
33
|
+
* @param network The Hardhat network object.
|
|
34
|
+
* @param networkName The name of the network to reset to.
|
|
35
|
+
*/
|
|
19
36
|
async function resetHardhatNetworkFork(network, networkName) {
|
|
20
37
|
if (networkName.toLowerCase() === 'hardhat') {
|
|
21
38
|
await network.provider.request({
|
|
@@ -37,6 +54,11 @@ async function resetHardhatNetworkFork(network, networkName) {
|
|
|
37
54
|
}
|
|
38
55
|
}
|
|
39
56
|
exports.resetHardhatNetworkFork = resetHardhatNetworkFork;
|
|
57
|
+
/**
|
|
58
|
+
* @category Hardhat-Setup
|
|
59
|
+
* @notice The Network class is a helper class to register networks and Etherscan API keys.
|
|
60
|
+
* See the [README](https://github.com/1inch/solidity-utils/tree/master/hardhat-setup/README.md) for usage.
|
|
61
|
+
*/
|
|
40
62
|
class Networks {
|
|
41
63
|
constructor(useHardhat = true, forkingNetworkName, saveHardhatDeployments = false) {
|
|
42
64
|
this.networks = {};
|