getNamespacesMethodsForChainId static method

List<String> getNamespacesMethodsForChainId({
  1. required String chainId,
  2. required Map<String, Namespace> namespaces,
})

Gets the methods from a namespace map for the given chain

Implementation

static List<String> getNamespacesMethodsForChainId({
  required String chainId,
  required Map<String, Namespace> namespaces,
}) {
  List<String> methods = [];
  namespaces.forEach((String nsOrChain, Namespace namespace) {
    if (nsOrChain == chainId) {
      methods.addAll(namespace.methods);
    } else {
      List<String> chains = getChainsFromAccounts(namespace.accounts);
      if (chains.contains(chainId)) {
        methods.addAll(namespace.methods);
      }
    }
  });

  return methods;
}