wallet-id.ts raw

   1  import { v4 as uuidv4 } from 'uuid';
   2  import { EntityId } from './entity-id';
   3  
   4  /**
   5   * Strongly-typed identifier for NWC wallet connection entities.
   6   */
   7  export class NwcConnectionId extends EntityId<'NwcConnectionId'> {
   8    private readonly _brand = 'NwcConnectionId' as const;
   9  
  10    private constructor(value: string) {
  11      super(value);
  12    }
  13  
  14    static generate(): NwcConnectionId {
  15      return new NwcConnectionId(uuidv4());
  16    }
  17  
  18    static from(value: string): NwcConnectionId {
  19      return new NwcConnectionId(value);
  20    }
  21  
  22    override equals(other: NwcConnectionId): boolean {
  23      return other instanceof NwcConnectionId && this._value === other._value;
  24    }
  25  }
  26  
  27  /**
  28   * Strongly-typed identifier for Cashu mint entities.
  29   */
  30  export class CashuMintId extends EntityId<'CashuMintId'> {
  31    private readonly _brand = 'CashuMintId' as const;
  32  
  33    private constructor(value: string) {
  34      super(value);
  35    }
  36  
  37    static generate(): CashuMintId {
  38      return new CashuMintId(uuidv4());
  39    }
  40  
  41    static from(value: string): CashuMintId {
  42      return new CashuMintId(value);
  43    }
  44  
  45    override equals(other: CashuMintId): boolean {
  46      return other instanceof CashuMintId && this._value === other._value;
  47    }
  48  }
  49