I’ve got the following contract in sway which implements the SRC7 standard:
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
}
}
}
And when I’m trying to call the metadata
function from rust, I’m getting the following error: “Enums currently support only one level deep heap types”. Looks like the rust sdk doesn’t support nested enums, and in the current context both Option
and Metadata
are enums, nested one into each other in the return parameter of the function.
The way I’m calling the function:
let meta = contract_instance
.methods()
.metadata(asset_id, "key".to_string())
.simulate()
.await
.unwrap();
And the error I’m getting:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidType("Enums currently support only one level deep heap types.")
fuelup show:
Default host: aarch64-apple-darwin
...
active toolchain
-----------------
beta-4-aarch64-apple-darwin (default)
forc : 0.46.1
- forc-client
- forc-deploy : 0.46.1
- forc-run : 0.46.1
- forc-doc : 0.46.1
- forc-explore : 0.28.1
- forc-fmt : 0.46.1
- forc-index : 0.23.0
- forc-lsp : 0.46.1
- forc-tx : 0.46.1
- forc-wallet : 0.3.0
fuel-core : 0.20.5
fuel-core-keygen : Error getting version string
fuel-indexer : 0.23.0
fuels versions
---------------
forc : 0.45
forc-wallet : 0.45
fuels-rs version:
fuels = "0.49.0"