2023-04-18 08:22:11 +00:00
|
|
|
|
namespace DistTestCore
|
|
|
|
|
{
|
|
|
|
|
public class Ether
|
|
|
|
|
{
|
|
|
|
|
public Ether(decimal wei)
|
|
|
|
|
{
|
|
|
|
|
Wei = wei;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public decimal Wei { get; }
|
2023-04-19 08:42:08 +00:00
|
|
|
|
|
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
|
{
|
|
|
|
|
return obj is Ether ether && Wei == ether.Wei;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return HashCode.Combine(Wei);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Wei} Wei";
|
|
|
|
|
}
|
2023-04-18 08:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TestToken
|
|
|
|
|
{
|
|
|
|
|
public TestToken(decimal amount)
|
|
|
|
|
{
|
|
|
|
|
Amount = amount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public decimal Amount { get; }
|
2023-04-19 07:57:37 +00:00
|
|
|
|
|
2023-04-19 08:42:08 +00:00
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
|
{
|
|
|
|
|
return obj is TestToken token && Amount == token.Amount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return HashCode.Combine(Amount);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-19 07:57:37 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Amount} TestTokens";
|
|
|
|
|
}
|
2023-04-18 08:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class TokensIntExtensions
|
|
|
|
|
{
|
|
|
|
|
private const decimal weiPerEth = 1000000000000000000;
|
|
|
|
|
|
|
|
|
|
public static TestToken TestTokens(this int i)
|
|
|
|
|
{
|
|
|
|
|
return TestTokens(Convert.ToDecimal(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TestToken TestTokens(this decimal i)
|
|
|
|
|
{
|
|
|
|
|
return new TestToken(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Ether Eth(this int i)
|
|
|
|
|
{
|
|
|
|
|
return Eth(Convert.ToDecimal(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Ether Wei(this int i)
|
|
|
|
|
{
|
|
|
|
|
return Wei(Convert.ToDecimal(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Ether Eth(this decimal i)
|
|
|
|
|
{
|
|
|
|
|
return new Ether(i * weiPerEth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Ether Wei(this decimal i)
|
|
|
|
|
{
|
|
|
|
|
return new Ether(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|