Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced elrond_codec import with multiversx_sc::codec #643

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ You always need to add new fields at the end of the struct, otherwise, this appr
To fix this, we need to manually implement the decoding traits, which were previously automatically added through the derives.

```rust
use multiversx_sc::codec::{NestedDecodeInput, TopDecodeInput};

#[derive(TypeAbi, TopEncode, NestedEncode)]
pub struct UserData<M: ManagedTypeApi> {
pub stake_amount: BigUint<M>,
Expand All @@ -82,7 +84,7 @@ pub struct UserData<M: ManagedTypeApi> {
impl<M: ManagedTypeApi> TopDecode for UserData<M> {
fn top_decode<I>(input: I) -> Result<Self, DecodeError>
where
I: elrond_codec::TopDecodeInput,
I: TopDecodeInput,
{
let mut buffer = input.into_nested_buffer();
Self::dep_decode(&mut buffer)
Expand Down Expand Up @@ -126,6 +128,8 @@ Unless you want to remove the very last field of the struct, and change nothing
Assuming you simply want to remove `last_update_block` for the example above, the implementation would be as follows:

```rust
use multiversx_sc::codec::{NestedDecodeInput, TopDecodeInput};

#[derive(TypeAbi, TopEncode, NestedEncode)]
pub struct UserData<M: ManagedTypeApi> {
pub stake_amount: BigUint<M>,
Expand All @@ -134,7 +138,7 @@ pub struct UserData<M: ManagedTypeApi> {
impl<M: ManagedTypeApi> TopDecode for UserData<M> {
fn top_decode<I>(input: I) -> Result<Self, DecodeError>
where
I: elrond_codec::TopDecodeInput,
I: TopDecodeInput,
{
let mut buffer = input.into_nested_buffer();
Self::dep_decode(&mut buffer)
Expand Down
Loading