buildNamespacesFromAuth static method

Map<String, Namespace> buildNamespacesFromAuth({
  1. required Set<String> methods,
  2. required Set<String> accounts,
})

Implementation

static Map<String, Namespace> buildNamespacesFromAuth({
  required Set<String> methods,
  required Set<String> accounts,
}) {
  final parsedAccounts = accounts.map(
    (account) => account.replaceAll('did:pkh:', ''),
  );

  final namespaces = getNamespacesFromAccounts(parsedAccounts.toList());

  final entries = namespaces.entries.map((e) {
    return MapEntry(
      e.key,
      Namespace.fromJson(e.value.toJson()).copyWith(
        methods: methods.toList(),
        events: EventsConstants.allEvents,
      ),
    );
  });

  return Map<String, Namespace>.fromEntries(entries);
}