getOptionalMethodsForChainId static method

List<String> getOptionalMethodsForChainId({
  1. required String chainId,
  2. required Map<String, RequiredNamespace> optionalNamespaces,
})

Gets the optional methods from a namespace map for the given chain

Implementation

static List<String> getOptionalMethodsForChainId({
  required String chainId,
  required Map<String, RequiredNamespace> optionalNamespaces,
}) {
  List<String> methods = [];
  optionalNamespaces.forEach((String nsOrChain, RequiredNamespace rns) {
    if (nsOrChain == chainId) {
      methods.addAll(rns.methods);
    } else {
      if ((rns.chains ?? []).contains('$nsOrChain:$chainId')) {
        methods.addAll(rns.methods);
      }
    }
  });

  return methods;
}