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

feat(cast): implementing cast call/send <address> <0xCalldata> #742

Merged
merged 1 commit into from
Feb 14, 2022
Merged
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
11 changes: 10 additions & 1 deletion cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ where

let func = if sig.contains('(') {
get_func(sig)?
} else if sig.starts_with("0x") {
// if only calldata is provided, returning a dummy function
get_func("x()")?
} else {
get_func_etherscan(
sig,
Expand All @@ -286,7 +289,13 @@ where
)
.await?
};
let data = encode_args(&func, &args)?;

let data = if sig.starts_with("0x") {
hex::decode(strip_0x(sig))?
} else {
encode_args(&func, &args)?
};

tx.set_data(data.into());
Some(func)
} else {
Expand Down