Skip to content

Commit

Permalink
args -> function_args
Browse files Browse the repository at this point in the history
  • Loading branch information
zees-dev committed Feb 5, 2025
1 parent 46e5007 commit 0eb0225
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/book/src/forc/plugins/forc_client/forc_call.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ forc call --help
```output
Perform Fuel RPC calls from the comfort of your command line
Usage: forc call [OPTIONS] --abi <ABI> <CONTRACT_ID> <FUNCTION> [ARGS]...
Usage: forc call [OPTIONS] --abi <ABI> <CONTRACT_ID> <FUNCTION> [FUNCTION_ARGS]...
Arguments:
<CONTRACT_ID>
Expand All @@ -62,8 +62,8 @@ Arguments:
<FUNCTION>
The function signature to call. When ABI is provided, this should be a selector (e.g. "transfer") When no ABI is provided, this should be the full function signature (e.g. "transfer(address,u64)")
[ARGS]...
Arguments to pass into main function with forc run
[FUNCTION_ARGS]...
Arguments to pass into the function to be called
Options:
--abi <ABI>
Expand Down
4 changes: 2 additions & 2 deletions forc-plugins/forc-client/src/cmd/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ pub struct Command {
/// It must be a valid selector present in the ABI file.
pub function: FuncType,

/// Arguments to pass into main function with forc run.
pub args: Vec<String>,
/// Arguments to pass into the function to be called.
pub function_args: Vec<String>,

#[clap(flatten)]
pub node: NodeTarget,
Expand Down
10 changes: 5 additions & 5 deletions forc-plugins/forc-client/src/op/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub async fn call(cmd: cmd::Call) -> anyhow::Result<String> {
contract_id,
abi,
function,
args,
function_args,
node,
caller,
call_parameters,
Expand Down Expand Up @@ -86,14 +86,14 @@ pub async fn call(cmd: cmd::Call) -> anyhow::Result<String> {
.find(|abi_func| abi_func.name == selector)
.unwrap_or_else(|| panic!("Function not found in ABI: {}", selector));

if abi_func.inputs.len() != args.len() {
bail!("Number of arguments does not match number of parameters in function signature; expected {}, got {}", abi_func.inputs.len(), args.len());
if abi_func.inputs.len() != function_args.len() {
bail!("Number of arguments does not match number of parameters in function signature; expected {}, got {}", abi_func.inputs.len(), function_args.len());
}

let tokens = abi_func
.inputs
.iter()
.zip(&args)
.zip(&function_args)
.map(|(type_application, arg)| {
let param_type = ParamType::try_from_type_application(type_application, &type_lookup)
.expect("Failed to convert input type application");
Expand Down Expand Up @@ -349,7 +349,7 @@ mod tests {
"../../forc-plugins/forc-client/test/data/contract_with_types/contract_with_types-abi.json",
)),
function: cmd::call::FuncType::Selector(selector.into()),
args: args.into_iter().map(String::from).collect(),
function_args: args.into_iter().map(String::from).collect(),
node: crate::NodeTarget {
node_url: Some(wallet.provider().unwrap().url().to_owned()),
..Default::default()
Expand Down

0 comments on commit 0eb0225

Please sign in to comment.