Skip to content

Commit 8c5aec4

Browse files
author
Geoff Lee
committed
reformatting
1 parent f0d6271 commit 8c5aec4

File tree

19 files changed

+118
-127
lines changed

19 files changed

+118
-127
lines changed

docs/core_modules/auth.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Account
2222
Transactions
2323
^^^^^^^^^^^^
2424

25-
.. automodule:: terra_sdk.core.auth.data.tx
25+
.. automodule:: terra_sdk.core.tx
2626
:members:
2727

2828
Public Key
2929
^^^^^^^^^^
3030

3131
.. automodule:: terra_sdk.core.auth.data.public_key
32-
:members:
32+
:members:

docs/guides/smart_contracts.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ Contract Deployment Example
1111
import base64
1212
from terra_sdk.client.localterra import LocalTerra
1313
from terra_sdk.core.wasm import MsgStoreCode, MsgInstantiateContract, MsgExecuteContract
14-
from terra_sdk.core.auth.data.tx import StdFee
14+
from terra_sdk.core.fee import Fee
1515
1616
terra = LocalTerra()
1717
test1 = terra.wallets["test1"]
1818
contract_file = open("./contract.wasm", "rb")
1919
file_bytes = base64.b64encode(contract_file.read()).decode()
2020
store_code = MsgStoreCode(test1.key.acc_address, file_bytes)
21-
store_code_tx = test1.create_and_sign_tx(msgs=[store_code], fee=StdFee(2100000, "60000uluna"))
21+
store_code_tx = test1.create_and_sign_tx(msgs=[store_code], fee=Fee(2100000, "60000uluna"))
2222
store_code_tx_result = terra.tx.broadcast(store_code_tx)
2323
print(store_code_tx_result)
2424
@@ -46,7 +46,7 @@ Contract Deployment Example
4646
)
4747
4848
execute_tx = test1.create_and_sign_tx(
49-
msgs=[execute], fee=StdFee(1000000, Coins(uluna=1000000))
49+
msgs=[execute], fee=Fee(1000000, Coins(uluna=1000000))
5050
)
5151
5252
execute_tx_result = terra.tx.broadcast(execute_tx)

docs/guides/transactions.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ If you want to perform a state-changing operation on the Terra blockchain such a
55
sending tokens, swapping assets, withdrawing rewards, or even invoking functions on
66
smart contracts, you must create a **transaction** and broadcast it to the network.
77

8-
An :class:`StdTx<terra_sdk.core.auth.data.tx.StdTx>` is a data object that represents
8+
An :class:`StdTx<terra_sdk.core.tx.Tx>` is a data object that represents
99
a transaction. It contains:
1010

1111
- **msgs**: a list of state-altering messages
@@ -42,7 +42,7 @@ Once you have your Wallet, you can simply create a StdTx using :meth:`Wallet.cre
4242

4343
.. code-block:: python
4444
45-
from terra_sdk.core.auth import StdFee
45+
from terra_sdk.core.fee import Fee
4646
from terra_sdk.core.bank import MsgSend
4747
4848
tx = wallet.create_and_sign_tx(
@@ -52,7 +52,7 @@ Once you have your Wallet, you can simply create a StdTx using :meth:`Wallet.cre
5252
"1000000uluna" # send 1 luna
5353
)],
5454
memo="test transaction!",
55-
fee=StdFee(200000, "120000uluna")
55+
fee=Fee(200000, "120000uluna")
5656
)
5757
5858
And that's it! You should now be able to broadcast your transaction to the network.
@@ -101,7 +101,7 @@ Signing transactions manually
101101
-----------------------------
102102

103103
Below is the full process of signing a transaction manually that does not use ``Wallet``.
104-
You will need to build a :class:`StdSignMsg<terra_sdk.core.auth.data.tx.StdSignMsg>`,
104+
You will need to build a :class:`StdSignMsg<terra_sdk.core..tx.SignDoc>`,
105105
sign it, and add the signatures to an ``StdTx``.
106106

