Releases: FuelLabs/fuels-rs
v0.42.0
What's Changed
- refactor!: unify type import path by @iqdecay in #934
- feat!: add predicate configurables by @hal3e in #935
- Add predicate code getter by @MujkicA in #941
- chore: reorganize and bump external dependencies by @hal3e in #943
- chore: update
sway
to0.38.0
andfuel-core
to0.17.11
by @xgreenx in #947 - docs: add section comments for devrel by @sarahschwartz in #946
- chore: bump
syn
to2.0
by @hal3e in #957 - feat: add trimming utilities to
SizedAsciiString
by @iqdecay in #955 - chore: default-features warnings on cargo nightly by @Salka1988 in #963
- chore: make api around Salt consistent by @MujkicA in #964
- bug: reexport lost fuels::tx::Output under fuels::types::output::Output by @segfault-magnet in #961
- feat!: add
u128
support by @hal3e in #972 - feat: add gas estimation to script calls by @MujkicA in #973
- feat(contracts): add tx_id to FuelCallResponse by @Br1ght0ne in #734
- feat:
low level call
support by @Salka1988 in #958 - Extend codeowners list by @digorithm in #979
- refactor!: update
sway
andfuel-core
to0.18.1
by @xgreenx in #950 - Bump versions to 0.42.0 by @digorithm in #983
Full Changelog: v0.41.0...v0.42.0
Breaking changes
Types import path changes
- Use
fuels::types::input::Input
instead offuels::tx::input
- Use
fuels::types::coin::Coin
instead offuels::client::schema::coin::Coin
andfuels::tx::Output::Coin
- Use
fuels::types::AssetId
instead offuels::client::schema::AssetId
andfuels::tx::AssetId
- Use
fuels::tx::UtxoId
instead offuels::client::schema::UtxoId
- Use
fuels::types::coin::CoinStatus
instead offuels::client::schema::coin::CoinStatus
- Use
fuels::types::resource::Resource
instead offuels::client::schema::resource::Resource
- Use
fuels_types::types::Bytes32
instead offuel_tx::Bytes32
Configurables for predicates
abigen!(Predicate(
name = "MyPredicate",
abi = "packages/fuels/tests/predicates/predicate_configurables/out/debug/predicate_configurables-abi.json"
));
let new_struct = StructWithGeneric {
field_1: 32u8,
field_2: 64,
};
let new_enum = EnumWithGeneric::VariantTwo;
let configurables = MyPredicateConfigurables::new()
.set_STRUCT(new_struct.clone())
.set_ENUM(new_enum.clone());
let predicate_data = MyPredicateEncoder::encode_data(8u8, true, new_struct, new_enum);
let mut predicate: Predicate = Predicate::load_from(
"tests/predicates/predicate_configurables/out/debug/predicate_configurables.bin",
)?
.with_data(predicate_data)
.with_configurables(configurable);
fuel-core @ 0.18
changes
Note that some of these changes are subject to subsequent changes in future UX improvements.
- Signing the transaction and predicate id generation requires
ChainId
(ConsensusParameters
). - Now, tokens should be transferred to the contract first, and after you can transfer them via
SMO
or another transfer. So in some tests, we first need to transfer money to the contract. - The
produce_blocks
function is updated and doesn't requireTimeParameters
. - Removed redundant usage of
MessageId
. Now the identifier of the message is aNonce
. - Removed
Output::Message
. Now you don't need to specify it in the outputs. Because of thatSMO
opcode doesn't require a message output index. - The proof API is updated with a new design: FuelLabs/fuel-core#1046. To prove the block at height
X
, you need at least a committedX + 1
block. Predicate::set_provider
now returns aResult
because it can fail if the "new" provider has different consensus parameters than the consensus parameters used previouslyPredicate
can be loaded with a provider usingload_from_with_provider
andfrom_code_and_provider
. Thefrom_code
andload_from
remain and use the defaultConsensusParameters
value.Provider::new
now takes aConsensusParameters
argument, so we can avoid changing the API of downstream clients.setup_test_client
now returnsConsensusParameters
of the client. This was either this orsetup_test_provider
would have to change, and the former is much less used than the latter.
v0.41.0
What's Changed
- style: fix typo in function names by @iqdecay in #924
- feat!: support scripts and predicates in
setup_program_test!
(oldsetup_contract_test
) by @segfault-magnet in #910 - feat: add receipt decoder by @MujkicA in #916
- feat: expose code root by @MujkicA in #937
- Bump versions to 0.41.0 by @digorithm in #938
Full Changelog: v0.40.0...v0.41.0
Breaking changes
New setup_program_test!
macro
The macro setup_contract_test!
has been renamed to setup_program_test!
and can now generate bindings for scripts and predicates. You can also create a script instance via LoadScript
. Example:
setup_program_test!(
Wallets("wallet"),
Abigen(Script(
name = "MyScript",
project = "packages/fuels/tests/types/scripts/script_generics"
)),
LoadScript(
name = "script_instance",
script = "MyScript",
wallet = "wallet"
)
);
The command for generating bindings (Abigen
) now requires the program type to be stated. Before: Abigen(name="...
, now: Abigen(Contract(name="..."
.
Read the doc section The setup_program_test! macro
for more details.
v0.40.0
What's Changed
- chore: default-features warnings on cargo nightly by @segfault-magnet in #921
- fix: broken doc link by @sarahschwartz in #922
- feat: add support for
Bytes
andRawSlice
inputs by @hal3e in #904 - refactor!: separate
Contract
loading and deploying by @hal3e in #899 - feat!: add
LogResult
struct by @Salka1988 in #919 - bug:
Parameterize
andTokenizable
for wasm enums is broken by @segfault-magnet in #928 - Bump versions to 0.40.0 by @digorithm in #929
Full Changelog: v0.39.0...v0.40.0
New Features
Add support for Bytes and RawSlice inputs (#904)
This update introduces support for Bytes and RawSlice input types, giving developers more flexibility when working with byte sequences and raw slices. Thanks to @hal3e for this contribution!
Add LogResult struct (#919)
We have added a new LogResult struct to make it easier to work with and process log results from the Fuel Virtual Machine. This new feature will improve the developer experience when working with logs. Kudos to @Salka1988 for this addition!
Improvements
Separate Contract loading and deploying (#899)
This release includes a significant refactor that separates the Contract loading and deploying process. This change aims to improve code readability and maintainability. Great work by @hal3e!
The biggest change for the user is the way to deploy contracts. Previously the user would use deploy
directly:
let contract_id = Contract::deploy(
"tests/contracts/configurables/out/debug/configurables.bin",
&wallet,
DeployConfiguration::default(),
)
.await?;
This function did two things: Load and then deploy the contract. Now, it looks like this:
let contract_id = Contract::load_from(
"tests/contracts/configurables/out/debug/configurables.bin",
LoadConfiguration::default(),
)?
.deploy(&wallet, TxParameters::default())
.await?;
This makes it clear what is being done. It makes the LoadConfiguration
simpler, and also, now the user can get the contract_id
or state_root
easily.
let contract_id = Contract::load_from(
"tests/contracts/configurables/out/debug/configurables.bin",
LoadConfiguration::default(),
)?
.contract_id();
Bug Fixes
Fix broken doc link (#922)
A broken documentation link has been fixed, ensuring users can now access the relevant information without issues. Thanks to @sarahschwartz for the quick fix!
Fix Parameterize and Tokenizable for wasm enums (#928)
We have resolved an issue where Parameterize and Tokenizable for wasm enums were broken. This fix ensures that these traits now work as intended for wasm enums. Credit goes to @segfault-magnet for identifying and fixing the issue!
Miscellaneous
Address default-features warnings on cargo nightly (chore) (#921)
We've addressed the default-features warnings on cargo nightly builds to keep the project up-to-date and reduce warnings. Special thanks to @segfault-magnet for taking care of this!
We encourage you to update your Fuels-rs library to v0.40 and take advantage of these new features and improvements. Your feedback is invaluable, so please don't hesitate to report any issues or share your thoughts on this release!
v0.39.0
What's Changed
- docs: change docs about vectors by @iqdecay in #895
- feat: support
Bytes
type return from contract by @iqdecay in #868 - feat!: enable payments with predicates by @Salka1988 in #815
- ci: add clippy check without all features by @hal3e in #900
- chore: reorganize harness tests by @hal3e in #897
- refactor!: improve log decoding and simplify
ParamType
by @segfault-magnet in #885 - Delete
provider
from withwith_account
function by @Salka1988 in #906 - refactor!:
fuels
wasm-offending packages/reexports hidden behindstd
flag by @segfault-magnet in #913 - bug: storage slots have to be sorted in a create tx by @segfault-magnet in #911
- chore: remove unused file
cargo
by @hal3e in #917 - Bump versions to 0.39.0 by @digorithm in #920
Full Changelog: v0.38.1...v0.39.0
New features
Bytes
types
The Sway Bytes
type is now supported in the SDK.
Pay for fees using predicate
We've recently introduced the Account
trait, which encapsulates all the behavior you commonly see in a wallet. Predicate
s also implement the Account
trait now. This means you can use a Predicate
the same way you'd use a wallet, when paying for transaction fees. For instance:
// Instead of passing the wallet used to sign the contract's transaction, we can now pass a predicate
let contract_methods = MyContract::new(contract_id, predicate).methods();
let tx_params = TxParameters::new(1000000, 10000, 0);
assert_eq!(predicate.get_asset_balance(&BASE_ASSET_ID).await?, 192);
let response = contract_methods
.initialize_counter(42) // Build the ABI call
.tx_params(tx_params)
.call()
.await?;
Note that this new feature introduces many breaking changes. Read more here: #815.
v0.38.1
What's Changed
- fix: make
load_contract
pub by @hal3e in #893 - Bump versions to 0.38.1 by @digorithm in #894
Full Changelog: v0.38.0...v0.38.1
v0.38.0
What's Changed
- Add message output estimation by @MujkicA in #846
- Add cname for gh-pages by @Voxelot in #864
- More cnaming for gh-pages by @Voxelot in #865
- Add latest block time and spendable resources with exclusion by @MujkicA in #833
- chore: update PR template by @hal3e in #869
- feat!: return result from
try_from_type_application
by @hal3e in #870 - fix: coins query no longer returns spent coins by @segfault-magnet in #873
- Resolve cyclic deps by @MujkicA in #859
- feat: check for unused md files in docs by @hal3e in #871
- fix minor typo by @K1-R1 in #876
- feat: support returning
Vec<>
types from contracts by @iqdecay in #848 - refactor: contract deployment configuration by @hal3e in #860
- refactor: remove the
Byte
type from the SDK by @iqdecay in #883 - feat: type path support (
forc
flag--json-abi-with-callpaths
) by @segfault-magnet in #872 - enable cargo sparse protocol by @segfault-magnet in #888
- Bump versions to 0.38.0 by @digorithm in #890
New Contributors
Full Changelog: v0.37.1...v0.38.0
New features
Message output estimation
The transaction dependencies estimation method that automatically estimates things like contract IDs and variable outputs now also estimates message outputs.
Filtering spendable resources
get_spendable_resources
now takes a filter object:
let filter = ResourceFilter {
from: wallet.address().clone(),
amount: coin_amount_1,
excluded_utxos: vec![coin_2_utxo_id],
excluded_message_ids: vec![message_id],
..Default::default()
};
let resources = provider.get_spendable_resources(filter).await.unwrap();
Retrieving latest block time
The Provider
now has a simple way to retrieve the latest block time: latest_block_time
:
#[tokio::test]
async fn can_retrieve_latest_block_time() -> Result<()> {
let provider = given_a_provider().await;
let since_epoch = 1676039910;
let latest_timestamp = Utc.timestamp_opt(since_epoch, 0).unwrap();
let time = TimeParameters {
start_time: latest_timestamp,
block_time_interval: Duration::seconds(1),
};
provider.produce_blocks(1, Some(time)).await?;
assert_eq!(
provider.latest_block_time().await?.unwrap(),
latest_timestamp
);
Ok(())
}
try_from_type_application
return type change
try_from_type_application
will not panic anymore. Instead, we propagate an InvalidData
error. Type::from()
is now Type::try_from()
.
Coins query no longer returns spent coins
Vec
as output types for contract methods
The SDK now supports contract methods that return a vector:
Contract deployment configuration object
We've introduced a new builder struct, DeployConfiguration
, for contract deployment. If you want to deploy a contract with the default configuration, you can do it like this:
let contract_id = Contract::deploy(
"tests/contracts/configurables/out/debug/configurables.bin",
&wallet,
DeployConfiguration::default(),
)
.await?;
Alternatively, you can set TxParameters
, StorageConfiguration
, Configurables
and Salt
like this:
abigen!(Contract(
name = "MyContract",
abi = "packages/fuels/tests/contracts/configurables/out/debug/configurables-abi.json"
));
let wallet = launch_provider_and_get_wallet().await;
let tx_parameters = TxParameters::default()
.set_gas_price(0)
.set_gas_limit(1_000_000)
.set_maturity(0);
let key = Bytes32::from([1u8; 32]);
let value = Bytes32::from([2u8; 32]);
let storage_slot = StorageSlot::new(key, value);
let storage_configuration =
StorageConfiguration::default().set_manual_storage(vec![storage_slot]);
let configurables = MyContractConfigurables::new()
.set_STR_4("FUEL".try_into()?)
.set_U8(42u8);
let rng = &mut StdRng::seed_from_u64(2322u64);
let salt: [u8; 32] = rng.gen();
let contract_id = Contract::deploy(
"tests/contracts/configurables/out/debug/configurables.bin",
&wallet,
DeployConfiguration::default()
.set_tx_parameters(tx_parameters)
.set_storage_configuration(storage_configuration)
.set_configurables(configurables)
.set_salt(salt),
)
.await?;
Type path support and resolution of conflicting types
If you have different types with the same name across multiple files, the previous SDK versions might have had difficulty dealing with them. The teams have been working on fixing this once and for all. The solution is that now you can compile your Sway code with a new flag --json-abi-with-callpaths
(which will soon be the default); this will generate the JSON ABI with proper paths (my_mod::MyType
instead of just MyType
) and the SDK will generate the appropriate Rust code in the appropriate module, solving the conflicting types issue.
v0.37.1
What's Changed
- fix: latest release cannot be used by cargo by @segfault-magnet in #857
- Bump versions to 0.37.1 by @digorithm in #858
Full Changelog: v0.37.0...v0.37.1
v0.37.0
What's Changed
- fix: clear environment before running fuel-core binary by @segfault-magnet in #843
- Improve devx for extracting data from Script by @MujkicA in #801
- docs: update the repo README by @iqdecay in #838
- fix: ci individual package testing by @segfault-magnet in #852
- feat: support configurable constants by @hal3e in #844
- fix!: wasm compatibility for
fuels-types
by @segfault-magnet in #839 - Bump versions to 0.37.0 by @digorithm in #856
Full Changelog: v0.36.1...v0.37.0
New features
New script APIs: ScriptTransaction
and CreateTransaction
You can now build a script transaction in a much easier fashion like this:
let mut tx = ScriptTransaction::new(&inputs, &outputs, params)
.with_script(binary)
.with_script_data(data);
// or to extend inputs/outputs
tx.inputs_mut().extend(other_inputs);
tx.outputs_mut().extend(other_outputs);
This means we've removed ExecutionScript
since this abstraction lacked functionality. And also, constants and params were moved from fuels-core to fuels-types to avoid circular dep.
Configurable constants
An exciting new feature recently landed in Sway: constants. Now, we've added support in the Rust SDK so that you can configure these constants without needing to recompile your Sway code. Read more here: #844.
v0.36.1
What's Changed
- feat: add support for assert_eq logs by @hal3e in #811
- ci: update
forc
version in CI by @hal3e in #830 - feat: support all revert signals by @hal3e in #831
- fix wasm compatibility when
no_std
is used in Abigen by @segfault-magnet in #825 - refactor: implement forc/sway workspaces to build fuels e2e tests by @Salka1988 in #792
- refactor: use revert error codes from
fuels-abi-types
by @hal3e in #836 - fix: Fuel-Core breaking changes by @segfault-magnet in #840
- Bump versions to 0.36.1 by @digorithm in #841
Full Changelog: v0.36.0...v0.36.1
v0.36.0
What's Changed
- docs: add call response error handling section by @sarahschwartz in #824
- Methods without #[payable] cannot accept assets by @MujkicA in #800
- Update for
fuel-asm
refactor. Updates for fuel-core 0.17, fuel-vm 0.26. by @mitchmindtree in #827 - Fuel asm release 0.36.0 by @Voxelot in #828
Full Changelog: v0.35.1...v0.36.0