XRPL Currency Models¶
The XRP Ledger has two kinds of money: XRP, and issued currencies. Both types have high precision, although their formats are different.
- class xrpl.models.currencies.IssuedCurrency(*args: List[Any], **kwargs: Dict[str, Any])¶
Bases:
xrpl.models.base_model.BaseModel
Specifies an amount in an issued currency, but without a value field. This format is used for some book order requests.
See https://xrpl.org/currency-formats.html#specifying-currency-amounts
- currency: str¶
This field is required.
- classmethod from_dict(value: Dict[str, Union[str, int, List[Any], Dict[str, Any]]]) xrpl.models.base_model.BaseModel ¶
Construct a new BaseModel from a dictionary of parameters.
- Parameters
value – The value to construct the BaseModel from.
- Returns
A new BaseModel object, constructed using the given parameters.
- Raises
XRPLModelException – If the dictionary provided is invalid.
- classmethod from_xrpl(value: Union[str, Dict[str, Any]]) xrpl.models.base_model.BaseModel ¶
Creates a BaseModel object based on a JSON-like dictionary of keys in the JSON format used by the binary codec, or an actual JSON string representing the same data.
- Parameters
value – The dictionary or JSON string to be instantiated.
- Returns
A BaseModel object instantiated from the input.
- classmethod is_dict_of_model(dictionary: Any) bool ¶
Checks whether the provided
dictionary
is a dictionary representation of this class.Note: This only checks the exact model, and does not count model inheritance. This method returns
False
if the dictionary represents a subclass of this class.- Parameters
dictionary – The dictionary to check.
- Returns
True if dictionary is a
dict
representation of an instance of this class; False if not.
- is_valid() bool ¶
Returns whether this BaseModel is valid.
- Returns
Whether this BaseModel is valid.
- issuer: str¶
This field is required.
- to_amount(value: Union[str, int, float]) xrpl.models.amounts.issued_currency_amount.IssuedCurrencyAmount ¶
Converts an IssuedCurrency to an IssuedCurrencyAmount.
- Parameters
value – The amount of issued currency in the IssuedCurrencyAmount.
- Returns
- An IssuedCurrencyAmount that represents the issued currency and the
provided value.
- to_dict() Dict[str, Any] ¶
Returns the dictionary representation of a BaseModel.
If not overridden, returns the object dict with all non-None values.
- Returns
The dictionary representation of a BaseModel.
- validate() None ¶
Raises if this object is invalid.
- Raises
XRPLModelException – if this object is invalid.
- class xrpl.models.currencies.XRP(*args: List[Any], **kwargs: Dict[str, Any])¶
Bases:
xrpl.models.base_model.BaseModel
Specifies XRP as a currency, without a value. Normally, you will not use this model as it does not specify an amount of XRP. In cases where you need to specify an amount of XRP, you will use a string. However, for some book order requests where currencies are specified without amounts, you may need to specify the use of XRP, without a value. In these cases, you will use this object.
See https://xrpl.org/currency-formats.html#specifying-currency-amounts
- currency: str = 'XRP'¶
- classmethod from_dict(value: Dict[str, Any]) xrpl.models.currencies.xrp.XRP ¶
Construct a new XRP from a dictionary of parameters.
- Parameters
value – The value to construct the XRP from.
- Returns
A new XRP object, constructed using the given parameters.
- Raises
XRPLModelException – If the dictionary provided is invalid.
- classmethod from_xrpl(value: Union[str, Dict[str, Any]]) xrpl.models.base_model.BaseModel ¶
Creates a BaseModel object based on a JSON-like dictionary of keys in the JSON format used by the binary codec, or an actual JSON string representing the same data.
- Parameters
value – The dictionary or JSON string to be instantiated.
- Returns
A BaseModel object instantiated from the input.
- classmethod is_dict_of_model(dictionary: Any) bool ¶
Checks whether the provided
dictionary
is a dictionary representation of this class.Note: This only checks the exact model, and does not count model inheritance. This method returns
False
if the dictionary represents a subclass of this class.- Parameters
dictionary – The dictionary to check.
- Returns
True if dictionary is a
dict
representation of an instance of this class; False if not.
- is_valid() bool ¶
Returns whether this BaseModel is valid.
- Returns
Whether this BaseModel is valid.
- to_amount(value: Union[str, int]) str ¶
Converts value to XRP.
- Parameters
value – The amount of XRP.
- Returns
A string representation of XRP amount.
- to_dict() Dict[str, Any] ¶
Returns the dictionary representation of an XRP currency object.
- Returns
The dictionary representation of an XRP currency object.
- validate() None ¶
Raises if this object is invalid.
- Raises
XRPLModelException – if this object is invalid.
- xrpl.models.currencies.Currency¶
The central part of internal API.
This represents a generic version of type ‘origin’ with type arguments ‘params’. There are two kind of these aliases: user defined and special. The special ones are wrappers around builtin collections and ABCs in collections.abc. These must have ‘name’ always set. If ‘inst’ is False, then the alias can’t be instantiated, this is used by e.g. typing.List and typing.Dict.
alias of
Union
[xrpl.models.currencies.issued_currency.IssuedCurrency
,xrpl.models.currencies.xrp.XRP
]