Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace structures with methods in the Python API #115

Open
appetrosyan opened this issue Aug 5, 2022 · 0 comments
Open

Replace structures with methods in the Python API #115

appetrosyan opened this issue Aug 5, 2022 · 0 comments
Labels
enhancement iroha2 Pull requests and issues associated with iroha 2

Comments

@appetrosyan
Copy link
Contributor

appetrosyan commented Aug 5, 2022

The current approach of creating lots of objects is not very pythonic. It would be preferable, if instead we had a way of using dick-typing and methods + keyword arguments to set things up.

Example

As of today our example contains the following:

asset_definition = asset.Definition(
    "pyasset#python",
    asset.ValueType.Quantity(),
    asset.Mintable.Infinitely(),
)

In reality what we should have

asset_definition = asset.definition("pyasset#python", value_type = "q", mintable=True)

Where the method handles the conversion of the shorthand notation of "q" into Quantity, mintable=True into Mintable.Infinitely and not specifying them creates an asset with sensible defaults (which are Quantity and Mintable.Infinitely).

We can also treat the rust FromStr methods to do the conversion in place.

@appetrosyan appetrosyan added enhancement iroha2 Pull requests and issues associated with iroha 2 labels Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement iroha2 Pull requests and issues associated with iroha 2
Projects
None yet
Development

No branches or pull requests

1 participant