Spaces:
Running
Running
gauravlochab
commited on
Commit
·
36a3394
1
Parent(s):
dbc4d5d
refactor: Update API endpoint in get_transfers function
Browse files
app.py
CHANGED
@@ -30,7 +30,7 @@ with open('./contracts/service_registry_abi.json', 'r') as abi_file:
|
|
30 |
service_registry = web3.eth.contract(address=contract_address, abi=contract_abi)
|
31 |
|
32 |
def get_transfers(integrator: str, wallet: str) -> str:
|
33 |
-
url = f"https://li.quest/v1/analytics/transfers
|
34 |
headers = {"accept": "application/json"}
|
35 |
response = requests.get(url, headers=headers)
|
36 |
return response.json()
|
@@ -82,12 +82,11 @@ def fetch_and_aggregate_transactions():
|
|
82 |
|
83 |
for service_id in range(1, total_services + 1):
|
84 |
service = service_registry.functions.getService(service_id).call()
|
85 |
-
|
86 |
# Extract the list of agent IDs from the service data
|
87 |
agent_ids = service[-1] # Assuming the last element is the list of agent IDs
|
88 |
|
89 |
-
# Check if
|
90 |
-
if 40 in agent_ids:
|
91 |
agent_address = service_registry.functions.getAgentInstances(service_id).call()[1][0]
|
92 |
response_transfers = get_transfers("valory", agent_address)
|
93 |
transfers = response_transfers.get("transfers", [])
|
@@ -95,10 +94,7 @@ def fetch_and_aggregate_transactions():
|
|
95 |
aggregated_transactions.extend(transfers)
|
96 |
|
97 |
# Track the daily number of agents
|
98 |
-
creation_event = service_registry.events.CreateService.create_filter(
|
99 |
-
from_block=0, argument_filters={'serviceId': service_id, 'configHash': service[2]}
|
100 |
-
).get_all_entries()
|
101 |
-
|
102 |
if creation_event:
|
103 |
block_number = creation_event[0]['blockNumber']
|
104 |
block = web3.eth.get_block(block_number)
|
@@ -116,7 +112,6 @@ def fetch_and_aggregate_transactions():
|
|
116 |
if multisig_nonces > 0:
|
117 |
daily_agents_with_transactions[date_str].add(agent_address)
|
118 |
daily_agent_counts[date_str].add(agent_address)
|
119 |
-
|
120 |
# Convert set to count
|
121 |
daily_agent_counts = {date: len(agents) for date, agents in daily_agent_counts.items()}
|
122 |
daily_agents_with_transactions = {date: len(agents) for date, agents in daily_agents_with_transactions.items()}
|
|
|
30 |
service_registry = web3.eth.contract(address=contract_address, abi=contract_abi)
|
31 |
|
32 |
def get_transfers(integrator: str, wallet: str) -> str:
|
33 |
+
url = f"https://li.quest/v1/analytics/transfers?&wallet={wallet}"
|
34 |
headers = {"accept": "application/json"}
|
35 |
response = requests.get(url, headers=headers)
|
36 |
return response.json()
|
|
|
82 |
|
83 |
for service_id in range(1, total_services + 1):
|
84 |
service = service_registry.functions.getService(service_id).call()
|
|
|
85 |
# Extract the list of agent IDs from the service data
|
86 |
agent_ids = service[-1] # Assuming the last element is the list of agent IDs
|
87 |
|
88 |
+
# Check if 40 is in the list of agent IDs
|
89 |
+
if 40 in agent_ids or 25 in agent_ids:
|
90 |
agent_address = service_registry.functions.getAgentInstances(service_id).call()[1][0]
|
91 |
response_transfers = get_transfers("valory", agent_address)
|
92 |
transfers = response_transfers.get("transfers", [])
|
|
|
94 |
aggregated_transactions.extend(transfers)
|
95 |
|
96 |
# Track the daily number of agents
|
97 |
+
creation_event = service_registry.events.CreateService.create_filter(from_block=0, argument_filters={'serviceId': service_id}).get_all_entries()
|
|
|
|
|
|
|
98 |
if creation_event:
|
99 |
block_number = creation_event[0]['blockNumber']
|
100 |
block = web3.eth.get_block(block_number)
|
|
|
112 |
if multisig_nonces > 0:
|
113 |
daily_agents_with_transactions[date_str].add(agent_address)
|
114 |
daily_agent_counts[date_str].add(agent_address)
|
|
|
115 |
# Convert set to count
|
116 |
daily_agent_counts = {date: len(agents) for date, agents in daily_agent_counts.items()}
|
117 |
daily_agents_with_transactions = {date: len(agents) for date, agents in daily_agents_with_transactions.items()}
|