Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit fd6a68d

Browse files
committed
Fix scatter token addresses, add timeout to claims
1 parent 21aba8a commit fd6a68d

4 files changed

Lines changed: 40 additions & 16 deletions

File tree

axie-utils/axie_utils/abis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@
134134
'type': 'function'
135135
}, {
136136
'constant': False,
137-
'inputs': [
138-
{'name': 'recipients', 'type': 'address[]'},{'name': 'values', 'type': 'uint256[]'}],
137+
'inputs': [{'name': 'recipients', 'type': 'address[]'},{'name': 'values', 'type': 'uint256[]'}],
139138
'name': 'disperseEther',
140139
'outputs': [],
141140
'payable': True,

axie-utils/axie_utils/claims.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
check_balance,
1515
get_nonce,
1616
SLP_CONTRACT,
17-
RONIN_PROVIDER
17+
RONIN_PROVIDER,
18+
TIMEOUT_MINS
1819
)
1920
from axie_utils.graphql import AxieGraphQL, TrezorAxieGraphQL
2021

@@ -116,8 +117,14 @@ async def async_execute(self):
116117
self.w3.eth.send_raw_transaction(signed_claim.rawTransaction)
117118
# Get transaction hash
118119
hash = self.w3.toHex(self.w3.keccak(signed_claim.rawTransaction))
119-
# Wait for transaction to finish
120+
# Wait for transaction to finish or timeout
121+
start_time = datetime.now()
120122
while True:
123+
# We will wait for max 5 minutes for this tx to respond
124+
if datetime.now() - start_time > timedelta(minutes=TIMEOUT_MINS):
125+
success = False
126+
logging.info(f"Transaction {self}, timed out!")
127+
break
121128
try:
122129
recepit = self.w3.eth.get_transaction_receipt(hash)
123130
if recepit["status"] == 1:
@@ -188,8 +195,14 @@ def execute(self):
188195
self.w3.eth.send_raw_transaction(signed_claim.rawTransaction)
189196
# Get transaction hash
190197
hash = self.w3.toHex(self.w3.keccak(signed_claim.rawTransaction))
191-
# Wait for transaction to finish
198+
# Wait for transaction to finish or timeout
199+
start_time = datetime.now()
192200
while True:
201+
# We will wait for max 5 minutes for this tx to respond
202+
if datetime.now() - start_time > timedelta(minutes=TIMEOUT_MINS):
203+
success = False
204+
logging.info(f"Transaction {self}, timed out!")
205+
break
193206
try:
194207
recepit = self.w3.eth.get_transaction_receipt(hash)
195208
if recepit["status"] == 1:
@@ -318,8 +331,14 @@ async def async_execute(self):
318331
# Send raw transaction
319332
self.w3.eth.send_raw_transaction(transaction)
320333
hash = self.w3.toHex(self.w3.keccak(transaction))
321-
# Wait for transaction to finish
334+
# Wait for transaction to finish or timeout
335+
start_time = datetime.now()
322336
while True:
337+
# We will wait for max 5 minutes for this tx to respond
338+
if datetime.now() - start_time > timedelta(minutes=TIMEOUT_MINS):
339+
success = False
340+
logging.info(f"Transaction {self}, timed out!")
341+
break
323342
try:
324343
recepit = self.w3.eth.get_transaction_receipt(hash)
325344
if recepit["status"] == 1:
@@ -400,8 +419,14 @@ def execute(self):
400419
# Send raw transaction
401420
self.w3.eth.send_raw_transaction(transaction)
402421
hash = self.w3.toHex(self.w3.keccak(transaction))
403-
# Wait for transaction to finish
422+
# Wait for transaction to finish or timeout
423+
start_time = datetime.now()
404424
while True:
425+
# We will wait for max 5 minutes for this tx to respond
426+
if datetime.now() - start_time > timedelta(minutes=TIMEOUT_MINS):
427+
success = False
428+
logging.info(f"Transaction {self}, timed out!")
429+
break
405430
try:
406431
recepit = self.w3.eth.get_transaction_receipt(hash)
407432
if recepit["status"] == 1:

