Skip to content

Commit 8d64346

Browse files
authored
Merge pull request #10 from geoffmunn/documentation_updates
Documentation updates
2 parents 7bac37f + edfe69a commit 8d64346

29 files changed

+1446
-273
lines changed

Diff for: dist/terra_classic_sdk-2.0.7-py3-none-any.whl

-124 KB
Binary file not shown.

Diff for: dist/terra_classic_sdk-2.0.7.tar.gz

-86.1 KB
Binary file not shown.

Diff for: docs/common/bech32.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ they take a type like :class:`AccAddress` where one may expect a ``str``. It is
88
type alias annotation (equivalent to ``str``) that serves only to remind the developer
99
which format the string is expected to be in.
1010

11-
Terra SDK also provides useful functions for checking and converting **addresses** and **pubkeys**.
11+
The Terra Classic SDK also provides useful functions for checking and converting **addresses** and **pubkeys**.
1212

1313
Addresses
1414
---------

Diff for: docs/common/numeric.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Numeric Types
99
Integers
1010
--------
1111

12-
Terra SDK uses Python's native ``int`` type to capture both native numbers like ``uint8``, as well
12+
The Terra Classic SDK uses Python's native ``int`` type to capture both native numbers like ``uint8``, as well
1313
as Cosmos SDK's ``sdk.Int`` which is normally coerced into a string as it must be passed in JSON format.
1414
The Python's ``int`` provides support for BigNumber implementation for artihmetic operations.
1515

1616
.. warning::
17-
It is possible to introduce numbers larger than 256-bit precision allowed by Terra blockchain but
17+
It is possible to introduce numbers larger than 256-bit precision allowed by the Terra Classic blockchain but
1818
they will result in an error when processing.
1919

2020

Diff for: docs/conf.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
# -- Project information -----------------------------------------------------
2121

22-
project = "Terra SDK"
23-
copyright = "2021, Terraform Labs, PTE."
24-
author = "Terraform Labs, PTE."
22+
project = "Terra Classic SDK"
23+
copyright = "License: CC-BY-SA-4.0"
24+
author = "Geoff Munn"
2525

2626
# The full version, including alpha/beta/rc tags
27-
release = "2.0.3"
27+
release = "2.0.4"
2828

2929

3030
# -- General configuration ---------------------------------------------------

Diff for: docs/guides/async.rst

+30-17
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Async module APIs
1010
You can replace your LCDClient instance with AsyncLCDClient inside a coroutine function:
1111

1212
.. code-block:: python
13-
:emphasize-lines: 5,8
1413
1514
import asyncio
1615
from terra_classic_sdk.client.lcd import AsyncLCDClient
@@ -21,14 +20,13 @@ You can replace your LCDClient instance with AsyncLCDClient inside a coroutine f
2120
print(total_supply)
2221
await terra.session.close() # you must close the session
2322
24-
asyncio.get_event_loop().run_until_complete(main())
23+
asyncio.run(main())
2524
2625
2726
For convenience, you can use the async context manager to automatically teardown the
2827
session. Here's the same code as above, this time using the ``async with`` construct.
2928

3029
.. code-block:: python
31-
:emphasize-lines: 5
3230
3331
import asyncio
3432
from terra_classic_sdk.client.lcd import AsyncLCDClient
@@ -38,7 +36,7 @@ session. Here's the same code as above, this time using the ``async with`` const
3836
total_supply = await terra.bank.total()
3937
print(total_supply)
4038
41-
asyncio.get_event_loop().run_until_complete(main())
39+
asyncio.run(main())
4240
4341
Async wallet API
4442
----------------
@@ -47,28 +45,30 @@ When creating a wallet with AsyncLCDClient, the wallet's methods that create LCD
4745
are also asychronous and therefore must be awaited.
4846

