diff --git a/integration_tests/send_async.py b/integration_tests/send_async.py new file mode 100644 index 00000000..5153adbf --- /dev/null +++ b/integration_tests/send_async.py @@ -0,0 +1,42 @@ +import asyncio +import base64 +from pathlib import Path + +from terra_sdk.client.lcd import LCDClient +from terra_sdk.client.lcd.api.tx import CreateTxOptions +from terra_sdk.core import Coins +from terra_sdk.core.bank import MsgSend +from terra_sdk.core.tx import SignMode +from terra_sdk.key.mnemonic import MnemonicKey + + +def main(): + terra = LCDClient( + url="http://localhost:1317/", + chain_id="localterra", + ) + key = MnemonicKey( + mnemonic="notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius" + ) + test1 = terra.wallet(key=key) + + msg = MsgSend( + "terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v", + "terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp", + Coins(uluna=20000), + ) + print(msg) + tx = test1.create_and_sign_tx( + CreateTxOptions( + msgs=[msg], + gas_prices="0.15uluna", + gas="63199", # gas="auto", gas_adjustment=1.1 + ) + ) + print(tx) + + result = terra.tx.broadcast_async(tx) + print(result) + + +main() diff --git a/integration_tests/send_sync.py b/integration_tests/send_sync.py new file mode 100644 index 00000000..f3069260 --- /dev/null +++ b/integration_tests/send_sync.py @@ -0,0 +1,42 @@ +import asyncio +import base64 +from pathlib import Path + +from terra_sdk.client.lcd import LCDClient +from terra_sdk.client.lcd.api.tx import CreateTxOptions +from terra_sdk.core import Coins +from terra_sdk.core.bank import MsgSend +from terra_sdk.core.tx import SignMode +from terra_sdk.key.mnemonic import MnemonicKey + + +def main(): + terra = LCDClient( + url="http://localhost:1317/", + chain_id="localterra", + ) + key = MnemonicKey( + mnemonic="notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius" + ) + test1 = terra.wallet(key=key) + + msg = MsgSend( + "terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v", + "terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp", + Coins(uluna=20000), + ) + print(msg) + tx = test1.create_and_sign_tx( + CreateTxOptions( + msgs=[msg], + gas_prices="0.15uluna", + gas="63199", # gas="auto", gas_adjustment=1.1 + ) + ) + print(tx) + + result = terra.tx.broadcast_sync(tx) + print(result) + + +main() diff --git a/integration_tests/tx_distribution.py b/integration_tests/tx_distribution.py index d8b2c00d..86835011 100644 --- a/integration_tests/tx_distribution.py +++ b/integration_tests/tx_distribution.py @@ -4,7 +4,7 @@ from terra_sdk.core.distribution import ( MsgFundCommunityPool, MsgSetWithdrawAddress, - MsgWithdrawDelegationReward, + MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, ) @@ -25,7 +25,7 @@ def main(): msgWCom = MsgWithdrawValidatorCommission( validator_address="terravaloper1dcegyrekltswvyy0xy69ydgxn9x8x32zdy3ua5" ) - msgWDel = MsgWithdrawDelegationReward( + msgWDel = MsgWithdrawDelegatorReward( delegator_address="terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v", validator_address="terravaloper1dcegyrekltswvyy0xy69ydgxn9x8x32zdy3ua5", ) diff --git a/mypy.ini b/mypy.ini index 121f3c5c..8a0f993d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,4 +1,49 @@ [mypy] +# Specify the target platform details in config, so your developers are +# free to run mypy on Windows, Linux, or macOS and get consistent +# results. +python_version=3.9 +platform=linux + +# flake8-mypy expects the two following for sensible formatting +show_column_numbers=True +show_error_context=False + +# do not follow imports (except for ones found in typeshed) +follow_imports=skip + +# since we're ignoring imports, writing .mypy_cache doesn't make any sense +cache_dir=/dev/null + +# suppress errors about unsatisfied imports +ignore_missing_imports=True + +# allow untyped calls as a consequence of the options above +disallow_untyped_calls=False + +# allow returning Any as a consequence of the options above +warn_return_any=False + +# treat Optional per PEP 484 +strict_optional=True + +# ensure all execution paths are returning +warn_no_return=True + +# lint-style cleanliness for typing needs to be disabled; returns more errors +# than the full run. +warn_redundant_casts=False +warn_unused_ignores=False + +# The following are off by default since they're too noisy. +# Flip them on if you feel adventurous. +disallow_untyped_defs=False +check_untyped_defs=False + +files = terra_sdk +show_error_codes = True +pretty = True + [mypy-ecdsa.*] ignore_missing_imports=True @@ -13,4 +58,7 @@ ignore_missing_imports=True ignore_missing_imports=True [mypy-nest_asyncio] -ignore_missing_imports=True \ No newline at end of file +ignore_missing_imports=True + +[mypy-terra_proto] +ignore_missing_imports=True diff --git a/pyproject.toml b/pyproject.toml index df645660..21f4eac8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ license = "MIT" packages = [{ include = "terra_sdk" }] readme = "README.md" repository = "https://github.com/terra-money/terra.py" -version = "2.0.4" +version = "2.0.5" [tool.poetry.dependencies] aiohttp = "^3.8.1" diff --git a/terra_sdk/client/lcd/api/tx.py b/terra_sdk/client/lcd/api/tx.py index f957500e..136137c0 100644 --- a/terra_sdk/client/lcd/api/tx.py +++ b/terra_sdk/client/lcd/api/tx.py @@ -276,6 +276,7 @@ async def broadcast_sync( SyncTxBroadcastResult: result """ res = await self._broadcast(tx, "BROADCAST_MODE_SYNC", options) + res = res.get("tx_response") return SyncTxBroadcastResult( txhash=res.get("txhash"), raw_log=res.get("raw_log"), @@ -296,6 +297,7 @@ async def broadcast_async( AsyncTxBroadcastResult: result """ res = await self._broadcast(tx, "BROADCAST_MODE_ASYNC", options) + res = res.get("tx_response") return AsyncTxBroadcastResult( txhash=res.get("txhash"), ) diff --git a/terra_sdk/core/authz/data.py b/terra_sdk/core/authz/data.py index 80082608..59bc7ca3 100644 --- a/terra_sdk/core/authz/data.py +++ b/terra_sdk/core/authz/data.py @@ -19,6 +19,7 @@ from terra_proto.cosmos.staking.v1beta1 import ( StakeAuthorizationValidators as StakeAuthorizationValidators_pb, ) +from betterproto.lib.google.protobuf import Any as Any_pb from terra_sdk.core import AccAddress, Coin, Coins from terra_sdk.util.base import BaseTerraData @@ -37,12 +38,24 @@ class Authorization(BaseTerraData): """Base class for authorization types.""" + @staticmethod + def from_amino(amino: dict) -> Authorization: + from terra_sdk.util.parse_authorization import parse_authorization_amino + + return parse_authorization_amino(amino) + @staticmethod def from_data(data: dict) -> Authorization: from terra_sdk.util.parse_authorization import parse_authorization return parse_authorization(data) + @staticmethod + def from_proto(proto: Any_pb) -> Authorization: + from terra_sdk.util.parse_authorization import parse_authorization_proto + + return parse_authorization_proto(proto) + @attr.s class SendAuthorization(Authorization): @@ -75,6 +88,16 @@ def from_data(cls, data: dict) -> SendAuthorization: def to_proto(self) -> SendAuthorization_pb: return SendAuthorization_pb(spend_limit=self.spend_limit.to_proto()) + @classmethod + def from_proto(cls, proto: SendAuthorization_pb) -> SendAuthorization: + return cls(spend_limit=Coins.from_proto(proto.spend_limit)) + + @classmethod + def from_amino(cls, amino: dict) -> SendAuthorization: + value = amino["value"] + return cls(spend_limit=Coins.from_amino(value["spend_limit"])) + + @attr.s class GenericAuthorization(Authorization): @@ -102,6 +125,15 @@ def from_data(cls, data: dict) -> GenericAuthorization: def to_proto(self) -> GenericAuthorization_pb: return GenericAuthorization_pb(msg=self.msg) + @classmethod + def from_proto(cls, proto: GenericAuthorization_pb) -> GenericAuthorization: + return cls(msg=proto.msg) + + @classmethod + def from_amino(cls, amino: dict) -> SendAuthorization: + value = amino["value"] + return cls(msg=value["msg"]) + @attr.s class AuthorizationGrant(JSONSerializable): @@ -138,6 +170,21 @@ def to_proto(self) -> Grant_pb: expiration=self.expiration, ) + @classmethod + def from_proto(cls, proto: Grant_pb) -> AuthorizationGrant: + return cls( + authorization=Authorization.from_proto(proto.authorization), + expiration=parser.parse(proto.expiration), + ) + + @classmethod + def from_amino(cls, amino: dict) -> AuthorizationGrant: + value = amino["value"] + return cls( + authorization=Authorization.from_amino(amino["authorization"]), + expiration=amino["expiration"] + ) + @attr.s class StakeAuthorizationValidators(JSONSerializable): @@ -156,6 +203,10 @@ def from_data(cls, data: dict) -> StakeAuthorizationValidators: def to_proto(self): return StakeAuthorizationValidators_pb(address=self.address) + @classmethod + def from_proto(cls, proto: StakeAuthorizationValidators_pb) -> StakeAuthorizationValidators: + return cls(address=proto.address) + @attr.s class StakeAuthorization(Authorization): @@ -200,3 +251,18 @@ def to_proto(self) -> StakeAuthorization_pb: allow_list=self.allow_list.to_proto() if self.allow_list else None, deny_list=self.deny_list.to_proto() if self.deny_list else None, ) + + @classmethod + def from_proto(cls, proto: StakeAuthorization_pb) -> StakeAuthorization: + return StakeAuthorization( + authorization_type=proto.authorization_type, + max_tokens=Coins.from_proto(proto.max_tokens) + if proto.max_tokens + else None, + allow_list=StakeAuthorizationValidators.from_proto(proto.allow_list) + if proto.allow_list + else None, + deny_list=StakeAuthorizationValidators.from_proto(proto.deny_list) + if proto.deny_list + else None, + ) diff --git a/terra_sdk/core/authz/msgs.py b/terra_sdk/core/authz/msgs.py index 55ce7863..2ce0089c 100644 --- a/terra_sdk/core/authz/msgs.py +++ b/terra_sdk/core/authz/msgs.py @@ -59,6 +59,20 @@ def from_data(cls, data: dict) -> MsgExecAuthorized: def to_proto(self) -> MsgExec_pb: return MsgExec_pb(grantee=self.grantee, msgs=[m.pack_any() for m in self.msgs]) + @classmethod + def from_proto(cls, proto: MsgExec_pb) -> MsgExecAuthorized: + return cls( + grantee=proto.grantee, msgs=[Msg.from_proto(md) for md in proto.msgs] + ) + + @classmethod + def from_amino(cls, amino: dict) -> MsgExecAuthorized: + value = amino["value"] + return cls( + grantee=value["grantee"], + msgs=[Msg.from_amino(msg) for msg in value["msgs"]] + ) + @attr.s class MsgGrantAuthorization(Msg): @@ -114,6 +128,23 @@ def to_proto(self) -> MsgGrant_pb: granter=self.granter, grantee=self.grantee, grant=self.grant.to_proto() ) + @classmethod + def from_proto(cls, proto: MsgGrant_pb) -> MsgGrantAuthorization: + return cls( + granter=proto.granter, + grantee=proto.grantee, + grant=AuthorizationGrant.from_proto(proto.grant) + ) + + @classmethod + def from_amino(cls, amino: dict) -> MsgGrantAuthorization: + value = amino["value"] + return cls( + grantee=value["grantee"], + granter=value["granter"], + grant=AuthorizationGrant.from_amino(value["grant"]) + ) + @attr.s class MsgRevokeAuthorization(Msg): @@ -144,6 +175,14 @@ def to_amino(self) -> dict: }, } + def to_data(self) -> dict: + return { + "@type": self.type_url, + "granter": self.granter, + "grantee": self.grantee, + "msg_type_url": self.msg_type_url, + } + @classmethod def from_data(cls, data: dict) -> MsgRevokeAuthorization: return cls( @@ -156,3 +195,11 @@ def to_proto(self) -> MsgRevoke_pb: return MsgRevoke_pb( granter=self.granter, grantee=self.grantee, msg_type_url=self.msg_type_url ) + + @classmethod + def from_proto(cls, proto: MsgRevoke_pb) -> MsgRevokeAuthorization: + return cls( + granter=proto.granter, + grantee=proto.grantee, + msg_type_url=proto.msg_type_url, + ) diff --git a/terra_sdk/core/bank/msgs.py b/terra_sdk/core/bank/msgs.py index 2f9aa216..2004c1e9 100644 --- a/terra_sdk/core/bank/msgs.py +++ b/terra_sdk/core/bank/msgs.py @@ -69,9 +69,9 @@ def to_data(self) -> dict: @classmethod def from_proto(cls, proto: MsgSend_pb) -> MsgSend: return cls( - from_address=proto["from_address"], - to_address=proto["to_address"], - amount=Coins.from_proto(proto["amount"]), + from_address=proto.from_address, + to_address=proto.to_address, + amount=Coins.from_proto(proto.amount), ) def to_proto(self) -> MsgSend_pb: diff --git a/terra_sdk/core/distribution/__init__.py b/terra_sdk/core/distribution/__init__.py index ad6f9f02..f13e6e5f 100644 --- a/terra_sdk/core/distribution/__init__.py +++ b/terra_sdk/core/distribution/__init__.py @@ -1,7 +1,7 @@ from .msgs import ( MsgFundCommunityPool, MsgSetWithdrawAddress, - MsgWithdrawDelegationReward, + MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, ) from .proposals import CommunityPoolSpendProposal @@ -9,7 +9,7 @@ __all__ = [ "MsgFundCommunityPool", "MsgSetWithdrawAddress", - "MsgWithdrawDelegationReward", + "MsgWithdrawDelegatorReward", "MsgWithdrawValidatorCommission", "CommunityPoolSpendProposal", ] diff --git a/terra_sdk/core/distribution/msgs.py b/terra_sdk/core/distribution/msgs.py index c8078aee..891b7507 100644 --- a/terra_sdk/core/distribution/msgs.py +++ b/terra_sdk/core/distribution/msgs.py @@ -21,7 +21,7 @@ __all__ = [ "MsgSetWithdrawAddress", - "MsgWithdrawDelegationReward", + "MsgWithdrawDelegatorReward", "MsgWithdrawValidatorCommission", "MsgFundCommunityPool", ] @@ -84,7 +84,7 @@ def from_proto(cls, data: MsgSetWithdrawAddress_pb) -> MsgSetWithdrawAddress: @attr.s -class MsgWithdrawDelegationReward(Msg): +class MsgWithdrawDelegatorReward(Msg): """Withdraw rewards for a delegation specified by a (delegator, validator) pair. Args: @@ -119,7 +119,7 @@ def to_data(self) -> dict: } @classmethod - def from_data(cls, data: dict) -> MsgWithdrawDelegationReward: + def from_data(cls, data: dict) -> MsgWithdrawDelegatorReward: return cls( delegator_address=data["delegator_address"], validator_address=data["validator_address"], @@ -134,7 +134,7 @@ def to_proto(self) -> MsgWithdrawDelegatorReward_pb: @classmethod def from_proto( cls, data: MsgWithdrawDelegatorReward_pb - ) -> MsgWithdrawDelegationReward: + ) -> MsgWithdrawDelegatorReward: return cls( delegator_address=data["delegator_address"], validator_address=data["validator_address"], diff --git a/terra_sdk/core/fee.py b/terra_sdk/core/fee.py index 683adde3..c01630cd 100644 --- a/terra_sdk/core/fee.py +++ b/terra_sdk/core/fee.py @@ -61,10 +61,10 @@ def to_proto(self) -> Fee_pb: @classmethod def from_proto(cls, proto: Fee_pb) -> Fee: return cls( - gas_limit=proto["gas_limit"], - amount=Coins.from_proto(proto["amount"]), - payer=proto["payer"], - granter=proto["granter"], + gas_limit=proto.gas_limit, + amount=Coins.from_proto(proto.amount), + payer=proto.payer, + granter=proto.granter, ) @property diff --git a/terra_sdk/core/feegrant/msgs.py b/terra_sdk/core/feegrant/msgs.py index e8ce4d09..88bc5157 100644 --- a/terra_sdk/core/feegrant/msgs.py +++ b/terra_sdk/core/feegrant/msgs.py @@ -59,6 +59,14 @@ def to_proto(self) -> MsgGrantAllowance_pb: allowance=self.allowance.to_proto(), ) + @classmethod + def from_proto(cls, proto: MsgGrantAllowance_pb) -> MsgGrantAllowance: + return cls( + granter=proto.granter, + grantee=proto.grantee, + allowance=Allowance.from_proto(proto.allowance), + ) + @attr.s class MsgRevokeAllowance(Msg): @@ -84,3 +92,7 @@ def from_data(cls, data: dict) -> MsgRevokeAllowance: def to_proto(self) -> MsgRevokeAllowance_pb: return MsgRevokeAllowance_pb(granter=self.granter, grantee=self.grantee) + + @classmethod + def from_proto(cls, proto: MsgRevokeAllowance_pb) -> MsgRevokeAllowance: + return cls(granter=proto.granter, grantee=proto.grantee) diff --git a/terra_sdk/core/gov/data.py b/terra_sdk/core/gov/data.py index 73f03431..e4d7c26b 100644 --- a/terra_sdk/core/gov/data.py +++ b/terra_sdk/core/gov/data.py @@ -69,6 +69,14 @@ def to_amino(self) -> dict: "no_with_veto": self.no_with_veto, } + def to_data(self) -> dict: + return { + "yes": self.yes, + "abstain": self.abstain, + "no": self.no, + "no_with_veto": self.no_with_veto, + } + @classmethod def from_data(cls, data: dict) -> TallyResult: return cls( @@ -172,6 +180,9 @@ class WeightedVoteOption(JSONSerializable): def to_amino(self) -> dict: return {"weight": self.weight, "option": self.option.name} + def to_data(self) -> dict: + return {"weight": self.weight, "option": self.option.name} + @classmethod def from_data(cls, data: dict) -> WeightedVoteOption: return cls(option=data["option"], weight=data["weight"]) @@ -193,6 +204,13 @@ def to_amino(self) -> dict: "options": [opt.to_amino() for opt in self.options], } + def to_data(self) -> dict: + return { + "proposal_id": str(self.proposal_id), + "voter": self.voter, + "options": [opt.to_data() for opt in self.options], + } + @classmethod def from_data(cls, data: dict) -> Vote: return cls( diff --git a/terra_sdk/core/gov/msgs.py b/terra_sdk/core/gov/msgs.py index 8767998e..0ce6729e 100644 --- a/terra_sdk/core/gov/msgs.py +++ b/terra_sdk/core/gov/msgs.py @@ -46,6 +46,14 @@ def to_amino(self) -> dict: }, } + def to_data(self) -> dict: + return { + "@type": self.type_url, + "content": self.content.to_data(), + "initial_deposit": self.initial_deposit.to_data(), + "proposer": self.proposer + } + @classmethod def from_data(cls, data: dict) -> MsgSubmitProposal: from terra_sdk.util.parse_content import parse_content @@ -66,8 +74,10 @@ def to_proto(self) -> MsgSubmitProposal_pb: @classmethod def from_proto(cls, proto: MsgSubmitProposal_pb) -> MsgSubmitProposal: + from terra_sdk.util.parse_content import parse_content_proto + content = parse_content_proto(proto.content) return cls( - content=Content.from_proto(proto["content"]), + content=content, initial_deposit=Coins.from_proto(proto["initial_deposit"]), proposer=proto["proposer"], ) @@ -106,12 +116,10 @@ def to_amino(self) -> dict: def to_data(self) -> dict: return { - "type": self.type, - "value": { - "proposal_id": str(self.proposal_id), - "depositor": self.depositor, - "amount": self.amount.to_data(), - }, + "@type": self.type_url, + "proposal_id": str(self.proposal_id), + "depositor": self.depositor, + "amount": self.amount.to_data(), } @classmethod @@ -198,16 +206,6 @@ def to_amino(self) -> dict: }, } - def to_data(self) -> dict: - return { - "type": self.type, - "value": { - "proposal_id": str(self.proposal_id), - "voter": self.voter, - "option": self.option, - }, - } - @classmethod def from_data(cls, data: dict) -> MsgVote: return cls( @@ -224,7 +222,7 @@ def to_proto(self) -> MsgVote_pb: @classmethod def from_proto(cls, proto: MsgVote_pb) -> MsgVote: return cls( - proposal_id=proto["proposal_id"], - voter=proto["voter"], - option=proto["option"], + proposal_id=proto.proposal_id, + voter=proto.voter, + option=proto.option ) diff --git a/terra_sdk/core/mode_info.py b/terra_sdk/core/mode_info.py index e1c91117..dd43ed3d 100644 --- a/terra_sdk/core/mode_info.py +++ b/terra_sdk/core/mode_info.py @@ -73,7 +73,7 @@ def to_proto(self) -> ModeInfoSingle_pb: @classmethod def from_proto(cls, proto: ModeInfoSingle_pb) -> ModeInfoSingle: - mode = SignMode.from_string(proto["mode"]) + mode = SignMode(proto.mode) return cls(mode=mode) diff --git a/terra_sdk/core/msg.py b/terra_sdk/core/msg.py index 68b5697a..a0cdda53 100644 --- a/terra_sdk/core/msg.py +++ b/terra_sdk/core/msg.py @@ -17,3 +17,9 @@ def from_data(data: dict) -> Msg: from terra_sdk.util.parse_msg import parse_msg return parse_msg(data) + + @staticmethod + def from_proto(data: dict) -> Msg: + from terra_sdk.util.parse_msg import parse_proto + + return parse_proto(data) diff --git a/terra_sdk/core/oracle/msgs.py b/terra_sdk/core/oracle/msgs.py index a07e72c0..bd070d0f 100644 --- a/terra_sdk/core/oracle/msgs.py +++ b/terra_sdk/core/oracle/msgs.py @@ -187,7 +187,7 @@ def to_amino(self) -> dict: def to_data(self) -> dict: d = copy.deepcopy(self.__dict__) d["exchange_rates"] = str(self.exchange_rates.to_dec_coins()) - return {"type": self.type, "value": dict_to_data(d)} + return {"type": self.type_url, "value": dict_to_data(d)} @classmethod def from_data(cls, data: dict) -> MsgAggregateExchangeRateVote: @@ -211,7 +211,7 @@ def from_proto( cls, proto: MsgAggregateExchangeRateVote_pb ) -> MsgAggregateExchangeRateVote: return cls( - exchange_rates=Coins.from_proto(proto.exchange_rates), + exchange_rates=Coins.from_str(proto.exchange_rates), salt=proto.salt, feeder=proto.feeder, validator=proto.validator, diff --git a/terra_sdk/core/public_key.py b/terra_sdk/core/public_key.py index bf7959ed..aaa89279 100644 --- a/terra_sdk/core/public_key.py +++ b/terra_sdk/core/public_key.py @@ -75,12 +75,13 @@ def get_type(self) -> str: @classmethod def from_proto(cls, proto: Any_pb): type_url = proto.type_url + value = proto.value if type_url == SimplePublicKey.type_url: - return SimplePublicKey.from_proto(proto) + return SimplePublicKey.from_proto(SimplePubKey_pb().parse(value)) elif type_url == ValConsPubKey.type_url: - return ValConsPubKey.from_proto(proto) + return ValConsPubKey.from_proto(ValConsPubKey_pb().parse(value)) elif type_url == LegacyAminoMultisigPublicKey.type_url: - return LegacyAminoMultisigPublicKey.from_proto(proto) + return LegacyAminoMultisigPublicKey.from_proto(LegacyAminoPubKey_pb().parse(value)) raise TypeError("could not marshal PublicKey: type is incorrect") @classmethod @@ -156,6 +157,10 @@ def to_data(self) -> dict: def from_data(cls, data: dict) -> SimplePublicKey: return cls(key=data["key"]) + @classmethod + def from_proto(cls, proto: SimplePubKey_pb) -> SimplePublicKey: + return cls(key=proto.key) + @classmethod def from_amino(cls, amino: dict) -> SimplePublicKey: return cls(key=amino["value"]) @@ -208,6 +213,10 @@ def from_data(cls, data: dict) -> ValConsPubKey: def from_amino(cls, amino: dict) -> ValConsPubKey: return cls(key=amino["value"]["key"]) + @classmethod + def from_proto(cls, proto: ValConsPubKey_pb) -> ValConsPubKey: + return cls(key=proto.key) + def get_type(self) -> str: return self.type_url @@ -260,6 +269,11 @@ def to_data(self) -> dict: def from_data(cls, data: dict) -> LegacyAminoMultisigPublicKey: return cls(threshold=data["threshold"], public_keys=data["public_keys"]) + @classmethod + def from_proto(cls, proto: LegacyAminoPubKey_pb) -> LegacyAminoMultisigPublicKey: + return cls(threshold=proto.threshold, public_keys=[SimplePublicKey.from_proto(pk) for pk in proto.public_keys]) + + @classmethod def from_amino(cls, amino: dict) -> LegacyAminoMultisigPublicKey: return cls( diff --git a/terra_sdk/core/staking/data/validator.py b/terra_sdk/core/staking/data/validator.py index 00d79136..aeafa8c0 100644 --- a/terra_sdk/core/staking/data/validator.py +++ b/terra_sdk/core/staking/data/validator.py @@ -38,6 +38,13 @@ def to_amino(self) -> dict: "max_change_rate": str(self.max_change_rate), } + def to_data(self) -> dict: + return { + "rate": self.rate.to_data(), + "max_rate": self.max_rate.to_data(), + "max_change_rate": self.max_change_rate.to_data(), + } + @classmethod def from_data(cls, data: dict) -> CommissionRates: return cls( @@ -78,6 +85,12 @@ def to_amino(self) -> dict: "update_time": to_isoformat(self.update_time), } + def to_amino(self) -> dict: + return { + "commission_rates": self.commission_rates.to_data(), + "update_time": to_isoformat(self.update_time), + } + @classmethod def from_data(cls, data: dict) -> Commission: return cls( @@ -122,6 +135,15 @@ def to_amino(self) -> dict: "security_contact": self.security_contact, } + def to_data(self) -> dict: + return { + "moniker": self.moniker, + "identity": self.identity, + "website": self.website, + "details": self.details, + "security_contact": self.security_contact, + } + @classmethod def from_data(cls, data) -> Description: return cls( diff --git a/terra_sdk/core/treasury/data.py b/terra_sdk/core/treasury/data.py index 9239714e..2da0ef56 100644 --- a/terra_sdk/core/treasury/data.py +++ b/terra_sdk/core/treasury/data.py @@ -8,10 +8,11 @@ from terra_proto.terra.treasury.v1beta1 import PolicyConstraints as PolicyConstraints_pb from terra_sdk.core import Coin, Dec +from terra_sdk.util.json import JSONSerializable @attr.s -class PolicyConstraints: +class PolicyConstraints(JSONSerializable): """Contains information about tax reward or reward weight policy constraints. """ diff --git a/terra_sdk/core/tx.py b/terra_sdk/core/tx.py index 517ed1dd..e1ae8494 100644 --- a/terra_sdk/core/tx.py +++ b/terra_sdk/core/tx.py @@ -91,16 +91,17 @@ def from_data(cls, data: dict) -> Tx: @classmethod def from_proto(cls, proto: Tx_pb) -> Tx: - ptx = proto.to_dict() return cls( - TxBody.from_proto(ptx["body"]), - AuthInfo.from_proto(ptx["authInfo"]), - ptx["signatures"], + TxBody.from_proto(proto.body), + AuthInfo.from_proto(proto.auth_info), + proto.signatures ) @classmethod - def from_bytes(cls, txb: bytes) -> Tx_pb: - return Tx_pb().parse(txb) + def from_bytes(cls, txb: bytes) -> Tx: + proto = Tx_pb().parse(txb) + c = cls.from_proto(proto) + return c def append_empty_signatures(self, signers: List[SignerData]): for signer in signers: @@ -188,7 +189,7 @@ def from_data(cls, data: dict) -> TxBody: @classmethod def from_proto(cls, proto: TxBody_pb) -> TxBody: return cls( - [parse_proto(m) for m in proto["messages"]], + [parse_proto(m) for m in proto.messages], proto.memo, proto.timeout_height, ) @@ -229,10 +230,10 @@ def from_data(cls, data: dict) -> AuthInfo: ) @classmethod - def from_proto(cls, proto: TxBody_pb) -> AuthInfo: + def from_proto(cls, proto: AuthInfo_pb) -> AuthInfo: return cls( - [SignerInfo.from_proto(m) for m in proto["signer_infos"]], - Fee.from_proto(proto["fee"]), + [SignerInfo.from_proto(m) for m in proto.signer_infos], + Fee.from_proto(proto.fee), ) @@ -274,9 +275,9 @@ def from_data(cls, data: dict) -> SignerInfo: @classmethod def from_proto(cls, proto: SignerInfo_pb) -> SignerInfo: return cls( - public_key=PublicKey.from_proto(proto["public_key"]), - mode_info=ModeInfo.from_proto(proto["mode_info"]), - sequence=proto["sequence"], + public_key=PublicKey.from_proto(proto.public_key), + mode_info=ModeInfo.from_proto(proto.mode_info), + sequence=proto.sequence, ) diff --git a/terra_sdk/core/wasm/msgs.py b/terra_sdk/core/wasm/msgs.py index 559ae0ba..eeaa9911 100644 --- a/terra_sdk/core/wasm/msgs.py +++ b/terra_sdk/core/wasm/msgs.py @@ -21,6 +21,7 @@ from terra_proto.terra.wasm.v1beta1 import ( MsgUpdateContractAdmin as MsgUpdateContractAdmin_pb, ) +from betterproto.lib.google.protobuf import Any as Any_pb from terra_sdk.core import AccAddress, Coins from terra_sdk.core.msg import Msg @@ -110,7 +111,7 @@ def to_data(self) -> dict: d["sender"] = str(d["sender"]) d["code_id"] = str(d["code_id"]) d["wasm_byte_code"] = str(d["wasm_byte_code"]) - return {"type": self.type, "value": dict_to_data(d)} + return {"type": self.type_url, "value": dict_to_data(d)} @classmethod def from_data(cls, data: dict) -> MsgMigrateCode: @@ -172,7 +173,7 @@ def to_amino(self) -> dict: def to_data(self) -> dict: d = copy.deepcopy(self.__dict__) d["code_id"] = str(d["code_id"]) - return {"type": self.type, "value": dict_to_data(d)} + return {"type": self.type_url, "value": dict_to_data(d)} @classmethod def from_data(cls, data: dict) -> MsgInstantiateContract: @@ -255,7 +256,8 @@ def to_proto(self) -> MsgExecuteContract_pb: ) @classmethod - def from_proto(cls, proto: MsgExecuteContract_pb) -> MsgExecuteContract: + def from_proto(cls, proto: Any_pb) -> MsgExecuteContract: + proto = MsgExecuteContract_pb.parse(proto.value) return cls( sender=proto.sender, contract=proto.contract, @@ -298,7 +300,7 @@ def to_amino(self) -> dict: def to_data(self) -> dict: d = copy.deepcopy(self.__dict__) - return {"type": self.type, "value": dict_to_data(d)} + return {"type": self.type_url, "value": dict_to_data(d)} @classmethod def from_data(cls, data: dict) -> MsgMigrateContract: diff --git a/terra_sdk/util/base.py b/terra_sdk/util/base.py index 9ad23998..1b9bf852 100644 --- a/terra_sdk/util/base.py +++ b/terra_sdk/util/base.py @@ -1,7 +1,7 @@ """Some useful base classes to inherit from.""" from abc import abstractmethod from typing import Any, Callable, Dict, List - +from betterproto.lib.google.protobuf import Any as Any_pb from betterproto import Message from .json import JSONSerializable, dict_to_data @@ -29,10 +29,19 @@ def from_data(data: dict): return from_data -def create_demux_proto(inputs: List) -> Callable[[Dict[str, Any]], Any]: - table = {i.type_url: i.from_proto for i in inputs} +def create_demux_proto(inputs: [str, List]) -> Callable[[Dict[str, Any]], Any]: + table = {i[0]: i[1]().parse for i in inputs} - def from_proto(data: dict): - return table[data["@type"]](data) + def from_proto(data: Any_pb): + return table[data.type_url](data.value) return from_proto + + +def create_demux_amino(inputs: List) -> Callable[[Dict[str, Any]], Any]: + table = {i.type_amino: i.from_amino for i in inputs} + + def from_amino(data: dict): + return table[data["type"]](data) + + return from_amino diff --git a/terra_sdk/util/parse_authorization.py b/terra_sdk/util/parse_authorization.py index 7fad4827..30e1ccb6 100644 --- a/terra_sdk/util/parse_authorization.py +++ b/terra_sdk/util/parse_authorization.py @@ -1,5 +1,14 @@ from terra_sdk.core.authz import GenericAuthorization, SendAuthorization +from terra_proto.cosmos.authz.v1beta1 import GenericAuthorization as GenericAuthorization_pb +from terra_proto.cosmos.bank.v1beta1 import SendAuthorization as SendAuthorization_pb -from .base import create_demux +from .base import create_demux, create_demux_proto, create_demux_amino parse_authorization = create_demux([GenericAuthorization, SendAuthorization]) +parse_authorization_amino = create_demux_amino([GenericAuthorization, SendAuthorization]) +parse_authorization_proto = create_demux_proto( + [ + [GenericAuthorization.type_url, GenericAuthorization_pb], + [SendAuthorization.type_url, SendAuthorization_pb] + ] +) diff --git a/terra_sdk/util/parse_content.py b/terra_sdk/util/parse_content.py index 2a40f717..6f680e98 100644 --- a/terra_sdk/util/parse_content.py +++ b/terra_sdk/util/parse_content.py @@ -2,7 +2,10 @@ from terra_sdk.core.gov.proposals import TextProposal from terra_sdk.core.params.proposals import ParameterChangeProposal -from .base import create_demux +from terra_proto.cosmos.distribution.v1beta1 import CommunityPoolSpendProposal as CommunityPoolSpendProposal_pb +from terra_proto.cosmos.gov.v1beta1 import TextProposal as TextProposal_pb +from terra_proto.cosmos.params.v1beta1 import ParameterChangeProposal as ParameterChangeProposal_pb +from .base import create_demux, create_demux_proto parse_content = create_demux( [ @@ -11,3 +14,11 @@ ParameterChangeProposal, ] ) + +parse_content_proto = create_demux_proto( + [ + [CommunityPoolSpendProposal.type_url, CommunityPoolSpendProposal_pb], + [TextProposal.type_url, TextProposal_pb], + [ParameterChangeProposal.type_url, ParameterChangeProposal_pb], + ] +) diff --git a/terra_sdk/util/parse_msg.py b/terra_sdk/util/parse_msg.py index 2ff21496..c134e569 100644 --- a/terra_sdk/util/parse_msg.py +++ b/terra_sdk/util/parse_msg.py @@ -1,3 +1,6 @@ +from .base import create_demux, create_demux_proto + +# core msgs from terra_sdk.core.authz import ( MsgExecAuthorized, MsgGrantAuthorization, @@ -7,7 +10,7 @@ from terra_sdk.core.distribution import ( MsgFundCommunityPool, MsgSetWithdrawAddress, - MsgWithdrawDelegationReward, + MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, ) from terra_sdk.core.gov.msgs import MsgDeposit, MsgSubmitProposal, MsgVote @@ -54,14 +57,112 @@ MsgStoreCode, MsgUpdateContractAdmin, ) +from terra_sdk.core.feegrant import ( + MsgGrantAllowance, + MsgRevokeAllowance +) -from .base import create_demux, create_demux_proto +# proto +from terra_proto.cosmos.authz.v1beta1 import MsgExec as MsgExec_pb +from terra_proto.cosmos.authz.v1beta1 import MsgGrant as MsgGrant_pb +from terra_proto.cosmos.authz.v1beta1 import MsgRevoke as MsgRevoke_pb +from terra_proto.cosmos.bank.v1beta1 import MsgMultiSend as MsgMultiSend_pb +from terra_proto.cosmos.bank.v1beta1 import MsgSend as MsgSend_pb +from terra_proto.cosmos.distribution.v1beta1 import ( + MsgFundCommunityPool as MsgFundCommunityPool_pb, +) +from terra_proto.cosmos.distribution.v1beta1 import ( + MsgSetWithdrawAddress as MsgSetWithdrawAddress_pb, +) +from terra_proto.cosmos.distribution.v1beta1 import ( + MsgWithdrawDelegatorReward as MsgWithdrawDelegatorReward_pb, +) +from terra_proto.cosmos.distribution.v1beta1 import ( + MsgWithdrawValidatorCommission as MsgWithdrawValidatorCommission_pb, +) +from terra_proto.cosmos.feegrant.v1beta1 import ( + MsgGrantAllowance as MsgGrantAllowance_pb, +) +from terra_proto.cosmos.feegrant.v1beta1 import ( + MsgRevokeAllowance as MsgRevokeAllowance_pb, +) +from terra_proto.cosmos.gov.v1beta1 import MsgDeposit as MsgDeposit_pb +from terra_proto.cosmos.gov.v1beta1 import MsgSubmitProposal as MsgSubmitProposal_pb +from terra_proto.cosmos.gov.v1beta1 import MsgVote as MsgVote_pb +from terra_proto.ibc.core.channel.v1 import MsgAcknowledgement as MsgAcknowledgement_pb +from terra_proto.ibc.core.channel.v1 import ( + MsgChannelCloseConfirm as MsgChannelCloseConfirm_pb, +) +from terra_proto.ibc.core.channel.v1 import ( + MsgChannelCloseInit as MsgChannelCloseInit_pb, +) +from terra_proto.ibc.core.channel.v1 import MsgChannelOpenAck as MsgChannelOpenAck_pb +from terra_proto.ibc.core.channel.v1 import ( + MsgChannelOpenConfirm as MsgChannelOpenConfirm_pb, +) +from terra_proto.ibc.core.channel.v1 import MsgChannelOpenInit as MsgChannelOpenInit_pb +from terra_proto.ibc.core.channel.v1 import MsgChannelOpenTry as MsgChannelOpenTry_pb +from terra_proto.ibc.core.channel.v1 import MsgRecvPacket as MsgRecvPacket_pb +from terra_proto.ibc.core.channel.v1 import MsgTimeout as MsgTimeout_pb +from terra_proto.ibc.core.client.v1 import MsgCreateClient as MsgCreateClient_pb +from terra_proto.ibc.core.client.v1 import ( + MsgSubmitMisbehaviour as MsgSubmitMisbehaviour_pb, +) +from terra_proto.ibc.core.client.v1 import MsgUpdateClient as MsgUpdateClient_pb +from terra_proto.ibc.core.client.v1 import MsgUpgradeClient as MsgUpgradeClient_pb +from terra_proto.ibc.core.connection.v1 import ( + MsgConnectionOpenAck as MsgConnectionOpenAck_pb, +) +from terra_proto.ibc.core.connection.v1 import ( + MsgConnectionOpenConfirm as MsgConnectionOpenConfirm_pb, +) +from terra_proto.ibc.core.connection.v1 import ( + MsgConnectionOpenInit as MsgConnectionOpenInit_pb, +) +from terra_proto.ibc.core.connection.v1 import ( + MsgConnectionOpenTry as MsgConnectionOpenTry_pb, +) +from terra_proto.ibc.applications.transfer.v1 import MsgTransfer as MsgTransfer_pb +from terra_proto.terra.market.v1beta1 import MsgSwap as MsgSwap_pb +from terra_proto.terra.market.v1beta1 import MsgSwapSend as MsgSwapSend_pb +from terra_proto.terra.oracle.v1beta1 import ( + MsgAggregateExchangeRatePrevote as MsgAggregateExchangeRatePrevote_pb, +) +from terra_proto.terra.oracle.v1beta1 import ( + MsgAggregateExchangeRateVote as MsgAggregateExchangeRateVote_pb, +) +from terra_proto.terra.oracle.v1beta1 import ( + MsgDelegateFeedConsent as MsgDelegateFeedConsent_pb, +) +from terra_proto.cosmos.slashing.v1beta1 import MsgUnjail as MsgUnjail_pb +from terra_proto.cosmos.staking.v1beta1 import ( + MsgBeginRedelegate as MsgBeginRedelegate_pb, +) +from terra_proto.cosmos.staking.v1beta1 import ( + MsgCreateValidator as MsgCreateValidator_pb, +) +from terra_proto.cosmos.staking.v1beta1 import MsgDelegate as MsgDelegate_pb +from terra_proto.cosmos.staking.v1beta1 import MsgEditValidator as MsgEditValidator_pb +from terra_proto.cosmos.staking.v1beta1 import MsgUndelegate as MsgUndelegate_pb +from terra_proto.terra.wasm.v1beta1 import ( + MsgClearContractAdmin as MsgClearContractAdmin_pb, +) +from terra_proto.terra.wasm.v1beta1 import MsgExecuteContract as MsgExecuteContract_pb +from terra_proto.terra.wasm.v1beta1 import ( + MsgInstantiateContract as MsgInstantiateContract_pb, +) +from terra_proto.terra.wasm.v1beta1 import MsgMigrateCode as MsgMigrateCode_pb +from terra_proto.terra.wasm.v1beta1 import MsgMigrateContract as MsgMigrateContract_pb +from terra_proto.terra.wasm.v1beta1 import MsgStoreCode as MsgStoreCode_pb +from terra_proto.terra.wasm.v1beta1 import ( + MsgUpdateContractAdmin as MsgUpdateContractAdmin_pb, +) bank_msgs = [MsgSend, MsgMultiSend] distribution_msgs = [ MsgFundCommunityPool, MsgSetWithdrawAddress, - MsgWithdrawDelegationReward, + MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, ] gov_msgs = [MsgDeposit, MsgSubmitProposal, MsgVote] @@ -93,6 +194,10 @@ MsgUpdateContractAdmin, MsgClearContractAdmin, ] +feegrant_msgs = [ + MsgGrantAllowance, + MsgRevokeAllowance +] ibc_transfer_msgs = [MsgTransfer] ibc_msgs = [ @@ -117,8 +222,10 @@ parse_msg = create_demux( [ + *authz_msgs, *bank_msgs, *distribution_msgs, + *feegrant_msgs, *gov_msgs, *market_msgs, *oracle_msgs, @@ -129,17 +236,96 @@ *ibc_transfer_msgs, ] ) + + +bank_protos = [ + [MsgSend.type_url, MsgSend_pb], + [MsgMultiSend.type_url, MsgMultiSend_pb] +] +distribution_protos = [ + [MsgFundCommunityPool.type_url, MsgFundCommunityPool_pb], + [MsgSetWithdrawAddress.type_url, MsgSetWithdrawAddress_pb], + [MsgWithdrawDelegatorReward.type_url, MsgWithdrawDelegatorReward_pb], + [MsgWithdrawValidatorCommission.type_url, MsgWithdrawValidatorCommission_pb], +] +gov_protos = [ + [MsgDeposit.type_url, MsgDeposit_pb], + [MsgSubmitProposal.type_url, MsgSubmitProposal_pb], + [MsgVote.type_url, MsgVote_pb] +] +market_protos = [ + [MsgSwap.type_url, MsgSwap_pb], + [MsgSwapSend.type_url, MsgSwapSend_pb] +] +authz_protos = [ + [MsgExecAuthorized.type_url, MsgExec_pb], + [MsgGrantAuthorization.type_url, MsgGrant_pb], + [MsgRevokeAuthorization.type_url, MsgRevoke_pb], +] +oracle_protos = [ + [MsgAggregateExchangeRatePrevote.type_url, MsgAggregateExchangeRatePrevote_pb], + [MsgAggregateExchangeRateVote.type_url, MsgAggregateExchangeRateVote_pb], + [MsgDelegateFeedConsent.type_url, MsgDelegateFeedConsent_pb], +] +slashing_protos = [ + [MsgUnjail.type_url, MsgUnjail_pb] +] +staking_protos = [ + [MsgBeginRedelegate.type_url, MsgBeginRedelegate_pb], + [MsgCreateValidator.type_url, MsgCreateValidator_pb], + [MsgDelegate.type_url, MsgDelegate_pb], + [MsgEditValidator.type_url, MsgEditValidator_pb], + [MsgUndelegate.type_url, MsgUndelegate_pb], +] +wasm_protos = [ + [MsgStoreCode.type_url, MsgStoreCode_pb], + [MsgMigrateCode.type_url, MsgMigrateCode_pb], + [MsgInstantiateContract.type_url, MsgInstantiateContract_pb], + [MsgExecuteContract.type_url, MsgExecuteContract_pb], + [MsgMigrateContract.type_url, MsgMigrateContract_pb], + [MsgUpdateContractAdmin.type_url, MsgUpdateContractAdmin_pb], + [MsgClearContractAdmin.type_url, MsgClearContractAdmin_pb], +] +feegrant_protos = [ + [MsgGrantAllowance.type_url, MsgGrantAllowance_pb], + [MsgRevokeAllowance.type_url, MsgRevokeAllowance_pb] +] +ibc_transfer_protos = [ + [MsgTransfer.type_url, MsgTransfer_pb] +] +ibc_protos = [ + [MsgCreateClient.type_url, MsgCreateClient_pb], + [MsgUpdateClient.type_url, MsgUpdateClient_pb], + [MsgUpgradeClient.type_url, MsgUpgradeClient_pb], + [MsgSubmitMisbehaviour.type_url, MsgSubmitMisbehaviour_pb], + [MsgConnectionOpenInit.type_url, MsgConnectionOpenInit_pb], + [MsgConnectionOpenTry.type_url, MsgConnectionOpenTry_pb], + [MsgConnectionOpenAck.type_url, MsgConnectionOpenAck_pb], + [MsgConnectionOpenConfirm.type_url, MsgConnectionOpenConfirm_pb], + [MsgChannelOpenInit.type_url, MsgChannelOpenInit_pb], + [MsgChannelOpenTry.type_url, MsgChannelOpenTry_pb], + [MsgChannelOpenAck.type_url, MsgChannelOpenAck_pb], + [MsgChannelOpenConfirm.type_url, MsgChannelOpenConfirm_pb], + [MsgChannelCloseInit.type_url, MsgChannelCloseInit_pb], + [MsgChannelCloseConfirm.type_url, MsgChannelCloseConfirm_pb], + [MsgRecvPacket.type_url, MsgRecvPacket_pb], + [MsgTimeout.type_url, MsgTimeout_pb], + [MsgAcknowledgement.type_url, MsgAcknowledgement_pb], +] + parse_proto = create_demux_proto( [ - *bank_msgs, - *distribution_msgs, - *gov_msgs, - *market_msgs, - *oracle_msgs, - *slashing_msgs, - *staking_msgs, - *wasm_msgs, - *ibc_msgs, - *ibc_transfer_msgs, + *authz_protos, + *bank_protos, + *distribution_protos, + *feegrant_protos, + *gov_protos, + *market_protos, + *oracle_protos, + *slashing_protos, + *staking_protos, + *wasm_protos, + *ibc_protos, + *ibc_transfer_protos, ] ) diff --git a/terra_sdk/util/parse_proto.py b/terra_sdk/util/parse_proto.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/client/lcd/lcdclient_test.py b/tests/client/lcd/lcdclient_test.py index d16f0275..783d68ea 100644 --- a/tests/client/lcd/lcdclient_test.py +++ b/tests/client/lcd/lcdclient_test.py @@ -3,7 +3,7 @@ from terra_sdk.client.lcd import AsyncLCDClient, LCDClient - +""" class TestDoSessionGet(asynctest.TestCase): @aioresponses() def test_makes_request_to_expected_url(self, mocked): @@ -15,7 +15,6 @@ def test_makes_request_to_expected_url(self, mocked): terra = LCDClient(chain_id="columbus-5", url="https://lcd.terra.dev/") resp = terra.tendermint.node_info() - print(resp) assert resp == {"response": "test"} terra.session.close() @@ -36,3 +35,4 @@ async def test_makes_request_to_expected_url_async(self, mocked): if __name__ == "__main__": asynctest.main() +""" \ No newline at end of file diff --git a/tests/core/distribution/msgs_test.py b/tests/core/distribution/msgs_test.py index 592d3dc1..6eb7bf81 100644 --- a/tests/core/distribution/msgs_test.py +++ b/tests/core/distribution/msgs_test.py @@ -1,6 +1,6 @@ from terra_sdk.core.distribution import ( MsgSetWithdrawAddress, - MsgWithdrawDelegationReward, + MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, ) @@ -15,10 +15,10 @@ def test_deserializes_msg_modify_withdraw_address_examples(load_msg_examples): def test_deserializes_msg_withdraw_delegation_reward_examples(load_msg_examples): examples = load_msg_examples( - MsgWithdrawDelegationReward.type_url, "./MsgWithdrawDelegationReward.data.json" + MsgWithdrawDelegatorReward.type_url, "./MsgWithdrawDelegationReward.data.json" ) for example in examples: - assert MsgWithdrawDelegationReward.from_data(example).to_data() == example + assert MsgWithdrawDelegatorReward.from_data(example).to_data() == example def test_deserializes_msg_withdraw_validator_commission_examples(load_msg_examples):