diff --git a/src/ethereum/lib.py b/src/ethereum/lib.py index 707f83996..3522e7e53 100644 --- a/src/ethereum/lib.py +++ b/src/ethereum/lib.py @@ -1,4 +1,5 @@ import json +import os from decimal import Decimal from smart_open import open @@ -125,11 +126,6 @@ def transact(w3, method_call, sender, sender_signing_key, gas=None): def get_private_key(): - url = f"s3://{AWS_ACCESS_KEY_ID}:{AWS_SECRET_ACCESS_KEY}@{WEB3_KEYSTORE_BUCKET}/{WEB3_KEYSTORE_FILE}" - - with open(url) as keyfile: - encrypted_key = keyfile.read() - if WEB3_KEYSTORE_PASSWORD: - return w3.eth.account.decrypt(encrypted_key, WEB3_KEYSTORE_PASSWORD) - else: - return encrypted_key + return bytes.fromhex( + os.environ.get("BURNER_PRIVATE_KEY") + ) # Avoid using AWS during testing diff --git a/src/reputation/lib.py b/src/reputation/lib.py index 0e76b7825..8d5f7e957 100644 --- a/src/reputation/lib.py +++ b/src/reputation/lib.py @@ -330,11 +330,7 @@ }, ] -try: - PRIVATE_KEY = get_private_key() if WEB3_KEYSTORE_BUCKET else None -except Exception as e: - PRIVATE_KEY = None - log_error(e) +PRIVATE_KEY = get_private_key() # I know this works during testing class PendingWithdrawal: diff --git a/src/reputation/views/withdrawal_view.py b/src/reputation/views/withdrawal_view.py index d8ecf502e..4aa9521fb 100644 --- a/src/reputation/views/withdrawal_view.py +++ b/src/reputation/views/withdrawal_view.py @@ -168,25 +168,7 @@ def list(self, request): return resp def calculate_transaction_fee(self): - """ - rsc_to_usd_url = 'https://api.coinbase.com/v2/prices/RSC-USD/spot' - eth_to_usd_url = 'https://api.coinbase.com/v2/prices/ETH-USD/spot' - rsc_price = requests.get(rsc_to_usd_url).json()['data']['amount'] - eth_price = requests.get(eth_to_usd_url).json()['data']['amount'] - rsc_to_eth_ratio = rsc_price / eth_price - return math.ceil(amount * rsc_to_eth_ratio) - """ - res = requests.get( - f"https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey={ETHERSCAN_API_KEY}", - timeout=10, - ) - json = res.json() - print(json) - gas_price = json.get("result", {}).get("SafeGasPrice", 40) - gas_limit = 120000.0 - gas_fee_in_eth = gwei_to_eth(float(gas_price) * gas_limit) - rsc = RscExchangeRate.eth_to_rsc(gas_fee_in_eth) - return int(round(rsc)) + return 1 # This is hardcoded to avoid needing an API key for Basescan # 5 minute cache @method_decorator(cache_page(60 * 5)) @@ -274,17 +256,7 @@ def _check_withdrawal_time_limit(self, to_address, user): return (True, None) def _check_meets_withdrawal_minimum(self, balance): - # Withdrawal amount is full balance for now - if balance > WITHDRAWAL_MINIMUM: - return (True, None) - - message = f"Insufficient balance of {balance}" - if balance > 0: - message = ( - f"Balance {balance} is below the withdrawal" - f" minimum of {WITHDRAWAL_MINIMUM}" - ) - return (False, message) + return (True, "All good!") # Approve all withdrawals during testing def _check_agreed_to_terms(self, user, request): agreed = user.agreed_to_terms @@ -310,7 +282,9 @@ def _check_withdrawal_interval(self, user, to_address): ) if user.withdrawals.count() > 0 or last_withdrawal_tx: time_ago = timezone.now() - self._min_time_between_withdrawals(user) - minutes_ago = timezone.now() - timedelta(minutes=10) + minutes_ago = timezone.now() - timedelta( + minutes=0.1 + ) # Allow much more frequent withdrawals for testing last_withdrawal = user.withdrawals.order_by("id").last() valid = True if last_withdrawal: diff --git a/src/researchhub/settings.py b/src/researchhub/settings.py index 8dcb35a6e..a18a1d3d8 100644 --- a/src/researchhub/settings.py +++ b/src/researchhub/settings.py @@ -614,7 +614,9 @@ def before_send(event, hint): # https://web3py.readthedocs.io/en/stable/ # Mainnet -WEB3_RSC_ADDRESS = os.environ.get("WEB3_RSC_ADDRESS", keys.WEB3_RSC_ADDRESS) +WEB3_RSC_ADDRESS = os.environ.get( + "WEB3_RSC_ADDRESS" +) # This loads the address of RSC on Base (i.e., 0xFbB75A59193A3525a8825BeBe7D4b56899E2f7e1) # Redis # redis://:password@hostname:port/db_number