Clara
July 24, 2024, 3:32am
1
First I try to use like this
storage {
asset_id: AssetId = AssetId::default(),
}
I got “Could not evaluate initializer to a const declaration.” when compile.
Then I try to use like this
storage {
asset_id: AssetId = AssetId::from_str("0xb9d62dec6e8b87e495772cd81862db31394bfc3b4d1cb6e04c530f21e3ac1f80").unwrap(),
}
I got above 100 errors when compile.
How to solve this problem?
naz3eh
July 24, 2024, 3:21pm
2
Hey @Clara , can you please try out the solution mentioned here ?
Clara
July 24, 2024, 10:29pm
3
Hey @naz3eh When I try to get the type of AssetId
#[storage(read)]
fn getAssetId() -> AssetId{
AssetId::default()
}
I got like this
{
"bits": "0x787ddef920236e1131aa72bfc80bf1ad23c5b76a959b5a0500f08acf77d39864"
}
it’s not the type of b256, like some wrap b256
If I try to use AssetId like b256
storage {
asset_id: b256 =
0xb9d62dec6e8b87e495772cd81862db31394bfc3b4d1cb6e04c530f21e3ac1f80,
}
......
require(storage.asset_id.read() == msg_asset_id(), AssetError::IncorrectAssetSent);
......
I got compile error like this
require(storage.asset_id.read() == msg_asset_id(), AssetError::IncorrectAssetSent);
|
^^^^^^^^^^^^^^
This parameter was declared as type b256, but argument of type AssetId was provided.
Clara
July 24, 2024, 10:55pm
4
using b256 storage
storage {
asset_id: b256 =
0xb9d62dec6e8b87e495772cd81862db31394bfc3b4d1cb6e04c530f21e3ac1f80,
}
and warp is by using
AssetId::from(storage.asset_id.read())
can work
1 Like
naz3eh
July 25, 2024, 8:38am
5
Hey @Clara , I am glad it worked for you. let me know if any more help is required
Clara
July 25, 2024, 1:30pm
6
Thanks @naz3eh
We don’t know when your grant will be reopened. Our full-chain game has been developed for more than a month and will be online in at most one month.
1 Like
naz3eh
July 26, 2024, 6:34am
7
you can apply for the grant by filling up this form
Clara
July 26, 2024, 8:18am
8
Thank you so much @naz3eh
1 Like
system
Closed
August 16, 2024, 4:19am
9
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.