You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can't invoke SRC7 metadata method from the rust SDK due to arbitrary nesting of heap types Since metadata Returns an Option wrapping an Enum that evaluate to string.
let meta = contract_instance
.methods()
.metadata(asset_id, "key".to_string())
.simulate()
.await
.unwrap();
Throws the following error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidType("Enums currently support only one level deep heap types.")
contract_instance comes from the following implementation:
contract;
use src_7::{Metadata, SRC7};
use std::{call_frames::contract_id, hash::Hash, storage::storage_string::*, string::String};
impl SRC7 for Contract {
#[storage(read)]
fn metadata(asset: AssetId, key: String) -> Option<Metadata> {
if key == String::from_ascii_str("key") {
Some(Metadata::String(String::from_ascii_str("value")))
} else {
None
}
}
}
Then, the execution should return something like:
let result: Option<Enum<String>> = SRC7.metadata(myAsset, myKey);
Considering:
/// Universal return type for metadata.
pub enum Metadata {
// Used when the stored metadata is a `b256`.
B256: b256,
/// Used when the stored metadata is `Bytes`.
Bytes: Bytes,
/// Used when the stored metadata is a `u64`.
Int: u64,
/// Used when the stored metadata is a `String`.
String: String,
}
Description
Can't invoke SRC7 metadata method from the rust SDK due to arbitrary nesting of heap types
Since
metadata
Returns an Option wrapping an Enum that evaluate to string.Throws the following error:
contract_instance comes from the following implementation:
Then, the execution should return something like:
Considering:
First incidence reported here.
The text was updated successfully, but these errors were encountered: