multiversx/mx-sdk-rs

SingleValueMapper<ManagedAddress> throws an error instead of returning a default value

Closed this issue · 1 comments

#[view(getAddress)]
#[storage_mapper("address")]
fn address(&self, id: usize) -> SingleValueMapper<ManagedAddress>;

self.address(id).get() throws Storage decode error: bad array length error.
storage of BigUint and other manged types returns default value but ManagedAddress storage throws an error if it's not initialized.

ManagedAddress is a fixed length 32-byte array. You cannot decode it from 0 bytes.

BigUint and ManagedBuffer being decoded from empty storage has nothing to do with their default value. It just happens that the value 0 and an empty buffer are both encoded as "empty".

Check with the is_empty method.