示例#1
0
 def from_data(cls, data: dict) -> MsgAggregateExchangeRateVote:
     data = data["value"]
     return cls(
         exchange_rates=Coins.from_str(data["exchange_rates"]),
         salt=data["salt"],
         feeder=data["feeder"],
         validator=data["validator"],
     )
示例#2
0
def test_from_str():
    int_coins_string = "5ukrw,12uluna"
    dec_coins_string = "2.3ukrw,1.45uluna"
    neg_dec_coins_string = "-1.0ukrw,2.5uluna"

    int_coins = Coins(ukrw=5, uluna="12")
    dec_coins = Coins(
        ukrw=2.3,
        uluna="1.45",
    )

    neg_dec_coins = Coins(
        ukrw="-1.0",
        uluna=2.5,
    )

    assert Coins.from_str(int_coins_string) == int_coins
    assert Coins.from_str(dec_coins_string) == dec_coins
    assert Coins.from_str(neg_dec_coins_string) == neg_dec_coins