sway
sway copied to clipboard
try_read returns invalid value for storage variable of type StorageMap<u64, StorageVec<u64>>
Related Component
compiler
Problem
try_read returns None even if the StorageVec value under given key is properly initialized and non-empty.
When test function is called on the contract below it reverts with try_read bug error.
My expectation is that try_read should return Some(...).
Steps
abi TestAbi {
#[storage(read, write)]
fn test(key: u64);
}
storage {
test_1: StorageMap<u64, StorageVec<u64>> = StorageMap {},
}
impl TestAbi for Contract {
#[storage(read, write)]
fn test(key: u64) {
require(storage.test_1.try_insert(key, StorageVec {}).is_ok(), "try_insert failed"); // initalized
storage.test_1.get(key).push(1); // vector is non-empty
require(storage.test_1.get(key).try_read().is_some(), "try_read bug"); // reverts here
}
}
Possible Solution(s)
No response
Notes
No response
Installed components
fuelup check
latest - Up to date
testnet - Up to date
fuelup - Up to date
Hi @pgebal I'm a new contributor and would love to handle this issue , I'm a full stack web developer thanks My contact info: *telegram: kellmusk ETA:2-3hrs