Skip to content

Commit

Permalink
~~
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Aug 17, 2023
1 parent ddc1dee commit 17a65b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/Keep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ contract Keep is ERC1155TokenReceiver, KeepToken, Multicallable {
bytes memory data
) internal virtual {
if (op == Operation.call) {
/// @solidity memory-safe-assembly
assembly {
let success := call(
gas(),
Expand All @@ -383,6 +384,7 @@ contract Keep is ERC1155TokenReceiver, KeepToken, Multicallable {
}
}
} else if (op == Operation.delegatecall) {
/// @solidity memory-safe-assembly
assembly {
let success := delegatecall(
gas(),
Expand All @@ -402,6 +404,7 @@ contract Keep is ERC1155TokenReceiver, KeepToken, Multicallable {
}
}
} else {
/// @solidity memory-safe-assembly
assembly {
if iszero(create(value, add(data, 0x20), mload(data))) {
revert(0, 0)
Expand Down Expand Up @@ -433,9 +436,9 @@ contract Keep is ERC1155TokenReceiver, KeepToken, Multicallable {
// This also confirms non-zero `user`.
if (balanceOf[ecrecover(hash, v, r, s)][SIGN_KEY] != 0)
return this.isValidSignature.selector;
} else {
return 0xffffffff;
}

return 0xffffffff;
}

/// -----------------------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions src/KeepToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ abstract contract KeepToken {
virtual
returns (bytes32 separator)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Load the free memory pointer.
mstore(
Expand Down Expand Up @@ -256,18 +257,19 @@ abstract contract KeepToken {
/// -----------------------------------------------------------------------

function name() public pure virtual returns (string memory) {
uint256 placeholder;
uint256 n;

/// @solidity memory-safe-assembly
assembly {
placeholder := sub(
n := sub(
calldatasize(),
add(shr(240, calldataload(sub(calldatasize(), 2))), 2)
)

placeholder := calldataload(add(placeholder, 2))
n := calldataload(add(n, 2))
}

return string(abi.encodePacked(placeholder));
return string(abi.encodePacked(n));
}

string public constant symbol = "KEEP";
Expand Down

0 comments on commit 17a65b9

Please sign in to comment.