Skip to content

Commit 07b60d6

Browse files
authored
Merge pull request #86 from InjectiveLabs/f/add_send_to_cosmos
feat: add SendToCosmos
2 parents 7446cd6 + f9c7ce3 commit 07b60d6

File tree

5 files changed

+97
-290
lines changed

5 files changed

+97
-290
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ python pyinjective/fetch_metadata.py
8383
* Add root CA certs for mainnet & testnet for secure gRPC connections
8484
* Add method to unpack responses inside MsgExec
8585
* Fix type hints in composer & clients
86-
* Add Peggy contract ABIs for mainnet & testnet
86+
* Add Peggy contract ABI
8787
* Add reduce-only support for market orders
8888
* Add sticky session cookie for broadcast methods
8989
* Add historical funding rates in clients
9090
* Minor fixes in spot conversions for price/quantity returned from the backend
91-
* Add MsgSendToEth in the composer
91+
* Add MsgSendToEth & SendToCosmos in the composer for INJ <> ETH transfers
9292
* Add function to compute order hashes locally
9393

9494
**0.5.6.3**

examples/SendToCosmos.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import json
2+
import requests
3+
4+
import asyncio
5+
import logging
6+
7+
from pyinjective.constant import Network
8+
from pyinjective.composer import Composer as ProtoMsgComposer
9+
10+
import importlib.resources as pkg_resources
11+
import pyinjective
12+
13+
async def main() -> None:
14+
# select network: testnet, mainnet
15+
network = Network.testnet()
16+
composer = ProtoMsgComposer(network=network.string())
17+
18+
private_key = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3"
19+
ethereum_endpoint = "https://kovan.infura.io/v3/c518f454950e48aeab12161c49f26e30"
20+
21+
maxFeePerGas_Gwei = 4
22+
maxPriorityFeePerGas_Gwei = 4
23+
24+
token_contract = "0x36b3d7ace7201e28040eff30e815290d7b37ffad"
25+
receiver = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku"
26+
amount = 1
27+
28+
import_peggo = pkg_resources.read_text(pyinjective, 'Peggo_ABI.json')
29+
peggo_abi = json.loads(import_peggo)
30+
31+
composer.SendToCosmos(ethereum_endpoint=ethereum_endpoint, private_key=private_key, token_contract=token_contract,
32+
receiver=receiver, amount=amount, maxFeePerGas=maxFeePerGas_Gwei, maxPriorityFeePerGas=maxPriorityFeePerGas_Gwei, peggo_abi=peggo_abi)
33+
34+
if __name__ == "__main__":
35+
logging.basicConfig(level=logging.INFO)
36+
asyncio.get_event_loop().run_until_complete(main())

pyinjective/Peggo_ABI_Testnet.json

Lines changed: 0 additions & 288 deletions
This file was deleted.

0 commit comments

Comments
 (0)