Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from allora-network/fix/worker-argv-parsing
Browse files Browse the repository at this point in the history
Fix: Update argv parsing to account for topic argv
  • Loading branch information
conache authored Mar 13, 2024
2 parents a279fca + 18e749b commit 58b5dbb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions node/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
import json


UPSHOT_API_TOKEN = os.environ.get('UPSHOT_API_TOKEN')
UPSHOT_API_TOKEN = os.environ.get("UPSHOT_API_TOKEN")


def get_signed_appraisal(asset_id):
return f"https://api.upshot.xyz/v2/appraisals/assets/signed?asset_ids={asset_id.lower()}"


def get_asset_appraisal(asset_id, api_key):
# Get the signed appraisal URL for the asset
url = get_signed_appraisal(asset_id)

# Send a GET request to the Upshot API with the signed URL and API key
response = requests.get(url, headers={'x-api-key': api_key})
response = requests.get(url, headers={"x-api-key": api_key})

# Check if the request was successful
if response.status_code != 200:
return None

# Parse the response JSON
res = response.json()

try:
# Extract the asset appraisal from the response data
appraisal = res['data'][0]['price']
appraisal = res["data"][0]["price"]
return f"{appraisal}"
except Exception as e:
# Return None if there is an error or no appraisal data available
Expand All @@ -51,7 +53,7 @@ def process(asset_id):
if __name__ == "__main__":
# Your code logic with the parsed argument goes here
try:
asset_id = sys.argv[1]
asset_id = sys.argv[2]
process(asset_id)
except Exception as e:
response = json.dumps({"error": {str(e)}})
Expand Down

0 comments on commit 58b5dbb

Please sign in to comment.