-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a77d0f7
commit 8ac0962
Showing
7 changed files
with
102 additions
and
97 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import json | ||
from starknet_py.contract import Contract | ||
|
||
from client_tools import fetch_coinbase, fetch_okx, prepare_contract_call_args | ||
from empiric.core.base_client import EmpiricBaseClient | ||
from empiric.core.types import HEX_STR | ||
|
||
|
||
class OpenOracleClient(EmpiricBaseClient): | ||
def __init__( | ||
self, | ||
open_oracle_address: HEX_STR, | ||
account_contract_address: HEX_STR, | ||
account_private_key: int, | ||
): | ||
super().__init__( | ||
account_private_key=account_private_key, | ||
account_contract_address=account_contract_address, | ||
) | ||
# OpenOracle contract | ||
open_oracle_abi = open("build/OpenOraclePublisher_abi.json", "r") | ||
self.open_oracle_contract = Contract( | ||
address=open_oracle_address, | ||
abi=json.load(open_oracle_abi), | ||
client=self.client, | ||
) | ||
open_oracle_abi.close() | ||
|
||
async def _fetch_contracts(self): | ||
pass | ||
|
||
async def publish_open_oracle_entries_okx( | ||
self, assets=["btc", "eth", "dai"] | ||
) -> hex: | ||
okx_oracle_data = fetch_okx(assets=assets) | ||
calls = [ | ||
self.open_oracle_contract.functions["publish_entry"].prepare( | ||
prepare_contract_call_args(*oracle_data) | ||
) | ||
for oracle_data in okx_oracle_data | ||
] | ||
|
||
return await self.send_transactions(calls=calls) | ||
|
||
async def publish_open_oracle_entries_coinbase( | ||
self, assets=["btc", "eth", "dai"] | ||
) -> hex: | ||
coinbase_oracle_data = fetch_coinbase(assets=assets) | ||
calls = [ | ||
self.open_oracle_contract.functions["publish_entry"].prepare( | ||
prepare_contract_call_args(*oracle_data) | ||
) | ||
for oracle_data in coinbase_oracle_data | ||
] | ||
|
||
return await self.send_transactions(calls=calls) | ||
|
||
async def publish_open_oracle_entries_all_publishers( | ||
self, assets=["btc", "eth", "dai"] | ||
) -> hex: | ||
okx_oracle_data = fetch_okx(assets=assets) | ||
coinbase_oracle_data = fetch_coinbase(assets=assets) | ||
all_data = okx_oracle_data + coinbase_oracle_data | ||
|
||
calls = [ | ||
self.open_oracle_contract.functions["publish_entry"].prepare( | ||
prepare_contract_call_args(*oracle_data) | ||
) | ||
for oracle_data in all_data | ||
] | ||
return await self.send_transactions(calls=calls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import asyncio | ||
from client import OpenOracleClient | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
|
||
load_dotenv("open_oracle_client/.env") | ||
account_private_key = int(os.getenv("ACCOUNT_PRIVATE_KEY")) | ||
account_contract_address = os.getenv("ACCOUNT_CONTRACT_ADDRESS") | ||
|
||
|
||
OPEN_ORACLE_ADDRESS = ( | ||
"0x03f0c6d6c792e8a1febc289e023de63824391a0056dd43a154bec792fec1ddff" | ||
) | ||
|
||
|
||
async def main(): | ||
c = OpenOracleClient( | ||
open_oracle_address=OPEN_ORACLE_ADDRESS, | ||
account_contract_address=account_contract_address, | ||
account_private_key=account_private_key, | ||
) | ||
|
||
await c.publish_open_oracle_entries_all_publishers(assets=["btc", "eth"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cairo-lang | ||
cairo-nile | ||
starknet.py | ||
openzeppelin-cairo-contracts | ||
empiric-network |