Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Nov 23, 2024
2 parents 186992e + e8759bd commit f7d43a5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ I'm sooooooOooooooooOoooOoooooooooooooooo...

## Installation

To install with [**Foundry**](https://github.com/gakonst/foundry):
To install with [**Foundry**](https://github.com/foundry-rs/foundry):

```sh
forge install vectorized/solady
Expand Down
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Foundry Configuration File
# Default definitions: https://github.com/gakonst/foundry/blob/b7917fa8491aedda4dd6db53fbb206ea233cd531/config/src/lib.rs#L782
# See more config options at: https://github.com/gakonst/foundry/tree/master/config
# Default definitions: https://github.com/foundry-rs/foundry/blob/b7917fa8491aedda4dd6db53fbb206ea233cd531/config/src/lib.rs#L782
# See more config options at: https://github.com/foundry-rs/foundry/tree/master/.config

# The Default Profile
[profile.default]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solady",
"license": "MIT",
"version": "0.0.270",
"version": "0.0.271",
"description": "Optimized Solidity snippets.",
"files": [
"src/**/*.sol",
Expand Down
46 changes: 3 additions & 43 deletions test/ERC7821.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ contract ERC7821Test is SoladyTest {

address target;

bytes32 internal constant _SUPPORTED_MODE = bytes10(0x01000000000078210001);

function setUp() public {
mbe = new MockERC7821();
target = LibClone.clone(address(this));
Expand All @@ -31,34 +29,7 @@ contract ERC7821Test is SoladyTest {
return keccak256(b);
}

function testERC7821Gas() public {
vm.pauseGasMetering();
vm.deal(address(this), 1 ether);

ERC7821.Call[] memory calls = new ERC7821.Call[](2);

calls[0].target = target;
calls[0].value = 123;
calls[0].data = abi.encodeWithSignature("returnsBytes(bytes)", "hehe");

calls[1].target = target;
calls[1].value = 789;
calls[1].data = abi.encodeWithSignature("returnsHash(bytes)", "lol");

bytes memory data = abi.encode(calls);
vm.resumeGasMetering();

bytes[] memory results = mbe.execute{value: _totalValue(calls)}(_SUPPORTED_MODE, data);

vm.pauseGasMetering();

assertEq(results.length, 2);
assertEq(abi.decode(results[0], (bytes)), "hehe");
assertEq(abi.decode(results[1], (bytes32)), keccak256("lol"));
vm.resumeGasMetering();
}

function testERC7821(bytes memory opData) public {
function testERC7821() public {
vm.deal(address(this), 1 ether);

ERC7821.Call[] memory calls = new ERC7821.Call[](2);
Expand All @@ -71,10 +42,7 @@ contract ERC7821Test is SoladyTest {
calls[1].value = 789;
calls[1].data = abi.encodeWithSignature("returnsHash(bytes)", "lol");

bytes[] memory results =
mbe.execute{value: _totalValue(calls)}(_SUPPORTED_MODE, _encode(calls, opData));

assertEq(mbe.lastOpData(), opData);
bytes[] memory results = mbe.execute{value: _totalValue(calls)}(calls, "");

assertEq(results.length, 2);
assertEq(abi.decode(results[0], (bytes)), "hehe");
Expand All @@ -88,15 +56,7 @@ contract ERC7821Test is SoladyTest {
calls[0].data = abi.encodeWithSignature("revertsWithCustomError()");

vm.expectRevert(CustomError.selector);
mbe.execute{value: _totalValue(calls)}(_SUPPORTED_MODE, _encode(calls, ""));
}

function _encode(ERC7821.Call[] memory calls, bytes memory opData)
internal
returns (bytes memory)
{
if (_randomChance(2) && opData.length == 0) return abi.encode(calls);
return abi.encode(calls, opData);
mbe.execute{value: _totalValue(calls)}(calls, "");
}

struct Payload {
Expand Down

0 comments on commit f7d43a5

Please sign in to comment.