From f0d6271a03748215d668ec5909776fb442a9a483 Mon Sep 17 00:00:00 2001 From: Geoff Lee Date: Sun, 7 Nov 2021 17:19:01 +0900 Subject: [PATCH] rename strings to bech32 --- docs/common/bech32.rst | 60 ++++++++++++++++++++++ docs/common/strings.rst | 65 ------------------------ docs/core_modules/distribution.rst | 5 +- docs/index.rst | 2 +- terra_sdk/core/__init__.py | 3 +- terra_sdk/core/{strings.py => bech32.py} | 3 +- terra_sdk/core/fee.py | 2 +- tests/core/strings_test.py | 2 +- 8 files changed, 68 insertions(+), 74 deletions(-) create mode 100644 docs/common/bech32.rst delete mode 100644 docs/common/strings.rst rename terra_sdk/core/{strings.py => bech32.py} (99%) diff --git a/docs/common/bech32.rst b/docs/common/bech32.rst new file mode 100644 index 00000000..b3893485 --- /dev/null +++ b/docs/common/bech32.rst @@ -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 + diff --git a/docs/common/strings.rst b/docs/common/strings.rst deleted file mode 100644 index 326ee1b8..00000000 --- a/docs/common/strings.rst +++ /dev/null @@ -1,65 +0,0 @@ -.. strings: - -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.strings.AccAddress - :members: - -.. autofunction:: terra_sdk.core.strings.is_acc_address - -.. autofunction:: terra_sdk.core.strings.to_acc_address - -ValAddress -^^^^^^^^^^ - -.. autoclass:: terra_sdk.core.strings.ValAddress - :members: - -.. autofunction:: terra_sdk.core.strings.is_val_address - -.. autofunction:: terra_sdk.core.strings.to_val_address - - - -PubKeys -------- - -AccPubKey -^^^^^^^^^ - -.. autoclass:: terra_sdk.core.strings.AccPubKey - :members: - -.. autofunction:: terra_sdk.core.strings.is_acc_pubkey - -.. autofunction:: terra_sdk.core.strings.to_acc_pubkey - -ValPubKey -^^^^^^^^^ - -.. autoclass:: terra_sdk.core.strings.ValPubKey - :members: - -.. autofunction:: terra_sdk.core.strings.is_acc_pubkey - -.. autofunction:: terra_sdk.core.strings.to_acc_pubkey - -ValConsPubKey -^^^^^^^^^^^^^ - -.. autoclass:: terra_sdk.core.strings.ValConsPubKey - :members: \ No newline at end of file diff --git a/docs/core_modules/distribution.rst b/docs/core_modules/distribution.rst index e4b96584..8a480ed6 100644 --- a/docs/core_modules/distribution.rst +++ b/docs/core_modules/distribution.rst @@ -13,9 +13,6 @@ Data .. autoclass:: terra_sdk.client.lcd.api.distribution.Rewards :members: -.. autoclass:: terra_sdk.client.lcd.api.distribution.ValidatorRewards - :members: - Messages -------- @@ -26,4 +23,4 @@ Proposals --------- .. automodule:: terra_sdk.core.distribution.proposals - :members: \ No newline at end of file + :members: diff --git a/docs/index.rst b/docs/index.rst index 3abd97b5..968172e0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -41,7 +41,7 @@ Unfamiliar with Terra? → `Check out Terra Docs `_ :maxdepth: 1 :caption: SDK Reference - common/strings + common/bech32 common/numeric common/coin_coins guides/lcdclient diff --git a/terra_sdk/core/__init__.py b/terra_sdk/core/__init__.py index 93055a65..eaf9ad43 100644 --- a/terra_sdk/core/__init__.py +++ b/terra_sdk/core/__init__.py @@ -7,6 +7,7 @@ "AccAddress", "AccPubKey", "ValAddress", + "SimplePublicKey", "ValConsPubKey", "ValPubKey", "SignDoc", @@ -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 diff --git a/terra_sdk/core/strings.py b/terra_sdk/core/bech32.py similarity index 99% rename from terra_sdk/core/strings.py rename to terra_sdk/core/bech32.py index f8630fb5..6ba3489d 100644 --- a/terra_sdk/core/strings.py +++ b/terra_sdk/core/bech32.py @@ -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", diff --git a/terra_sdk/core/fee.py b/terra_sdk/core/fee.py index e2817830..9a5d687c 100644 --- a/terra_sdk/core/fee.py +++ b/terra_sdk/core/fee.py @@ -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 diff --git a/tests/core/strings_test.py b/tests/core/strings_test.py index 50fbdb69..81f28b6e 100644 --- a/tests/core/strings_test.py +++ b/tests/core/strings_test.py @@ -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,