ContractCall object has a nice builder pattern attached to it. For example, we could build one like this:
let result: MultiValueEncoded<ManagedBuffer> = self .vault_proxy() .contract(to) .echo_arguments(args) .with_egld_or_single_esdt_transfer(payment) .with_gas_limit(gas) .execute_on_dest_context();
.echo_arguments(args).with_egld_or_single_esdt_transfer(payment).with_gas_limit(gas) is part of a builder pattern that initializes the
ContractCall object. Until recently, all
ContractCall functions were working on a single structure (
ContractCall) and the differences between behaviors were resolved at runtime. It was also not forbidden to combine incompatible payment types, like EGLD and ESDT.
We made the
ContractCall to be a trait that describes several structures:
Now, when setting a payment type, the built structure also changes, e.g in the example above from
ContractCallWithEgldOrSingleEsdt, which has no method to provide additional payments. This makes the compiler check the correctness of the builder sequence.
The compiled code gets smaller because the compiler now knows what kind of payment was chosen and does not need to include code that handles the other payment types.
ContractBase supertrait can be now stated explicitly for contract and module traits
All contract and module traits have the
ContractBase supertrait. Developers don’t need to specify it, the framework does it for them.
However, this can confuse some of the IDEs out there. There was a request (and solution) from the community to allow
ContractBase to be explicitly stated in the contract sources for the sake of IDEs and dev tooling.
If contract A calls contract B and contract B sends some EGLD or ESDT tokens back to contract A, the callback in A will see this transfer as payment. This is essential for certain contracts, e.g. contracts that withdraw funds or claim rewards. Until recently, the Rust debugger did not have this feature. It is now fixed.
Function names were kept as bytes. They looked unreadable in the debugger. Made them strings (actually
Cow<'static, str> to be precise), at no penalty to performance.
This feature was preventing contracts from calling functions that were new at the time and not yet available on mainnet. In the meantime they have been deployed to mainnet, so the feature was no longer necessary.
New utility functions
As requested by the contract teams:
- self.send().esdt_local_burn_multi(...) - simply burns several ESDT tokens in a loop;
- self.blockchain().get_token_attributes(...) - only extracts the attributes from the token metadata.
Updated all crates to Rust 2021
We use Rust 2021 everywhere, but some of the crates were missing the update.
Github Release Link: elrond-wasm-rs: v0.38.0, elrond-codec 0.16.0, mandos 0.18.0.
Feel free to send us feedback or open a topic in our Github Discussions tab and share your thoughts so that the entire MultiversX community can hear you. If you have a great idea, share it with us and let's make it happen by implementing and integrating it in our ecosystem.
Stay Hungry! Stay Foolish!