107107
A StdSignMsg contains the information required to build a StdTx:
@@ -128,7 +128,7 @@ A StdSignMsg contains the information required to build a StdTx:
128128
chain_id="columbus-4",
129129
account_number=23982,
130130
sequence=12,
131-
fee=StdFee(200000, "120000uluna"),
131+
fee=Fee(200000, "120000uluna"),
132132
msgs=[MsgSend(
133133
mk.acc_address,
134134
RECIPIENT,
@@ -157,7 +157,7 @@ Applying multiple signatures
157157

158158
Some messages, such as ``MsgMultiSend``, require the transaction to be signed with multiple signatures.
159159
You must prepare a separate ``StdSignMsg`` for each signer to sign individually, and then
160-
combine them in the ``signatures`` field of the final :class:`StdTx<terra_sdk.core.auth.data.tx.StdTx>` object.
160+
combine them in the ``signatures`` field of the final :class:`StdTx<terra_sdk.core..tx.Tx>` object.
161161
Each ``StdSignMsg`` should only differ by ``account`` and ``sequence``, which vary according to the signing key.
162162

163163
.. note::
@@ -167,7 +167,7 @@ Each ``StdSignMsg`` should only differ by ``account`` and ``sequence``, which va
167167
.. code-block:: python
168168
169169
from terra_sdk.client.lcd import LCDClient
170-
from terra_sdk.core.auth import StdFee
170+
from terra_sdk.core.fee import Fee
171171
from terra_sdk.core.bank import MsgMultiSend
172172
from terra_sdk.key.mnemonic import MnemonicKey
173173
@@ -187,7 +187,7 @@ Each ``StdSignMsg`` should only differ by ``account`` and ``sequence``, which va
187187
)
188188
189189
msgs = [multisend]
190-
fee = StdFee(200000, "12000uluna")
190+
fee = Fee(200000, "12000uluna")
191191
memo = "multisend example"
192192
193193
# create unsigned_tx #1
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from terra_sdk.exceptions import LCDResponseError
2-
31
from terra_sdk.client.lcd import LCDClient, PaginationOptions
42
from terra_sdk.client.lcd.api.tx import CreateTxOptions
53
from terra_sdk.core import Coin, Coins
64
from terra_sdk.core.ibc import Height
75
from terra_sdk.core.ibc_transfer import MsgTransfer
8-
from terra_sdk.util.contract import get_code_id
9-
6+
from terra_sdk.exceptions import LCDResponseError
107
from terra_sdk.key.mnemonic import MnemonicKey
8+
from terra_sdk.util.contract import get_code_id
119

1210

1311
def main():
@@ -16,21 +14,24 @@ def main():
1614
chain_id="bombay-12",
1715
)
1816

19-
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")
17+
key = MnemonicKey(
18+
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"
19+
)
2020

2121
wallet = terra.wallet(key=key)
2222

2323
signedTx = wallet.create_and_sign_tx(
2424
CreateTxOptions(
2525
msgs=[
26-
MsgTransfer(source_port="transfer",
27-
source_channel="channel-9",
28-
token="10000uluna",
29-
sender="terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v",
30-
receiver="terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp",
31-
timeout_height=Height(revision_number=0, revision_height=10000),
32-
timeout_timestamp=0
33-
)
26+
MsgTransfer(
27+
source_port="transfer",
28+
source_channel="channel-9",
29+
token="10000uluna",
30+
sender="terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v",
31+
receiver="terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp",
32+
timeout_height=Height(revision_number=0, revision_height=10000),
33+
timeout_timestamp=0,
34+
)
3435
]
3536
)
3637
)
@@ -44,5 +45,4 @@ def main():
4445
print(result)
4546

4647

47-
4848
main()

terra_sdk/client/lcd/api/gov.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ async def votes(self, proposal_id: int, params: Optional[APIParams] = None):
163163
msg.get("@type") == "/cosmos.gov.v1beta1.MsgVoteWeighted"
164164
and msg.get("proposal_id") == proposal_id
165165
):
166-
votes.append(Vote(
167-
proposal_id=proposal_id,
168-
voter=msg.get("voter"),
169-
options=msg.get("options")
170-
))
166+
votes.append(
167+
Vote(
168+
proposal_id=proposal_id,
169+
voter=msg.get("voter"),
170+
options=msg.get("options"),
171+
)
172+
)
171173
return votes, pagination
172174

173175
async def tally(self, proposal_id: int):

terra_sdk/client/lcd/api/slashing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from datetime import datetime
22
from typing import List, Optional, Union
33

4-
from terra_sdk.core import Dec, Numeric, ValConsPubKey
54
from dateutil import parser
65

6+
from terra_sdk.core import Dec, Numeric, ValConsPubKey
7+
78
from ._base import BaseAsyncAPI, sync_bind
89

910
__all__ = ["AsyncSlashingAPI", "SlashingAPI"]
@@ -12,7 +13,6 @@
1213

1314

1415
class AsyncSlashingAPI(BaseAsyncAPI):
15-
1616
async def signing_info(
1717
self, val_cons_pub_key: ValConsPubKey
1818
) -> Union[List[dict], dict]:
@@ -32,7 +32,9 @@ async def signing_info(
3232
"address": info["address"],
3333
"start_height": Numeric.parse(info["start_height"]),
3434
"index_offset": Numeric.parse(info["index_offset"]),
35-
"jailed_until": parser.parse(info["jailed_until"]), # TODO: convert to datetime
35+
"jailed_until": parser.parse(
36+
info["jailed_until"]
37+
), # TODO: convert to datetime
3638
"tombstoned": bool(info["tombstoned"]),
3739
"missed_blocks_counter": Numeric.parse(info["missed_blocks_counter"]),
3840
}

terra_sdk/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"SignatureV2",
1515
]
1616

17+
from .bech32 import AccAddress, AccPubKey, ValAddress, ValPubKey
1718
from .coin import Coin
1819
from .coins import Coins
1920
from .numeric import Dec, Numeric
2021
from .public_key import PublicKey, SimplePublicKey, ValConsPubKey
2122
from .sign_doc import SignDoc
2223
from .signature_v2 import SignatureV2
23-
from .bech32 import AccAddress, AccPubKey, ValAddress, ValPubKey

