Skip to content

Commit

Permalink
⚡ Smol Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 14, 2024
1 parent 537c12d commit c1f7921
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
30 changes: 15 additions & 15 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
IETest:testBalanceInERC20() (gas: 49226)
IETest:testBalanceInETH() (gas: 40352)
IETest:testCommandSendERC0() (gas: 103011)
IETest:testCommandSendETH() (gas: 69493)
IETest:testCommandSendUSDC() (gas: 135741)
IETest:testCommandSwapDAI() (gas: 101932)
IETest:testCommandSwapETH() (gas: 143575)
IETest:testCommandSwapUSDC() (gas: 156814)
IETest:testDeploy() (gas: 2600880)
IETest:testENSNameOwnership() (gas: 84145)
IETest:testBalanceInERC20() (gas: 49207)
IETest:testBalanceInETH() (gas: 40333)
IETest:testCommandSendERC0() (gas: 102992)
IETest:testCommandSendETH() (gas: 69474)
IETest:testCommandSendUSDC() (gas: 135722)
IETest:testCommandSwapDAI() (gas: 101711)
IETest:testCommandSwapETH() (gas: 112535)
IETest:testCommandSwapUSDC() (gas: 156092)
IETest:testDeploy() (gas: 2599275)
IETest:testENSNameOwnership() (gas: 84088)
IETest:testIENameSetting() (gas: 8142)
IETest:testPreviewCommandSendDecimals() (gas: 92022)
IETest:testPreviewCommandSendUSDC() (gas: 66132)
IETest:testPreviewSend() (gas: 42692)
IETest:testPreviewSendCommand() (gas: 54523)
IETest:testSendETH() (gas: 59714)
IETest:testPreviewCommandSendDecimals() (gas: 91984)
IETest:testPreviewCommandSendUSDC() (gas: 66113)
IETest:testPreviewSend() (gas: 42673)
IETest:testPreviewSendCommand() (gas: 54504)
IETest:testSendETH() (gas: 59695)
IETest:testTotalSupply() (gas: 14844)
19 changes: 7 additions & 12 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ contract IE {
_extractSwap(normalized);
(amount, token, to) = previewSwap(amountIn, tokenIn, tokenOut);
} else {
revert InvalidSyntax();
revert InvalidSyntax(); // Invalid command format.
}
}

/// @dev Previews a send command from the parts of a matched intent string.
/// @dev Previews a `send` command from the parts of a matched intent string.
function previewSend(string memory to, string memory amount, string memory token)
public
view
Expand All @@ -206,7 +206,7 @@ contract IE {
abi.encodeCall(IExecutor.execute, (isETH ? _to : _token, isETH ? _amount : 0, callData));
}

/// @dev Previews a swap command from the parts of a matched intent string.
/// @dev Previews a `swap` command from the parts of a matched intent string.
function previewSwap(string memory amountIn, string memory tokenIn, string memory tokenOut)
public
view
Expand Down Expand Up @@ -269,7 +269,7 @@ contract IE {
_extractSwap(normalized);
swap(amountIn, tokenIn, tokenOut);
} else {
revert InvalidSyntax();
revert InvalidSyntax(); // Invalid command format.
}
}

Expand Down Expand Up @@ -437,17 +437,12 @@ contract IE {
virtual
returns (address domainOwner, bytes32 node)
{
(, node) = _namehash(domain);
node = _namehash(domain);
return (ENS_REGISTRY.owner(node), node);
}

/// @dev Computes an ENS domain namehash.
function _namehash(string memory domain)
internal
view
virtual
returns (string memory normalized, bytes32 node)
{
function _namehash(string memory domain) internal view virtual returns (bytes32 node) {
// Process labels (in reverse order for namehash).
uint256 i = bytes(domain).length;
uint256 lastDot = i;
Expand All @@ -467,7 +462,7 @@ contract IE {
}
}
}
return (domain, keccak256(abi.encodePacked(node, _labelhash(domain, i, lastDot))));
return keccak256(abi.encodePacked(node, _labelhash(domain, i, lastDot)));
}

/// @dev Computes an ENS domain labelhash given its start and end.
Expand Down

0 comments on commit c1f7921

Please sign in to comment.