Skip to content

Commit b74d5fb

Browse files
authored
Merge pull request #348 from cardanoapi/fix/fix-stake-key-hash-query-dbsync-issue
fix: convert stake key hash into stake address before query
2 parents 9fc8566 + e7c870d commit b74d5fb

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

api/.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ AGENT_MNEMONIC=
55
KAFKA_ENABLED=true
66
METADATA_BASE_URL='https://metadata.drep.id/api'
77
DB_SYNC_BASE_URL=
8-
KAFKA_PREFIX=
8+
KAFKA_PREFIX=
9+
#preview , mainnet , prepod ... defaults to mainnet
10+
NETWORK=''

api/backend/app/services/agent_service.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,14 @@ async def return_agent_with_wallet_details(self, agent: AgentResponse):
280280
async with aiohttp.ClientSession() as session:
281281
async with asyncio.TaskGroup() as group:
282282
agent_configurations = group.create_task(self.trigger_service.list_triggers_by_agent_id(agent.id))
283-
wallet_balance = group.create_task(self.fetch_balance(wallet.stake_key_hash, session))
284-
drep_details = group.create_task(self.fetch_drep_details(wallet.stake_key_hash, session))
283+
wallet_balance = group.create_task(
284+
self.fetch_balance(convert_stake_key_hash_to_address(wallet.stake_key_hash), session)
285+
)
286+
drep_details = group.create_task(
287+
self.fetch_drep_details(convert_stake_key_hash_to_address(wallet.stake_key_hash), session)
288+
)
285289
delegation_details = group.create_task(
286-
self.fetch_delegation_details(wallet.stake_key_hash, session)
290+
self.fetch_delegation_details(convert_stake_key_hash_to_address(wallet.stake_key_hash), session)
287291
)
288292
stake_address_details = group.create_task(
289293
self.fetch_stake_address_details(wallet.stake_key_hash, session)
@@ -303,3 +307,13 @@ async def return_agent_with_wallet_details(self, agent: AgentResponse):
303307
is_stake_registered=stake_address_details.result().get("is_stake_registered"),
304308
stake_last_registered=stake_address_details.result().get("last_registered"),
305309
)
310+
311+
312+
def convert_stake_key_hash_to_address(stake_key_hash):
313+
if stake_key_hash.startswith("e0") or stake_key_hash.startswith("e1"):
314+
return stake_key_hash
315+
else:
316+
if api_settings.APP_ENV == "mainnet":
317+
return "e1" + stake_key_hash
318+
else:
319+
return "e0" + stake_key_hash

api/backend/config/application.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Application(BaseSettings):
3636
KAFKA_BROKERS: str = "localhost:9092"
3737
KAFKA_ENABLED: bool = False
3838
KUBER_URL: str = ""
39+
NETWORK: str = "mainnet"
3940
# All your additional application configuration should go either here or in
4041
# separate file in this submodule.
4142

0 commit comments

Comments
 (0)