Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated makefile foundry command + changed contract imports to relative paths #28

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/1337/
/broadcast/*/31337/
/broadcast/*/41144114/
/broadcast/**/dry-run/
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -6,10 +6,16 @@ install:

.PHONY: foundry
foundry:
@if [[ "$(cmd)" == anvil* ]]; then \
extra_flags="-p 8545:8545"; \
else \
extra_flags=""; \
fi; \
docker run --rm \
-v $$(pwd):/app/foundry \
-u $$(id -u):$$(id -g) \
-p 8545:8545 \
ghcr.io/paradigmxyz/foundry-alphanet:latest \
--foundry-directory /app/foundry \
--foundry-command "$(cmd)"
--env-file .env \
-v "$$(pwd):/app/foundry" \
-u "$$(id -u):$$(id -g)" \
$$extra_flags \
ghcr.io/paradigmxyz/foundry-alphanet:latest \
--foundry-directory /app/foundry \
--foundry-command "$(cmd)"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ make cmd="anvil"
Deploy the `BatchInvoker` contract to the network.

```shell
make cmd="forge script Deploy --sig 'deploy()' --rpc-url $RPC_URL --private-key $EXECUTOR_PRIVATE_KEY --broadcast"
make cmd="forge script Deploy --sig deploy() --rpc-url $RPC_URL --private-key $EXECUTOR_PRIVATE_KEY --broadcast"
```

**Note:** if the `$RPC_URL` you're pointing to is on host, you should use http://host.docker.internal:8545 instead of http://localhost:8545. See Docker's networking docs [here](https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host).
@@ -73,7 +73,7 @@ make cmd="forge script Deploy --sig 'deploy()' --rpc-url $RPC_URL --private-key
We can test the `BatchInvoker` by sending a transaction via the contract.

```shell
make cmd="forge script Executor --sig 'sendEth(address,address,uint256)' $INVOKER_ADDRESS 0x3074ca113074ca113074ca113074ca113074ca11 0.01ether --rpc-url $RPC_URL --broadcast"
make cmd="forge script Executor --sig sendEth(address,address,uint256) $INVOKER_ADDRESS 0x3074ca113074ca113074ca113074ca113074ca11 0.01ether --rpc-url $RPC_URL --broadcast"
```

## 3074-Compatible Networks
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@3074-invokers/contracts/=src/
2 changes: 1 addition & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { BatchInvoker } from "../src/BatchInvoker.sol";

contract Deploy is Script {
// deploy:
// make cmd="forge script Deploy --sig 'deploy()' --rpc-url $RPC_URL --private-key $EXECUTOR_PRIVATE_KEY --broadcast"
// make cmd="forge script Deploy --sig deploy() --rpc-url $RPC_URL --private-key $EXECUTOR_PRIVATE_KEY --broadcast"
function deploy() public {
vm.broadcast();
new BatchInvoker();
24 changes: 24 additions & 0 deletions script/Execute.s.sol
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import { BatchInvoker } from "../src/BatchInvoker.sol";
import { vToYParity, packCalls } from "../test/utils.sol";
import { Script } from "forge-std/Script.sol";
import { Test } from "forge-std/Test.sol";
import { LibString } from "solady/utils/LibString.sol";

contract Executor is Script, Test {
uint256 apk = vm.envUint("AUTHORITY_PRIVATE_KEY");
@@ -43,4 +44,27 @@ contract Executor is Script, Test {
call(invoker, recipient, value, "");
assertEq(recipient.balance, balanceBefore + value);
}

function test_fork_sendEth() public {
// set up fork, skip if localhost or docker.internal
string memory rpcUrl = vm.envString("RPC_URL");
if (bytes(rpcUrl).length > 0 && (LibString.contains(rpcUrl, "localhost") || LibString.contains(rpcUrl, "docker.internal"))) {
return;
}
uint256 forkId = vm.createFork(rpcUrl);
vm.selectFork(forkId);

// deploy batchinvoker
BatchInvoker invoker = new BatchInvoker();
// send 10 eth to authority
vm.broadcast(epk);
address authority = vm.addr(apk);
authority.call{value: 10 ether}("");
assertEq(authority.balance, 10 ether);

// send 1 eth to 0x3074 via invoker
sendEth(address(invoker), address(0x3074), 1 ether);
assertEq(address(0x3074).balance, 1 ether);
assertEq(authority.balance, 9 ether);
}
}
2 changes: 1 addition & 1 deletion src/BaseInvoker.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.20;

import { Auth } from "src/Auth.sol";
import { Auth } from "./Auth.sol";

/// @title BaseInvoker
/// @author Anna Carroll <https://github.com/anna-carroll/3074>
4 changes: 2 additions & 2 deletions src/BatchInvoker.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.20;

import { BaseInvoker } from "src/BaseInvoker.sol";
import { MultiSendAuthCallOnly } from "src/MultiSendAuthCallOnly.sol";
import { BaseInvoker } from "./BaseInvoker.sol";
import { MultiSendAuthCallOnly } from "./MultiSendAuthCallOnly.sol";

/// @title BatchInvoker
/// @author Anna Carroll <https://github.com/anna-carroll/3074>