Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SecretSaturn committed Sep 26, 2024
1 parent 5af85de commit 779ef84
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.idea
TNLS-Relayers/etherscan_api_key.txt
TNLS-Relayers/infura_api_endpoint.txt
*/*/*/infura_api_endpoint.txt
*/.*
*/venv
*/__pycache__
Expand All @@ -24,7 +22,6 @@ TNLS-Gateways/secret/contract.wasm
TNLS-Gateways/secret/contract.wasm.gz
.env
__pycache__/
*.example
TNLS-Gateways/public-gateway/broadcast/*
TNLS-Gateways/public-gateway/lib/*
*.gz
Expand Down
2 changes: 1 addition & 1 deletion TNLS-Gateways/public-gateway/script/ChangeAdmin.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract ChangeAdmin is Script {
vm.startBroadcast();

// Initialize the ProxyAdmin
gatewayProxyAdmin = ProxyAdmin(0x59D8C9591dB7179c5d592c5bCD42694021885aFC);
gatewayProxyAdmin = ProxyAdmin(0xb352D4449dC7355d4478784027d7AfAe69843085);

// Get the current owner of the ProxyAdmin
address currentOwner = gatewayProxyAdmin.owner();
Expand Down
1 change: 0 additions & 1 deletion TNLS-Relayers/Gateway.json

This file was deleted.

26 changes: 13 additions & 13 deletions TNLS-Relayers/eth_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from logging import getLogger, basicConfig, INFO, StreamHandler
from typing import List
from concurrent.futures import ThreadPoolExecutor, as_completed
from threading import Lock, Thread, Event
from threading import Lock, Timer

from web3 import Web3, middleware, auto
from web3.datastructures import AttributeDict
Expand Down Expand Up @@ -46,21 +46,21 @@ def __init__(self, private_key="", provider=None, contract_address="", chain_id=
self.timer = None
self.sync_interval = sync_interval

self.stop_event = Event()
self.sync_thread = Thread(target=self.sync_loop)
self.sync_thread.start()
self.sync_interval = sync_interval
self.executor = ThreadPoolExecutor(max_workers=1)
self.schedule_sync()

def sync_loop(self):
def schedule_sync(self):
"""
Continuously sync nonce at specified intervals.
Schedule the sync task with the executor and restart the timer
"""
while not self.stop_event.is_set():
try:
self.sync_nonce()
except Exception as e:
self.logger.error(f"Error during Ethereum nonce sync: {e}")
# Wait for the sync interval or until the stop event is set
self.stop_event.wait(self.sync_interval)
try:
self.executor.submit(self.sync_nonce)
except Exception as e:
self.logger.error(f"Error during Secret sequence sync: {e}")
finally:
self.timer = Timer(self.sync_interval, self.schedule_sync)
self.timer.start()

def sync_nonce(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion TNLS-Relayers/scrt_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def construct_txn(self, function_schema, function_name, args):
account_number=self.interface.account_number,
)
fee = self.interface.provider.tx.estimate_fee(options=tx_options)
fee.granter = self.interface.feegrant_address
if self.interface.feegrant_address is not None:
fee.granter = self.interface.feegrant_address
tx_options = CreateTxOptions(
msgs=[txn_msgs],
gas=gas,
Expand Down
10 changes: 5 additions & 5 deletions TNLS-Relayers/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from dotenv import load_dotenv

load_dotenv()
with open(f'{Path(__file__).parent.absolute()}/Gateway.json', 'r') as file:
eth_contract_schema = json.load(file)
with open(f'{Path(__file__).parent.absolute()}/gateway.json', 'r') as file:
eth_contract_schema = file.read()


def generate_eth_config(config_dict, provider=None):
Expand Down Expand Up @@ -89,7 +89,7 @@ def generate_scrt_config(config_dict, provider=None):
api_endpoint = config_dict['api_endpoint']
chain_id = config_dict['chain_id']
code_hash = config_dict['code_hash']
feegrant_address = config_dict['feegrant_address']
feegrant_address = config_dict['feegrant_address'] if 'feegrant_address' in config_dict else None
with open(f'{Path(__file__).parent.absolute()}/secret_abi.json') as f:
contract_schema = f.read()
event_name = 'wasm'
Expand Down Expand Up @@ -142,11 +142,11 @@ def generate_full_config(config_file, providers=None):
chains_dict[chain] = generate_eth_config(config_dict[chain], provider=provider_eth)
except Exception as e:
logger.error(f"Error generating ETH config for chain '{chain}': {e}")

for chain in solana_chains:
if config_dict[chain]['active']:
chains_dict[chain] = generate_solana_config(config_dict[chain], provider=provider_solana)

for chain in scrt_chains:
if config_dict[chain]['active']:
try:
Expand Down

0 comments on commit 779ef84

Please sign in to comment.