getApprovedMethods method

List<String>? getApprovedMethods({
  1. String? namespace,
})

Implementation

List<String>? getApprovedMethods({String? namespace}) {
  final methodsList = <String>[];

  if (sessionService.noSession) {
    return null;
  }
  if (sessionService.isCoinbase) {
    return GetIt.I<ICoinbaseService>().supportedMethods;
  }
  if (sessionService.isMagic) {
    final ns = namespace ?? NetworkUtils.eip155;
    return GetIt.I<IMagicService>().supportedMethods[ns];
  }

  final sessionNamespaces = _sessionData!.namespaces;
  if ((namespace ?? '').isEmpty) {
    for (var namespace in sessionNamespaces.keys) {
      final events = sessionNamespaces[namespace]?.methods ?? [];
      methodsList.addAll(events);
    }

    return methodsList;
  }

  return sessionNamespaces[namespace]?.methods ?? [];
}