Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles exhausted "The Graph" API key #295

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"contract/valory/mech_activity/0.1.0": "bafybeiec6nnvfs6captlncrtjfygpp275vkfajvj4frrnab7thsca6337e",
"contract/valory/staking_token/0.1.0": "bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4",
"contract/valory/relayer/0.1.0": "bafybeihzgjyvhtorugjw3yldznqsbwo3aqpxowm7k2nrvj6qtwpsc7jl7u",
"skill/valory/market_manager_abci/0.1.0": "bafybeigvo6hh2lz4h4om67qxugxdeq23inbezyo6u4bb3uth23tniuka6m",
"skill/valory/decision_maker_abci/0.1.0": "bafybeifztxsujapt5f475f73zuok3pg4laj3slvf5ick6s3uxt7ds5qt3y",
"skill/valory/trader_abci/0.1.0": "bafybeiagrarjq27oiw5wdn3sxri7fre3yc5azn4jtektwf6cn2mxqzhlcq",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeidr5qdyk7e4wkodpqrnf56t5xyqf4t7mwvtyqsziglb3uoadz5wwu",
"skill/valory/market_manager_abci/0.1.0": "bafybeig44vtxcq7aarqkg2mskly3zwwnyfc45rtdvorwz6ywspwg3obqn4",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiejbfkl4im6srigta53ysan3tu5hlbb44cbd2mgryp2hsanyxpdge",
"skill/valory/trader_abci/0.1.0": "bafybeigfccxw5v76pectrmh2a3ibd4gt2hhtskkqay6an3g7lgdyotuz34",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiaiek6b3p7dro45qjoecmgseznhixhrgqgxfiap7lqw4rbi5fyhvy",
"skill/valory/staking_abci/0.1.0": "bafybeidubhfvlf6x627t4wetc6ran5sb4pttjphyhv6vefp2a4kcuca2be",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeiboctfgetji6xlzw2buts5zsejnlrrhqkppme2p6fwzu26zznb324",
"agent/valory/trader/0.1.0": "bafybeifna5cj46m3ytqixm3eqevnthzcxa7sq63eitybfmb23zelfrfb2u",
"service/valory/trader/0.1.0": "bafybeicdglua2ylh4fmqwi5o6rspv77gep5dtb247bn2xiwtwh5h4zcuza",
"service/valory/trader_pearl/0.1.0": "bafybeigpd2mqjnpkufadkgojgqb2qdtj4ygmjxgmllageykclpoyidb7le"
"agent/valory/trader/0.1.0": "bafybeiaxm4ts4odvhmbltyaa7rngm6jio7b4fdwvwszahw2ndfjdpd547a",
"service/valory/trader/0.1.0": "bafybeig3dk2wuzspnu7aeop2wbxd7sfe5yjlsj3yreen6v6vrtqwj4htyq",
"service/valory/trader_pearl/0.1.0": "bafybeicnm3uxoo7xfotbuhiafqalhfai2etkj5pqha6v4gejy4ilg5lcom"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
26 changes: 22 additions & 4 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidr5qdyk7e4wkodpqrnf56t5xyqf4t7mwvtyqsziglb3uoadz5wwu
- valory/market_manager_abci:0.1.0:bafybeigvo6hh2lz4h4om67qxugxdeq23inbezyo6u4bb3uth23tniuka6m
- valory/decision_maker_abci:0.1.0:bafybeifztxsujapt5f475f73zuok3pg4laj3slvf5ick6s3uxt7ds5qt3y
- valory/trader_abci:0.1.0:bafybeiagrarjq27oiw5wdn3sxri7fre3yc5azn4jtektwf6cn2mxqzhlcq
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiaiek6b3p7dro45qjoecmgseznhixhrgqgxfiap7lqw4rbi5fyhvy
- valory/market_manager_abci:0.1.0:bafybeig44vtxcq7aarqkg2mskly3zwwnyfc45rtdvorwz6ywspwg3obqn4
- valory/decision_maker_abci:0.1.0:bafybeiejbfkl4im6srigta53ysan3tu5hlbb44cbd2mgryp2hsanyxpdge
- valory/trader_abci:0.1.0:bafybeigfccxw5v76pectrmh2a3ibd4gt2hhtskkqay6an3g7lgdyotuz34
- valory/staking_abci:0.1.0:bafybeidubhfvlf6x627t4wetc6ran5sb4pttjphyhv6vefp2a4kcuca2be
- valory/check_stop_trading_abci:0.1.0:bafybeiboctfgetji6xlzw2buts5zsejnlrrhqkppme2p6fwzu26zznb324
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
Expand Down Expand Up @@ -178,6 +178,9 @@ models:
languages: ${list:["en_US"]}
average_block_time: ${int:5}
abt_error_mult: ${int:5}
the_graph_error_message_key: ${str:message}
the_graph_payment_required_error: ${str:payment required for subsequent requests
for this API key}
mech_contract_address: ${str:0x77af31De935740567Cf4fF1986D04B2c964A786a}
mech_request_price: ${int:null}
mech_chain_id: ${str:gnosis}
Expand Down Expand Up @@ -269,6 +272,9 @@ models:
response_key: ${str:data:blocks}
response_index: ${int:0}
response_type: ${str:dict}
error_key: ${str:errors}
error_index: ${int:0}
error_type: ${str:dict}
retries: ${int:5}
url: ${str:https://api.thegraph.com/subgraphs/name/stakewise/ethereum-gnosis}
omen_subgraph:
Expand All @@ -278,6 +284,9 @@ models:
method: ${str:POST}
response_key: ${str:data:fixedProductMarketMakers}
response_type: ${str:list}
error_key: ${str:errors}
error_index: ${int:0}
error_type: ${str:dict}
retries: ${int:5}
url: ${str:https://api.thegraph.com/subgraphs/name/protofire/omen-xdai}
randomness_api:
Expand Down Expand Up @@ -312,6 +321,9 @@ models:
method: ${str:POST}
response_key: ${str:data:fpmmTrades}
response_type: ${str:list}
error_key: ${str:errors}
error_index: ${int:0}
error_type: ${str:dict}
retries: ${int:5}
url: ${str:https://api.thegraph.com/subgraphs/name/protofire/omen-xdai}
conditional_tokens_subgraph:
Expand All @@ -321,6 +333,9 @@ models:
method: ${str:POST}
response_key: ${str:data:user:userPositions}
response_type: ${str:list}
error_key: ${str:errors}
error_index: ${int:0}
error_type: ${str:dict}
retries: ${int:5}
url: ${str:https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc}
realitio_subgraph:
Expand All @@ -330,6 +345,9 @@ models:
method: ${str:POST}
response_key: ${str:data:answers}
response_type: ${str:list}
error_key: ${str:errors}
error_index: ${int:0}
error_type: ${str:dict}
retries: ${int:5}
url: ${str:https://api.thegraph.com/subgraphs/name/realityeth/realityeth-gnosis}
---
Expand Down
29 changes: 28 additions & 1 deletion packages/valory/services/trader/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeifna5cj46m3ytqixm3eqevnthzcxa7sq63eitybfmb23zelfrfb2u
agent: valory/trader:0.1.0:bafybeiaxm4ts4odvhmbltyaa7rngm6jio7b4fdwvwszahw2ndfjdpd547a
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -83,6 +83,9 @@ type: skill
languages: ${LANGUAGES:list:["en_US"]}
average_block_time: ${ABT:int:5}
abt_error_mult: ${ABT_ERROR_MULT:int:5}
the_graph_error_message_key: ${THE_GRAPH_ERROR_MESSAGE_KEY:str:message}
the_graph_payment_required_error: ${THE_GRAPH_PAYMENT_REQUIRED_ERROR:str:payment
required for subsequent requests for this API key}
mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31De935740567Cf4fF1986D04B2c964A786a}
mech_request_price: ${MECH_REQUEST_PRICE:int:null}
mech_chain_id: ${MECH_CHAIN_ID:str:gnosis}
Expand Down Expand Up @@ -178,6 +181,9 @@ type: skill
response_key: ${NETWORK_SUBGRAPH_RESPONSE_KEY:str:data:blocks}
response_index: ${NETWORK_SUBGRAPH_RESPONSE_INDEX:int:0}
response_type: ${NETWORK_SUBGRAPH_RESPONSE_TYPE:str:dict}
error_key: ${NETWORK_SUBGRAPH_ERROR_KEY:str:errors}
error_index: ${NETWORK_SUBGRAPH_ERROR_INDEX:int:0}
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${NETWORK_SUBGRAPH_RETRIES:int:5}
url: ${NETWORK_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/stakewise/ethereum-gnosis}
omen_subgraph: &id007
Expand All @@ -187,6 +193,9 @@ type: skill
method: ${OMEN_SUBGRAPH_METHOD:str:POST}
response_key: ${OMEN_SUBGRAPH_RESPONSE_KEY:str:data:fixedProductMarketMakers}
response_type: ${OMEN_SUBGRAPH_RESPONSE_TYPE:str:list}
error_key: ${NETWORK_SUBGRAPH_ERROR_KEY:str:errors}
error_index: ${NETWORK_SUBGRAPH_ERROR_INDEX:int:0}
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${OMEN_SUBGRAPH_RETRIES:int:5}
url: ${OMEN_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/protofire/omen-xdai}
randomness_api: &id008
Expand Down Expand Up @@ -221,6 +230,9 @@ type: skill
method: ${TRADES_SUBGRAPH_METHOD:str:POST}
response_key: ${TRADES_SUBGRAPH_RESPONSE_KEY:str:data:fpmmTrades}
response_type: ${TRADES_SUBGRAPH_RESPONSE_TYPE:str:list}
error_key: ${NETWORK_SUBGRAPH_ERROR_KEY:str:errors}
error_index: ${NETWORK_SUBGRAPH_ERROR_INDEX:int:0}
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${TRADES_SUBGRAPH_RETRIES:int:5}
url: ${TRADES_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/protofire/omen-xdai}
conditional_tokens_subgraph: &id012
Expand All @@ -230,6 +242,9 @@ type: skill
method: ${CONDITIONAL_TOKENS_SUBGRAPH_METHOD:str:POST}
response_key: ${CONDITIONAL_TOKENS_SUBGRAPH_RESPONSE_KEY:str:data:user:userPositions}
response_type: ${CONDITIONAL_TOKENS_SUBGRAPH_RESPONSE_TYPE:str:list}
error_key: ${NETWORK_SUBGRAPH_ERROR_KEY:str:errors}
error_index: ${NETWORK_SUBGRAPH_ERROR_INDEX:int:0}
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${CONDITIONAL_TOKENS_SUBGRAPH_RETRIES:int:5}
url: ${CONDITIONAL_TOKENS_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc}
realitio_subgraph: &id013
Expand All @@ -239,6 +254,9 @@ type: skill
method: ${REALITIO_SUBGRAPH_METHOD:str:POST}
response_key: ${REALITIO_SUBGRAPH_RESPONSE_KEY:str:data:answers}
response_type: ${REALITIO_SUBGRAPH_RESPONSE_TYPE:str:list}
error_key: ${NETWORK_SUBGRAPH_ERROR_KEY:str:errors}
error_index: ${NETWORK_SUBGRAPH_ERROR_INDEX:int:0}
error_type: ${NETWORK_SUBGRAPH_ERROR_TYPE:str:dict}
retries: ${REALITIO_SUBGRAPH_RETRIES:int:5}
url: ${REALITIO_SUBGRAPH_URL:str:https://api.thegraph.com/subgraphs/name/realityeth/realityeth-gnosis}
1:
Expand Down Expand Up @@ -288,6 +306,9 @@ type: skill
languages: ${LANGUAGES:list:["en_US"]}
average_block_time: ${ABT:int:5}
abt_error_mult: ${ABT_ERROR_MULT:int:5}
the_graph_error_message_key: ${THE_GRAPH_ERROR_MESSAGE_KEY:str:message}
the_graph_payment_required_error: ${THE_GRAPH_PAYMENT_REQUIRED_ERROR:str:payment
required for subsequent requests for this API key}
mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31De935740567Cf4fF1986D04B2c964A786a}
mech_request_price: ${MECH_REQUEST_PRICE:int:null}
mech_chain_id: ${MECH_CHAIN_ID:str:gnosis}
Expand Down Expand Up @@ -400,6 +421,9 @@ type: skill
languages: ${LANGUAGES:list:["en_US"]}
average_block_time: ${ABT:int:5}
abt_error_mult: ${ABT_ERROR_MULT:int:5}
the_graph_error_message_key: ${THE_GRAPH_ERROR_MESSAGE_KEY:str:message}
the_graph_payment_required_error: ${THE_GRAPH_PAYMENT_REQUIRED_ERROR:str:payment
required for subsequent requests for this API key}
mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31De935740567Cf4fF1986D04B2c964A786a}
mech_request_price: ${MECH_REQUEST_PRICE:int:null}
mech_chain_id: ${MECH_CHAIN_ID:str:gnosis}
Expand Down Expand Up @@ -512,6 +536,9 @@ type: skill
languages: ${LANGUAGES:list:["en_US"]}
average_block_time: ${ABT:int:5}
abt_error_mult: ${ABT_ERROR_MULT:int:5}
the_graph_error_message_key: ${THE_GRAPH_ERROR_MESSAGE_KEY:str:message}
the_graph_payment_required_error: ${THE_GRAPH_PAYMENT_REQUIRED_ERROR:str:payment
required for subsequent requests for this API key}
mech_contract_address: ${MECH_CONTRACT_ADDRESS:str:0x77af31De935740567Cf4fF1986D04B2c964A786a}
mech_request_price: ${MECH_REQUEST_PRICE:int:null}
mech_chain_id: ${MECH_CHAIN_ID:str:gnosis}
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeifna5cj46m3ytqixm3eqevnthzcxa7sq63eitybfmb23zelfrfb2u
agent: valory/trader:0.1.0:bafybeiaxm4ts4odvhmbltyaa7rngm6jio7b4fdwvwszahw2ndfjdpd547a
number_of_agents: 1
deployment:
agent:
Expand Down
13 changes: 8 additions & 5 deletions packages/valory/skills/decision_maker_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy
from packages.valory.skills.decision_maker_abci.redeem_info import Trade
from packages.valory.skills.decision_maker_abci.rounds import DecisionMakerAbciApp
from packages.valory.skills.market_manager_abci.models import MarketManagerParams
from packages.valory.skills.market_manager_abci.models import (
MarketManagerParams,
Subgraph,
)
from packages.valory.skills.mech_interact_abci.models import (
Params as MechInteractParams,
)
Expand Down Expand Up @@ -569,13 +572,13 @@ def is_winning(self) -> bool:
)


class TradesSubgraph(ApiSpecs):
class TradesSubgraph(Subgraph):
"""A model that wraps ApiSpecs for the OMEN's subgraph specifications for trades."""


class ConditionalTokensSubgraph(ApiSpecs):
"""A model that wraps ApiSpecs for the Coniditonal Tokens's subgraph specifications."""
class ConditionalTokensSubgraph(Subgraph):
"""A model that wraps ApiSpecs for the Conditional Tokens' subgraph specifications."""


class RealitioSubgraph(ApiSpecs):
class RealitioSubgraph(Subgraph):
"""A model that wraps ApiSpecs for the Realitio's subgraph specifications."""
16 changes: 14 additions & 2 deletions packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fingerprint:
handlers.py: bafybeigod6gbjrxy4mbmulbzsbokeaoycoqys64vqtxnumishfukzf73za
io_/__init__.py: bafybeifxgmmwjqzezzn3e6keh2bfo4cyo7y5dq2ept3stfmgglbrzfl5rq
io_/loader.py: bafybeih3sdsx5dhe4kzhtoafexjgkutsujwqy3zcdrlrkhtdks45bc7exa
models.py: bafybeihsvfsa5dbx54p3twnln5wbln2annmnszfrrzdguweugffdlsuigu
models.py: bafybeif76bwktyx6i4h7gqunn33q2s4fjlstm4xb5hhsj3zmq4jsofmq4i
payloads.py: bafybeia32ds4ks5g3rhd43w6siy74vi5inaheuxhswiy5ndykxtgncoeu4
policy.py: bafybeihp4lzv4ejyu6k5reukbpa6kamglicpymxfx6obm5pgugik4vc63y
redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm
Expand Down Expand Up @@ -82,7 +82,7 @@ protocols:
- valory/http:1.0.0:bafybeifugzl63kfdmwrxwphrnrhj7bn6iruxieme3a4ntzejf6kmtuwmae
skills:
- valory/abstract_round_abci:0.1.0:bafybeiar2yhzxacfe3qqamqhaihtlcimquwedffctw55sowx6rac3cm3ui
- valory/market_manager_abci:0.1.0:bafybeigvo6hh2lz4h4om67qxugxdeq23inbezyo6u4bb3uth23tniuka6m
- valory/market_manager_abci:0.1.0:bafybeig44vtxcq7aarqkg2mskly3zwwnyfc45rtdvorwz6ywspwg3obqn4
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
behaviours:
Expand Down Expand Up @@ -201,6 +201,9 @@ models:
- en_US
average_block_time: 5
abt_error_mult: 5
the_graph_error_message_key: message
the_graph_payment_required_error: payment required for subsequent requests for
this API key
sample_bets_closing_days: 10
trading_strategy: strategy_name
use_fallback_strategy: true
Expand Down Expand Up @@ -325,6 +328,9 @@ models:
parameters: {}
response_key: data:fpmmTrades
response_type: list
error_key: errors
error_index: 0
error_type: dict
retries: 5
url: https://api.thegraph.com/subgraphs/name/protofire/omen-xdai
class_name: TradesSubgraph
Expand All @@ -337,6 +343,9 @@ models:
parameters: {}
response_key: data:user:userPositions
response_type: list
error_key: errors
error_index: 0
error_type: dict
retries: 5
url: https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc
class_name: ConditionalTokensSubgraph
Expand All @@ -349,6 +358,9 @@ models:
parameters: {}
response_key: data:answers
response_type: list
error_key: errors
error_index: 0
error_type: dict
retries: 5
url: https://api.thegraph.com/subgraphs/name/realityeth/realityeth-gnosis
class_name: RealitioSubgraph
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/market_manager_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def async_act(self) -> Generator:
self.read_bets()
yield from self._update_bets()
self.store_bets()
bets_hash = self.hash_stored_bets()
bets_hash = self.hash_stored_bets() if self.bets else None
payload = UpdateBetsPayload(self.context.agent_address, bets_hash)

with self.context.benchmark_tool.measure(self.behaviour_id).consensus():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,16 @@ def fetch_user_positions(

all_positions.extend(positions)
user_positions_id_gt = positions[-1]["id"]

def clean_up(self) -> None:
"""Clean up the resources."""
markets_subgraphs = tuple(market for market, _ in self.params.creators_iterator)
other_subgraphs = (
"conditional_tokens_subgraph",
"network_subgraph",
"realitio_subgraph",
"trades_subgraph",
)
for subgraph in markets_subgraphs + other_subgraphs:
subgraph_specs = getattr(self.context, subgraph)
subgraph_specs.reset_retries()
34 changes: 31 additions & 3 deletions packages/valory/skills/market_manager_abci/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023 Valory AG
# Copyright 2023-2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,8 +20,10 @@

"""Custom objects for the MarketManager ABCI application."""

import builtins
from typing import Any, Dict, Iterator, List, Tuple

from packages.valory.protocols.http import HttpMessage
from packages.valory.skills.abstract_round_abci.models import ApiSpecs, BaseParams
from packages.valory.skills.abstract_round_abci.models import (
BenchmarkTool as BaseBenchmarkTool,
Expand All @@ -44,11 +46,31 @@ class SharedState(BaseSharedState):
abci_app_cls = MarketManagerAbciApp


class OmenSubgraph(ApiSpecs):
class Subgraph(ApiSpecs):
"""Specifies `ApiSpecs` with common functionality for subgraphs."""

def process_response(self, response: HttpMessage) -> Any:
"""Process the response."""
res = super().process_response(response)
if res is not None:
return res

error_data = self.response_info.error_data
expected_error_type = getattr(builtins, self.response_info.error_type)
if isinstance(error_data, expected_error_type):
error_message_key = self.context.params.the_graph_error_message_key
error_message = error_data.get(error_message_key, None)
if self.context.params.the_graph_payment_required_error in error_message:
err = "Payment required for subsequent requests for the current 'The Graph' API key!"
self.context.logger.error(err)
return None


class OmenSubgraph(Subgraph):
"""A model that wraps ApiSpecs for the OMEN's subgraph specifications."""


class NetworkSubgraph(ApiSpecs):
class NetworkSubgraph(Subgraph):
"""A model that wraps ApiSpecs for the network's subgraph specifications."""


Expand All @@ -72,6 +94,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.languages: List[str] = self._ensure("languages", kwargs, List[str])
self.average_block_time: int = self._ensure("average_block_time", kwargs, int)
self.abt_error_mult: int = self._ensure("abt_error_mult", kwargs, int)
self.the_graph_error_message_key: str = self._ensure(
"the_graph_error_message_key", kwargs, str
)
self.the_graph_payment_required_error: str = self._ensure(
"the_graph_payment_required_error", kwargs, str
)
super().__init__(*args, **kwargs)

@property
Expand Down
Loading
Loading