49 lines
1.2 KiB
C#
Raw Normal View History

2025-01-16 11:31:50 +01:00
namespace Utils
{
[Serializable]
2025-05-29 16:37:20 +02:00
public class EthAccount : IComparable<EthAccount>
2025-01-16 11:31:50 +01:00
{
public EthAccount(EthAddress ethAddress, string privateKey)
{
EthAddress = ethAddress;
PrivateKey = privateKey;
}
public EthAddress EthAddress { get; }
public string PrivateKey { get; }
2025-05-29 16:37:20 +02:00
public int CompareTo(EthAccount? other)
{
return PrivateKey.CompareTo(other!.PrivateKey);
}
public override bool Equals(object? obj)
{
return obj is EthAccount token && PrivateKey == token.PrivateKey;
}
public override int GetHashCode()
{
return HashCode.Combine(PrivateKey);
}
2025-01-16 11:31:50 +01:00
public override string ToString()
{
return EthAddress.ToString();
}
2025-05-29 16:37:20 +02:00
public static bool operator ==(EthAccount? a, EthAccount? b)
2025-05-29 16:37:20 +02:00
{
if (ReferenceEquals(a, b)) return true;
if (ReferenceEquals(a, null)) return false;
if (ReferenceEquals(b, null)) return false;
2025-05-29 16:37:20 +02:00
return a.PrivateKey == b.PrivateKey;
}
public static bool operator !=(EthAccount? a, EthAccount? b)
2025-05-29 16:37:20 +02:00
{
return !(a == b);
2025-05-29 16:37:20 +02:00
}
2025-01-16 11:31:50 +01:00
}
}