Skip to content

Commit

Permalink
feat:add pancake address
Browse files Browse the repository at this point in the history
  • Loading branch information
constwz committed Nov 2, 2023
1 parent a3fb218 commit 7a02264
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,5 @@
"api_key": {"type": "apiKey", "in": "header", "name": "Authorization"}
},
}

EXTERNAL_ADDRESS_LIST = env("EXTERNAL_ADDRESS_LIST", default="").split(",")
6 changes: 5 additions & 1 deletion safe_transaction_service/history/services/safe_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from dataclasses import dataclass, replace
from datetime import datetime
from typing import Optional, Tuple, Union
from django.conf import settings

from eth_typing import ChecksumAddress
from web3 import Web3
Expand Down Expand Up @@ -165,6 +166,9 @@ def get_safe_info_from_blockchain(self, safe_address: ChecksumAddress) -> SafeIn
safe = Safe(safe_address, self.ethereum_client)
safe_info = safe.retrieve_all_info()
# Return same master copy information than the db method
if safe_address in settings.EXTERNAL_ADDRESS_LIST:
return safe_info

return replace(
safe_info,
version=SafeMasterCopy.objects.get_version_for_address(
Expand All @@ -175,7 +179,7 @@ def get_safe_info_from_blockchain(self, safe_address: ChecksumAddress) -> SafeIn
raise NodeConnectionException from exc
except CannotRetrieveSafeInfoException as exc:
raise CannotGetSafeInfoFromBlockchain(safe_address) from exc

def get_safe_info_from_db(self, safe_address: ChecksumAddress) -> SafeInfo:
try:
return SafeLastStatus.objects.get_or_generate(safe_address).get_safe_info()
Expand Down
4 changes: 3 additions & 1 deletion safe_transaction_service/history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,9 @@ def get(self, request, address, *args, **kwargs):
},
)

if not SafeContract.objects.filter(address=address).exists():
logger.debug("param:%s", address)
logger.debug(settings.EXTERNAL_ADDRESS_LIST)
if (not SafeContract.objects.filter(address=address).exists()) and (address not in settings.EXTERNAL_ADDRESS_LIST):
return Response(status=status.HTTP_404_NOT_FOUND)

try:
Expand Down

0 comments on commit 7a02264

Please sign in to comment.