|
6 | 6 | /// @notice Adapted from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) |
7 | 7 |
|
8 | 8 | // Imports |
9 | | -#include "../utils/Errors.huff" |
10 | 9 | #include "../auth/NonPayable.huff" |
11 | 10 | #include "../data-structures/Hashmap.huff" |
12 | 11 |
|
|
70 | 69 | [INITIAL_DOMAIN_SEPARATOR] sstore // [] |
71 | 70 |
|
72 | 71 | // Copy the runtime bytecode with constructor argument concatenated. |
73 | | - 0x67 // [offset] - constructor code size |
| 72 | + __codesize(CONSTRUCTOR) // [offset] - constructor code size |
74 | 73 | dup1 // [offset, offset] |
75 | 74 | codesize // [total_size, offset, offset] |
76 | 75 | sub // [runtime_size, offset] |
|
243 | 242 | [BALANCE_SLOT] STORE_ELEMENT_FROM_KEYS(0x00) // [value, from, to] |
244 | 243 | } |
245 | 244 |
|
246 | | -/// @notice Approve |
247 | | -/// @notice Approves an address to spend an amount of tokens on the caller's behalf |
248 | | -#define macro APPROVE() = takes (0) returns (0) { |
249 | | - 0x24 calldataload // [value] |
250 | | - dup1 0x00 mstore // [value] |
251 | | - 0x04 calldataload // [to, value] |
252 | | - caller // [from, to, value] |
253 | | - |
254 | | - // Emit the approval event. |
255 | | - dup2 dup2 // [from, to, from, to, value] |
256 | | - __EVENT_HASH(APPROVAL_EVENT_SIGNATURE) // [sig, from, to, from, to, value] |
257 | | - 0x20 0x00 // [0, 32, sig, from, to, from, to, value] |
258 | | - log3 // [from, to, value] |
259 | | - |
260 | | - // Store the value at slot = keccak256(from . to) |
261 | | - STORE_ELEMENT_FROM_KEYS(0x00) |
262 | | -} |
263 | | - |
264 | 245 | /// @notice Domain Separator |
265 | 246 | /// @notice Returns the EIP-712 domain separator |
266 | 247 | #define macro DOMAIN_SEPARATOR() = takes (0) returns (0) { |
|
0 commit comments