Skip to content

Commit

Permalink
Fix wallet not being identified
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Sep 6, 2024
1 parent 9601574 commit 7376b49
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 79 deletions.
82 changes: 6 additions & 76 deletions stats-backend/api2/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from django.db.models.functions import Abs
from django.db import transaction
import calendar
from .utils import identify_network_by_offer
from .utils import identify_network_by_offer,identify_wallet_and_network
from django.db import transaction
from django.db.models import OuterRef, Subquery

Expand Down Expand Up @@ -147,20 +147,13 @@ def update_providers_info(node_props):
is_online = check_node_status(obj.node_id)
obj.online = is_online
is_online_checked_providers.add(obj.node_id)
obj.network = identify_network_by_offer(offerobj)
obj.network = data['network']

obj.save()
print(f"Done updating {len(unique_providers)} providers")


TESTNET_KEYS = [
"golem.com.payment.platform.erc20-goerli-tglm.address",
"golem.com.payment.platform.erc20-mumbai-tglm.address",
"golem.com.payment.platform.erc20-holesky-tglm.address",
"golem.com.payment.platform.erc20next-goerli-tglm.address",
"golem.com.payment.platform.erc20next-mumbai-tglm.address",
"golem.com.payment.platform.erc20next-holesky-tglm.address",
]


examples_dir = pathlib.Path(__file__).resolve().parent.parent
sys.path.append(str(examples_dir))
Expand Down Expand Up @@ -326,72 +319,9 @@ async def list_offers(
data = event.props
if not event.issuer in current_scan_providers:
current_scan_providers.add(event.issuer)
if "golem.com.payment.platform.zksync-mainnet-glm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.zksync-mainnet-glm.address"
]
elif "golem.com.payment.platform.zksync-rinkeby-tglm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.zksync-rinkeby-tglm.address"
]
elif "golem.com.payment.platform.erc20-mainnet-glm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20-mainnet-glm.address"
]
elif "golem.com.payment.platform.erc20-polygon-glm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20-polygon-glm.address"
]
elif "golem.com.payment.platform.erc20-goerli-tglm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20-goerli-tglm.address"
]
elif "golem.com.payment.platform.erc20-rinkeby-tglm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20-rinkeby-tglm.address"
]
elif "golem.com.payment.platform.polygon-polygon-glm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.polygon-polygon-glm.address"
]
elif "golem.com.payment.platform.erc20next-mainnet-glm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20next-mainnet-glm.address"
]
elif "golem.com.payment.platform.erc20next-polygon-glm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20next-polygon-glm.address"
]
elif "golem.com.payment.platform.erc20next-goerli-tglm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20next-goerli-tglm.address"
]
elif "golem.com.payment.platform.erc20next-rinkeby-tglm.address" in str(
event.props
):
data["wallet"] = event.props[
"golem.com.payment.platform.erc20next-rinkeby-tglm.address"
]
wallet, network = identify_wallet_and_network(event.props)
data["wallet"] = wallet
data["network"] = network
data["node_id"] = event.issuer
node_props.append(json.dumps(data))

Expand Down
18 changes: 15 additions & 3 deletions stats-backend/api2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@


def identify_network_by_offer(offer):
for driver in settings.GOLEM_MAINNET_PAYMENT_DRIVERS:
if f"golem.com.payment.platform.{driver}.address" in offer.properties:
for key in settings.GOLEM_MAINNET_KEYS:
if key in offer.properties:
return "mainnet"
return "testnet"
for key in settings.GOLEM_TESTNET_KEYS:
if key in offer.properties:
return "testnet"
return "unknown" # If neither mainnet nor testnet keys are found

def identify_wallet_and_network(event_props):
for key in settings.GOLEM_MAINNET_KEYS:
if key in event_props:
return event_props[key], "mainnet"
for key in settings.GOLEM_TESTNET_KEYS:
if key in event_props:
return event_props[key], "testnet"
return None, "unknown"


def is_provider_online(provider):
Expand Down
16 changes: 16 additions & 0 deletions stats-backend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@
"erc20-polygon-glm",
"erc20next-polygon-glm",
]
GOLEM_TESTNET_KEYS = [
"golem.com.payment.platform.erc20-goerli-tglm.address",
"golem.com.payment.platform.erc20-amoy-tglm.address",
"golem.com.payment.platform.erc20-holesky-tglm.address",
"golem.com.payment.platform.erc20-mumbai-tglm.address",
"golem.com.payment.platform.erc20next-goerli-tglm.address",
"golem.com.payment.platform.erc20next-mumbai-tglm.address",
"golem.com.payment.platform.erc20next-holesky-tglm.address",
"golem.com.payment.platform.erc20-sepolia-tglm.address",
]

GOLEM_MAINNET_KEYS = [
"golem.com.payment.platform.erc20-mainnet-glm.address",
"golem.com.payment.platform.erc20-polygon-glm.address",

]


TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"
Expand Down

0 comments on commit 7376b49

Please sign in to comment.