Skip to content

Commit

Permalink
handle testnet potfactory & pot contract patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlanglen committed Jun 3, 2024
1 parent 9b8e6e7 commit 9b12842
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 3 additions & 8 deletions indexer_app/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
from near_lake_framework import near_primitives

from base.utils import convert_ns_to_utc
from pots.utils import (
match_pot_factory_version_pattern,
match_pot_subaccount_version_pattern,
)
from pots.utils import match_pot_factory_pattern, match_pot_subaccount_pattern

from .logging import logger
from .utils import (
Expand Down Expand Up @@ -129,14 +126,12 @@ async def handle_streamer_message(streamer_message: near_primitives.StreamerMess

match method_name:
case "new":
if match_pot_factory_version_pattern(receipt.receiver_id):
if match_pot_factory_pattern(receipt.receiver_id):
logger.info(f"matched for factory pattern: {args_dict}")
await handle_new_pot_factory(
args_dict, receiver_id, created_at
)
elif match_pot_subaccount_version_pattern(
receipt.receiver_id
):
elif match_pot_subaccount_pattern(receipt.receiver_id):
logger.info(
f"new pot deployment: {args_dict}, {action}"
)
Expand Down
12 changes: 9 additions & 3 deletions pots/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import re

BASE_PATTERN = r"v\d+\.potfactory\.potlock\.near$"
from django.conf import settings

BASE_PATTERN = (
r"^potlock\.testnet$"
if settings.ENVIRONMENT == "testnet"
else r"v\d+\.potfactory\.potlock\.near$"
)

def match_pot_factory_version_pattern(receiver):

def match_pot_factory_pattern(receiver):
"""Matches the base pot factory version pattern without a subaccount. NB: does not currently handle testnet factory."""
pattern = f"^{BASE_PATTERN}"
return bool(re.match(pattern, receiver))


def match_pot_subaccount_version_pattern(receiver):
def match_pot_subaccount_pattern(receiver):
"""Matches the pot factory version pattern with a subaccount. NB: does not currently handle testnet factory."""
pattern = f"^[a-zA-Z0-9_]+\.{BASE_PATTERN}"
return bool(re.match(pattern, receiver))

0 comments on commit 9b12842

Please sign in to comment.