@polkadot/types/interfaces#AssetMetadata TypeScript Examples
The following examples show how to use
@polkadot/types/interfaces#AssetMetadata.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useAssetInfos.ts From crust-apps with Apache License 2.0 | 6 votes |
function extractInfo (allAccounts: string[], id: AssetId, optDetails: Option<AssetDetails>, metadata: AssetMetadata): AssetInfo {
const details = optDetails.unwrapOr(null);
return {
...(details
? {
isAdminMe: isAccount(allAccounts, details.admin),
isFreezerMe: isAccount(allAccounts, details.freezer),
isIssuerMe: isAccount(allAccounts, details.issuer),
isOwnerMe: isAccount(allAccounts, details.owner)
}
: EMPTY_FLAGS
),
details,
id,
key: id.toString(),
metadata: metadata.isEmpty
? null
: metadata
};
}
Example #2
Source File: useAssetInfos.ts From crust-apps with Apache License 2.0 | 6 votes |
export default function useAssetInfos (ids?: AssetId[]): AssetInfo[] | undefined {
const { api } = useApi();
const { allAccounts } = useAccounts();
const allMetadata = useCall<AssetMetadata[]>(api.query.assets.metadata.multi, [ids]);
const allDetails = useCall<Option<AssetDetails>[]>(api.query.assets.asset.multi, [ids]);
return useMemo(
() => allDetails && allMetadata && ids && (allDetails.length === ids.length) && (allMetadata.length === ids.length)
? ids.map((id, index) => extractInfo(allAccounts, id, allDetails[index], allMetadata[index]))
: undefined,
[allAccounts, allDetails, allMetadata, ids]
);
}