Skip to content

Commit 2097380

Browse files
zees-devJoshuaBattykayagokalp
authored
forc-call logs support (#6968)
## Description - Added support for viewing emitted logs when making a transaction using forc-call - Added `show_receipts` param (default-false) - so we can optionally prnt out all receipts - The CLI output becomes too long for a call with multiple receipts; this is a minor UI enhancement Addresses #6887 ## Example usage/output ```sway script; struct ExampleParams { test_val: u32, test_str: str, test_tuple: (u32, u64), } fn main() -> u64 { log("hiiii"); log(123); log(ExampleParams { test_val: 5, test_str: "hello world", test_tuple: (1,2) }); 5 } ``` <img width="986" alt="image" src="https://github.com/user-attachments/assets/3725ff17-29c9-43d7-98cc-4cacfc213ecb" /> ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: z <zees-dev@users.noreply.github.com> Co-authored-by: Joshua Batty <joshpbatty@gmail.com> Co-authored-by: kayagokalp <kayagokalp123@gmail.com>
1 parent b7d1539 commit 2097380

File tree

18 files changed

+205
-214
lines changed

18 files changed

+205
-214
lines changed

Cargo.lock

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/src/forc/plugins/forc_client/forc_call.md

-111
Original file line numberDiff line numberDiff line change
@@ -55,116 +55,6 @@ Where the following arguments are required:
5555
- `SELECTOR` is the function name (selector) you want to call
5656
- `ARGS` are the arguments to pass to the function
5757

58-
## CLI Reference
59-
60-
<details>
61-
<summary><b>Forc Call CLI reference</b></summary>
62-
63-
```sh
64-
forc call --help
65-
```
66-
67-
```output
68-
Perform Fuel RPC calls from the comfort of your command line
69-
70-
Usage: forc call [OPTIONS] --abi <ABI> <CONTRACT_ID> <FUNCTION> [FUNCTION_ARGS]...
71-
72-
Arguments:
73-
<CONTRACT_ID>
74-
The contract ID to call
75-
76-
<FUNCTION>
77-
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)")
78-
79-
[FUNCTION_ARGS]...
80-
Arguments to pass into the function to be called
81-
82-
Options:
83-
--abi <ABI>
84-
Path or URI to a JSON ABI file
85-
86-
--node-url <NODE_URL>
87-
The URL of the Fuel node to which we're submitting the transaction. If unspecified, checks the manifest's `network` table, then falls back to `http://127.0.0.1:4000`
88-
89-
You can also use `--target`, `--testnet`, or `--mainnet` to specify the Fuel node.
90-
91-
[env: FUEL_NODE_URL=]
92-
93-
--target <TARGET>
94-
Preset configurations for using a specific target.
95-
96-
You can also use `--node-url`, `--testnet`, or `--mainnet` to specify the Fuel node.
97-
98-
Possible values are: [local, testnet, mainnet]
99-
100-
--mainnet
101-
Use preset configuration for mainnet.
102-
103-
You can also use `--node-url`, `--target`, or `--testnet` to specify the Fuel node.
104-
105-
--testnet
106-
Use preset configuration for testnet.
107-
108-
You can also use `--node-url`, `--target`, or `--mainnet` to specify the Fuel node.
109-
110-
--devnet
111-
Use preset configuration for devnet.
112-
113-
You can also use `--node-url`, `--target`, or `--testnet` to specify the Fuel node.
114-
115-
--signing-key <SIGNING_KEY>
116-
Derive an account from a secret key to make the call
117-
118-
[env: SIGNING_KEY=]
119-
120-
--wallet
121-
Use forc-wallet to make the call
122-
123-
--amount <AMOUNT>
124-
Amount of native assets to forward with the call
125-
126-
[default: 0]
127-
128-
--asset-id <ASSET_ID>
129-
Asset ID to forward with the call
130-
131-
--gas-forwarded <GAS_FORWARDED>
132-
Amount of gas to forward with the call
133-
134-
--mode <MODE>
135-
The execution mode to use for the call; defaults to dry-run; possible values: dry-run, simulate, live
136-
137-
[default: dry-run]
138-
139-
--gas-price <PRICE>
140-
Gas price for the transaction
141-
142-
--script-gas-limit <SCRIPT_GAS_LIMIT>
143-
Gas limit for the transaction
144-
145-
--max-fee <MAX_FEE>
146-
Max fee for the transaction
147-
148-
--tip <TIP>
149-
The tip for the transaction
150-
151-
--external-contracts <EXTERNAL_CONTRACTS>
152-
The external contract addresses to use for the call If none are provided, the call will automatically populate external contracts by making a dry-run calls to the node, and extract the contract addresses based on the revert reason
153-
154-
--output <OUTPUT>
155-
The output format to use; possible values: default, raw
156-
157-
[default: default]
158-
159-
-h, --help
160-
Print help (see a summary with '-h')
161-
162-
-V, --version
163-
Print version
164-
```
165-
166-
</details>
167-
16858
## Type Encoding
16959

17060
When passing arguments to contract functions, values are encoded according to their Sway types.
@@ -313,7 +203,6 @@ forc call <CONTRACT_ID> --abi <PATH> update_params 42 --live
313203

314204
The following features are planned for future releases:
315205

316-
- Decode and display logs for contract calls
317206
- Support direct transfer of asset(s) to addresses
318207
- Function signature based calls without ABI
319208
- Raw calldata input support

forc-pkg/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ byte-unit.workspace = true
1515
cid.workspace = true
1616
flate2.workspace = true
1717
forc-tracing.workspace = true
18-
forc-util.workspace = true
18+
forc-util = { workspace = true }
1919
fuel-abi-types.workspace = true
2020
futures.workspace = true
2121
git2 = { workspace = true, features = ["vendored-libgit2", "vendored-openssl"] }

forc-plugins/forc-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ forc.workspace = true
2222
forc-pkg.workspace = true
2323
forc-tracing.workspace = true
2424
forc-tx.workspace = true
25-
forc-util.workspace = true
25+
forc-util = { workspace = true, features = ["tx"] }
2626
forc-wallet.workspace = true
2727
fuel-abi-types.workspace = true
2828
fuel-core-client = { workspace = true, features = ["subscriptions"] }

forc-plugins/forc-client/src/cmd/call.rs

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ pub struct Command {
223223
/// The output format to use; possible values: default, raw
224224
#[clap(long, default_value = "default")]
225225
pub output: OutputFormat,
226+
227+
/// Output call receipts
228+
#[clap(long, short = 'r', alias = "receipts")]
229+
pub show_receipts: bool,
226230
}
227231

228232
fn parse_abi_path(s: &str) -> Result<Either<PathBuf, Url>, String> {

0 commit comments

Comments
 (0)