@1inch/solidity-utils 4.1.0 → 4.2.1

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.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/contracts/interfaces/IERC7597Permit.sol +13 -0
  3. package/contracts/libraries/BySigTraits.sol +37 -5
  4. package/contracts/libraries/SafeERC20.sol +1 -1
  5. package/contracts/mixins/BySig.sol +220 -0
  6. package/contracts/mixins/EthReceiver.sol +27 -0
  7. package/contracts/mixins/OnlyWethReceiver.sol +31 -0
  8. package/contracts/mixins/PermitAndCall.sol +39 -0
  9. package/contracts/mixins/SelfdestructEthSender.sol +32 -0
  10. package/contracts/mocks/SelfdestructEthSenderMock.sol +10 -0
  11. package/dist/docgen/index.d.ts +2 -0
  12. package/dist/docgen/index.js +7 -0
  13. package/dist/docgen/index.js.map +1 -0
  14. package/dist/docgen/templates.d.ts +6 -0
  15. package/dist/docgen/templates.js +15 -0
  16. package/dist/docgen/templates.js.map +1 -0
  17. package/dist/hardhat-setup/networks.d.ts +6 -1
  18. package/dist/hardhat-setup/networks.js +1 -1
  19. package/dist/hardhat-setup/networks.js.map +1 -1
  20. package/dist/src/permit.d.ts +14 -2
  21. package/dist/src/permit.js +14 -2
  22. package/dist/src/permit.js.map +1 -1
  23. package/dist/src/utils.d.ts +41 -15
  24. package/dist/src/utils.js +9 -11
  25. package/dist/src/utils.js.map +1 -1
  26. package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.d.ts +1 -1
  27. package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.js +1 -1
  28. package/dist/typechain-types/factories/contracts/libraries/SafeERC20__factory.d.ts +1 -1
  29. package/dist/typechain-types/factories/contracts/libraries/SafeERC20__factory.js +1 -1
  30. package/dist/typechain-types/factories/contracts/libraries/UniERC20__factory.d.ts +1 -1
  31. package/dist/typechain-types/factories/contracts/libraries/UniERC20__factory.js +1 -1
  32. package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.d.ts +1 -1
  33. package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.js +1 -1
  34. package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.d.ts +1 -1
  35. package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.js +1 -1
  36. package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.d.ts +1 -1
  37. package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.js +1 -1
  38. package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.d.ts +1 -1
  39. package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.js +1 -1
  40. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.d.ts +1 -1
  41. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.js +1 -1
  42. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.d.ts +1 -1
  43. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.js +1 -1
  44. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.d.ts +1 -1
  45. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.js +1 -1
  46. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.d.ts +1 -1
  47. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.js +1 -1
  48. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.d.ts +1 -1
  49. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.js +1 -1
  50. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.d.ts +1 -1
  51. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.js +1 -1
  52. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.d.ts +1 -1
  53. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.js +1 -1
  54. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.d.ts +1 -1
  55. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.js +1 -1
  56. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.d.ts +1 -1
  57. package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.js +1 -1
  58. package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.d.ts +1 -1
  59. package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.js +1 -1
  60. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.d.ts +1 -1
  61. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.js +1 -1
  62. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.d.ts +1 -1
  63. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.js +1 -1
  64. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.d.ts +1 -1
  65. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.js +1 -1
  66. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.d.ts +1 -1
  67. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.js +1 -1
  68. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.d.ts +1 -1
  69. package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.js +1 -1
  70. package/package.json +9 -6
  71. package/utils/README.md +21 -3
  72. package/utils/docify.utils.js +1 -32
  73. package/utils/contract.hbs +0 -69
package/README.md CHANGED
@@ -19,7 +19,7 @@ This repository is a comprehensive toolkit designed to streamline and optimize t
19
19
 
