Skip to content

Commit

Permalink
restore changes (#9539)
Browse files Browse the repository at this point in the history
  • Loading branch information
chibie authored Sep 29, 2021
1 parent ae86908 commit 6f0e4e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
25 changes: 12 additions & 13 deletions app/grants/models/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import requests
from economy.models import SuperModel
from economy.tx import check_for_replaced_tx
from townsquare.models import Comment
from web3 import Web3

Expand Down Expand Up @@ -153,9 +154,8 @@ def leave_gitcoinbot_comment_for_status(self, status):
def update_tx_status(self):
"""Updates tx status for Ethereum contributions."""
try:
from dashboard.utils import get_web3
from economy.tx import grants_transaction_validator
from dashboard.utils import get_tx_status
from economy.tx import getReplacedTX

# If `tx_override` is True, we don't run the validator for this contribution
if self.tx_override:
Expand Down Expand Up @@ -186,20 +186,19 @@ def update_tx_status(self):
self.tx_cleared = True
self.validator_comment = "zkSync checkout. Success" if self.success else f"zkSync Checkout. {tx_data['fail_reason']}"

elif self.checkout_type == 'eth_std':
# Standard L1 checkout using the BulkCheckout contract
elif self.checkout_type == 'eth_std' or self.checkout_type == 'eth_polygon':
# Standard L1 and sidechain L2 checkout using the BulkCheckout contract

# get active chain std/polygon
chain = self.checkout_type.split('_')[-1]

# Prepare web3 provider
PROVIDER = "wss://" + network + ".infura.io/ws/v3/" + settings.INFURA_V3_PROJECT_ID
w3 = Web3(Web3.WebsocketProvider(PROVIDER))
w3 = get_web3(network, chain=chain)

# Handle dropped/replaced transactions
split_tx_status, _ = get_tx_status(self.split_tx_id, self.subscription.network, self.created_on)
if split_tx_status in ['pending', 'dropped', 'unknown', '']:
new_tx = getReplacedTX(self.split_tx_id)
if new_tx:
self.split_tx_id = new_tx
split_tx_status, _ = get_tx_status(self.split_tx_id, self.subscription.network, self.created_on)
_, split_tx_status, _ = check_for_replaced_tx(
self.split_tx_id, network, self.created_on, chain=chain
)

# Handle pending txns
if split_tx_status in ['pending']:
Expand All @@ -225,7 +224,7 @@ def update_tx_status(self):
return

# Validate that the token transfers occurred
response = grants_transaction_validator(self, w3)
response = grants_transaction_validator(self, w3, chain=chain)
if len(response['originator']):
self.originated_address = response['originator'][0]
self.validator_passed = response['validation']['passed']
Expand Down
2 changes: 1 addition & 1 deletion app/grants/models/grant_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class GrantTag(SuperModel):

def __str__(self):
"""Return the string representation of a GrantTag."""
return f"{self.name}"
return f"{self.name}"
2 changes: 1 addition & 1 deletion app/grants/tests/models/factories/grant_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class GrantFactory(factory.django.DjangoModelFactory):
"""Create mock Grant for testing."""

class Meta:
model = Grant
model = Grant
2 changes: 0 additions & 2 deletions app/grants/tests/models/test_cart_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ def test_cart_activity_has_latest_attribute(self):

assert hasattr(cart_activity, "latest")
assert cart_activity.latest == False


0 comments on commit 6f0e4e2

Please sign in to comment.