Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: parse_coins not handling factory tokens #323

Open
4 tasks done
joaophi opened this issue Dec 21, 2022 · 0 comments
Open
4 tasks done

Bug report: parse_coins not handling factory tokens #323

joaophi opened this issue Dec 21, 2022 · 0 comments

Comments

@joaophi
Copy link

joaophi commented Dec 21, 2022

Prerequisites

Expected Behavior

Allow to execute contract with factory tokens funds like 33362484factory/kujira1r85reqy6h0lu02vyz0hnzhv5whsns55gdt4w0d7ft87utzk7u0wqr4ssll/uusk

Current Behavior

the parse_coins function is only picking the 33362484 and factory resulting in a failed to execute message; message index: 0: 0factory is smaller than 33362484factory: insufficient funds

root cause:

match = re.match(r"(\d+)(\w+)", part)

suggestion:

match = re.match(r"(\d+)([\w/]+)", part) 

To Reproduce

wallet = LocalWallet(private_key, prefix="kujira")

cfg = NetworkConfig(
    chain_id="harpoon-4",
    url="rest+https://lcd.harpoon.kujira.setten.io",
    fee_minimum_gas_price=0.025,
    fee_denomination="ukuji",
    staking_denomination="ukuji",
)
ledger_client = LedgerClient(cfg)

contract = LedgerContract(path=None, client=ledger_client, address=Address(
    "kujira1exd7mzv8azf7tpqukm6fzxnvdt7a8kddyz2puwzk9lm7qmlx3vxq0thezm"))

def submit_bid(premium_slot: int, funds: str) -> SubmittedTx:
    message = {"submit_bid": {"premium_slot": premium_slot}}
    tx = contract.execute(message, wallet, gas_limit=237153, funds=funds)
    return tx.wait_to_complete()


result = submit_bid(premium_slot=30, funds="33362484factory/kujira1r85reqy6h0lu02vyz0hnzhv5whsns55gdt4w0d7ft87utzk7u0wqr4ssll/uusk")

Context

Ubuntu 22.04.1 LTS
Python 3.10.6
cosmpy==0.6.2

Failure Logs

Traceback (most recent call last):
  File "/var/home/pedro/Projects/kujira-python-bot/main.py", line 49, in <module>
    result = submit_bid(premium_slot=10, funds="33362484factory/kujira1r85reqy6h0lu02vyz0hnzhv5whsns55gdt4w0d7ft87utzk7u0wqr4ssll/uusk")
  File "/var/home/pedro/Projects/kujira-python-bot/main.py", line 36, in submit_bid
    return tx.wait_to_complete()
  File "/var/home/pedro/Projects/kujira-python-bot/venv/lib/python3.10/site-packages/cosmpy/aerial/tx_helpers.py", line 178, in wait_to_complete
    self._response.ensure_successful()
  File "/var/home/pedro/Projects/kujira-python-bot/venv/lib/python3.10/site-packages/cosmpy/aerial/tx_helpers.py", line 96, in ensure_successful
    raise BroadcastError(self.hash, self.raw_log)
cosmpy.aerial.exceptions.BroadcastError: failed to execute message; message index: 0: 0factory is smaller than 33362484factory: insufficient funds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant