setting up feed handlers, more to come
This commit is contained in:
BIN
modules/__pycache__/apex_api.cpython-313.pyc
Normal file
BIN
modules/__pycache__/apex_api.cpython-313.pyc
Normal file
Binary file not shown.
37
modules/apex_api.py
Normal file
37
modules/apex_api.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from apexomni.http_private_v3 import HttpPrivate_v3
|
||||
from apexomni.http_private_sign import HttpPrivateSign
|
||||
from apexomni.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_MAIN
|
||||
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
def apex_create_client() -> HttpPrivateSign:
|
||||
load_dotenv()
|
||||
print("Authenticating...")
|
||||
eth_private_key = os.getenv("RABBY_PRIVATE_KEY")
|
||||
key = os.getenv("APEX_API_KEY")
|
||||
secret = os.getenv("APEX_API_SECRET")
|
||||
passphrase = os.getenv("APEX_API_PASSPHRASE")
|
||||
|
||||
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=eth_private_key)
|
||||
zkKeys = client.derive_zk_key(client.default_address)
|
||||
|
||||
seeds = zkKeys['seeds']
|
||||
l2Key = zkKeys['l2Key']
|
||||
|
||||
client = HttpPrivateSign(
|
||||
APEX_OMNI_HTTP_MAIN,
|
||||
network_id=NETWORKID_MAIN,
|
||||
zk_seeds=seeds,
|
||||
zk_l2Key=l2Key,
|
||||
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
|
||||
|
||||
try:
|
||||
client.configs_v3()
|
||||
client.get_account_v3()
|
||||
except Exception as e:
|
||||
raise ConnectionError(f'Failed to authenticate with APEX OMNI: {e}')
|
||||
|
||||
print("...Authenticated")
|
||||
|
||||
return client
|
||||
Reference in New Issue
Block a user