v0.32.0
What's Changed
- Use non-tagged version of forc in CI by @Salka1988 in #699
- feat: Add support for custom block time by @MujkicA in #684
- ci: update
forc
andrustc
version in CI by @iqdecay in #706 - docs: update forc setup and test workflow by @hal3e in #705
- fix: support empty structs by @hal3e in #708
- feat!: add parsed log to revert error by @hal3e in #690
- feat: support main function arguments in scripts by @iqdecay in #620
- fix: pay tx fees with message by @MujkicA in #715
- feat: get message proof by @MujkicA in #700
- feat: add logs for scripts by @hal3e in #716
- feat: derive additional traits for Identity by @hal3e in #719
- feat: add predicate data encoder method by @digorithm in #720
- Fix some broken links to the Sway book by @mohammadfawaz in #722
- feat!: convert client types to fuels types by @MujkicA in #707
- feat: add vector support for scripts by @hal3e in #718
- release: Bump versions to 0.32.0 by @digorithm in #725
Full Changelog: v0.31.1...v0.32.0
New features and breaking changes
Custom block time
Adds an optional parameter to produce_blocks
to set the start time and the interval of the produced blocks. Useful for testing conditions that require specific times for a block to be produced.
Breaking change
produce_blocks()
now takes an additional parameter:Option<TimeParameters>
.
Parsed and readable revert errors
Revert errors used to be hard to debug, as the SDK would simply dump the hex value of the error coming from the client. Now, this revert error is properly parsed, making debugging a lot easier.
Script arguments support
This release also includes supporting script arguments. I.e., your script main()
functions can take arguments; now they're supported by the SDK. This is done through the new script_abigen!
macro:
script_abigen!(
MyScript,
"packages/fuels/tests/scripts/script_with_arguments/out/debug/script_with_arguments-abi.json"
);
let wallet = launch_provider_and_get_wallet().await;
let bin_path =
"../fuels/tests/scripts/script_with_arguments/out/debug/script_with_arguments.bin";
let instance = MyScript::new(wallet, bin_path);
let bim = Bimbam { val: 90 };
let bam = SugarySnack {
twix: 100,
mars: 1000,
};
let result = instance.main(bim, bam).call().await?;
let expected = Bimbam { val: 2190 };
assert_eq!(result.value, expected);
Pay for transaction fees using Message
s
Before, you could only use Coin
s to pay for tx fees; now, you can use Message
s as well. Which is useful, e.g., if you want to spend ETH
through bridging to pay for fees.
Logs for scripts
Logs can now be decoded when using scripts. The interface is similar to the contract's interface.
Breaking changes
Logs now are pulled through the response
returned from a contract call. Instead of pulling them from the contract instance itself:
let contract_methods = contract_instance.methods();
let response = contract_methods.produce_logs_values().call().await?;
let log_u64 = contract_instance.logs_with_type::<u64>(&response.receipts)?;
let log_u32 = contract_instance.logs_with_type::<u32>(&response.receipts)?;
let log_u16 = contract_instance.logs_with_type::<u16>(&response.receipts)?;
let log_u8 = contract_instance.logs_with_type::<u8>(&response.receipts)?;
Pull the logs from the response:
let contract_methods = contract_instance.methods();
let response = contract_methods.produce_logs_values().call().await?;
let log_u64 = response.get_logs_with_type::<u64>()?;
let log_u32 = response.get_logs_with_type::<u32>()?;
let log_u16 = response.get_logs_with_type::<u16>()?;
let log_u8 = response.get_logs_with_type::<u8>()?;
Predicate data encoder
Instead of having to use the SDK's ABIEncoder
directly and deal with Token
s directly in order to encode the predicate_data
that you're passing to your predicate call, you can now simply use the new interface predicate.encode_data()
.
So, we're going from:
// Here we have some abstraction leakage. Having to go to `Token`-land in order to get the job done.
let arg = Token::U32(12345_u32);
let args: Vec<Token> = vec![arg];
let predicate_data = ABIEncoder::encode(&args).unwrap();
let amount_to_unlock = 500;
let _result = second_wallet
.spend_predicate(
predicate_address,
predicate_code,
amount_to_unlock,
AssetId::default(),
second_wallet.address(),
Some(predicate_data),
TxParameters::default(),
)
.await?;
To this:
// No need to deal with `Token`s, just pass whatever Rust's native data here.
let predicate_data: Vec<u8> = predicate.encode_data(42_u64)?;
let amount_to_unlock = 500;
let _result = second_wallet
.spend_predicate(
predicate_address,
predicate_code,
amount_to_unlock,
AssetId::default(),
second_wallet.address(),
Some(predicate_data),
TxParameters::default(),
)
.await?;
Other breaking changes
Type rename: CallResponse
-> FuelCallResponse
Type rename: Script
-> ExecutableFuelCall
The method get_call_execution_script
is now get_executable_call
.
We also go from:
let script = multi_call_handler.get_call_execution_script().await?;
let receipts = script.call(provider).await.unwrap();
to:
let execution_script = multi_call_handler.get_executable_call().await?;
let receipts = execution_script.execute(provider).await.unwrap();