Search code examples
substrate

String and Vec<u128> not found in this scope


I have following code in decl_storage!

Group get(fn group): map hasher(blake2_128_concat) u128 => Vec<u128>;
VoteStatus get(fn vote_status): map hasher(blake2_128_concat) (u128, u128, String) => bool;

Neither its accepts String, nor Vec<u128>, it says not found in this scope.

Update:
Fixed the Vec part by importing

use sp_std::vec::Vec;

How can I import string?? Unable to use str?

Will I use Vec<u8>? Link


Solution

  • You can also import sp_std::prelude::* for common stuff, such as Vec<_>. For string, as noted in your link, you cannot do it and can use Vec<u8> instead.