Skip to content

Commit

Permalink
rename strings to bech32
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Lee committed Nov 7, 2021
1 parent bbdd047 commit f0d6271
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 74 deletions.
60 changes: 60 additions & 0 deletions docs/common/bech32.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. bech32:
Bech32 Strings
==============

To provide some clarity for arguments, some functions in the SDK are documented that
they take a type like :class:`AccAddress` where one may expect a ``str``. It is simply a
type alias annotation (equivalent to ``str``) that serves only to remind the developer
which format the string is expected to be in.

Terra SDK also provides useful functions for checking and converting **addresses** and **pubkeys**.

Addresses
---------

AccAddress
^^^^^^^^^^

.. autoclass:: terra_sdk.core.bech32.AccAddress
:members:

.. autofunction:: terra_sdk.core.bech32.is_acc_address

.. autofunction:: terra_sdk.core.bech32.to_acc_address

ValAddress
^^^^^^^^^^

.. autoclass:: terra_sdk.core.bech32.ValAddress
:members:

.. autofunction:: terra_sdk.core.bech32.is_val_address

.. autofunction:: terra_sdk.core.bech32.to_val_address



PubKeys
-------

AccPubKey
^^^^^^^^^

.. autoclass:: terra_sdk.core.bech32.AccPubKey
:members:

.. autofunction:: terra_sdk.core.bech32.is_acc_pubkey

.. autofunction:: terra_sdk.core.bech32.to_acc_pubkey

ValPubKey
^^^^^^^^^

.. autoclass:: terra_sdk.core.bech32.ValPubKey
:members:

.. autofunction:: terra_sdk.core.bech32.is_acc_pubkey

.. autofunction:: terra_sdk.core.bech32.to_acc_pubkey

65 changes: 0 additions & 65 deletions docs/common/strings.rst

This file was deleted.

5 changes: 1 addition & 4 deletions docs/core_modules/distribution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ Data
.. autoclass:: terra_sdk.client.lcd.api.distribution.Rewards
:members:

.. autoclass:: terra_sdk.client.lcd.api.distribution.ValidatorRewards
:members:

Messages
--------

Expand All @@ -26,4 +23,4 @@ Proposals
---------

.. automodule:: terra_sdk.core.distribution.proposals
:members:
:members:
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Unfamiliar with Terra? → `Check out Terra Docs <https://docs.terra.money>`_
:maxdepth: 1
:caption: SDK Reference

common/strings
common/bech32
common/numeric
common/coin_coins
guides/lcdclient
Expand Down
3 changes: 2 additions & 1 deletion terra_sdk/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"AccAddress",
"AccPubKey",
"ValAddress",
"SimplePublicKey",
"ValConsPubKey",
"ValPubKey",
"SignDoc",
Expand All @@ -19,4 +20,4 @@
from .public_key import PublicKey, SimplePublicKey, ValConsPubKey
from .sign_doc import SignDoc
from .signature_v2 import SignatureV2
from .strings import AccAddress, AccPubKey, ValAddress, ValPubKey
from .bech32 import AccAddress, AccPubKey, ValAddress, ValPubKey
3 changes: 2 additions & 1 deletion terra_sdk/core/strings.py → terra_sdk/core/bech32.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

from bech32 import bech32_decode, bech32_encode

from .public_key import ValConsPubKey

__all__ = [
"AccAddress",
"ValAddress",
"AccPubKey",
"ValPubKey",
"ValConsPubKey",
"is_acc_address",
"is_acc_pubkey",
"is_val_address",
Expand Down
2 changes: 1 addition & 1 deletion terra_sdk/core/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import attr
from terra_proto.cosmos.tx.v1beta1 import Fee as Fee_pb

from terra_sdk.core.strings import AccAddress
from terra_sdk.core.bech32 import AccAddress
from terra_sdk.core.coins import Coins
from terra_sdk.util.json import JSONSerializable

Expand Down
2 changes: 1 addition & 1 deletion tests/core/strings_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from terra_sdk.core.strings import (
from terra_sdk.core.bech32 import (
is_acc_address,
is_acc_pubkey,
is_val_address,
Expand Down

0 comments on commit f0d6271

Please sign in to comment.