getPaymentAssetsForNetwork method
ℹ️ Get supported assets on the given chainId (CAIP-2) Null value will return all supported assets in all networks
Implementation
@override
List<ExchangeAsset> getPaymentAssetsForNetwork({
String? chainId,
bool includeNative = true,
bool includeTest = true,
}) {
final List<ExchangeAsset> assetList = [];
if (chainId == null) {
if (includeNative) {
assetList
..clear()
..addAll(allExchangeAssets);
} else {
final nonNatives = allExchangeAssets.where((e) => !e.isNative());
assetList
..clear()
..addAll(nonNatives);
}
} else {
if (!NamespaceUtils.isValidChainId(chainId)) {
throw Errors.getSdkError(
Errors.UNSUPPORTED_CHAINS,
context: 'chainId should conform to "CAIP-2" format',
).toSignError();
}
final matchingChain = allExchangeAssets.where(
(a) => a.network == chainId,
);
if (includeNative) {
assetList
..clear()
..addAll(matchingChain);
} else {
final matchingNonNatives = matchingChain.where((a) => !a.isNative());
assetList
..clear()
..addAll(matchingNonNatives);
}
}
if (!includeTest) {
assetList.removeWhere((a) {
final chainInfo = ReownAppKitModalNetworks.getNetworkInfo(
a.network,
a.network,
);
return chainInfo?.isTestNetwork == true;
});
}
return assetList;
}