-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.0 - Major update - return instances instead of dicts
**Data classes / objects** As many of us know, it gets tiring having to constantly type `x['balance']` when something returns a dictionary, especially when there's no IDE completion for it. To solve this problem, new classes have been written to represent SteemEngine objects, such as balances, transactions, and tokens. This allows you to access keys simply through `x.balance` instead. For backwards compatibility, the `ObjBase` parent class allows instances of these data classes to be treated like dictionaries/lists, so `x['balance']` will still work, and it will return the same format as before, while `x.balance` for example, would return the balance as a proper `Decimal` object. You can also convert the classes into dicts/lists with `dict(x)` and `list(x)`, but be aware that this uses the `raw_data` that was originally passed, so these converted objects will not have their keys casted to the appropriate Python types, unless they were casted before being passed into the class. - New module `privex.steemengine.objects` for classes designed to hold data - `ObjBase` is used as the base class for the data classes. For backwards compatibility, it allows instances of the classes to be accessed like a dictionary/list, offers `from_list` for easy conversions of `list<dict>` into their respective data classes, and also implements `__iter__` so instances can be converted using `dict(x)` and `list(x)`. - `Token` represents the data of a SteemEngine token such as name/symbol/supply - `SEBalance` represents a balance with account/symbol/balance - `SETransaction` represents a history tx with txid/timestamp/quantity etc. - `TokenMetadata` represents the `metadata` field of token data **Upgraded SteemEngineToken to use the data classes** The **SteemEngineToken** class has been updated to use the new data classes. Thanks to `ObjBase`, this should hopefully not break any existing applications, but there's always a risk. The methods that have been updated: - `list_tokens` now returns `List[Token]` instead of `List[dict]` - `get_token` now returns `Token` instead of `dict` - `get_token_balances` now returns `List[SEBalance]` instead of `List[dict]` - `list_transactions` now returns `List[SETransaction]` instead of `List[dict]` **Documentation for the new data classes** The documentation has been updated with details on how the data classes work. The documentation for **SteemEngineToken** methods have *mostly* been updated to show usage of the new data classes instead of `dict`s.
- Loading branch information
1 parent
f03efc2
commit e0cd844
Showing
12 changed files
with
326 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Data Objects (Token/SEBalance etc.) | ||
==================================== | ||
|
||
.. automodule:: privex.steemengine.objects | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
.. rubric:: Classes | ||
|
||
.. autosummary:: | ||
:toctree: stubs | ||
|
||
ObjBase | ||
SEBalance | ||
SETransaction | ||
Token | ||
TokenMetadata | ||
|
||
|
||
|
||
|
||
|
||
|
23 changes: 23 additions & 0 deletions
23
docs/source/code/stubs/privex.steemengine.objects.ObjBase.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
objects.ObjBase | ||
================================== | ||
|
||
.. currentmodule:: privex.steemengine.objects | ||
|
||
.. autoclass:: ObjBase | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~ObjBase.__init__ | ||
~ObjBase.from_list | ||
|
||
|
||
|
||
|
||
|
||
|
23 changes: 23 additions & 0 deletions
23
docs/source/code/stubs/privex.steemengine.objects.SEBalance.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
objects.SEBalance | ||
==================================== | ||
|
||
.. currentmodule:: privex.steemengine.objects | ||
|
||
.. autoclass:: SEBalance | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~SEBalance.__init__ | ||
~SEBalance.from_list | ||
|
||
|
||
|
||
|
||
|
||
|
23 changes: 23 additions & 0 deletions
23
docs/source/code/stubs/privex.steemengine.objects.SETransaction.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
objects.SETransaction | ||
======================================== | ||
|
||
.. currentmodule:: privex.steemengine.objects | ||
|
||
.. autoclass:: SETransaction | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~SETransaction.__init__ | ||
~SETransaction.from_list | ||
|
||
|
||
|
||
|
||
|
||
|
23 changes: 23 additions & 0 deletions
23
docs/source/code/stubs/privex.steemengine.objects.Token.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
objects.Token | ||
================================ | ||
|
||
.. currentmodule:: privex.steemengine.objects | ||
|
||
.. autoclass:: Token | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~Token.__init__ | ||
~Token.from_list | ||
|
||
|
||
|
||
|
||
|
||
|
23 changes: 23 additions & 0 deletions
23
docs/source/code/stubs/privex.steemengine.objects.TokenMetadata.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
objects.TokenMetadata | ||
======================================== | ||
|
||
.. currentmodule:: privex.steemengine.objects | ||
|
||
.. autoclass:: TokenMetadata | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~TokenMetadata.__init__ | ||
~TokenMetadata.from_list | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.