terra_sdk/core/authz/data.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ class SendAuthorization(Authorization):
5959
spend_limit: Coins = attr.ib(converter=Coins)
6060

6161
def to_data(self) -> dict:
62-
return {
63-
"@type": self.type_url,
64-
"spend_limit": self.spend_limit.to_data()
65-
}
62+
return {"@type": self.type_url, "spend_limit": self.spend_limit.to_data()}
6663

6764
@classmethod
6865
def from_data(cls, data: dict) -> SendAuthorization:
@@ -86,10 +83,7 @@ class GenericAuthorization(Authorization):
8683
msg: str = attr.ib()
8784

8885
def to_data(self) -> dict:
89-
return {
90-
"@type": self.type_url,
91-
"msg": self.msg
92-
}
86+
return {"@type": self.type_url, "msg": self.msg}
9387

9488
@classmethod
9589
def from_data(cls, data: dict) -> GenericAuthorization:
@@ -112,7 +106,7 @@ class AuthorizationGrant(JSONSerializable):
112106
def to_data(self) -> dict:
113107
return {
114108
"authorization": self.authorization.to_data(),
115-
"expiration": self.expiration
109+
"expiration": self.expiration,
116110
}
117111

118112
@classmethod
@@ -134,9 +128,7 @@ class StakeAuthorizationValidators(JSONSerializable):
134128
address: List[AccAddress] = attr.ib(converter=list)
135129

136130
def to_data(self) -> dict:
137-
return {
138-
"address": self.address
139-
}
131+
return {"address": self.address}
140132

141133
@classmethod
142134
def from_data(cls, data: dict) -> StakeAuthorizationValidators:
@@ -161,16 +153,22 @@ def to_data(self) -> dict:
161153
"authorization_type": self.authorization_type,
162154
"max_tokens": self.max_tokens.to_data() if self.max_tokens else None,
163155
"allow_list": self.allow_list.to_data() if self.allow_list else None,
164-
"deny_list": self.deny_list.to_data() if self.deny_list else None
156+
"deny_list": self.deny_list.to_data() if self.deny_list else None,
165157
}
166158

167159
@classmethod
168160
def from_data(cls, data: dict) -> StakeAuthorization:
169161
return StakeAuthorization(
170162
authorization_type=data["authorization_type"],
171-
max_tokens=Coins.from_data(data["max_tokens"]) if data.get("max_tokens") else None,
172-
allow_list=StakeAuthorizationValidators.from_data(data["allow_list"]) if data.get("allow_list") else None,
173-
deny_list=StakeAuthorizationValidators.from_data(data["deny_list"]) if data.get("deny_list") else None
163+
max_tokens=Coins.from_data(data["max_tokens"])
164+
if data.get("max_tokens")
165+
else None,
166+
allow_list=StakeAuthorizationValidators.from_data(data["allow_list"])
167+
if data.get("allow_list")
168+
else None,
169+
deny_list=StakeAuthorizationValidators.from_data(data["deny_list"])
170+
if data.get("deny_list")
171+
else None,
174172
)
175173

176174
def to_proto(self) -> StakeAuthorization_pb:

terra_sdk/core/authz/msgs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def to_data(self) -> dict:
3939
return {
4040
"@type": self.type_url,
4141
"grantee": self.grantee,
42-
"msgs": [msg.to_data() for msg in self.msgs]
42+
"msgs": [msg.to_data() for msg in self.msgs],
4343
}
4444

4545
@classmethod
@@ -51,6 +51,7 @@ def from_data(cls, data: dict) -> MsgExecAuthorized:
5151
def to_proto(self) -> MsgExec_pb:
5252
return MsgExec_pb(grantee=self.grantee, msgs=[m.pack_any() for m in self.msgs])
5353

54+
5455
@attr.s
5556
class MsgGrantAuthorization(Msg):
5657
"""Grant an authorization to ``grantee`` to call messages on behalf of ``granter``.
@@ -75,7 +76,7 @@ def to_data(self) -> dict:
7576
"@type": self.type_url,
7677
"granter": self.granter,
7778
"grantee": self.grantee,
78-
"grant": self.grant.to_data()
79+
"grant": self.grant.to_data(),
7980
}
8081

8182
@classmethod

terra_sdk/core/bank/msgs.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ class MultiSendInput(JSONSerializable):
9797
"""Coins to be sent / received."""
9898

9999
def to_data(self) -> dict:
100-
return {
101-
"address": self.address,
102-
"coins": self.coins.to_data()
103-
}
100+
return {"address": self.address, "coins": self.coins.to_data()}
104101

105102
@classmethod
106103
def from_data(cls, data: dict):
@@ -141,10 +138,7 @@ def from_data(cls, data: dict):
141138
return cls(address=data["address"], coins=Coins.from_data(data["coins"]))
142139

143140
def to_data(self) -> dict:
144-
return {
145-
"address": self.address,
146-
"coins": self.coins.to_data()
147-
}
141+
return {"address": self.address, "coins": self.coins.to_data()}
148142

149143
@classmethod
150144
def from_proto(cls, proto: Output_pb) -> MultiSendOutput:

0 commit comments

Comments
 (0)