crossmintDedupeSigners function

Deduplicates a list of approval signers by locator, keeping the first occurrence of each. Used when composing a runtime wallet's primary + additional signers so the same signer can never appear twice.

Implementation

List<CrossmintWalletApprovalSigner> crossmintDedupeSigners(
  List<CrossmintWalletApprovalSigner> signers,
) {
  final Set<String> seen = <String>{};
  final List<CrossmintWalletApprovalSigner> deduped =
      <CrossmintWalletApprovalSigner>[];
  for (final CrossmintWalletApprovalSigner signer in signers) {
    if (seen.add(signer.locator)) {
      deduped.add(signer);
    }
  }
  return deduped;
}