getNamespacesMethodsForChainId function

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

Implementation

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

  return methods;
}