terra.py icon indicating copy to clipboard operation
terra.py copied to clipboard

The latest version does not support Classic Network

Open weiailjx opened this issue 2 years ago • 8 comments

  • terra_sdk version:3.0.1
  • Python version:3.9
  • Operating System:win 10

Description

I want to connect to classic Network,but I can't find the chain_id.

What I Did

from terra_sdk.client.lcd import LCDClient
terra = LCDClient(chain_id="columbus-5", url=" https://lcd.terra.dev ")

weiailjx avatar Sep 10 '22 20:09 weiailjx

I installed terra_sdk version : 2.0.5, but found an error.

ModuleNotFoundError: No module named 'terra_proto.terra'

weiailjx avatar Sep 10 '22 20:09 weiailjx

@weiailjx Try to use terra_sdk v2.0.6

JSHan94 avatar Sep 11 '22 05:09 JSHan94

@JSHan94 I installed terra_sdk v2.0.6, but the same error as terra_sdk v2.0.5 occurred

weiailjx avatar Sep 11 '22 19:09 weiailjx

Same problem. I downgraded to 2.0.6 and get an error regarding terra_proto module is missing.

But it is installed, I can import it to a script without any errors. And when I downgraded, terminal showed terra-proto was downgraded too:

  Updating terra-proto (2.1.0 -> 1.1.0)
  Updating terra-sdk (3.0.1 -> 2.0.6)

Running a script to get the supply returns this error:

Traceback (most recent call last):
  File "/terra.py", line 1, in <module>
    from terra_sdk.client.lcd import LCDClient
  File "/python3.10/site-packages/terra_sdk/client/lcd/__init__.py", line 1, in <module>
    from .lcdclient import AsyncLCDClient, LCDClient
  File "/python3.10/site-packages/terra_sdk/client/lcd/lcdclient.py", line 11, in <module>
    from terra_sdk.core import Coins, Dec, Numeric
  File "/python3.10/site-packages/terra_sdk/core/__init__.py", line 38, in <module>
    from .sign_doc import SignDoc
  File "/python3.10/site-packages/terra_sdk/core/sign_doc.py", line 10, in <module>
    from terra_sdk.core.tx import AuthInfo, TxBody
  File "/python3.10/site-packages/terra_sdk/core/tx.py", line 46, in <module>
    from terra_sdk.util.parse_msg import parse_proto
  File "/python3.10/site-packages/terra_sdk/util/parse_msg.py", line 37, in <module>
    from terra_sdk.core.market import MsgSwap, MsgSwapSend
  File "/python3.10/site-packages/terra_sdk/core/market/__init__.py", line 1, in <module>
    from .msgs import MsgSwap, MsgSwapSend
  File "/python3.10/site-packages/terra_sdk/core/market/msgs.py", line 6, in <module>
    from terra_proto.terra.market.v1beta1 import MsgSwap as MsgSwap_pb
ModuleNotFoundError: No module named 'terra_proto.terra'

kartzke avatar Sep 23 '22 03:09 kartzke

Same problem. As a quick test, I tried restoring the chain ID to the LCD client, but requests for tx data give back a 403 response: LCDResponseError: Status 403 - None

    if chain_id == "columbus-5":
         return [Coins.from_str("0.15uusd"), Numeric.parse(1.75)]

@JSHan94 Any ideas for a fix on this?

ThinksFast avatar Sep 23 '22 10:09 ThinksFast

if chain_id == "columbus-5": return [Coins.from_str("0.15uusd"), Numeric.parse(1.75)]

If you are getting the "chain_id is invalid" error, add the quoted lines to the lcdclient.py file:

def get_default(chain_id: str) -> List[Coins, Numeric]:
    if chain_id == "phoenix-1":
        return [Coins.from_str("0.15uluna"), Numeric.parse(1.75)]
    if chain_id == "pisco-1":
        return [Coins.from_str("0.15uluna"), Numeric.parse(1.75)]
    if chain_id == "columbus-5":
         return [Coins.from_str("0.15uusd"), Numeric.parse(1.75)]
    if chain_id == "localterra":
        return [Coins.from_str("0.15uluna"), Numeric.parse(1.75)]

    raise ValueError("chain_id is invalid")

This works with terra-skd version 3.0.1 and terra-proto version 2.1.0.

geoffmunn avatar Dec 23 '22 19:12 geoffmunn

if chain_id == "columbus-5": return [Coins.from_str("0.15uusd"), Numeric.parse(1.75)]

If you are getting the "chain_id is invalid" error, add the quoted lines to the lcdclient.py file:

def get_default(chain_id: str) -> List[Coins, Numeric]:
    if chain_id == "phoenix-1":
        return [Coins.from_str("0.15uluna"), Numeric.parse(1.75)]
    if chain_id == "pisco-1":
        return [Coins.from_str("0.15uluna"), Numeric.parse(1.75)]
    if chain_id == "columbus-5":
         return [Coins.from_str("0.15uusd"), Numeric.parse(1.75)]
    if chain_id == "localterra":
        return [Coins.from_str("0.15uluna"), Numeric.parse(1.75)]

    raise ValueError("chain_id is invalid")

This works with terra-skd version 3.0.1 and terra-proto version 2.1.0.

UPDATE: The columbus-5 change should actually be this:

if chain_id == "columbus-5":
        return [Coins.from_str("5.665uluna"), Numeric.parse(3)]

I have created a pull request (#184 ) - hopefully this problem will be fixed.

geoffmunn avatar Jan 04 '23 23:01 geoffmunn

Thanks! I ended up not using terra.py for my project, but it'd be nice if this package supported terra classic natively.

ThinksFast avatar Jan 05 '23 21:01 ThinksFast