4947
.. code-block:: python
50-
:emphasize-lines: 12-13
5148
5249
import asyncio
5350
from terra_classic_sdk.client.lcd.api.tx import CreateTxOptions
5451
from terra_classic_sdk.client.lcd import AsyncLCDClient
52+
from terra_classic_sdk.core.bank import MsgSend
5553
from terra_classic_sdk.key.mnemonic import MnemonicKey
5654
from terra_classic_sdk.core import Coins
55+
from terra_classic_sdk.core.tx import Tx
5756
58-
mk = MnemonicKey()
59-
recipient = "terra1..."
57+
mk = MnemonicKey(mnemonic='secret 24 word phrase')
58+
recipient = "terra..."
6059
6160
async def main():
6261
async with AsyncLCDClient("https://terra-classic-lcd.publicnode.com", "columbus-5") as terra:
6362
wallet = terra.wallet(mk)
64-
account_number = await wallet.account_number()
65-
tx = await wallet.create_and_sign_tx(
63+
tx:Tx = await wallet.create_and_sign_tx(
6664
CreateTxOptions(
67-
msgs=[MsgSend(wallet.key.acc_address, recipient, Coins(uluna=10202))]
65+
msgs=[MsgSend(wallet.key.acc_address, recipient, Coins(uluna=100000000))]
6866
)
6967
)
70-
71-
asyncio.get_event_loop().run_until_complete(main())
68+
69+
print (tx.auth_info.fee)
70+
71+
asyncio.run(main())
7272
7373
Alternative event loops
7474
-----------------------
@@ -77,16 +77,29 @@ The native ``asyncio`` event loop can be replaced with an alternative such as ``
7777
for more performance. For example:
7878

7979
.. code-block:: python
80-
:emphasize-lines: 2, 10
8180
8281
import asyncio
8382
import uvloop
84-
83+
from terra_classic_sdk.client.lcd.api.tx import CreateTxOptions
8584
from terra_classic_sdk.client.lcd import AsyncLCDClient
85+
from terra_classic_sdk.core.bank import MsgSend
86+
from terra_classic_sdk.key.mnemonic import MnemonicKey
87+
from terra_classic_sdk.core import Coins
88+
from terra_classic_sdk.core.tx import Tx
89+
90+
mk = MnemonicKey(mnemonic='secret 24 word phrase')
91+
recipient = "terra..."
8692
8793
async def main():
8894
async with AsyncLCDClient("https://terra-classic-lcd.publicnode.com", "columbus-5") as terra:
89-
total_supply = await wallet.bank.total()
95+
wallet = terra.wallet(mk)
96+
tx:Tx = await wallet.create_and_sign_tx(
97+
CreateTxOptions(
98+
msgs=[MsgSend(wallet.key.acc_address, recipient, Coins(uluna=100000000))]
99+
)
100+
)
101+
102+
print (tx.auth_info.fee)
90103
91-
uvloop.install()
92-
asyncio.get_event_loop().run_until_complete(main())
104+
uvloop.install()
105+
asyncio.run(main())

Diff for: docs/guides/custom_key.rst

+27-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
Implementing a Custom Key
44
=========================
55

6-
If none of the Key solutions provided by Terra Classic SDK or the community are able to meet your requirements,
6+
If none of the Key solutions provided by the Terra Classic SDK or the community are able to meet your requirements,
77
you might consider writing your own Key implementation.
88

9-
Here are just a couple that help guide
10-
your design pathways:
9+
Here are just a couple that help guide your design pathways:
1110

1211
Is the private key accessible by developer?
1312
* YES: Subclass :class:`terra_classic_sdk.key.raw.RawKey`
@@ -26,13 +25,13 @@ Usually, reasons for requiring a custom Key fall into one of 3 patterns:
2625

2726
* External signing
2827

29-
**Scenario:** The transaction signing is to be performed outside the Python program running Terra Classic SDK,
28+
**Scenario:** The transaction signing is to be performed outside the Python program running the Terra Classic SDK,
3029
such as signing via hardware wallet (Ledger, Trezor), etc.
3130

3231

3332
* Alternative signing algorithm
3433

35-
**Scenario:** Terra Classic account you need to sign transactions for requires a signature algorithm other than
34+
**Scenario:** The Terra Classic account you need to sign transactions for requires a signature algorithm other than
3635
ECDSA on Secp256k1, such as Threshold Multisig or Ed25519.
3736

3837

@@ -49,14 +48,34 @@ The source for MnemonicKey is provided as an example:
4948
from bip32utils import BIP32_HARDEN, BIP32Key
5049
from mnemonic import Mnemonic
5150
51+
coin_types = {
52+
'cosmos': 118,
53+
'juno': 118,
54+
'kava': 459,
55+
'kujira': 118,
56+
'osmo': 118,
57+
'terra': 330,
58+
'emoney': 118,
59+
'sif': 118,
60+
'inj': 60, # Possibly wrong coin type
61+
'axelar': 118,
62+
'umee': 118,
63+
'omniflix': 118,
64+
'gravity': 118,
65+
'somm': 118
66+
}
67+
5268
class MnemonicKey(RawKey):
5369
def __init__(
5470
self,
5571
mnemonic: str = None,
5672
account: int = 0,
5773
index: int = 0,
58-
coin_type: int = 330,
74+
prefix:str = 'terra'
5975
):
76+
77+
coin_type = coin_types[prefix]
78+
6079
if mnemonic is None:
6180
mnemonic = Mnemonic("english").generate(256)
6281
seed = Mnemonic("english").to_seed(mnemonic)
@@ -72,5 +91,7 @@ The source for MnemonicKey is provided as an example:
7291
7392
super().__init__(child.PrivateKey())
7493
self.mnemonic = mnemonic
94+
self.coin_type = coin_type
7595
self.account = account
7696
self.index = index
97+
self.address_prefix = prefix

Diff for: docs/guides/lcdclient.rst

+42-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
LCDClient
22
=========
33

4-
The :class:`LCDClient` is an object representing a HTTP connection to a Terra LCD node.
4+
The :class:`LCDClient` is an object representing a HTTP connection to a Terra Classic LCD node.
55

66
Get connected
77
-------------
@@ -16,24 +16,29 @@ Create a new LCDClient instance by specifying the URL and chain ID of the node t
1616
>>> from terra_classic_sdk.client.lcd import LCDClient
1717
>>> terra = LCDClient(url="https://terra-classic-lcd.publicnode.com", chain_id="columbus-5")
1818
>>> terra.tendermint.node_info()['default_node_info']['network']
19+
1920
'columbus-5'
2021
2122
You can also specify gas estimation parameters for your chain for building transactions.
2223

2324
.. code-block:: python
24-
:emphasize-lines: 8-9
2525
26-
import requests
27-
from terra_classic_sdk.core import Coins
26+
>>> import requests
27+
>>> from terra_classic_sdk.client.lcd import LCDClient
28+
>>> from terra_classic_sdk.core import Coins
2829
29-
res = requests.get("https://terra-classic-fcd.publicnode.com/v1/txs/gas_prices")
30-
terra = LCDClient(
31-
url="https://terra-classic-lcd.publicnode.com",
32-
chain_id="columbus-5",
33-
gas_prices=Coins(res.json()),
34-
gas_adjustment="1.4"
35-
)
30+
>>> res = requests.get("https://terra-classic-fcd.publicnode.com/v1/txs/gas_prices")
3631
32+
>>> terra = LCDClient(
33+
url="https://terra-classic-lcd.publicnode.com",
34+
chain_id="columbus-5",
35+
gas_prices=Coins(res.json()),
36+
gas_adjustment="1.4"
37+
)
38+
39+
>>> terra.gas_prices
40+
41+
Coins('0.95uaud,0.95ucad,0.7uchf,4.9ucny,4.5udkk,0.625ueur,0.55ugbp,5.85uhkd,10900.0uidr,54.4uinr,81.85ujpy,850.0ukrw,28.325uluna,2142.855umnt,3.0umyr,6.25unok,38.0uphp,0.52469usdr,6.25usek,1.0usgd,23.1uthb,20.0utwd,0.75uusd')
3742
3843
Using the module APIs
3944
---------------------
@@ -46,15 +51,21 @@ Each request fetches live data from the blockchain:
4651

4752
.. code-block:: python
4853
54+
>>> from terra_classic_sdk.client.lcd import LCDClient
55+
>>> terra = LCDClient(url="https://terra-classic-lcd.publicnode.com", chain_id="columbus-5")
4956
>>> terra.market.parameters()
50-
{'base_pool': '7000000000000.000000000000000000', 'pool_recovery_period': '200', 'min_spread': '0.005000000000000000'}
57+
58+
{'base_pool': Dec('100000000000000'), 'pool_recovery_period': 18, 'min_stability_spread': Dec('1')}
5159
5260
The height of the last result (if applicable) is available:
5361

5462
.. code-block:: python
5563
56-
>>> terra.last_request_height
57-
89292
64+
>>> from terra_classic_sdk.client.lcd import LCDClient
65+
>>> terra = LCDClient(url="https://terra-classic-lcd.publicnode.com", chain_id="columbus-5")
66+
>>> terra.treasury.tax_rate()
67+
68+
0.005000000000000000
5869
5970
6071
Create a wallet
@@ -65,11 +76,25 @@ are useful for easily creating and signing transactions.
6576

6677
.. code-block:: python
6778
79+
>>> import requests
80+
>>> from terra_classic_sdk.client.lcd import LCDClient
81+
>>> from terra_classic_sdk.client.lcd.wallet import Wallet
82+
>>> from terra_classic_sdk.core import Coins
6883
>>> from terra_classic_sdk.key.mnemonic import MnemonicKey
69-
>>> mk = MnemonicKey()
70-
>>> wallet = terra.wallet(mk)
84+
85+
>>> res = requests.get("https://terra-classic-fcd.publicnode.com/v1/txs/gas_prices")
86+
87+
>>> mk = MnemonicKey(mnemonic='secret 24 word phrase')
88+
>>> terra = LCDClient(
89+
url="https://terra-classic-lcd.publicnode.com",
90+
chain_id="columbus-5",
91+
gas_prices=Coins(res.json()),
92+
gas_adjustment="1.4"
93+
)
94+
>>> wallet:Wallet = terra.wallet(mk)
7195
>>> wallet.account_number()
72-
27
96+
97+
5151262
7398
7499
75100
LCDClient Reference

Diff for: docs/guides/pagination.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,26 @@ PaginationOption
1515
You can use PaginationOptions as APIParams for params of query functions.
1616

1717
.. code-block:: python
18-
:emphasize-lines: 5,8
1918
2019
from terra_classic_sdk.client.lcd import LCDClient, PaginationOptions
2120
2221
terra = LCDClient(
2322
url="https://terra-classic-lcd.publicnode.com",
24-
chain_id="columbus-5",
23+
chain_id="columbus-5"
2524
)
2625
27-
2826
result, pagination = terra.gov.proposals()
2927
28+
page_count:int = 1
3029
while pagination["next_key"] is not None:
3130
pagOpt = PaginationOptions(key=pagination["next_key"])
32-
result, pagination = terra.gov.proposals(params=pagOpt)
31+
proposals, pagination = terra.gov.proposals(params=pagOpt)
3332
pagOpt.key = pagination["next_key"]
34-
print(result)
33+
34+
print ('****************')
35+
print (f'Page number {page_count}')
36+
for proposal in proposals:
37+
print (proposal.content.title)
38+
39+
page_count += 1
3540

0 commit comments

Comments
 (0)