Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Transaction simulating doesn't work #8

Open
mbartn opened this issue Nov 24, 2020 · 1 comment
Open

Transaction simulating doesn't work #8

mbartn opened this issue Nov 24, 2020 · 1 comment

Comments

@mbartn
Copy link

mbartn commented Nov 24, 2020

  • Jigu version: 0.1.4
  • Python version: Python 3.7.9
  • Operating System: macOS Catalina 10.15.6 (19G2021)
  • Local Terra: newest master

Description

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).

What I Did

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/python@3.7/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.

@TomaszKot11
Copy link

Also not working for me :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants