Skip to content

feat(forge): Solidity Scripting #1208

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

Merged
merged 139 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
a055744
forge install: ds-test
brockelmore Apr 5, 2022
fda729d
basic scripting
brockelmore Apr 5, 2022
0db6be0
remove dirty file
brockelmore Apr 5, 2022
3bb489d
Merge branch 'master' into brock/scripting
brockelmore Apr 5, 2022
19a2a38
updates
brockelmore Apr 5, 2022
22bfc12
fixes
brockelmore Apr 5, 2022
ba514e5
remove excess comments
brockelmore Apr 5, 2022
51f5aa6
updates
brockelmore Apr 15, 2022
74d4857
fmt
brockelmore Apr 15, 2022
29fd71e
Merge remote-tracking branch 'origin/master' into brock/scripting
brockelmore Apr 15, 2022
299e401
diff score move
brockelmore Apr 15, 2022
1bc36f9
working transaction sending MVP
brockelmore Apr 15, 2022
6b7389e
Merge remote-tracking branch 'origin/master' into brock/scripting
brockelmore Apr 15, 2022
e6a611d
fixes
brockelmore Apr 15, 2022
c6836fa
remove accidental short rename
brockelmore Apr 15, 2022
6723ba9
Merge branch 'master' into brock/scripting
brockelmore Apr 17, 2022
8689595
updates
brockelmore Apr 17, 2022
3264d6b
write tx receipts to file
brockelmore Apr 17, 2022
4dd5261
Merge branch 'master' into brock/scripting
gakonst May 4, 2022
d04dbc0
panic if nonce changes unexpectedly while sending txes
joshieDo May 2, 2022
2f1b27c
add ScriptSequence
joshieDo May 2, 2022
c3e077c
add transaction receipts to ScriptSequence
joshieDo May 2, 2022
ed833d8
add resume
joshieDo May 2, 2022
04cdf9f
add forgetest for script
joshieDo May 3, 2022
9a8a1d4
fix nonce tracking on broadcastable txes
joshieDo May 3, 2022
a5e24f4
do not send transactions if simulation failed
joshieDo May 3, 2022
e5f8288
add test with and without library
joshieDo May 3, 2022
3998d34
replace link for link_with_nonce(1)
joshieDo May 3, 2022
b673577
make valid fork url a requirement
joshieDo May 3, 2022
ab83f12
fix nonce tracking & helper contract callers
joshieDo May 3, 2022
bb97a9f
refactor to a script testbuilder
joshieDo May 4, 2022
ebb26a3
remove old comment
joshieDo May 4, 2022
f6fb3d2
cleanup
joshieDo May 4, 2022
36da1f4
change localhost to 127.0.0.1
joshieDo May 4, 2022
da693a8
ScriptTester takes ownership of cmd
joshieDo May 4, 2022
484251d
move ScriptTester to its own module
joshieDo May 4, 2022
893e7a8
use Paint instead of ansi
joshieDo May 4, 2022
634a799
add missing Chain import
joshieDo May 4, 2022
4422553
turn scripttester fn into async
joshieDo May 4, 2022
55fdf89
add anvil to tests :fire: :hammer:
joshieDo May 4, 2022
9103d92
better help description
joshieDo May 4, 2022
5c55fcb
make sure anvil spawns on different ports
joshieDo May 4, 2022
39c4583
link testdata to scripttester
joshieDo May 4, 2022
5ec1a69
enforce evm.sender as the predeploys deployer
joshieDo May 5, 2022
c0a4f86
handle call_inner nonces + test
joshieDo May 5, 2022
d0f121f
remove ganache references
joshieDo May 5, 2022
dac87e0
Revert "enforce evm.sender as the predeploys deployer"
joshieDo May 5, 2022
1fd7a9b
add --deployer to script
joshieDo May 5, 2022
ef6bb79
better error messages
joshieDo May 5, 2022
0a07594
add better description to resume command
joshieDo May 5, 2022
40ad4c9
cover case without a deployer set
joshieDo May 5, 2022
2cc05f2
split forge script into modules
joshieDo May 12, 2022
28e4e55
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 12, 2022
af3ec8f
add missing arguments from merge
joshieDo May 12, 2022
44fdd26
remove unneeded .gitmodules
joshieDo May 12, 2022
c1b555d
refactor script/runner
joshieDo May 12, 2022
ce44e6a
refactor script/executor
joshieDo May 12, 2022
d675774
some more script refactor
joshieDo May 12, 2022
334f2da
add forgetest_async! macro
joshieDo May 12, 2022
ed00d69
refactor cli/wallet
joshieDo May 13, 2022
51f48c6
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 13, 2022
04c632c
refactor: forge run calls forge script
joshieDo May 13, 2022
4fdc963
rename forge run to forge debug
joshieDo May 13, 2022
e21a062
add etherscan identifier to script
joshieDo May 13, 2022
0c0d2d7
move some functions to its proper modules
joshieDo May 13, 2022
6c81d0c
turn panic into bail
joshieDo May 13, 2022
75e5391
smol nits :shipit:
joshieDo May 15, 2022
d0ca036
simplify needs_setup
joshieDo May 15, 2022
75eac82
use ethers set_chain_id
joshieDo May 15, 2022
2b31cad
impl drop for scriptsequence
joshieDo May 15, 2022
e4edde4
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 15, 2022
fa46f78
remove --force-resume
joshieDo May 17, 2022
d462919
fix broadcast without args
joshieDo May 17, 2022
9288308
remove --deployer use --sender instead
joshieDo May 17, 2022
3578e9e
fix gas for committed transactions
joshieDo May 17, 2022
13eaa98
add missing arg on test_executor
joshieDo May 17, 2022
837df25
fmt
joshieDo May 17, 2022
7cbddab
add support for preexisting CREATE2
joshieDo May 17, 2022
b40d164
remove unnecessary println
joshieDo May 17, 2022
3da69fe
Merge branch 'master' into brock/scripting
gakonst May 18, 2022
99af23d
chore: use RuntimeOrHandle from ethers
gakonst May 18, 2022
955b4eb
broadcast & receipt refactor for concurrent broadcasts
joshieDo May 18, 2022
1ea8442
replace sender if only a single private key has been passed
joshieDo May 18, 2022
95736b4
better logs
joshieDo May 18, 2022
0e95d81
adapt resume test to new changes
joshieDo May 18, 2022
8dea1fa
change scriptsequence saving behaviour
joshieDo May 18, 2022
98b0daa
pass contract name, path or both to script/debug
joshieDo May 19, 2022
1549dc2
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 19, 2022
110c098
add can_deploy_100_txes_concurrently test
joshieDo May 19, 2022
49478df
add support for linking existing library addresses on script
joshieDo May 19, 2022
df30d13
only link external addresses if there is a RPC set
joshieDo May 19, 2022
5e4d83e
increase gas estimation to 1.3
joshieDo May 19, 2022
4eb4b90
remove unused forge run file
joshieDo May 19, 2022
181f6e9
set --sender as msg.sender with nonce correction instead
joshieDo May 19, 2022
fdb5441
change broadcast log to filename-ts.json
joshieDo May 19, 2022
b525bd1
make broadcast log folder configurable
joshieDo May 19, 2022
f518031
improve documentation of correct_sender_nonce
joshieDo May 19, 2022
a3d06a8
add missing broadcast field on forgetest
joshieDo May 19, 2022
814b306
fix broadcast wrap
joshieDo May 19, 2022
90da469
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 20, 2022
1b3489f
group logs by chain_id
joshieDo May 20, 2022
6bbfba0
only show return data if it's not empty
joshieDo May 20, 2022
3ea0bd6
change accounts on ScriptTester to Address
joshieDo May 20, 2022
ca8c593
add default and async to debug.rs
joshieDo May 23, 2022
fe023e8
add all() to MultiWallet
joshieDo May 23, 2022
f5a13bb
convert some bails into map_err
joshieDo May 23, 2022
627b5fa
wrap_err on link()
joshieDo May 23, 2022
559131e
remove rt from debug and script
joshieDo May 23, 2022
0070f5a
docs
joshieDo May 23, 2022
7776d28
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 23, 2022
deba4e5
clippy
joshieDo May 23, 2022
7c0a4b1
use SourceFile coming from artifact
joshieDo May 23, 2022
7271026
when sending, only clone tx as it iterates
joshieDo May 23, 2022
ed29f12
add ScriptOutcome
joshieDo May 23, 2022
74c57e6
save tx with correct tx type on scriptsequence
joshieDo May 23, 2022
7a08027
set DEFAULT_SENDER as H160
joshieDo May 23, 2022
8b48159
dont replace tx.caller on broadcast end
joshieDo May 23, 2022
93ff980
add create2 deployer to TestRunner as well
joshieDo May 23, 2022
90abb33
fix expected output on script tests
joshieDo May 23, 2022
25fd5c7
fix up receipts when resuming
joshieDo May 23, 2022
7ef8df7
store and try to recover from pending transaction hashes on scriptseq…
joshieDo May 24, 2022
8b51055
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 24, 2022
67bd90f
correct nonce after setUp if necessary
joshieDo May 24, 2022
ff83055
check status of the transaction receipt
joshieDo May 24, 2022
4bf5abb
add fix and test for deployment with setUp
joshieDo May 24, 2022
928558b
add slow flag to enforce sequential broadcasting
joshieDo May 25, 2022
2762ce7
change docs for cheatcodes
joshieDo May 25, 2022
a3f530f
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 25, 2022
ae5e640
chore: add missing trait import
gakonst May 25, 2022
14d84cc
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 25, 2022
059a5b8
decode Create2Deployer on traces by default
joshieDo May 27, 2022
8ff4359
revert if it it finds a staticcall after vm.broadcast
joshieDo May 27, 2022
ad8bb44
Merge remote-tracking branch 'origin/master' into brock/scripting
joshieDo May 28, 2022
8384d8f
refactor signer discovery
joshieDo May 28, 2022
b7071ba
update test
joshieDo May 28, 2022
0913d29
show missing warning
joshieDo May 28, 2022
f2317c8
Merge branch 'master' into brock/scripting
gakonst May 28, 2022
8bed3a4
Merge branch 'master' into brock/scripting
gakonst May 29, 2022
12921e2
chore: bump ethers
gakonst May 29, 2022
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ bytes = "1.1.0"
strum = { version = "0.24", features = ["derive"] }

