From e5b491d08285f6a56e484d077255b0fbbb13ef96 Mon Sep 17 00:00:00 2001 From: Snedashkovsky Date: Sat, 7 Oct 2023 12:01:45 +0300 Subject: [PATCH] - add export to a neutron-testnet contract --- config.py | 30 ++++++++++++++++++++++-------- contract_deploy.py | 11 +++++++---- src/contract_export.py | 5 +++-- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/config.py b/config.py index 7d9c49945..70bad61d2 100644 --- a/config.py +++ b/config.py @@ -24,12 +24,14 @@ CONTRACT_NAMES = { 'bostrom': 'on-chain-registry github.com/Snedashkovsky/on-chain-registry', 'localbostrom': 'on-chain-registry github.com/Snedashkovsky/on-chain-registry', - 'osmosis-testnet': 'on-chain-registry github.com/Snedashkovsky/on-chain-registry' + 'osmosis-testnet': 'on-chain-registry github.com/Snedashkovsky/on-chain-registry', + 'neutron-testnet': 'on-chain-registry github.com/Snedashkovsky/on-chain-registry' } CODE_IDS = { 'bostrom': '33', 'localbostrom': '57', - 'osmosis-testnet': '3352' + 'osmosis-testnet': '3352', + 'neutron-testnet': '1697' } # for export to contracts @@ -37,32 +39,44 @@ CHAIN_IDS = { 'bostrom': 'bostrom', 'localbostrom': 'localbostrom', - 'osmosis-testnet': 'osmo-test-5' + 'osmosis-testnet': 'osmo-test-5', + 'neutron-testnet': 'pion-1' } PREFIXES = { 'bostrom': 'bostrom', 'localbostrom': 'bostrom', - 'osmosis-testnet': 'osmo' + 'osmosis-testnet': 'osmo', + 'neutron-testnet': 'neutron' } FEE_DENOMS = { 'bostrom': 'boot', 'localbostrom': 'boot', - 'osmosis-testnet': 'uosmo' + 'osmosis-testnet': 'uosmo', + 'neutron-testnet': 'untrn' +} +CLI_NAME = { + 'bostrom': 'cyber', + 'localbostrom': 'cyber', + 'osmosis-testnet': 'osmosisd', + 'neutron-testnet': 'neutrond' } NODE_RPC_URLS = { 'bostrom': 'https://rpc.bostrom.cybernode.ai:443', 'localbostrom': 'http://localhost:26657', - 'osmosis-testnet': 'https://osmosis-testnet-rpc.polkachu.com:443' + 'osmosis-testnet': 'https://osmosis-testnet-rpc.polkachu.com:443', + 'neutron-testnet': 'https://rpc-falcron.pion-1.ntrn.tech:443' } NODE_LCD_URLS = { 'bostrom': 'https://lcd.bostrom.cybernode.ai', 'localbostrom': 'http://localhost:1317', - 'osmosis-testnet': 'https://osmosis-testnet-api.polkachu.com' + 'osmosis-testnet': 'https://osmosis-testnet-api.polkachu.com', + 'neutron-testnet': 'https://rest-falcron.pion-1.ntrn.tech' } CONTRACT_ADDRESSES = { 'bostrom': 'bostrom1w33tanvadg6fw04suylew9akcagcwngmkvns476wwu40fpq36pms92re6u', 'localbostrom': 'bostrom1l2rs0hxzfy343z8n6punpj9gwzrsq644nzzls6dql52jjj2nxncqjn5vg3', - 'osmosis-testnet': 'osmo1nwesd2xe6cnvtpqd29xg7qeznlm65x02lfjfg20wlvkdze20hcxsftxtzz' + 'osmosis-testnet': 'osmo1nwesd2xe6cnvtpqd29xg7qeznlm65x02lfjfg20wlvkdze20hcxsftxtzz', + 'neutron-testnet': 'neutron10v5u2pqce59j0sm6nzv6a42qfus2rdcsxr5y2g27qawulqdss57qjsta8y' } LCD_CLIENTS = {_network: LCDClient(url=NODE_LCD_URLS[_network], diff --git a/contract_deploy.py b/contract_deploy.py index 556e26647..aa00b9477 100644 --- a/contract_deploy.py +++ b/contract_deploy.py @@ -4,7 +4,7 @@ from cyberutils.bash import execute_bash -from config import logging, CHAIN_IDS, NODE_RPC_URLS, WALLET_ADDRESSES, CONTRACT_NAMES, CODE_IDS +from config import logging, CHAIN_IDS, NODE_RPC_URLS, WALLET_ADDRESSES, CONTRACT_NAMES, CODE_IDS, CLI_NAME def build_code( @@ -157,18 +157,20 @@ def init_on_chain_registry_contract( chain_name = args.chain_name if args.chain_name else 'bostrom' assert chain_name in CHAIN_IDS.keys() - + logging.info('!!! start') if args.build_code: + logging.info(f'start code building') build_code() logging.info(f'the code has been built') if args.store_code: + logging.info('start storing of code') code_id = store_code( wallet_address=WALLET_ADDRESSES[chain_name], note=CONTRACT_NAMES[chain_name], chain_id=CHAIN_IDS[chain_name], node_rpc_url=NODE_RPC_URLS[chain_name], - cli_name='osmosisd' if chain_name[:7] == 'osmosis' else 'cyber' + cli_name=CLI_NAME[chain_name] ) if code_id: logging.info(f'the code has been stored in {chain_name}, code id {code_id}.\nplease update `config.py`') @@ -176,6 +178,7 @@ def init_on_chain_registry_contract( code_id = CODE_IDS[chain_name] if args.init_contract: + logging.info('start contract instantiating') contract_address = init_on_chain_registry_contract( executors_addresses=[WALLET_ADDRESSES[chain_name]], admins_addresses=[WALLET_ADDRESSES[chain_name]], @@ -184,7 +187,7 @@ def init_on_chain_registry_contract( contract_label=CONTRACT_NAMES[chain_name], chain_id=CHAIN_IDS[chain_name], node_rpc_url=NODE_RPC_URLS[chain_name], - cli_name='osmosisd' if chain_name[:7] == 'osmosis' else 'cyber' + cli_name=CLI_NAME[chain_name] ) if contract_address: logging.info(f'the contract has been instantiated in {chain_name} network, ' diff --git a/src/contract_export.py b/src/contract_export.py index e7848a0db..5de50a070 100644 --- a/src/contract_export.py +++ b/src/contract_export.py @@ -3,11 +3,11 @@ from tqdm import tqdm import requests import base64 -from time import sleep from cyber_sdk.client.lcd import LCDClient, Wallet from cyber_sdk.client.lcd.api.tx import BlockTxBroadcastResult from cyberutils.contract import execute_contract +from cyberutils.bash import display_sleep from config import logging, CONTRACT_ADDRESSES, LCD_CLIENTS, WALLETS, WALLET_ADDRESSES, FEE_DENOMS, EXPORT_CHAINS @@ -99,10 +99,11 @@ def save_to_contract( fee_amount=int(gas * 0.0025) if wallet_address[:4] == 'osmo' else 0 ) if _res is None: - sleep(10) + display_sleep(10) _res_list.append(_res) if len(str(_res)) < 500: logging.error(_res) + display_sleep(10) return _res_list