20
20
  - **[Configuration and Management](https://github.com/1inch/solidity-utils/blob/master/docs/js/modules/hardhat_setup.md)**: Tools for setting up Hardhat network configurations and managing project settings efficiently.
21
21
 
22
- - **[Solidity Contracts and Libraries](https://github.com/1inch/solidity-utils/blob/master/docs/contracts/SUMMARY.md)**: Frequently used smart contracts, libraries, and interfaces aimed at providing reusable code for common use cases, alongside optimizations to improve contract efficiency.
22
+ - **[Solidity Contracts and Libraries](https://github.com/1inch/solidity-utils/blob/master/docs/SUMMARY.md)**: Frequently used smart contracts, libraries, and interfaces aimed at providing reusable code for common use cases, alongside optimizations to improve contract efficiency.
23
23
 
24
24
  ## Contributing
25
25
 
@@ -2,7 +2,20 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
+ /**
6
+ * @title IERC7597Permit
7
+ * @dev A new extension for ERC-2612 permit, which has already been added to USDC v2.2.
8
+ */
5
9
  interface IERC7597Permit {
10
+ /**
11
+ * @notice Update allowance with a signed permit.
12
+ * @dev Signature bytes can be used for both EOA wallets and contract wallets.
13
+ * @param owner Token owner's address (Authorizer).
14
+ * @param spender Spender's address.
15
+ * @param value Amount of allowance.
16
+ * @param deadline The time at which the signature expires (unixtime).
17
+ * @param signature Unstructured bytes signature signed by an EOA wallet or a contract wallet.
18
+ */
6
19
  function permit(
7
20
  address owner,
8
21
  address spender,
@@ -2,14 +2,25 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
+ /**
6
+ * @title BySigTraits
7
+ * @notice Provides utility functions for decoding and working with `BySig` call traits encoded in a single `uint256` value.
8
+ * @dev This library allows for the compact representation and manipulation of various call traits such as nonce type,
9
+ * deadline, relayer allowance, and nonce value using bit manipulation techniques.
10
+ */
5
11
  library BySigTraits {
12
+ /// @notice Thrown when an invalid nonce type is encountered.
6
13
  error WrongNonceType();
7
14
 
8
- // 2 bits for type
9
- // 6 bits reserved for future use
10
- // 40 bits for deadline
11
- // 80 bits for relayer address lower bits
12
- // 128 bits for nonce value
15
+ /**
16
+ * @dev Represents the encoded traits of a call, packed within a single `uint256`.
17
+ * The encoding is as follows:
18
+ * [255-254] - 2 bits - Nonce type (e.g., Account, Selector, Unique).
19
+ * [253-248] - 6 bits - Reserved for future use.
20
+ * [247-208] - 40 bits - Deadline (Unix timestamp at which the call becomes invalid).
21
+ * [207-128] - 80 bits - Relayer address's lower bits. A value of 0 indicates that any relayer is allowed.
22
+ * [127-0] - 128 bits - Nonce value (used for ensuring calls are executed in order and not replayed).
23
+ */
13
24
  type Value is uint256;
14
25
 
15
26
  enum NonceType {
@@ -25,21 +36,42 @@ library BySigTraits {
25
36
  uint256 constant internal RELAYER_BIT_MASK = (1 << 80) - 1;
26
37
  uint256 constant internal NONCE_MASK = (1 << 128) - 1;
27
38
 
39
+ /**
40
+ * @notice Decodes and returns the nonce type from the traits.
41
+ * @param traits The encoded call traits.
42
+ * @return The decoded nonce type as an enum.
43
+ */
28
44
  function nonceType(Value traits) internal pure returns(NonceType) {
29
45
  uint256 _type = Value.unwrap(traits) >> TYPE_BIT_SHIFT;
30
46
  if (_type > uint256(NonceType.Unique)) revert WrongNonceType();
31
47
  return NonceType(_type);
32
48
  }
33
49
 
50
+ /**
51
+ * @notice Decodes and returns the deadline from the traits.
52
+ * @param traits The encoded call traits.
53
+ * @return The decoded deadline timestamp.
54
+ */
34
55
  function deadline(Value traits) internal pure returns(uint256) {
35
56
  return (Value.unwrap(traits) >> DEADLINE_BIT_SHIFT) & DEADLINE_BIT_MASK;
36
57
  }
37
58
 
59
+ /**
60
+ * @notice Checks if a given relayer address is allowed to relay the call based on the traits.
61
+ * @param traits The encoded call traits.
62
+ * @param relayer The address of the relayer to check.
63
+ * @return True if the relayer is allowed, false otherwise.
64
+ */
38
65
  function isRelayerAllowed(Value traits, address relayer) internal pure returns(bool) {
39
66
  uint256 relayerBits = (Value.unwrap(traits) >> RELAYER_BIT_SHIFT) & RELAYER_BIT_MASK;
40
67
  return relayerBits == 0 || (uint160(relayer) & RELAYER_BIT_MASK) == relayerBits;
41
68
  }
42
69
 
70
+ /**
71
+ * @notice Decodes and returns the nonce value from the traits.
72
+ * @param traits The encoded call traits.
73
+ * @return The decoded nonce value.
74
+ */
43
75
  function nonce(Value traits) internal pure returns(uint256) {
44
76
  return Value.unwrap(traits) & NONCE_MASK;
45
77
  }
@@ -282,7 +282,7 @@ library SafeERC20 {
282
282
 
283
283
  /**
284
284
  * @notice The function attempts to call the permit function on a given ERC20 token.
285
- * @dev The function is designed to support a variety of permit functions, namely: IERC20Permit, IDaiLikePermit, and IPermit2.
285
+ * @dev The function is designed to support a variety of permit functions, namely: IERC20Permit, IDaiLikePermit, IERC7597Permit and IPermit2.
286
286
  * It accommodates both Compact and Full formats of these permit types.
287
287
  * Please note, it is expected that the `expiration` parameter for the compact Permit2 and the `deadline` parameter
288
288
  * for the compact Permit are to be incremented by one before invoking this function. This approach is motivated by
@@ -0,0 +1,220 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import { Context } from "@openzeppelin/contracts/utils/Context.sol";
6
+ import { Address } from "@openzeppelin/contracts/utils/Address.sol";
7
+ import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
8
+ import { ECDSA } from "../libraries/ECDSA.sol";
9
+ import { BySigTraits } from "../libraries/BySigTraits.sol";
10
+ import { AddressArray } from "../libraries/AddressArray.sol";
11
+
12
+ /**
13
+ * @title BySig
14
+ * @notice Mixin that provides signature-based accessibility to every external method of the smart contract.
15
+ * @dev Inherit your contract from this mixin and use `_msgSender()` instead of `msg.sender` everywhere.
16
+ */
17
+ abstract contract BySig is Context, EIP712 {
18
+ using Address for address;
19
+ using BySigTraits for BySigTraits.Value;
20
+ using AddressArray for AddressArray.Data;
21
+
22
+ /// @notice Emitted when the nonce used for a call is incorrect.
23
+ error WrongNonce();
24
+ /// @notice Emitted when a call is made by an unauthorized relayer.
25
+ error WrongRelayer();
26
+ /// @notice Emitted when the signature provided for a call does not match the expected signature.
27
+ error WrongSignature();
28
+ /// @notice Emitted when a call is attempted after the specified deadline has passed.
29
+ error DeadlineExceeded();
30
+
31
+ /**
32
+ * @notice Represents a call to be signed and executed.
33
+ * @dev This structure encapsulates all necessary information for executing a signed call,
34
+ * including traits that specify how the call should be authorized and the actual data to be executed.
35
+ * @param traits An instance of `Value` from the `BySigTraits` library, specifying the nonce type,
36
+ * nonce value, deadline, whether a relayer is allowed for this call and another params, see {BySigTraits-Value}.
37
+ * These traits define the authorization strategy and replay protection for the signed call.
38
+ * @param data The encoded function call data to be executed. This should be generated, for instance,
39
+ * using `encodeFunctionData` of the target contract's interface, containing the function signature and arguments.
40
+ * It represents the exact action to be taken, including which function to call of which contract and with what parameters.
41
+ */
42
+ struct SignedCall {
43
+ BySigTraits.Value traits;
44
+ bytes data;
45
+ }
46
+
47
+ bytes32 constant public SIGNED_CALL_TYPEHASH = keccak256("SignedCall(uint256 traits,bytes data)");
48
+
49
+ // Various nonces used for signature verification and replay protection.
50
+ AddressArray.Data /* transient */ private _msgSenders;
51
+ mapping(address => uint256) private _bySigAccountNonces;
52
+ mapping(address => mapping(bytes4 => uint256)) private _bySigSelectorNonces;
53
+ mapping(address => mapping(uint256 => uint256)) private _bySigUniqueNonces;
54
+
55
+ /**
56
+ * @notice Retrieves the account nonce for the specified account.
57
+ * @param account The address of the account.
58
+ * @return The current nonce for the account.
59
+ */
60
+ function bySigAccountNonces(address account) public view returns(uint256) {
61
+ return _bySigAccountNonces[account];
62
+ }
63
+
64
+ /**
65
+ * @notice Retrieves the selector nonce for a specific account and selector.
66
+ * @param account The address of the account.
67
+ * @param selector The selector for which the nonce is being retrieved.
68
+ * @return The current nonce for the specified selector and account.
69
+ */
70
+ function bySigSelectorNonces(address account, bytes4 selector) public view returns(uint256) {
71
+ return _bySigSelectorNonces[account][selector];
72
+ }
73
+
74
+ /**
75
+ * @notice Checks if a unique nonce has already been used for a given account.
76
+ * @dev This function divides the nonce space into slots to efficiently manage storage.
77
+ * A unique nonce is considered used if its corresponding bit in the storage slot is set.
78
+ * @param account The address of the account for which the nonce is being checked.
79
+ * @param nonce The unique nonce to check. It is divided into slots for storage efficiency.
80
+ * @return bool True if the nonce has been used, false otherwise.
81
+ */
82
+ function bySigUniqueNonces(address account, uint256 nonce) public view returns(bool) {
83
+ return (_bySigUniqueNonces[account][nonce >> 8] & (1 << (nonce & 0xff))) != 0;
84
+ }
85
+
86
+ /**
87
+ * @notice Retrieves the storage slot value for a given account and nonce slot.
88
+ * @dev This function allows access to the raw storage slot used to track used nonces, divided into slots for efficiency.
89
+ * Each bit in the returned value represents the used/unused status of a nonce within that slot.
90
+ * @param account The address of the account for which the nonce slot is being retrieved.
91
+ * @param nonce The nonce for which the storage slot is being retrieved. The function calculates the correct slot based on this value.
92
+ * @return uint256 The raw value of the storage slot that tracks the used/unused status of nonces in the specified slot for the given account.
93
+ */
94
+ function bySigUniqueNoncesSlot(address account, uint256 nonce) public view returns(uint256) {
95
+ return _bySigUniqueNonces[account][nonce >> 8];
96
+ }
97
+
98
+ /**
99
+ * @notice Hashes a `SignedCall` struct using EIP-712 typed data hashing rules.
100
+ * @param sig The `SignedCall` structure containing the call traits and data.
101
+ * @return The EIP-712 compliant hash of the `SignedCall` struct.
102
+ */
103
+ function hashBySig(SignedCall calldata sig) public view returns(bytes32) {
104
+ return _hashTypedDataV4(
105
+ keccak256(abi.encode(
106
+ SIGNED_CALL_TYPEHASH,
107
+ sig.traits,
108
+ keccak256(sig.data)
109
+ ))
110
+ );
111
+ }
112
+
113
+ /**
114
+ * @notice Executes a signature-authorized call on behalf of the signer.
115
+ * @param signer The address of the signer authorizing the call.
116
+ * @param sig The `SignedCall` structure containing the call traits and data.
117
+ * @param signature The signature authorizing the call.
118
+ * @return ret The bytes result of the executed call.
119
+ */
120
+ function bySig(address signer, SignedCall calldata sig, bytes calldata signature) public payable returns(bytes memory ret) {
121
+ if (block.timestamp > sig.traits.deadline()) revert DeadlineExceeded(); // solhint-disable-line not-rely-on-time
122
+ // Using _msgSender() in the next line allows private relay execution redelegation
123
+ if (!sig.traits.isRelayerAllowed(_msgSender())) revert WrongRelayer();
124
+ if (!_useNonce(signer, sig.traits, sig.data)) revert WrongNonce();
125
+ if (!ECDSA.recoverOrIsValidSignature(signer, hashBySig(sig), signature)) revert WrongSignature();
126
+
127
+ _msgSenders.push(signer);
128
+ ret = address(this).functionDelegateCall(sig.data);
129
+ _msgSenders.pop();
130
+ }
131
+
132
+ /**
133
+ * @notice Executes a call sponsored by the signer (for instance, by fee), intended to be used,
134
+ * for instance, in conjunction with `bySig`.
135
+ * @dev Facilitates execution of a delegate call where the signer covers the transaction fees.
136
+ * Requires `_chargeSigner` to be overridden to define the fee transfer logic.
137
+ * @param token Address of the token used for sponsored logic (for instance, for fee payment).
138
+ * @param amount amount value used for sponsored logic (for instance, fee amount to be charged to the signer).
139
+ * @param data Encoded function call to execute.
140
+ * @param extraData Additional data for sponsored process in `_chargeSigner` method.
141
+ * @return ret Result of the executed call.
142
+ */
143
+ function sponsoredCall(address token, uint256 amount, bytes calldata data, bytes calldata extraData) public payable returns(bytes memory ret) {
144
+ ret = address(this).functionDelegateCall(data);
145
+ _chargeSigner(_msgSender(), msg.sender, token, amount, extraData);
146
+ }
147
+
148
+ /**
149
+ * @dev Placeholder for custom logic to charge the signer for sponsored calls.
150
+ * Override this method to implement sponsored call accounting.
151
+ * Example imeplementation:
152
+ *
153
+ * function _chargeSigner(address signer, address relayer, address token, uint256 amount, bytes calldata extraData) internal override {
154
+ * balances[token][signer] -= amount;
155
+ * balances[token][relayer] += amount;
156
+ * }
157
+ *
158
+ * @param signer The address of the signer being charged.
159
+ * @param relayer The address of the relayer facilitating the call.
160
+ * @param token The token address used for charging.
161
+ * @param amount The amount to be charged.
162
+ * @param extraData Additional data for sponsored call accounting and executions.
163
+ */
164
+ function _chargeSigner(address signer, address relayer, address token, uint256 amount, bytes calldata extraData) internal virtual;
165
+
166
+ /**
167
+ * @notice Advances the account nonce for the sender by a specified amount.
168
+ * @param advance The amount by which to advance the nonce.
169
+ */
170
+ function useBySigAccountNonce(uint32 advance) public {
171
+ _bySigAccountNonces[_msgSender()] += advance;
172
+ }
173
+
174
+ /**
175
+ * @notice Advances the selector nonce for the sender and a specific selector by a specified amount.
176
+ * @param selector The selector for which the nonce is being advanced.
177
+ * @param advance The amount by which to advance the nonce.
178
+ */
179
+ function useBySigSelectorNonce(bytes4 selector, uint32 advance) public {
180
+ _bySigSelectorNonces[_msgSender()][selector] += advance;
181
+ }
182
+
183
+ /**
184
+ * @notice Marks a unique nonce as used for the sender.
185
+ * @param nonce The nonce being marked as used.
186
+ */
187
+ function useBySigUniqueNonce(uint256 nonce) public {
188
+ _bySigUniqueNonces[_msgSender()][nonce >> 8] |= 1 << (nonce & 0xff);
189
+ }
190
+
191
+ /**
192
+ * @dev Returns the address of the message sender, replacing the traditional `msg.sender` with a potentially signed sender.
193
+ * @return The address of the message sender.
194
+ */
195
+ function _msgSender() internal view override virtual returns (address) {
196
+ uint256 length = _msgSenders.length();
197
+ if (length == 0) {
198
+ return super._msgSender();
199
+ }
200
+ return _msgSenders.at(length - 1);
201
+ }
202
+
203
+ function _useNonce(address signer, BySigTraits.Value traits, bytes calldata data) private returns(bool) {
204
+ BySigTraits.NonceType nonceType = traits.nonceType();
205
+ uint256 nonce = traits.nonce();
206
+ if (nonceType == BySigTraits.NonceType.Account) {
207
+ return nonce == _bySigAccountNonces[signer]++;
208
+ }
209
+ if (nonceType == BySigTraits.NonceType.Selector) {
210
+ return nonce == _bySigSelectorNonces[signer][bytes4(data)]++;
211
+ }
212
+ if (nonceType == BySigTraits.NonceType.Unique) {
213
+ mapping(uint256 => uint256) storage map = _bySigUniqueNonces[signer];
214
+ uint256 cache = map[nonce >> 8];
215
+ map[nonce >> 8] |= 1 << (nonce & 0xff);
216
+ return cache != map[nonce >> 8];
217
+ }
218
+ return false;
219
+ }
220
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ /**
6
+ * @title EthReceiver
7
+ * @dev Abstract contract for rejecting direct ETH transfers from EOAs.
8
+ * Implements a custom error and logic to reject ETH deposits from non-contract addresses.
9
+ */
10
+ abstract contract EthReceiver {
11
+ /// @dev Error thrown when an ETH deposit from an EOA is attempted.
12
+ error EthDepositRejected();
13
+
14
+ /// @dev External payable function to receive ETH, automatically rejects deposits from EOAs.
15
+ receive() external payable {
16
+ _receive();
17
+ }
18
+
19
+ /**
20
+ * @dev Internal function containing the logic to reject ETH deposits.
21
+ * Can be overridden by derived contracts for specific behaviors while maintaining the base rejection mechanism.
22
+ */
23
+ function _receive() internal virtual {
24
+ // solhint-disable-next-line avoid-tx-origin
25
+ if (msg.sender == tx.origin) revert EthDepositRejected();
26
+ }
27
+ }
@@ -0,0 +1,31 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import "./EthReceiver.sol";
6
+
7
+ /**
8
+ * @title OnlyWethReceiver
9
+ * @dev Abstract contract extending EthReceiver to accept only ETH deposits from a specified WETH contract.
10
+ * This contract ensures that only wrapped ETH (WETH) can be deposited, rejecting all other direct ETH transfers.
11
+ */
12
+ abstract contract OnlyWethReceiver is EthReceiver {
13
+ /// @notice Address of the WETH contract allowed to deposit ETH.
14
+ address private immutable _WETH; // solhint-disable-line var-name-mixedcase
15
+
16
+ /**
17
+ * @dev Sets the WETH contract address during construction.
18
+ * @param weth Address of the WETH contract.
19
+ */
20
+ constructor(address weth) {
21
+ _WETH = address(weth);
22
+ }
23
+
24
+ /**
25
+ * @dev Overrides _receive to restrict ETH transfers solely to the WETH contract.
26
+ * Reverts with EthDepositRejected if ETH is sent from any other address.
27
+ */
28
+ function _receive() internal virtual override {
29
+ if (msg.sender != _WETH) revert EthDepositRejected();
30
+ }
31
+ }
@@ -0,0 +1,39 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6
+ import { SafeERC20 } from "../libraries/SafeERC20.sol";
7
+
8
+ /**
9
+ * @title PermitAndCall
10
+ * @dev Abstract contract to support permit and action execution in a single transaction.
11
+ * Allows tokens that implement EIP-2612 permits, DAI-like permits, USDC-like permits and Permit2 to be approved and spent in a single transaction.
12
+ */
13
+ abstract contract PermitAndCall {
14
+ using SafeERC20 for IERC20;
15
+
16
+ /**
17
+ * @notice Executes a permit for an ERC20 token and then a specified action in a single transaction.
18
+ * @param permit ERC20 token address (20 bytes) concatinated with the permit data, allowing this contract to spend the token.
19
+ * Format: [token address (20 bytes)][permit data]
20
+ * @param action The data representing the action to be executed after the permit.
21
+ */
22
+ function permitAndCall(bytes calldata permit, bytes calldata action) external payable {
23
+ IERC20(address(bytes20(permit))).tryPermit(permit[20:]);
24
+ // solhint-disable-next-line no-inline-assembly
25
+ assembly ("memory-safe") {
26
+ let ptr := mload(0x40)
27
+ calldatacopy(ptr, action.offset, action.length)
28
+ let success := delegatecall(gas(), address(), ptr, action.length, 0, 0)
29
+ returndatacopy(ptr, 0, returndatasize())
30
+ switch success
31
+ case 0 {
32
+ revert(ptr, returndatasize())
33
+ }
34
+ default {
35
+ return(ptr, returndatasize())
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,32 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.25;
4
+
5
+ /**
6
+ * @title SelfdestructEthSender
7
+ * @notice A one-time-use contract for cost-effective ETH transfers using the `selfdestruct` mechanism.
8
+ * @dev Upon construction, this contract verifies EVM compatibility with the Cancun upgrade, specifically
9
+ * testing for support of transient storage via `tload`. It is intended for single-use, allowing for ETH to
10
+ * be sent more cheaply by self-destructing and sending its balance to a designated address.
11
+ */
12
+ abstract contract SelfdestructEthSender {
13
+ /**
14
+ * @dev Initializes the contract, verifying compatibility with the Cancun EVM upgrade through transient storage support check.
15
+ */
16
+ constructor() {
17
+ // solhint-disable-next-line no-inline-assembly
18
+ assembly ("memory-safe") {
19
+ pop(tload(0))
20
+ }
21
+ }
22
+
23
+ /**
24
+ * @notice Makes the selfdestruct call, transferring the entire ETH balance of the contract to the specified address.
25
+ * Due to EIP-6780 chnges selfdestruct will destroy the contract only if it was created in the same transaction.
26
+ * In other cases it will stop the execution and transfer all the ETH balance saving about 1700 gas comparing to trivial transfer.
27
+ * @param receiver The recipient address of the contract's ETH balance.
28
+ */
29
+ function stopAndTransferBalance(address payable receiver) external {
30
+ selfdestruct(receiver);
31
+ }
32
+ }
@@ -4,11 +4,21 @@ pragma solidity ^0.8.25;
4
4
 
5
5
  import "../mixins/SelfdestructEthSender.sol";
6
6
 
7
+ /**
8
+ * @title SelfdestructEthSenderMock
9
+ * @notice Mock contract extending SelfdestructEthSender for testing purposes, with added functionality to transfer ETH.
10
+ */
7
11
  contract SelfdestructEthSenderMock is SelfdestructEthSender {
12
+ /// @notice Indicates that an attempt to transfer ETH has failed.
8
13
  error ETHTransferFailed();
9
14
 
15
+ /// @notice Allows the contract to receive ETH.
10
16
  receive() external payable {}
11
17
 
18
+ /**
19
+ * @notice Transfers the contract's entire ETH balance to the specified address.
20
+ * @param receiver The address to which the contract's ETH balance will be transferred.
21
+ */
12
22
  function transferBalance(address payable receiver) external payable {
13
23
  // solhint-disable-next-line avoid-low-level-calls
14
24
  (bool success, ) = receiver.call{value: address(this).balance}("");
@@ -0,0 +1,2 @@
1
+ export * from './templates';
2
+ export * from './templates';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // created from 'create-ts-index'
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./templates"), exports);
6
+ tslib_1.__exportStar(require("./templates"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../docgen/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;;;AAEjC,sDAA4B;AAC5B,sDAA4B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @category Docgen
3
+ * @notice A helper method to get the path to the templates folder.
4
+ * @returns The the path to templates folder.
5
+ */
6
+ export declare function oneInchTemplates(): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.oneInchTemplates = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ /**
7
+ * @category Docgen
8
+ * @notice A helper method to get the path to the templates folder.
9
+ * @returns The the path to templates folder.
10
+ */
11
+ function oneInchTemplates() {
12
+ return path_1.default.normalize(path_1.default.join(__dirname, '../../docgen/templates'));
13
+ }
14
+ exports.oneInchTemplates = oneInchTemplates;
15
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../docgen/templates.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB;;;;GAIG;AACH,SAAgB,gBAAgB;IAC5B,OAAO,cAAI,CAAC,SAAS,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC,CAAC;AAC1E,CAAC;AAFD,4CAEC"}
@@ -1,6 +1,11 @@
1
1
  import { ChainConfig } from '@nomicfoundation/hardhat-verify/src/types';
2
2
  import { Network, NetworksUserConfig } from 'hardhat/types';
3
- /** @internal */
3
+ /**
4
+ * @category Hardhat-Setup
5
+ * @notice Configuration type for managing Etherscan integration in Hardhat setups.
6
+ * @param apiKey Dictionary of API keys for accessing Etherscan, indexed by network name.
7
+ * @param customChains Array of custom blockchain network configurations.
8
+ */
4
9
  export type Etherscan = {
5
10
  apiKey: {
6
11
  [key: string]: string;
@@ -140,7 +140,7 @@ class Networks {
140
140
  // For 'zksyncFork' network you should use zksync fork node: https://github.com/matter-labs/era-test-node
141
141
  this.registerZksync('zksyncFork', 260, process.env.ZKSYNC_FORK_RPC_URL, 'mainnet', process.env.ZKSYNC_FORK_PRIVATE_KEY || privateKey);
142
142
  this.registerZksync('zksyncLocal', 270, process.env.ZKSYNC_LOCAL_RPC_URL, process.env.ZKSYNC_LOCAL_ETH_NETWORK, process.env.ZKSYNC_PRIVATE_KEY || privateKey);
143
- this.registerZksync('zksyncTest', 280, process.env.ZKSYNC_TEST_RPC_URL, 'goerli', process.env.ZKSYNC_TEST_PRIVATE_KEY || privateKey, process.env.ZKSYNC_TEST_VERIFY_URL);
143
+ this.registerZksync('zksyncTest', 300, process.env.ZKSYNC_TEST_RPC_URL, 'sepolia', process.env.ZKSYNC_TEST_PRIVATE_KEY || privateKey, process.env.ZKSYNC_TEST_VERIFY_URL);
144
144
  return { networks: this.networks, etherscan: this.etherscan };
145
145
  }
146
146
  }
@@ -1 +1 @@
1
- {"version":3,"file":"networks.js","sourceRoot":"","sources":["../../hardhat-setup/networks.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAO5B;;;;GAIG;AACH,SAAgB,UAAU;IACtB,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,WAAW,CAAC,GAAG,CAAC,CAAC;IACvE,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC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AC,kBAAkB,IAAI,UAAU,CAAC,CAAC;QAC9J,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAC1K,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IAClE,CAAC;CACJ;AAzFD,4BAyFC"}
@@ -159,8 +159,20 @@ export declare function getPermit2(owner: Wallet | SignerWithAddress, token: str
159
159
  * @return A signed permit string in Dai-like format.
160
160
  */
161
161
  export declare function getPermitLikeDai(holder: Wallet | SignerWithAddress, permitContract: DaiLikePermitMock, tokenVersion: string, chainId: number, spender: string, allowed: boolean, expiry?: string, compact?: boolean): Promise<string>;
162
- export declare function getPermitLikeUSDC(owner: string, // contract with isValidSignature function
163
- signer: Wallet | SignerWithAddress, permitContract: USDCLikePermitMock, tokenVersion: string, chainId: number, spender: string, value: string, deadline?: string): Promise<string>;
162
+ /**
163
+ * @category permit
164
+ * @notice Generates a ERC-7597 permit signature for tokens.
165
+ * @param owner Contract with isValidSignature function.
166
+ * @param signer The wallet or signer issuing the permit.
167
+ * @param permitContract The contract object with ERC7597Permit type and token address for which the permit creating.
168
+ * @param tokenVersion The version of the token's EIP-712 domain.
169
+ * @param chainId The unique identifier for the blockchain network.
170
+ * @param spender The address allowed to spend the tokens.
171
+ * @param value The amount of tokens the spender is allowed to use.
172
+ * @param deadline Time until when the permit is valid.
173
+ * @return A signed permit string in ERC7597Permit format.
174
+ */
175
+ export declare function getPermitLikeUSDC(owner: string, signer: Wallet | SignerWithAddress, permitContract: USDCLikePermitMock, tokenVersion: string, chainId: number, spender: string, value: string, deadline?: string): Promise<string>;
164
176
  /**
165
177
  * @category permit
166
178
  * @notice Concatenates a target address with data, trimming the '0x' prefix from the data.
@@ -204,8 +204,20 @@ async function getPermitLikeDai(holder, permitContract, tokenVersion, chainId, s
204
204
  return compact ? compressPermit(permitCall) : decompressPermit(compressPermit(permitCall), prelude_1.constants.ZERO_ADDRESS, holder.address, spender);
205
205
  }
206
206
  exports.getPermitLikeDai = getPermitLikeDai;
207
- async function getPermitLikeUSDC(owner, // contract with isValidSignature function
208
- signer, permitContract, tokenVersion, chainId, spender, value, deadline = exports.defaultDeadline.toString()) {
207
+ /**
208
+ * @category permit
209
+ * @notice Generates a ERC-7597 permit signature for tokens.
210
+ * @param owner Contract with isValidSignature function.
211
+ * @param signer The wallet or signer issuing the permit.
212
+ * @param permitContract The contract object with ERC7597Permit type and token address for which the permit creating.
213
+ * @param tokenVersion The version of the token's EIP-712 domain.
214
+ * @param chainId The unique identifier for the blockchain network.
215
+ * @param spender The address allowed to spend the tokens.
216
+ * @param value The amount of tokens the spender is allowed to use.
217
+ * @param deadline Time until when the permit is valid.
218
+ * @return A signed permit string in ERC7597Permit format.
219
+ */
220
+ async function getPermitLikeUSDC(owner, signer, permitContract, tokenVersion, chainId, spender, value, deadline = exports.defaultDeadline.toString()) {
209
221
  const nonce = await permitContract.nonces(owner);
210
222
  const name = await permitContract.name();
211
223
  const data = buildData(name, tokenVersion, chainId, await permitContract.getAddress(), owner, spender, value, nonce.toString(), deadline);