/ Framework / Utils / EthAccount.cs
EthAccount.cs
 1  namespace Utils
 2  {
 3      [Serializable]
 4      public class EthAccount : IComparable<EthAccount>
 5      {
 6          public EthAccount(EthAddress ethAddress, string privateKey)
 7          {
 8              EthAddress = ethAddress;
 9              PrivateKey = privateKey;
10          }
11  
12          public EthAddress EthAddress { get; }
13          public string PrivateKey { get; }
14  
15          public int CompareTo(EthAccount? other)
16          {
17              return PrivateKey.CompareTo(other!.PrivateKey);
18          }
19  
20          public override bool Equals(object? obj)
21          {
22              return obj is EthAccount token && PrivateKey == token.PrivateKey;
23          }
24  
25          public override int GetHashCode()
26          {
27              return HashCode.Combine(PrivateKey);
28          }
29  
30          public override string ToString()
31          {
32              return EthAddress.ToString();
33          }
34  
35          public static bool operator ==(EthAccount? a, EthAccount? b)
36          {
37              if (ReferenceEquals(a, b)) return true;
38              if (ReferenceEquals(a, null)) return false;
39              if (ReferenceEquals(b, null)) return false;
40              return a.PrivateKey == b.PrivateKey;
41          }
42  
43          public static bool operator !=(EthAccount? a, EthAccount? b)
44          {
45              return !(a == b);
46          }
47      }
48  }