Skip to content

Commit

Permalink
- add support for any networks
Browse files Browse the repository at this point in the history
  • Loading branch information
Snedashkovsky committed Mar 6, 2023
1 parent af09638 commit e063e23
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cyber_sdk/client/lcd/lcdclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from asyncio import AbstractEventLoop, get_event_loop
from json import JSONDecodeError
from typing import List, Optional, Union
from warnings import warn

import nest_asyncio
from aiohttp import ClientSession
Expand Down Expand Up @@ -40,14 +41,20 @@

def get_default(chain_id: str) -> [Coins, Numeric]:
if chain_id == "bostrom":
return [Coins.from_str("0.15boot"), Numeric.parse(1.75)]
return [Coins.from_str("0.1boot"), Numeric.parse(1.75)]
if chain_id == "localbostrom":
return [Coins.from_str("0.15boot"), Numeric.parse(1.75)]
return [Coins.from_str("0.1boot"), Numeric.parse(1.75)]
if chain_id == "space-pussy":
return [Coins.from_str("0.15pussy"), Numeric.parse(1.75)]
return [Coins.from_str("0.1pussy"), Numeric.parse(1.75)]
if chain_id == "osmosis-1":
return [Coins.from_str("0.0015osmo"), Numeric.parse(1.75)]
raise ValueError("chain_id is invalid")
return [Coins.from_str("0.001uosmo"), Numeric.parse(1.75)]
if chain_id == "crescent-1":
return [Coins.from_str("0.001ucre"), Numeric.parse(1.75)]
if chain_id == "cosmoshub-4":
return [Coins.from_str("0.001uatom"), Numeric.parse(1.75)]
if chain_id == "juno-1":
return [Coins.from_str("0.001ujuno"), Numeric.parse(1.75)]
return [Coins(), Numeric.parse(1.75)]


class AsyncLCDClient:
Expand Down Expand Up @@ -75,6 +82,9 @@ def __init__(
self.last_request_height = None

default_price, default_adjustment = get_default(chain_id)
if default_price == Coins() and gas_prices is None:
warn('Please set `gas_price` and optionally `gas_adjustment` for the LCD client to work properly',
stacklevel=2)
self.gas_prices = Coins(gas_prices) if gas_prices else default_price
self.gas_adjustment = gas_adjustment if gas_adjustment else default_adjustment

Expand Down

0 comments on commit e063e23

Please sign in to comment.