[dev-dependencies]
anvil = { path = "../anvil" }
foundry-utils = { path = "./../utils", features = ["test"] }
foundry-cli-test-utils = { path = "./test-utils" }
pretty_assertions = "1.0.0"
Expand Down
65 changes: 65 additions & 0 deletions cli/src/cmd/forge/debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use super::{build::BuildArgs, script::ScriptArgs, watch::WatchArgs};
use crate::{cmd::forge::build::CoreBuildArgs, opts::MultiWallet};
use clap::{Parser, ValueHint};
use foundry_common::evm::EvmArgs;
use std::path::PathBuf;

// Loads project's figment and merges the build cli arguments into it
foundry_config::impl_figment_convert!(DebugArgs, opts, evm_opts);

#[derive(Debug, Clone, Parser)]
pub struct DebugArgs {
/// The contract you want to run. Either the file path or contract name.
///
/// If multiple contracts exist in the same file you must specify the target contract with
/// --target-contract.
#[clap(value_hint = ValueHint::FilePath, value_name = "PATH")]
pub path: PathBuf,

/// Arguments to pass to the script function.
#[clap(value_name = "ARGS")]
pub args: Vec<String>,

/// The name of the contract you want to run.
#[clap(long, alias = "tc", value_name = "CONTRACT_NAME")]
pub target_contract: Option<String>,

/// The signature of the function you want to call in the contract, or raw calldata.
#[clap(long, short, default_value = "run()", value_name = "SIGNATURE")]
pub sig: String,

/// Open the script in the debugger.
#[clap(long)]
pub debug: bool,

#[clap(flatten, next_help_heading = "BUILD OPTIONS")]
pub opts: CoreBuildArgs,

#[clap(flatten, next_help_heading = "EVM OPTIONS")]
pub evm_opts: EvmArgs,
}

