terra_sdk.core.coins
Coins Objects
_1class Coins(JSONSerializable, List[Coin_pb])
Represents an unordered collection of :class:Coin objects
-- analagous to sdk.Coins and sdk.DecCoins in Cosmos SDK. If one of the
input coins would be Dec-amount type coin, the resultant Coins is converted to
Dec-amount coins.
Arguments:
argOptional[Coins.Input], optional - argument to convert. Defaults to{}.
Raises:
TypeError- ifargis not an Iterable
Input
Types which can be converted into a :class:Coins object.
from_str
_2@classmethod_2def from_str(cls, s: str) -> Coins
Converts a comma-separated list of Coin-format strings to :class:Coins.
>>> Coins.from_str('1000uluna,1234ukrw') Coins("1000uluna,1234ukrw")
Arguments:
sstr - string to convert
__init__
_1def __init__(arg: Optional[Coins.Input] = {}, **denoms)
Converts the argument into a :class:Coins object.
get
_1def get(denom: str) -> Optional[Coin]
Get the Coin with the denom contained in the Coins set.
Arguments:
denomstr - denom
Returns:
Optional[Coin]- result (can beNone)
from_data
_2@classmethod_2def from_data(cls, data: list) -> Coins
Converts list of Coin-data objects to :class:Coins.
Arguments:
datalist - list of Coin-data objects
from_amino
_2@classmethod_2def from_amino(cls, amino: list) -> Coins
Converts list of Coin-amino objects to :class:Coins.
Arguments:
aminolist - list of Coin-data objects
from_proto
_2@classmethod_2def from_proto(cls, proto: List[Coin_pb]) -> Coins
Converts list of Coin-data objects to :class:Coins.
Arguments:
datalist - list of Coin-data objects
denoms
_1def denoms() -> List[str]
Get the list of denoms for all Coin objects contained.
to_dec_coins
_1def to_dec_coins() -> Coins
Creates new set of :class:Coins that have :classDec amounts.
to_int_coins
_1def to_int_coins() -> Coins
Creates new set of :class:Coins that have int amounts.
to_int_ceil_coins
_1def to_int_ceil_coins() -> Coins
Creates a new :class:Coins object with all int coins with ceiling the amount
add
_1def add(addend: Union[Coin, Coins]) -> Coins
Performs addition, which combines the sets of Coin objects. Coins of similar denoms will be merged into one Coin representing the denom.
Arguments:
addendUnion[Coin, Coins] - addend
sub
_1def sub(subtrahend: Union[Coin, Coins]) -> Coins
Performs subtraction, which combines the sets of Coin objects. Coins of similar denoms will be merged into one Coin representing the denom.
Arguments:
subtrahendUnion[Coin, Coins] - subtrahend
mul
_1def mul(multiplier: Numeric.Input) -> Coins
Performs multiplicaiton, which multiplies all the Coin objects in the set by a multiplier.
Arguments:
multiplierNumeric.Input - multiplier
div
_1def div(divisor: Numeric.Input) -> Coins
Performs division, which divides all the Coin objects in the set by a divisor.
Arguments:
divisorNumeric.Input - divisor
to_list
_1def to_list() -> List[Coin]
Converts the set of :class:Coin objects contained into a sorted list by denom.
Returns:
List[Coin]- list, sorted by denom
filter
_1def filter(predicate: Callable[[Coin], bool]) -> Coins
Creates a new :class:Coins collection which filters out all Coin objects that
do not meet the predicate.
Arguments:
predicateCallable[[Coin], bool] - predicate for filtering
map
_1def map(fn: Callable[[Coin], Any]) -> Iterator[Any]
Creates an iterable which applies the function to all coins in the set, ordered by denomination.
Arguments:
fnCallable[[Coin], Any] - function to apply
Returns:
Iterator[Any]- coin map
Yields:
Iterator[Any]- coin map