Skip to content

Commit 20a3e44

Browse files
authored
Merge branch 'master' into xunilrj/enum-const-generics
2 parents 0af659d + 078c507 commit 20a3e44

File tree

13 files changed

+495
-188
lines changed

13 files changed

+495
-188
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,42 @@ jobs:
903903
env:
904904
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
905905

906+
publish-sway-lib-std:
907+
needs: publish
908+
if: github.event_name == 'release' && github.event.action == 'published'
909+
runs-on: buildjet-4vcpu-ubuntu-2204
910+
steps:
911+
- name: Checkout repository
912+
uses: actions/checkout@v4
913+
914+
- name: Install toolchain
915+
uses: dtolnay/rust-toolchain@master
916+
with:
917+
toolchain: ${{ env.RUST_VERSION }}
918+
919+
- name: Publish sway-lib-std
920+
run: |
921+
cd sway-lib-std
922+
cargo run --locked -p forc-publish
923+
env:
924+
FORC_PUB_TOKEN: ${{ secrets.FORCPUB_TOKEN }}
925+
926+
- name: Notify if Job Fails
927+
uses: ravsamhq/notify-slack-action@v2
928+
if: always()
929+
with:
930+
status: ${{ job.status }}
931+
token: ${{ secrets.GITHUB_TOKEN }}
932+
notification_title: "{workflow} has {status_message}"
933+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
934+
footer: ""
935+
notify_when: "failure"
936+
env:
937+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
938+
906939
build-publish-release-image:
907940
# Build & Publish Docker Image Per Sway Release
908-
needs: publish
941+
needs: [publish, publish-sway-lib-std]
909942
runs-on: buildjet-4vcpu-ubuntu-2204
910943
permissions:
911944
contents: read
@@ -962,7 +995,7 @@ jobs:
962995
name: Build and upload forc binaries to release
963996
runs-on: ${{ matrix.job.os }}
964997
if: github.event_name == 'release' && github.event.action == 'published'
965-
needs: publish
998+
needs: [publish, publish-sway-lib-std]
966999
strategy:
9671000
matrix:
9681001
job:

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/src/testing/testing_with_forc_call.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,39 @@ forc call \
6868

6969
## Usage
7070

71-
The basic syntax for `forc call` is:
71+
Forc call has **3** usage modes:
72+
73+
### List functions
74+
75+
Syntax for `forc call` for listing supported functions from the ABI - with example command to perform call operation:
76+
77+
```bash
78+
forc call --abi <ABI-PATH/URL> <CONTRACT_ID> --list-functions
79+
```
80+
81+
Where the following arguments are required:
82+
83+
- `ABI-PATH/URL` is the path or URL to the contract's JSON ABI file
84+
- `CONTRACT_ID` is the ID of the deployed contract you want to interact with
85+
86+
### Transfer assets
87+
88+
Syntax for `forc call` for transferring assets:
89+
90+
```bash
91+
forc call <RECEIVER_ADDRESS> --amount <AMOUNT> --mode=live
92+
```
93+
94+
Where the following arguments are required:
95+
96+
- `RECEIVER_ADDRESS` is address of the receiver (identity or contract).
97+
- `AMOUNT` is the amount of assets to transfer.
98+
99+
Note: only live mode `--mode=live` is supported; transfers cannot be simulated.
100+
101+
### Call contracts
102+
103+
Syntax for `forc call` for contract calls:
72104

73105
```bash
74106
forc call [OPTIONS] --abi <ABI-PATH/URL> <CONTRACT_ID> <SELECTOR> [ARGS]...

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
use clap::Parser;
2-
use forc_tracing::{init_tracing_subscriber, println_error};
2+
use forc_tracing::{init_tracing_subscriber, println_error, TracingSubscriberOptions};
33

44
#[tokio::main]
55
async fn main() {
6-
init_tracing_subscriber(Default::default());
76
let command = forc_client::cmd::Call::parse();
7+
8+
// Initialize tracing with verbosity from command
9+
init_tracing_subscriber(TracingSubscriberOptions {
10+
verbosity: Some(command.verbosity),
11+
writer_mode: Some(command.output.clone().into()),
12+
regex_filter: Some("forc_tracing".to_string()),
13+
..Default::default()
14+
});
15+
816
let operation = match command.validate_and_get_operation() {
917
Ok(operation) => operation,
1018
Err(err) => {

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use either::Either;
44
use fuel_crypto::SecretKey;
55
use fuels::programs::calls::CallParameters;
66
use fuels_core::types::{Address, AssetId, ContractId};
7-
use std::{path::PathBuf, str::FromStr};
7+
use std::{io::Write, path::PathBuf, str::FromStr};
88
use url::Url;
99

1010
pub use forc::cli::shared::{BuildOutput, BuildProfile, Minify, Pkg, Print};
@@ -57,34 +57,34 @@ pub enum OutputFormat {
5757
Default,
5858
/// Raw unformatted output
5959
Raw,
60+
/// JSON output with full tracing information (logs, errors, and result)
61+
Json,
6062
}
6163

62-
/// Verbosity level for log output
63-
#[derive(Debug, Clone, PartialEq, Default)]
64-
#[repr(transparent)]
65-
pub struct Verbosity(pub u8);
66-
67-
impl Verbosity {
68-
/// Verbose mode (-v)
69-
pub(crate) fn v1(&self) -> bool {
70-
self.0 >= 1
64+
impl Write for OutputFormat {
65+
fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
66+
match self {
67+
OutputFormat::Default => std::io::stdout().write(buf),
68+
OutputFormat::Raw => std::io::stdout().write(buf),
69+
OutputFormat::Json => Ok(buf.len()), // no-op for json
70+
}
7171
}
7272

73-
/// Very Verbose mode (-vv)
74-
pub(crate) fn v2(&self) -> bool {
75-
self.0 >= 2
76-
}
77-
}
78-
79-
impl From<u8> for Verbosity {
80-
fn from(level: u8) -> Self {
81-
Verbosity(level)
73+
fn flush(&mut self) -> Result<(), std::io::Error> {
74+
match self {
75+
OutputFormat::Default => std::io::stdout().flush(),
76+
OutputFormat::Raw => std::io::stdout().flush(),
77+
OutputFormat::Json => Ok(()),
78+
}
8279
}
8380
}
8481

85-
impl From<Verbosity> for u8 {
86-
fn from(verbosity: Verbosity) -> Self {
87-
verbosity.0
82+
impl From<OutputFormat> for forc_tracing::TracingWriter {
83+
fn from(format: OutputFormat) -> Self {
84+
match format {
85+
OutputFormat::Json => forc_tracing::TracingWriter::Json,
86+
_ => forc_tracing::TracingWriter::Stdio,
87+
}
8888
}
8989
}
9090

@@ -316,7 +316,7 @@ pub struct Command {
316316
pub external_contracts: Option<Vec<ContractId>>,
317317

318318
/// Output format for the call result
319-
#[clap(long, default_value = "default", help_heading = "OUTPUT")]
319+
#[clap(long, short = 'o', default_value = "default", help_heading = "OUTPUT")]
320320
pub output: OutputFormat,
321321

322322
/// Set verbosity levels; currently only supports max 2 levels

0 commit comments

Comments
 (0)