Skip to content

Commit 0652401

Browse files
committed
(feat) Refactor Composer to use actual markets and tokens to translate human-readable values into chain format
1 parent ee19f3f commit 0652401

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1308
-659
lines changed

Pipfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ websockets = "*"
2323
[dev-packages]
2424
pytest = "*"
2525
pytest-asyncio = "*"
26-
pytest-grpc = "*"
2726

2827
[requires]
2928
python_version = "3"

Pipfile.lock

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ make tests
8787
```
8888

8989
### Changelogs
90-
**0.6.3**(change before release)
90+
**0.7**(change before release)
9191
* Change logging logic to use different loggers for each module and class
92+
* Refactor Composer to be created with all the markets and tokens. The Composer now uses the real markets and tokens to convert human-readable values to chain format
93+
* The Composer can still be instantiated without markets and tokens. When markets and tokens are not provided the Composer loads the required information from the Denoms used in previous versions
94+
* Change in AsyncClient to be able to create Composer instances for the client network, markets and tokens
95+
* Examples have been adapted to create Composer instances using the AsyncClient
9296
* Add `pytest` as a development dependency to implement and run unit tests
9397

9498
**0.6.2.7**

examples/chain_client/0_LocalOrderHash.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
2-
import logging
32

4-
from pyinjective.composer import Composer as ProtoMsgComposer
53
from pyinjective.async_client import AsyncClient
64
from pyinjective.transaction import Transaction
75
from pyinjective.constant import Network
@@ -11,10 +9,10 @@
119
async def main() -> None:
1210
# select network: local, testnet, mainnet
1311
network = Network.testnet()
14-
composer = ProtoMsgComposer(network=network.string())
1512

1613
# initialize grpc client
1714
client = AsyncClient(network, insecure=False)
15+
composer = await client.composer()
1816
await client.sync_timeout_height()
1917

2018
# load account

examples/chain_client/13_MsgIncreasePositionMargin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
2-
import logging
32

4-
from pyinjective.composer import Composer as ProtoMsgComposer
53
from pyinjective.async_client import AsyncClient
64
from pyinjective.transaction import Transaction
75
from pyinjective.constant import Network
@@ -11,10 +9,10 @@
119
async def main() -> None:
1210
# select network: local, testnet, mainnet
1311
network = Network.testnet()
14-
composer = ProtoMsgComposer(network=network.string())
1512

1613
# initialize grpc client
1714
client = AsyncClient(network, insecure=False)
15+
composer = await client.composer()
1816
await client.sync_timeout_height()
1917

2018
# load account

examples/chain_client/15_MsgWithdraw.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
# limitations under the License.
1414

1515
import asyncio
16-
import logging
1716

18-
from pyinjective.composer import Composer as ProtoMsgComposer
1917
from pyinjective.async_client import AsyncClient
2018
from pyinjective.transaction import Transaction
2119
from pyinjective.constant import Network
@@ -25,10 +23,10 @@
2523
async def main() -> None:
2624
# select network: local, testnet, mainnet
2725
network = Network.testnet()
28-
composer = ProtoMsgComposer(network=network.string())
2926

3027
# initialize grpc client
3128
client = AsyncClient(network, insecure=False)
29+
composer = await client.composer()
3230
await client.sync_timeout_height()
3331

3432
# load account

examples/chain_client/16_MsgSubaccountTransfer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
2-
import logging
32

4-
from pyinjective.composer import Composer as ProtoMsgComposer
53
from pyinjective.async_client import AsyncClient
64
from pyinjective.transaction import Transaction
75
from pyinjective.constant import Network
@@ -11,10 +9,10 @@
119
async def main() -> None:
1210
# select network: local, testnet, mainnet
1311
network = Network.testnet()
14-
composer = ProtoMsgComposer(network=network.string())
1512

1613
# initialize grpc client
1714
client = AsyncClient(network, insecure=False)
15+
composer = await client.composer()
1816
await client.sync_timeout_height()
1917

2018
# load account

examples/chain_client/17_MsgBatchUpdateOrders.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
2-
import logging
32

4-
from pyinjective.composer import Composer as ProtoMsgComposer
53
from pyinjective.async_client import AsyncClient
64
from pyinjective.transaction import Transaction
75
from pyinjective.constant import Network
@@ -11,10 +9,10 @@
119
async def main() -> None:
1210
# select network: local, testnet, mainnet
1311
network = Network.testnet()
14-
composer = ProtoMsgComposer(network=network.string())
1512

1613
# initialize grpc client
1714
client = AsyncClient(network, insecure=False)
15+
composer = await client.composer()
1816
await client.sync_timeout_height()
1917

2018
# load account
@@ -132,7 +130,7 @@ async def main() -> None:
132130
print(sim_res)
133131
return
134132

135-
sim_res_msg = ProtoMsgComposer.MsgResponses(sim_res.result.data, simulation=True)
133+
sim_res_msg = composer.MsgResponses(sim_res.result.data, simulation=True)
136134
print("---Simulation Response---")
137135
print(sim_res_msg)
138136

examples/chain_client/18_MsgBid.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
2-
import logging
32

4-
from pyinjective.composer import Composer as ProtoMsgComposer
53
from pyinjective.async_client import AsyncClient
64
from pyinjective.transaction import Transaction
75
from pyinjective.constant import Network
@@ -10,10 +8,10 @@
108
async def main() -> None:
119
# select network: local, testnet, mainnet
1210
network = Network.testnet()
13-
composer = ProtoMsgComposer(network=network.string())
1411

1512
# initialize grpc client
1613
client = AsyncClient(network, insecure=False)
14+
composer = await client.composer()
1715
await client.sync_timeout_height()
1816

1917
# load account

examples/chain_client/19_MsgGrant.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
2-
import logging
32

4-
from pyinjective.composer import Composer as ProtoMsgComposer
53
from pyinjective.async_client import AsyncClient
64
from pyinjective.transaction import Transaction
75
from pyinjective.constant import Network
@@ -11,10 +9,10 @@
119
async def main() -> None:
1210
# select network: local, testnet, mainnet
1311
network = Network.testnet()
14-
composer = ProtoMsgComposer(network=network.string())
1512

1613
# initialize grpc client
1714
client = AsyncClient(network, insecure=False)
15+
composer = await client.composer()
1816
await client.sync_timeout_height()
1917

2018
# load account

0 commit comments

Comments
 (0)