Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into upgrade/fuel-core-m…
Browse files Browse the repository at this point in the history
…aster
  • Loading branch information
IGI-111 committed Nov 15, 2023
2 parents df6f403 + d8704e1 commit 4875fbb
Show file tree
Hide file tree
Showing 60 changed files with 641 additions and 664 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ env:
FUEL_CORE_VERSION: 0.20.6
RUST_VERSION: 1.72.1
FORC_VERSION: 0.46.0
FORC_PATCH_BRANCH: ""
FORC_PATCH_BRANCH: "xunilrj/fix-implicit-std-env-vars"
FORC_PATCH_REVISION: ""
FORC_IMPLICIT_STD_GIT_BRANCH: "xunilrj/fix-implicit-std-env-vars"

jobs:
setup-test-projects:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/verify_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi

# strip preceeding 'v' if it exists on tag
REF=${REF/#v}
TOML_VERSION=$(cat $MANIFEST | dasel -r toml 'workspace.package.version')
TOML_VERSION=$(cat $MANIFEST | dasel -r toml -w plain 'workspace.package.version')

if [ "$TOML_VERSION" != "$REF" ]; then
err "Crate version $TOML_VERSION, doesn't match tag version $REF"
Expand Down
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ readme = "README.md"
license = "Apache-2.0"
repository = "https://github.com/FuelLabs/fuels-rs"
rust-version = "1.72.1"
version = "0.49.0"
version = "0.50.1"

[workspace.dependencies]
Inflector = "0.11.4"
Expand Down Expand Up @@ -87,13 +87,13 @@ fuel-types = { version = "0.35.4", default-features = false }
fuel-vm = "0.35.4"

# Workspace projects
fuels = { version = "0.49.0", path = "./packages/fuels" }
fuels-accounts = { version = "0.49.0", path = "./packages/fuels-accounts", default-features = false }
fuels-code-gen = { version = "0.49.0", path = "./packages/fuels-code-gen", default-features = false }
fuels-core = { version = "0.49.0", path = "./packages/fuels-core", default-features = false }
fuels-macros = { version = "0.49.0", path = "./packages/fuels-macros", default-features = false }
fuels-programs = { version = "0.49.0", path = "./packages/fuels-programs", default-features = false }
fuels-test-helpers = { version = "0.49.0", path = "./packages/fuels-test-helpers", default-features = false }
fuels = { version = "0.50.1", path = "./packages/fuels" }
fuels-accounts = { version = "0.50.1", path = "./packages/fuels-accounts", default-features = false }
fuels-code-gen = { version = "0.50.1", path = "./packages/fuels-code-gen", default-features = false }
fuels-core = { version = "0.50.1", path = "./packages/fuels-core", default-features = false }
fuels-macros = { version = "0.50.1", path = "./packages/fuels-macros", default-features = false }
fuels-programs = { version = "0.50.1", path = "./packages/fuels-programs", default-features = false }
fuels-test-helpers = { version = "0.50.1", path = "./packages/fuels-test-helpers", default-features = false }

[patch.crates-io]
fuel-core = { git = "https://github.com/FuelLabs/fuel-core", branch = "master" }
Expand Down
4 changes: 2 additions & 2 deletions docs/src/connecting/short-lived.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ let wallet = launch_provider_and_get_wallet().await?;
The `fuel-core-lib` feature allows us to run a `fuel-core` node without installing the `fuel-core` binary on the local machine. Using the `fuel-core-lib` feature flag entails downloading all the dependencies needed to run the fuel-core node.

```rust,ignore
fuels = { version = "0.49.0", features = ["fuel-core-lib"] }
fuels = { version = "0.50.1", features = ["fuel-core-lib"] }
```

### RocksDb

The `rocksdb` is an additional feature that, when combined with `fuel-core-lib`, provides persistent storage capabilities while using `fuel-core` as a library.

```rust,ignore
fuels = { version = "0.49.0", features = ["rocksdb"] }
fuels = { version = "0.50.1", features = ["rocksdb"] }
```
4 changes: 2 additions & 2 deletions examples/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod tests {
.await?;
// ANCHOR_END: contract_call_cost_estimation

assert_eq!(transaction_cost.gas_used, 397);
assert_eq!(transaction_cost.gas_used, 470);

Ok(())
}
Expand Down Expand Up @@ -649,7 +649,7 @@ mod tests {
.await?;
// ANCHOR_END: multi_call_cost_estimation

assert_eq!(transaction_cost.gas_used, 618);
assert_eq!(transaction_cost.gas_used, 693);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fuels-accounts/src/accounts_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use fuels_core::{
constants::BASE_ASSET_ID,
types::{
bech32::Bech32Address,
errors::{error, Error, Result},
errors::{error, Result},
input::Input,
transaction_builders::TransactionBuilder,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/fuels-accounts/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Provider {
TxStatus::Revert {
receipts,
reason,
id: revert_id,
revert_id,
}
}
TransactionStatus::Submitted { .. } => TxStatus::Submitted,
Expand Down Expand Up @@ -384,7 +384,7 @@ impl Provider {
Some(reason) => TxStatus::Revert {
receipts,
reason,
id: 0,
revert_id: 0,
},
None => TxStatus::Success { receipts },
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fuels-accounts/src/provider/retry_util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fmt::Debug, future::Future, num::NonZeroU32, time::Duration};

use fuels_core::types::errors::{error, Error, Result as SdkResult};
use fuels_core::types::errors::{error, Result as SdkResult};

/// A set of strategies to control retry intervals between attempts.
///
Expand Down
5 changes: 1 addition & 4 deletions packages/fuels-accounts/src/provider/retryable_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use fuel_core_client::client::{
};
use fuel_tx::{Receipt, Transaction, TxId, UtxoId};
use fuel_types::{Address, AssetId, BlockHeight, ContractId, MessageId, Nonce};
use fuels_core::{
error,
types::errors::{Error, Result},
};
use fuels_core::{error, types::errors::Result};

use crate::provider::{retry_util, RetryConfig};

Expand Down
74 changes: 29 additions & 45 deletions packages/fuels-core/src/codec/abi_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ impl ABIDecoder {
///
/// let decoder = ABIDecoder::default();
///
/// let token = decoder.decode(&ParamType::U8, &[0, 0, 0, 0, 0, 0, 0, 7]).unwrap();
/// let token = decoder.decode(&ParamType::U64, &[0, 0, 0, 0, 0, 0, 0, 7]).unwrap();
///
/// assert_eq!(u8::from_token(token).unwrap(), 7u8);
/// assert_eq!(u64::from_token(token).unwrap(), 7u64);
/// ```
pub fn decode(&self, param_type: &ParamType, bytes: &[u8]) -> Result<Token> {
BoundedDecoder::new(self.config).decode(param_type, bytes)
}

/// Decode data from one of the receipt returns.
pub fn decode_receipt_return(&self, param_type: &ParamType, bytes: &[u8]) -> Result<Token> {
BoundedDecoder::new(self.config).decode(param_type, bytes)
}

/// Same as `decode` but decodes multiple `ParamType`s in one go.
/// # Examples
/// ```
Expand All @@ -68,7 +73,7 @@ impl ABIDecoder {
/// use fuels_core::types::Token;
///
/// let decoder = ABIDecoder::default();
/// let data: &[u8] = &[0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8];
/// let data: &[u8] = &[7, 8];
///
/// let tokens = decoder.decode_multiple(&[ParamType::U8, ParamType::U8], &data).unwrap();
///
Expand Down Expand Up @@ -114,7 +119,7 @@ mod tests {
];
let data = [
0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, // u32
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, // u8
0xff, // u8
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, // u16
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // u64
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
Expand All @@ -141,9 +146,7 @@ mod tests {
#[test]
fn decode_bool() -> Result<()> {
let types = vec![ParamType::Bool, ParamType::Bool];
let data = [
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x00,
];
let data = [0x01, 0x0];

let decoded = ABIDecoder::default().decode_multiple(&types, &data)?;

Expand Down Expand Up @@ -215,9 +218,7 @@ mod tests {
fn decode_array() -> Result<()> {
// Create a parameter type for u8[2].
let types = vec![ParamType::Array(Box::new(ParamType::U8), 2)];
let data = [
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2a,
];
let data = [0xff, 0x2a];

let decoded = ABIDecoder::default().decode_multiple(&types, &data)?;

Expand All @@ -234,7 +235,7 @@ mod tests {
// }

let data = [
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1,
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
];
let param_type = ParamType::Struct {
fields: vec![ParamType::U8, ParamType::Bool],
Expand Down Expand Up @@ -366,8 +367,8 @@ mod tests {
};

let data = [
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1,
0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
];

let decoded = ABIDecoder::default().decode(&nested_struct, &data)?;
Expand Down Expand Up @@ -416,26 +417,23 @@ mod tests {

let u8_arr = ParamType::Array(Box::new(ParamType::U8), 2);
let b256 = ParamType::B256;
let s = ParamType::StringArray(3);
let ss = ParamType::StringSlice;

let types = [nested_struct, u8_arr, b256, s, ss];
let types = [nested_struct, u8_arr, b256];

let bytes = [
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, // foo.x == 10u16
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, // foo.y.a == true
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, // foo.b.0 == 1u8
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, // foo.b.1 == 2u8
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, // u8[2].0 == 1u8
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, // u8[2].0 == 2u8
0xd5, 0x57, 0x9c, 0x46, 0xdf, 0xcc, 0x7f, 0x18, // b256
0x20, 0x70, 0x13, 0xe6, 0x5b, 0x44, 0xe4, 0xcb, // b256
0x4e, 0x2c, 0x22, 0x98, 0xf4, 0xac, 0x45, 0x7b, // b256
0xa8, 0xf8, 0x27, 0x43, 0xf3, 0x1e, 0x93, 0xb, // b256
0x66, 0x6f, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, // str[3]
0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, // str data
0x61, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x73, // str data
0x65, 0x6e, 0x74, 0x65, 0x6e, 0x63, 0x65, // str data
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, // u16
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // bool
0x1, 0x2, // array[u8]
0x1, 0x2, // array[u8]
0xd5, 0x57, 0x9c, 0x46, 0xdf, 0xcc, 0x7f, 0x18, // b256 start
0x20, 0x70, 0x13, 0xe6, 0x5b, 0x44, 0xe4, 0xcb, //
0x4e, 0x2c, 0x22, 0x98, 0xf4, 0xac, 0x45, 0x7b, //
0xa8, 0xf8, 0x27, 0x43, 0xf3, 0x1e, 0x93,
0xb, // b256 end
// 0x66, 0x6f, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, // "foo"
// 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, //
// 0x61, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x73, //
// 0x65, 0x6e, 0x74, 0x65, 0x6e, 0x63, 0x65, //
];

let decoded = ABIDecoder::default().decode_multiple(&types, &bytes)?;
Expand All @@ -457,14 +455,7 @@ mod tests {
0xf3, 0x1e, 0x93, 0xb,
]);

let ss = Token::StringSlice(StaticStringToken::new(
"This is a full sentence".into(),
None,
));

let s = Token::StringArray(StaticStringToken::new("foo".into(), Some(3)));

let expected: Vec<Token> = vec![foo, u8_arr, b256, s, ss];
let expected: Vec<Token> = vec![foo, u8_arr, b256];

assert_eq!(decoded, expected);
Ok(())
Expand Down Expand Up @@ -555,13 +546,6 @@ mod tests {
assert!(matches!(result, Err(Error::InvalidType(_))));
}

#[test]
pub fn multiply_overflow_vector() {
let param_type = Vec::<[(); usize::MAX]>::param_type();
let result = ABIDecoder::default().decode(&param_type, &[]);
assert!(matches!(result, Err(Error::InvalidData(_))));
}

#[test]
pub fn multiply_overflow_arith() {
let mut param_type: ParamType = U16;
Expand Down
Loading

0 comments on commit 4875fbb

Please sign in to comment.