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

Prizetap: distinguish between dev and main deployment #174

Merged
merged 2 commits into from
Nov 8, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ jobs:
LIGHTNING_RPC_URL: https://api.lnpay.co/v1/
LIGHTNING_WALLET: ${{ secrets.LIGHTNING_WALLET }}
LIGHTNING_FUND_MANAGER: ${{ secrets.LIGHTNING_FUND_MANAGER }}
DEPLOYMENT_ENV: "dev"
3 changes: 3 additions & 0 deletions brightIDfaucet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def str2bool(v):
MEMCACHED_URL = os.environ.get("MEMCACHEDCLOUD_SERVERS")
MEMCACHED_USERNAME = os.environ.get("MEMCACHEDCLOUD_USERNAME")
MEMCACHED_PASSWORD = os.environ.get("MEMCACHEDCLOUD_PASSWORD")
DEPLOYMENT_ENV = os.environ.get("DEPLOYMENT_ENV")

assert DEPLOYMENT_ENV in ["dev", "main"]


def before_send(event, hint):
Expand Down
3 changes: 2 additions & 1 deletion prizetap/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,8 @@
},
]

VRF_CLIENT_POLYGON_ADDRESS = "0xD1E7877A1C3F782dec76FB58C2B926365433d46F"
VRF_CLIENT_POLYGON_ADDRESS = "0xd713f3584EADc92848d64C31fD66CD50AdF272CD"
VRF_CLIENT_MUMBAI_ADDRESS = "0xD1E7877A1C3F782dec76FB58C2B926365433d46F"

CONTRACT_ADDRESSES = {
"137": {
Expand Down
4 changes: 3 additions & 1 deletion prizetap/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from celery import shared_task
from django.utils import timezone

from brightIDfaucet.settings import DEPLOYMENT_ENV
from core.helpers import memcache_lock

from .models import Raffle
Expand Down Expand Up @@ -41,9 +42,10 @@ def set_raffle_random_words(self):


def set_random_words(raffle: Raffle):
app = "unitap" if DEPLOYMENT_ENV == "main" else "stage_unitap"
muon_response = requests.get(
(
"https://shield.unitap.app/v1/?app=stage_unitap&method=random-words&"
f"https://shield.unitap.app/v1/?app={app}&method=random-words&"
f"params[chainId]={raffle.chain.chain_id}&params[prizetapRaffle]={raffle.contract}&"
f"params[raffleId]={raffle.raffleId}"
)
Expand Down
5 changes: 4 additions & 1 deletion prizetap/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time

from brightIDfaucet.settings import DEPLOYMENT_ENV
from core.utils import Web3Utils
from faucet.models import Chain

Expand All @@ -8,6 +9,7 @@
PRIZETAP_ERC721_ABI,
UNITAP_PASS_ABI,
VRF_CLIENT_ABI,
VRF_CLIENT_MUMBAI_ADDRESS,
VRF_CLIENT_POLYGON_ADDRESS,
)

Expand Down Expand Up @@ -61,7 +63,8 @@ def get_raffle_winners_count(self):
class VRFClientContractClient(Web3Utils):
def __init__(self, chain) -> None:
super().__init__(chain.rpc_url_private, chain.poa)
self.set_contract(VRF_CLIENT_POLYGON_ADDRESS, VRF_CLIENT_ABI)
address = VRF_CLIENT_POLYGON_ADDRESS if DEPLOYMENT_ENV == "main" else VRF_CLIENT_MUMBAI_ADDRESS
self.set_contract(address, VRF_CLIENT_ABI)
self.set_account(chain.wallet.private_key)

def get_last_request_id(self):
Expand Down
1 change: 1 addition & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ SECRET_KEY="django-insecure-!=_mi0j#rhk7c9p-0wg-3me6y&fk$+fahz6fh)k1n#&@s(9vf5"
BRIGHT_PRIVATE_KEY=""
DEBUG="True"
SENTRY_DSN="DEBUG-DSN"
DEPLOYMENT_ENV="env"