Hello im stuck with yul inline assembly when i want to access a double mapping.
mapping(address => mapping(address => uint256)) public approval_;
function approve(address spender, uint256 amount) external returns (bool) {
assembly {
// doc => https://docs.soliditylang.org/en/v0.8.9/internals/layout_in_storage.html
// keccak(keccak(spender) => keccak(caller => approve slot))
// load if user already approve this user
let msgsender
mstore(msgsender, caller()) // store msg.sender
let spender_
mstore(spender_, spender) // store spender
let ptr := mload(0x40) // load free memory
mstore(ptr, keccak256(spender_, 0x20)) // store hash spender
mstore(add(ptr, 0x20), msgsender) // store msg.sender after spender hash
mstore(add(ptr, 0x40), approval_.slot) // store approval slot after msg.sender
let googHash := keccak256(add(ptr, 0x20), 0x40) // hash msg.sender + approval slot
mstore(add(ptr, 0x20), googHash)
let approveSlot := keccak256(ptr, 0x40) // hash => hash spender + hash msg.sender + approval slot
let balanceApproved := sload(approveSlot) // load approve balance
// store the new value
sstore(approveSlot, add(balanceApproved, amount))
}
return true;
}
dont understand what im doing wrong, thank's for ut help ;)