Skip to content

Commit

Permalink
Merge 4cc730b into 2353803
Browse files Browse the repository at this point in the history
  • Loading branch information
kayagokalp authored May 16, 2024
2 parents 2353803 + 4cc730b commit 70d0380
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 62 deletions.
41 changes: 19 additions & 22 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ fuel-tx = "0.49.0"
fuel-vm = "0.49.0"

# Dependencies from the `fuels-rs` repository:
fuels-core = "0.60.0"
fuels-accounts = "0.60.0"
fuels-core = "0.62.0"
fuels-accounts = "0.62.0"

# Dependencies from the `forc-wallet` repository:
forc-wallet = "0.7.0"
forc-wallet = "0.7.1"

# Dependencies from the `fuel-abi-types` repository:
fuel-abi-types = "0.4.0"
fuel-abi-types = "0.5.0"

[workspace.package]
edition = "2021"
Expand Down
13 changes: 3 additions & 10 deletions forc-plugins/forc-client/src/op/run/encode.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::util::encode::{Token, Type};
use fuel_abi_types::abi::full_program::FullProgramABI;
use fuels_core::{
codec::{ABIEncoder, EncoderConfig},
types::unresolved_bytes::UnresolvedBytes,
};
use fuels_core::codec::{ABIEncoder, EncoderConfig};

#[derive(Debug, PartialEq, Eq)]
pub(crate) struct ScriptCallHandler {
Expand Down Expand Up @@ -39,7 +36,7 @@ impl ScriptCallHandler {
/// Encode the provided values with script's main argument types.
///
/// Returns an error if the provided value count does not match the number of arguments.
pub(crate) fn encode_arguments(&self, values: &[&str]) -> anyhow::Result<UnresolvedBytes> {
pub(crate) fn encode_arguments(&self, values: &[&str]) -> anyhow::Result<Vec<u8>> {
let main_arg_types = &self.main_arg_types;
let expected_arg_count = main_arg_types.len();
let provided_arg_count = values.len();
Expand Down Expand Up @@ -99,11 +96,7 @@ mod tests {
let call_handler = ScriptCallHandler::from_json_abi_str(test_json_abi).unwrap();
let values = ["2", "true"];

let test_data_offset = 0;
let encoded_bytes = call_handler
.encode_arguments(&values)
.unwrap()
.resolve(test_data_offset);
let encoded_bytes = call_handler.encode_arguments(&values).unwrap();
let expected_bytes = vec![2u8, 1u8];
assert_eq!(encoded_bytes, expected_bytes);
}
Expand Down
3 changes: 1 addition & 2 deletions forc-plugins/forc-client/src/op/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ pub async fn run_pkg(
.ok_or_else(|| anyhow::anyhow!("Missing json abi string"))?;
let main_arg_handler = ScriptCallHandler::from_json_abi_str(&package_json_abi)?;
let args = args.iter().map(|arg| arg.as_str()).collect::<Vec<_>>();
let unresolved_bytes = main_arg_handler.encode_arguments(args.as_slice())?;
unresolved_bytes.resolve(0)
main_arg_handler.encode_arguments(args.as_slice())?
}
(Some(_), Some(_)) => {
bail!("Both --args and --data provided, must choose one.")
Expand Down
4 changes: 2 additions & 2 deletions forc-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ fn deployment_transaction(
}

pub fn decode_log_data(
log_id: u64,
log_id: &str,
log_data: &[u8],
program_abi: &ProgramABI,
) -> anyhow::Result<DecodedLog> {
Expand All @@ -683,7 +683,7 @@ pub fn decode_log_data(
.logged_types
.iter()
.flatten()
.map(|logged_type| (logged_type.log_id, logged_type.application.clone()))
.map(|logged_type| (logged_type.log_id.as_str(), logged_type.application.clone()))
.collect();

let type_application = logged_type_lookup
Expand Down
3 changes: 2 additions & 1 deletion forc/src/cli/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ fn print_tested_pkg(pkg: &TestedPackage, test_print_opts: &TestPrintOpts) -> For
..
} = log
{
let decoded_log_data = decode_log_data(*rb, data, &pkg.built.program_abi)?;
let decoded_log_data =
decode_log_data(&rb.to_string(), data, &pkg.built.program_abi)?;
let var_value = decoded_log_data.value;
info!("Decoded log value: {}, log rb: {}", var_value, rb);
}
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/abi_generation/fuel_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn generate_logged_types(
.logged_types
.iter()
.map(|(log_id, type_id)| program_abi::LoggedType {
log_id: **log_id as u64,
log_id: log_id.to_string(),
application: program_abi::TypeApplication {
name: "".to_string(),
type_id: type_id.index(),
Expand Down
9 changes: 6 additions & 3 deletions test/src/e2e_vm_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,12 @@ impl TestContext {
..
} = log
{
let decoded_log_data =
decode_log_data(*rb, data, &pkg.built.program_abi)
.unwrap();
let decoded_log_data = decode_log_data(
&rb.to_string(),
data,
&pkg.built.program_abi,
)
.unwrap();
let var_value = decoded_log_data.value;
if verbose {
println!(
Expand Down
33 changes: 17 additions & 16 deletions test/src/sdk-harness/Cargo.lock

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

2 changes: 1 addition & 1 deletion test/src/sdk-harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fuel-core-client = { version = "0.26.0", default-features = false }
fuel-vm = { version = "0.49.0", features = ["random"] }

# Dependencies from the `fuels-rs` repository:
fuels = { version = "0.61.0", features = ["fuel-core-lib"] }
fuels = { version = "0.62.0", features = ["fuel-core-lib"] }

hex = "0.4.3"
paste = "1.0.14"
Expand Down

0 comments on commit 70d0380

Please sign in to comment.