Skip to content

Commit

Permalink
Merge pull request #228 from InjectiveLabs/fix/fix_testnet_urls
Browse files Browse the repository at this point in the history
fix/fix testnet urls'
  • Loading branch information
aarmoa authored Aug 22, 2023
2 parents f4db6f2 + 2fb5da4 commit aa191ae
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 69 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ make tests
```

### Changelogs
**0.7.1.1**
* Fixed Testnet network URLs

**0.7.1**
* Include implementation of the MessageBroadcaster, to simplify the transaction creation and broadcasting process.

Expand Down
136 changes: 68 additions & 68 deletions pyinjective/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
MAX_MEMO_CHARACTERS = 256

devnet_config = ConfigParser()
devnet_config.read(os.path.join(os.path.dirname(__file__), 'denoms_devnet.ini'))
devnet_config.read(os.path.join(os.path.dirname(__file__), "denoms_devnet.ini"))

testnet_config = ConfigParser()
testnet_config.read(os.path.join(os.path.dirname(__file__), 'denoms_testnet.ini'))
testnet_config.read(os.path.join(os.path.dirname(__file__), "denoms_testnet.ini"))

mainnet_config = ConfigParser()
mainnet_config.read(os.path.join(os.path.dirname(__file__), 'denoms_mainnet.ini'))
mainnet_config.read(os.path.join(os.path.dirname(__file__), "denoms_mainnet.ini"))

class Denom:
def __init__(
Expand All @@ -31,32 +31,32 @@ def __init__(

@classmethod
def load_market(cls, network, market_id):
if network == 'devnet':
if network == "devnet":
config = devnet_config
elif network == 'testnet':
elif network == "testnet":
config = testnet_config
else:
config =mainnet_config

return cls(
description=config[market_id]['description'],
base=int(config[market_id]['base']),
quote=int(config[market_id]['quote']),
min_price_tick_size=float(config[market_id]['min_price_tick_size']),
min_quantity_tick_size=float(config[market_id]['min_quantity_tick_size']),
description=config[market_id]["description"],
base=int(config[market_id]["base"]),
quote=int(config[market_id]["quote"]),
min_price_tick_size=float(config[market_id]["min_price_tick_size"]),
min_quantity_tick_size=float(config[market_id]["min_quantity_tick_size"]),
)

@classmethod
def load_peggy_denom(cls, network, symbol):
if network == 'devnet':
if network == "devnet":
config = devnet_config
elif network == 'local':
elif network == "local":
config = devnet_config
elif network == 'testnet':
elif network == "testnet":
config = testnet_config
else:
config = mainnet_config
return config[symbol]['peggy_denom'], int(config[symbol]['decimals'])
return config[symbol]["peggy_denom"], int(config[symbol]["decimals"])


class Network:
Expand All @@ -83,14 +83,14 @@ def __init__(
@classmethod
def devnet(cls):
return cls(
lcd_endpoint='https://devnet.lcd.injective.dev',
tm_websocket_endpoint='wss://devnet.tm.injective.dev/websocket',
grpc_endpoint='devnet.injective.dev:9900',
grpc_exchange_endpoint='devnet.injective.dev:9910',
grpc_explorer_endpoint='devnet.injective.dev:9911',
chain_id='injective-777',
fee_denom='inj',
env='devnet'
lcd_endpoint="https://devnet.lcd.injective.dev",
tm_websocket_endpoint="wss://devnet.tm.injective.dev/websocket",
grpc_endpoint="devnet.injective.dev:9900",
grpc_exchange_endpoint="devnet.injective.dev:9910",
grpc_explorer_endpoint="devnet.injective.dev:9911",
chain_id="injective-777",
fee_denom="inj",
env="devnet"
)

@classmethod
Expand All @@ -100,78 +100,78 @@ def testnet(cls, node="lb"):
"sentry",
]
if node not in nodes:
raise ValueError('Must be one of {}'.format(nodes))

if node == 'lb':
lcd_endpoint = 'https://k8s.testnet.lcd.injective.network',
tm_websocket_endpoint = 'wss://k8s.testnet.tm.injective.network/websocket',
grpc_endpoint = 'k8s.testnet.chain.grpc.injective.network:443',
grpc_exchange_endpoint = 'k8s.testnet.exchange.grpc.injective.network:443',
grpc_explorer_endpoint = 'k8s.testnet.explorer.grpc.injective.network:443',
raise ValueError("Must be one of {}".format(nodes))

if node == "lb":
lcd_endpoint = "https://k8s.testnet.lcd.injective.network"
tm_websocket_endpoint = "wss://k8s.testnet.tm.injective.network/websocket"
grpc_endpoint = "k8s.testnet.chain.grpc.injective.network:443"
grpc_exchange_endpoint = "k8s.testnet.exchange.grpc.injective.network:443"
grpc_explorer_endpoint = "k8s.testnet.explorer.grpc.injective.network:443"
else:
lcd_endpoint = 'https://testnet.lcd.injective.network'
tm_websocket_endpoint = 'wss://testnet.tm.injective.network/websocket'
grpc_endpoint = 'testnet.chain.grpc.injective.network'
grpc_exchange_endpoint = 'testnet.exchange.grpc.injective.network'
grpc_explorer_endpoint = 'testnet.explorer.grpc.injective.network'
lcd_endpoint = "https://testnet.lcd.injective.network"
tm_websocket_endpoint = "wss://testnet.tm.injective.network/websocket"
grpc_endpoint = "testnet.chain.grpc.injective.network"
grpc_exchange_endpoint = "testnet.exchange.grpc.injective.network"
grpc_explorer_endpoint = "testnet.explorer.grpc.injective.network"

return cls(
lcd_endpoint=lcd_endpoint,
tm_websocket_endpoint=tm_websocket_endpoint,
grpc_endpoint=grpc_endpoint,
grpc_exchange_endpoint=grpc_exchange_endpoint,
grpc_explorer_endpoint=grpc_explorer_endpoint,
chain_id='injective-888',
fee_denom='inj',
env='testnet'
chain_id="injective-888",
fee_denom="inj",
env="testnet"
)

@classmethod
def mainnet(cls, node='lb'):
def mainnet(cls, node="lb"):
nodes = [
'lb', # us, asia, prod
'sentry0', # ca, prod
'sentry1', # ca, prod
'sentry3', # us, prod
"lb", # us, asia, prod
"sentry0", # ca, prod
"sentry1", # ca, prod
"sentry3", # us, prod
]
if node not in nodes:
raise ValueError('Must be one of {}'.format(nodes))

if node == 'lb':
lcd_endpoint = 'https://k8s.global.mainnet.lcd.injective.network:443'
tm_websocket_endpoint = 'wss://k8s.global.mainnet.tm.injective.network:443/websocket'
grpc_endpoint = 'k8s.global.mainnet.chain.grpc.injective.network:443'
grpc_exchange_endpoint = 'k8s.global.mainnet.exchange.grpc.injective.network:443'
grpc_explorer_endpoint = 'k8s.global.mainnet.explorer.grpc.injective.network:443'
raise ValueError("Must be one of {}".format(nodes))

if node == "lb":
lcd_endpoint = "https://k8s.global.mainnet.lcd.injective.network:443"
tm_websocket_endpoint = "wss://k8s.global.mainnet.tm.injective.network:443/websocket"
grpc_endpoint = "k8s.global.mainnet.chain.grpc.injective.network:443"
grpc_exchange_endpoint = "k8s.global.mainnet.exchange.grpc.injective.network:443"
grpc_explorer_endpoint = "k8s.global.mainnet.explorer.grpc.injective.network:443"
else:
lcd_endpoint=f'http://{node}.injective.network:10337'
tm_websocket_endpoint=f'ws://{node}.injective.network:26657/websocket'
grpc_endpoint=f'{node}.injective.network:9900'
grpc_exchange_endpoint=f'{node}.injective.network:9910'
grpc_explorer_endpoint=f'{node}.injective.network:9911'
lcd_endpoint = f"http://{node}.injective.network:10337"
tm_websocket_endpoint = f"ws://{node}.injective.network:26657/websocket"
grpc_endpoint = f"{node}.injective.network:9900"
grpc_exchange_endpoint = f"{node}.injective.network:9910"
grpc_explorer_endpoint = f"{node}.injective.network:9911"

return cls(
lcd_endpoint=lcd_endpoint,
tm_websocket_endpoint=tm_websocket_endpoint,
grpc_endpoint=grpc_endpoint,
grpc_exchange_endpoint=grpc_exchange_endpoint,
grpc_explorer_endpoint=grpc_explorer_endpoint,
chain_id='injective-1',
fee_denom='inj',
env='mainnet'
chain_id="injective-1",
fee_denom="inj",
env="mainnet"
)

@classmethod
def local(cls):
return cls(
lcd_endpoint='http://localhost:10337',
tm_websocket_endpoint='ws://localhost:26657/websocket',
grpc_endpoint='localhost:9900',
grpc_exchange_endpoint='localhost:9910',
grpc_explorer_endpoint='localhost:9911',
chain_id='injective-1',
fee_denom='inj',
env='local'
lcd_endpoint="http://localhost:10337",
tm_websocket_endpoint="ws://localhost:26657/websocket",
grpc_endpoint="localhost:9900",
grpc_exchange_endpoint="localhost:9910",
grpc_explorer_endpoint="localhost:9911",
chain_id="injective-1",
fee_denom="inj",
env="local"
)

@classmethod
Expand All @@ -183,7 +183,7 @@ def custom(cls, lcd_endpoint, tm_websocket_endpoint, grpc_endpoint, grpc_exchang
grpc_exchange_endpoint=grpc_exchange_endpoint,
grpc_explorer_endpoint=grpc_explorer_endpoint,
chain_id=chain_id,
fee_denom='inj',
fee_denom="inj",
env=env
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
EMAIL = "[email protected]"
AUTHOR = "Injective Labs"
REQUIRES_PYTHON = ">=3.9"
VERSION = "0.7.1"
VERSION = "0.7.1.1"

REQUIRED = [
"aiohttp",
Expand Down

0 comments on commit aa191ae

Please sign in to comment.