Enable creating `AssetId`s from `ContactId`s and `SubId`s
Opened this issue · 0 comments
bitzoic commented
Currently there is no way to get an AssetId
if you have a ContractId
and a SubId
. This means if you mint an asset from a contract, you do not know the AssetId
of what you just minted. Something similar to this needs to be added to the rust SDK:
pub fn get_asset_id(sub_id: Bytes32, contract: ContractId) -> AssetId {
let mut hasher = Sha256::new();
hasher.update(*contract);
hasher.update(*sub_id);
AssetId::new(*Bytes32::from(<[u8; 32]>::from(hasher.finalize())))
}
Documentation on this should also be included in the AssetId section of the book