impl DebugArgs {
pub async fn debug(self) -> eyre::Result<()> {
let script = ScriptArgs {
path: self.path.to_str().expect("Invalid path string.").to_string(),
args: self.args,
target_contract: self.target_contract,
sig: self.sig,
legacy: false,
broadcast: false,
opts: BuildArgs {
args: self.opts,
names: false,
sizes: false,
watch: WatchArgs::default(),
},
wallets: MultiWallet::default(),
evm_opts: self.evm_opts,
resume: false,
debug: true,
slow: false,
};
script.run_script().await
}
}
5 changes: 3 additions & 2 deletions cli/src/cmd/forge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! [`foundry_config::Config`].
//!
//! See [`BuildArgs`] for a reference implementation.
//! And [`RunArgs`] for how to merge `Providers`.
//! And [`DebugArgs`] for how to merge `Providers`.
//!
//! # Example
//!
Expand Down Expand Up @@ -42,14 +42,15 @@ pub mod build;
pub mod cache;
pub mod config;
pub mod create;
pub mod debug;
pub mod flatten;
pub mod fmt;
pub mod fourbyte;
pub mod init;
pub mod inspect;
pub mod install;
pub mod remappings;
pub mod run;
pub mod script;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cannot comment on teh file, but the .gitmodules above is probably unneeded

pub mod snapshot;
pub mod test;
pub mod tree;
Expand Down
Loading