terra-money / jigu Goto Github PK
View Code? Open in Web Editor NEWThe Python SDK for Terra.
Home Page: https://jigu.terra.money/
License: MIT License
The Python SDK for Terra.
Home Page: https://jigu.terra.money/
License: MIT License
I try to send a transaction with automated fee estimation on local network using jigu. To set it up I used the newest version of Local Terra. Terra station successfully connected to the Local Terra and I am able to perform operations. Unfortunately, when I try to perform transaction with jigu (e.g. send Luna tokens) it throws on simulating fee transaction (code shown below).
Here is a minimal working example with Local Terra:
from jigu import Terra
from jigu.core import AccAddress, Coin
from jigu.core.msg import MsgSend
from jigu.key.mnemonic import MnemonicKey
terra = Terra('localterra', 'http://0.0.0.0:1317/')
key = MnemonicKey(
'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius')
wallet = terra.wallet(key)
msg = MsgSend(
from_address=AccAddress('terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v'),
to_address=AccAddress('terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp'),
amount=[Coin("uluna", 3000)]
)
send_tx = wallet.create_and_sign_tx(
msg)
print(send_tx)
Here is the output:
/usr/local/opt/[email protected]/bin/python3 /Users/michal/repo/python-toy/main.py
Traceback (most recent call last):
File "/Users/michal/repo/python-toy/main.py", line 17, in <module>
msg)
File "/usr/local/lib/python3.7/site-packages/jigu/client/object_query/wallet.py", line 75, in create_and_sign_tx
return self.sign_tx(self.create_tx(*msgs, fee=fee, memo=memo))
File "/usr/local/lib/python3.7/site-packages/jigu/client/object_query/wallet.py", line 50, in create_tx
fee = self.terra.tx.estimate_fee(tx)
File "/usr/local/lib/python3.7/site-packages/jigu/client/lcd/api/tx.py", line 79, in estimate_fee
res = self._api_post("/txs/estimate_fee", data=data)
File "/usr/local/lib/python3.7/site-packages/jigu/client/lcd/api/__init__.py", line 79, in _api_post
return self._handle_response(self.terra.lcd.post(path, **kwargs), unwrap)
File "/usr/local/lib/python3.7/site-packages/jigu/client/lcd/lcdclient.py", line 111, in post
return self._request("post", path, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jigu/client/lcd/lcdclient.py", line 88, in _request
return self.handle_response(response)
File "/usr/local/lib/python3.7/site-packages/jigu/client/lcd/lcdclient.py", line 82, in handle_response
r = resp_m(self, r)
File "/usr/local/lib/python3.7/site-packages/jigu/client/lcd/middlewares.py", line 87, in handle_general_errors
raise LcdInternalError(response.status_code, error_msg, response.request)
jigu.error.LcdInternalError: (500) invalid request: must contain at least one message: failed to simulate tx
Process finished with exit code 1
This example works when i change line:
send_tx = wallet.create_and_sign_tx(
msg
)
to
send_tx = wallet.create_and_sign_tx(
msg,
fee=StdFee.make(gas=200_000, uluna=1_000_000)
)
I investigated the problem a little bit and looks like jigu sends post request to /txs/estimate_fee
endpoint with incorrectly structured body.
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
list all signing info as indicated here.
>>> from jigu import Terra
>>> terra = Terra("columbus-3", "https://lcd.terra.dev")
>>> terra.is_connected()
True
>>> terra.slashing.signing_info_by_address()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/etienne/Library/Caches/pypoetry/virtualenvs/valmailer-tZO3ahg3-py3.7/lib/python3.7/site-packages/jigu/client/lcd/api/modules/slashing.py", line 36, in signing_info_by_address
validate_val_consaddress(address)
File "/Users/etienne/Library/Caches/pypoetry/virtualenvs/valmailer-tZO3ahg3-py3.7/lib/python3.7/site-packages/jigu/util/validation.py", line 84, in validate_val_consaddress
if not is_val_consaddress(data):
File "/Users/etienne/Library/Caches/pypoetry/virtualenvs/valmailer-tZO3ahg3-py3.7/lib/python3.7/site-packages/jigu/util/validation.py", line 45, in is_val_consaddress
is_bech32(data)
File "/Users/etienne/Library/Caches/pypoetry/virtualenvs/valmailer-tZO3ahg3-py3.7/lib/python3.7/site-packages/jigu/util/validation.py", line 20, in is_bech32
return bech32.bech32_decode(data) != (None, None,)
File "/Users/etienne/Library/Caches/pypoetry/virtualenvs/valmailer-tZO3ahg3-py3.7/lib/python3.7/site-packages/bech32/__init__.py", line 66, in bech32_decode
if (any(ord(x) < 33 or ord(x) > 126 for x in bech)) or (
TypeError: 'NoneType' object is not iterable
I can't send calls with parameters with jigu testnet because the SSL cert is expired.
requests.exceptions.SSLError: HTTPSConnectionPool(host='soju-lcd.terra.dev', port=443): Max retries exceeded with url: /auth/accounts/terra1pqj9aec7wh2qlxwwhrxvts6vypeq3nd3xl5e6w (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)')))
was trying
wallet.balance('uluna')
@ouiliame @etienne-napoleone
_api_post("/txs/estimate_fee")
returns the title error.
terra = Terra("tequila-0004", "https://tequila-lcd.terra.dev")
...
send = MsgSend(from_address=wallet.address, to_address=to, amount=[Coin("uluna", 3000)])
# no error
fee = StdFee.make(gas=200_000, uluna=1_000_000)
tx = wallet.create_and_sign_tx(send, fee=fee)
# error
tx2 = wallet.create_and_sign_tx(send)
This is the stack trace:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/object_query/wallet.py", line 75, in create_and_sign_tx
return self.sign_tx(self.create_tx(*msgs, fee=fee, memo=memo))
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/object_query/wallet.py", line 50, in create_tx
fee = self.terra.tx.estimate_fee(tx)
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/lcd/api/tx.py", line 79, in estimate_fee
res = self._api_post("/txs/estimate_fee", data=data)
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/lcd/api/__init__.py", line 79, in _api_post
return self._handle_response(self.terra.lcd.post(path, **kwargs), unwrap)
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/lcd/lcdclient.py", line 111, in post
return self._request("post", path, **kwargs)
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/lcd/lcdclient.py", line 88, in _request
return self.handle_response(response)
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/lcd/lcdclient.py", line 82, in handle_response
r = resp_m(self, r)
File "/Users/yp/bin/miniconda3/envs/bcbank/lib/python3.7/site-packages/jigu/client/lcd/middlewares.py", line 87, in handle_general_errors
raise LcdInternalError(response.status_code, error_msg, response.request)
jigu.error.LcdInternalError: (500) invalid request: must contain at least one message: failed to simulate tx
Hey,
Trying to follow the getting started instructions and send some Lunas across Tequila-0004.
When trying to send a transaction that encounters an error, it is not parsed properly, yielding a json.decoder.JSONDecodeError
.
In jigu/client/lcd/api/tx.py:120 (json.loads(res["raw_log"])
), the assumption, that raw_log
is a valid JSON does not hold true. These two examples show what res
contained for two different errors, in which the raw_log
isn't a valid JSON.
I'm not sure whether this is a jigu issue, or a bad response returned by the server-side.
This happens for two errors I was able to generate:
{'height': '0', 'txhash': 'A1D2D6DA98C0192A2F559BA51E40F2CA90F4E8354AFD6C96B4F2E919B388D6B1', 'codespace': 'sdk', 'code': 11, 'raw_log': 'out of gas: out of gas in location: WriteFlat; gasWanted: 50000, gasUsed: 51899', 'gas_wanted': '50000', 'gas_used': '51899'}
{'height': '0', 'txhash': '150ABCFB784A5E2F68B5316AC1AD5AC490E16D3C952D90D6F172E45497E4A77D', 'codespace': 'sdk', 'code': 13, 'raw_log': 'insufficient fee: insufficient fees; got: "7500uluna", required: "9258600ukrw,7800uluna,22444547umnt,5294usdr,7800uusd" = "9258600ukrw,7800uluna,22444547umnt,5294usdr,7800uusd"(gas) +""(stability)', 'gas_wanted': '52000', 'gas_used': '1054'}
Use the following snippet to reproduce:
jg = Terra("tequila-0004", "https://tequila-lcd.terra.dev")
wallet_a = jg.wallet(MnemonicKey.generate())
wallet_b = jg.wallet(MnemonicKey.generate())
send = MsgSend(
from_address=wallet_a.address,
to_address=wallet_b.address,
amount=Coins(uluna=20000000)
)
fee = StdFee.make(55000, uluna=7800) # include a small fee..
tx = wallet_a.create_and_sign_tx(send, memo="memo", fee=fee)
res = wallet_a.broadcast(tx)
Thanks!
def balance(self, denom: Optional[str] = None) -> Union[ApiResponse, Coin, Coins]:
Querying balance thru Jigu
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
AccountQuery has not attribute "balances"
Update the doc so it shows actual method "balance" instead of balances
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.