isValidNamespacesChainId static method
Validates the provided chainId, then ensures that the chainId is contained in the namespaces
Implementation
static bool isValidNamespacesChainId({
required Map<String, Namespace> namespaces,
required String chainId,
}) {
// Validate the chainId
if (!NamespaceUtils.isValidChainId(chainId)) {
throw Errors.getSdkError(
Errors.UNSUPPORTED_CHAINS,
context: 'chain $chainId should conform to "CAIP-2" format',
).toSignError();
}
// Validate the namespaces
isValidNamespaces(
namespaces: namespaces,
context: 'isValidNamespacesChainId',
);
// Get the chains from the namespaces and
List<String> chains = NamespaceUtils.getChainIdsFromNamespaces(
namespaces: namespaces,
);
if (!chains.contains(chainId)) {
throw Errors.getSdkError(
Errors.UNSUPPORTED_CHAINS,
context: 'The chain $chainId is not supported',
).toSignError();
}
return true;
}