Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Dec 16, 2023
1 parent a9b1628 commit 9551af6
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions forc-plugins/forc-client/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ pub use super::submit::Network;
pub use forc::cli::shared::{BuildOutput, BuildProfile, Minify, Pkg, Print};
pub use forc_tx::{Gas, Maturity};

forc::cli_examples! {
}

/// Run script project.
/// Crafts a script transaction then sends it to a running node.
#[derive(Debug, Default, Parser)]
Expand Down
1 change: 1 addition & 0 deletions forc-plugins/forc-tx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ path = "src/main.rs"
anyhow = "1"
clap = { version = "3", features = ["derive", "env"] }
devault = "0.1"
forc = { version = "0.48.1", path = "../../forc" }
forc-util = { version = "0.48.1", path = "../../forc-util" }
fuel-tx = { workspace = true, features = ["serde"] }
fuel-types = { workspace = true, features = ["serde"] }
Expand Down
45 changes: 45 additions & 0 deletions forc-plugins/forc-tx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,51 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use thiserror::Error;

#[cfg(test)]
const ROOT: &str = "0x2222222222222222222222222222222222222222222222222222222222222222";
#[cfg(test)]
const DATA_PATH: &str = "out/debug/tests.bin";
#[cfg(test)]
const BYTECODE_PATH: &str = "out/debug/tests.bin";

forc::cli_examples!{
[ Script example => tx "script" "--bytecode" BYTECODE_PATH "--data" DATA_PATH "--receipts-root" ROOT ]
[ Multiple inputs => tx "create" "--bytecode" "out/debug/tests.bin"
"--storage-slots" "out/debug/tests-storage_slots.json"
"--script-gas-limit" "100"
"--gas-price" "0"
"--maturity" "0"
"--witness" "ADFD"
"--witness" "DFDA"
"input" "contract"
"--utxo-id" "1"
"--output-ix" "1"
"--balance-root" "0x0000000000000000000000000000000000000000000000000000000000000000"
"--state-root" "0x0000000000000000000000000000000000000000000000000000000000000000"
"--tx-ptr" "89ACBDEFBDEF"
"--contract-id" "0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"output" "coin"
"--to" "0x2222222222222222222222222222222222222222222222222222222222222222"
"--amount" "100"
"--asset-id" "0x0000000000000000000000000000000000000000000000000000000000000000"
"output" "contract"
"--input-ix" "1"
"--balance-root" "0x0000000000000000000000000000000000000000000000000000000000000000"
"--state-root" "0x0000000000000000000000000000000000000000000000000000000000000000"
"output" "change"
"--to" "0x2222222222222222222222222222222222222222222222222222222222222222"
"--amount" "100"
"--asset-id" "0x0000000000000000000000000000000000000000000000000000000000000000"
"output" "variable"
"--to" "0x2222222222222222222222222222222222222222222222222222222222222222"
"--amount" "100"
"--asset-id" "0x0000000000000000000000000000000000000000000000000000000000000000"
"output" "contract-created"
"--contract-id" "0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"--state-root" "0x0000000000000000000000000000000000000000000000000000000000000000"
]
}

/// The top-level `forc tx` command.
#[derive(Debug, Parser, Deserialize, Serialize)]
#[clap(about, version, after_help = EXAMPLES)]
Expand Down
2 changes: 2 additions & 0 deletions forc-plugins/forc-tx/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out
target
13 changes: 13 additions & 0 deletions forc-plugins/forc-tx/tests/Forc.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[package]]
name = "core"
source = "path+from-root-AC247AEA3D39B916"

[[package]]
name = "std"
source = "git+https://github.com/fuellabs/sway?tag=v0.47.0#34265301c6037d51444899a99df1cfc563df6016"
dependencies = ["core"]

[[package]]
name = "tests"
source = "member"
dependencies = ["std"]
7 changes: 7 additions & 0 deletions forc-plugins/forc-tx/tests/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
entry = "main.sw"
license = "Apache-2.0"
name = "tests"

[dependencies]
11 changes: 11 additions & 0 deletions forc-plugins/forc-tx/tests/src/main.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
contract;

abi MyContract {
fn test_function() -> bool;
}

impl MyContract for Contract {
fn test_function() -> bool {
true
}
}

0 comments on commit 9551af6

Please sign in to comment.