Skip to content

Commit

Permalink
Migrate from Foundry Foreign Interface to File System (#10)
Browse files Browse the repository at this point in the history
* Refactor to use ffs instead of ffi

* Add seemingly newer broadcast type, without rpc

* Remove call to cleanStringPath, incompatible with fs_permissions

* Add makefile

* added example that doenst work

---------

Co-authored-by: PatrickAlphac <54278053+PatrickAlphaC@users.noreply.github.com>
  • Loading branch information
rocknet and PatrickAlphaC committed Nov 20, 2023
1 parent a8f7a89 commit 5415faa
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 158 deletions.
48 changes: 48 additions & 0 deletions broadcast/DeployStuff.s.sol/31337/run-1700448371.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"transactions": [
{
"hash": "0x642b1f5b3c0f5e2972d9e2e32d0af76d52017236fdccc4678c8b403245e15a3b",
"transactionType": "CREATE",
"contractName": "Stuff",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"function": null,
"arguments": null,
"transaction": {
"type": "0x02",
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"gas": "0x191eb",
"value": "0x0",
"data": "0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063cf33c3be14602d575b600080fd5b600760405190815260200160405180910390f3fea26469706673582212200382dc5886d11d466628cc59d88a4311d34375a8581173060a08b39ffe47d32464736f6c63430008150033",
"nonce": "0x0",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"transactionHash": "0x642b1f5b3c0f5e2972d9e2e32d0af76d52017236fdccc4678c8b403245e15a3b",
"transactionIndex": "0x0",
"blockHash": "0x73373ba2a0b941145f4b90354551b964a6fa7ace4a9517590a2caa952b9d2c75",
"blockNumber": "0x8",
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"to": null,
"cumulativeGasUsed": "0x13535",
"gasUsed": "0x13535",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"logs": [],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"effectiveGasPrice": "0xca386e61"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1700448371,
"chain": 31337,
"multi": false,
"commit": "742f1ca"
}
26 changes: 12 additions & 14 deletions broadcast/DeployStuff.s.sol/31337/run-latest.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"transactions": [
{
"hash": "0x707f599297156a5de34dee2fdc4d9266c3f3c63133130f1e2de605dc7e3e83d4",
"hash": "0x642b1f5b3c0f5e2972d9e2e32d0af76d52017236fdccc4678c8b403245e15a3b",
"transactionType": "CREATE",
"contractName": "Stuff",
"contractAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"function": null,
"arguments": null,
"rpc": "http://127.0.0.1:8545",
"transaction": {
"type": "0x02",
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"gas": "0x191eb",
"value": "0x0",
"data": "0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063cf33c3be14602d575b600080fd5b600760405190815260200160405180910390f3fea264697066735822122018510bdeac5343a57cccf367fda88793df7ffd26e6238a89c2521a68343c5b8e64736f6c63430008130033",
"nonce": "0x7",
"data": "0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063cf33c3be14602d575b600080fd5b600760405190815260200160405180910390f3fea26469706673582212200382dc5886d11d466628cc59d88a4311d34375a8581173060a08b39ffe47d32464736f6c63430008150033",
"nonce": "0x0",
"accessList": []
},
"additionalContracts": [],
Expand All @@ -23,28 +22,27 @@
],
"receipts": [
{
"transactionHash": "0x707f599297156a5de34dee2fdc4d9266c3f3c63133130f1e2de605dc7e3e83d4",
"transactionHash": "0x642b1f5b3c0f5e2972d9e2e32d0af76d52017236fdccc4678c8b403245e15a3b",
"transactionIndex": "0x0",
"blockHash": "0x5f5fc1671cfc65aa65134af53fd8b6238401a4d20c3f317a094527af56b077cf",
"blockHash": "0x73373ba2a0b941145f4b90354551b964a6fa7ace4a9517590a2caa952b9d2c75",
"blockNumber": "0x8",
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"to": null,
"cumulativeGasUsed": "0x1352b",
"gasUsed": "0x1352b",
"contractAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"cumulativeGasUsed": "0x13535",
"gasUsed": "0x13535",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"logs": [],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"effectiveGasPrice": "0xca6df430"
"effectiveGasPrice": "0xca386e61"
}
],
"libraries": [],
"pending": [],
"path": "/Users/patrick/code/foundry-recent-deploy/broadcast/DeployStuff.s.sol/31337/run-latest.json",
"returns": {},
"timestamp": 1681340536,
"timestamp": 1700448371,
"chain": 31337,
"multi": false,
"commit": "0544b38"
"commit": "742f1ca"
}
48 changes: 48 additions & 0 deletions broadcast/NewDeployStuff.s.sol/31337/run-1700352554.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"transactions": [
{
"hash": "0xb9af5f14dd8208e7a5fa4315f2e23e915c56ecf8b37f11c1abe0086a3a3f0f30",
"transactionType": "CREATE",
"contractName": "NewStuff",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"function": null,
"arguments": null,
"transaction": {
"type": "0x02",
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"gas": "0x191eb",
"value": "0x0",
"data": "0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063cf33c3be14602d575b600080fd5b600760405190815260200160405180910390f3fea26469706673582212201d5632e18d7fe499584a6ee0e5aa0e7e68761b304d3018503db2bb4badc34e8264736f6c63430008150033",
"nonce": "0x0",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"transactionHash": "0xb9af5f14dd8208e7a5fa4315f2e23e915c56ecf8b37f11c1abe0086a3a3f0f30",
"transactionIndex": "0x0",
"blockHash": "0x177a9f26fdfb32f329fbdac84132e343500da1f100eb3fd1d8c234b471338d41",
"blockNumber": "0x1",
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"to": null,
"cumulativeGasUsed": "0x13535",
"gasUsed": "0x13535",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"logs": [],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"effectiveGasPrice": "0xee6b2800"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1700352554,
"chain": 31337,
"multi": false,
"commit": "f421ebf"
}
48 changes: 48 additions & 0 deletions broadcast/NewDeployStuff.s.sol/31337/run-latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"transactions": [
{
"hash": "0xb9af5f14dd8208e7a5fa4315f2e23e915c56ecf8b37f11c1abe0086a3a3f0f30",
"transactionType": "CREATE",
"contractName": "NewStuff",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"function": null,
"arguments": null,
"transaction": {
"type": "0x02",
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"gas": "0x191eb",
"value": "0x0",
"data": "0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063cf33c3be14602d575b600080fd5b600760405190815260200160405180910390f3fea26469706673582212201d5632e18d7fe499584a6ee0e5aa0e7e68761b304d3018503db2bb4badc34e8264736f6c63430008150033",
"nonce": "0x0",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"transactionHash": "0xb9af5f14dd8208e7a5fa4315f2e23e915c56ecf8b37f11c1abe0086a3a3f0f30",
"transactionIndex": "0x0",
"blockHash": "0x177a9f26fdfb32f329fbdac84132e343500da1f100eb3fd1d8c234b471338d41",
"blockNumber": "0x1",
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"to": null,
"cumulativeGasUsed": "0x13535",
"gasUsed": "0x13535",
"contractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"logs": [],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"effectiveGasPrice": "0xee6b2800"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1700352554,
"chain": 31337,
"multi": false,
"commit": "f421ebf"
}
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
src = "src"
out = "out"
libs = ["lib"]
ffi = true
fs_permissions = [{ access = "read", path = "./broadcast" }]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
11 changes: 11 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: update anvil deploy

DEFAULT_ANVIL_KEY := 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

update:; forge update

anvil:; anvil -m 'test test test test test test test test test test test junk' --steps-tracing --block-time 1

deploy:; forge script script/DeployStuff.s.sol:DeployStuff --broadcast --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) -vvvv

interact:; forge script script/InteractWithStuff.s.sol:InteractWithStuff --broadcast --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) -vvvv
14 changes: 14 additions & 0 deletions script/InteractWithStuff.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Script} from "forge-std/Script.sol";
import {DevOpsTools} from "../src/DevOpsTools.sol";
import {Stuff} from "./DeployStuff.s.sol";

contract InteractWithStuff is Script {
function run() external {
address mostRecent = DevOpsTools.get_most_recent_deployment("DeployStuff", block.chainid);
uint256 value = Stuff(mostRecent).getSeven();
assert(value == 7);
}
}
18 changes: 18 additions & 0 deletions script/NewDeployStuff.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {Script} from "forge-std/Script.sol";

contract NewStuff {
function getSeven() public pure returns (uint256) {
return 7;
}
}

contract NewDeployStuff is Script {
function run() external {
vm.startBroadcast();
new NewStuff();
vm.stopBroadcast();
}
}

0 comments on commit 5415faa

Please sign in to comment.