getNamespacesEventsForChainId function

List<String> getNamespacesEventsForChainId(
  1. SessionNamespaces namespaces,
  2. String chainId
)

Implementation

List<String> getNamespacesEventsForChainId(
  SessionNamespaces namespaces,
  String chainId,
) {
  final List<String> events = [];
  namespaces.values.forEach((namespace) {
    final chains = getAccountsChains(namespace.accounts);
    if (chains.contains(chainId)) events.addAll(namespace.events);
    if (namespace.extension != null) {
      namespace.extension!.forEach((extension) {
        final extensionChains = getAccountsChains(extension.accounts);
        if (extensionChains.contains(chainId)) events.addAll(extension.events);
      });
    }
  });

  return events;
}