axie-utils/axie_utils/payments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def execute(self, gas_price=1, nonce=None):
8080
break
8181
except exceptions.TransactionNotFound:
8282
# Sleep 10s while waiting
83-
sleep(10)
8483
logging.info(f"Waiting for transaction '{self}' to finish (Nonce:{nonce})...")
84+
sleep(10)
8585

8686
if success:
8787
logging.info(f"Transaction {self} completed! _hash: {_hash} - "
@@ -168,8 +168,8 @@ def execute(self, gas_price=1, nonce=None):
168168
break
169169
except exceptions.TransactionNotFound:
170170
# Sleep 10s while waiting
171-
sleep(10)
172171
logging.info(f"Waiting for transaction '{self}' to finish (Nonce:{nonce})...")
172+
sleep(10)
173173

174174
if success:
175175
logging.info(f"Transaction {self} completed! _hash: {_hash} - "

axie-utils/axie_utils/scatter.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def execute_token(self, gas_price=1, nonce=None):
9696
nonce = get_nonce(self.from_acc)
9797
# Build transaction
9898
transaction = self.contract.functions.disperseTokenSimple(
99-
TOKEN[self.token],
99+
Web3.toChecksumAddress(TOKEN[self.token]),
100100
self.to_list,
101101
self.amounts_list
102102
).buildTransaction({
@@ -131,8 +131,8 @@ def execute_token(self, gas_price=1, nonce=None):
131131
break
132132
except exceptions.TransactionNotFound:
133133
# Sleep 10s while waiting
134-
sleep(10)
135134
logging.info(f"Waiting for transaction '{self}' to finish (Nonce:{nonce})...")
135+
sleep(10)
136136

137137
if success:
138138
logging.info(f"Transaction {self} completed! hash: {_hash} - "
@@ -188,8 +188,8 @@ def execute_ron(self, gas_price=1, nonce=None):
188188
break
189189
except exceptions.TransactionNotFound:
190190
# Sleep 10s while waiting
191-
sleep(10)
192191
logging.info(f"Waiting for transaction '{self}' to finish (Nonce:{nonce})...")
192+
sleep(10)
193193

194194
if success:
195195
logging.info(f"Transaction {self} completed! hash: {_hash} - "
@@ -259,7 +259,7 @@ def approve_contract(self):
259259
nonce=nonce,
260260
gas_price=self.w3.toWei(1, "gwei"),
261261
gas_limit=1000000,
262-
to=TOKEN[self.token],
262+
to=Web3.toChecksumAddress(TOKEN[self.token]),
263263
value=0,
264264
data=data,
265265
chain_id=2020
@@ -299,7 +299,7 @@ def execute_token(self, gas_price=1, nonce=None):
299299
nonce = get_nonce(self.from_acc)
300300
# Build transaction
301301
transaction = self.contract.functions.disperseTokenSimple(
302-
TOKEN[self.token],
302+
Web3.toChecksumAddress(TOKEN[self.token]),
303303
self.to_list,
304304
self.amounts_list
305305
).buildTransaction({
@@ -342,8 +342,8 @@ def execute_token(self, gas_price=1, nonce=None):
342342
break
343343
except exceptions.TransactionNotFound:
344344
# Sleep 10s while waiting
345-
sleep(10)
346345
logging.info(f"Waiting for transaction '{self}' to finish (Nonce:{nonce})...")
346+
sleep(10)
347347

348348
if success:
349349
logging.info(f"Transaction {self} completed! hash: {_hash} - "
@@ -407,8 +407,8 @@ def execute_ron(self, gas_price=1, nonce=None):
407407
break
408408
except exceptions.TransactionNotFound:
409409
# Sleep 10s while waiting
410-
sleep(10)
411410
logging.info(f"Waiting for transaction '{self}' to finish (Nonce:{nonce})...")
411+
sleep(10)
412412

413413
if success:
414414
logging.info(f"Transaction {self} completed! hash: {_hash} - "

0 commit comments

Comments
 (0)