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

Commit 642b86f

Browse files
author
FerranMarin
committed
Change claim endpoint for the new one
1 parent c7588eb commit 642b86f

2 files changed

Lines changed: 62 additions & 71 deletions

File tree

axie-utils/axie_utils/claims.py

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ def localize_date(self, date_utc):
4141
def humanize_date(self, date):
4242
local_date = self.localize_date(date)
4343
return local_date.strftime("%m/%d/%Y, %H:%M")
44-
44+
4545
def has_unclaimed_slp(self):
46-
url = f"https://game-api.skymavis.com/game-api/clients/{self.account}/items/1"
46+
url = f"http://game-api-pre.skymavis.com/v1/players/{self.account}/items/1"
4747
try:
4848
response = self.request.get(url, headers={"User-Agent": self.user_agent})
4949
except RetryError:
5050
logging.critical(f"Important: Failed to check if there is unclaimed SLP for acc {self.acc_name} "
51-
f"({self.account.replace('0x','ronin:')})")
51+
f"({self.account.replace('0x', 'ronin:')})")
5252
return None
5353
if 200 <= response.status_code <= 299:
5454
data = response.json()
55-
last_claimed = datetime.utcfromtimestamp(data['last_claimed_item_at'])
55+
last_claimed = datetime.utcfromtimestamp(data['lastClaimedItemAt'])
5656
next_claim_date = last_claimed + timedelta(days=14)
5757
utcnow = datetime.utcnow()
5858
if utcnow < next_claim_date and not self.force:
59-
logging.critical(f"Important: This account will be claimable again on {self.humanize_date(next_claim_date)}.")
59+
logging.critical(
60+
f"Important: This account will be claimable again on {self.humanize_date(next_claim_date)}.")
6061
return None
6162
elif self.force:
62-
logging.info('Skipping check of dates, --force option was selected')
63-
wallet_total = check_balance(self.account)
64-
in_game_total = int(data['total'])
65-
if in_game_total > wallet_total:
66-
return in_game_total - wallet_total
63+
logging.info('Important: Skipping check of dates, --force option was selected')
64+
claimable_total = int(data['rawClaimableTotal'])
65+
if claimable_total > 0:
66+
return claimable_total
6767
return None
6868

6969
async def async_execute(self):
@@ -83,18 +83,18 @@ async def async_execute(self):
8383
"User-Agent": self.user_agent,
8484
"authorization": f"Bearer {jwt}"
8585
}
86-
url = f"https://game-api.skymavis.com/game-api/clients/{self.account}/items/1/claim"
86+
url = "http://game-api-pre.skymavis.com/v1/players/me/items/1/claim"
8787
try:
8888
response = self.request.post(url, headers=headers, json="")
8989
except RetryError as e:
9090
logging.critical(f"Important: Error! Executing SLP claim API call for account {self.acc_name}"
9191
f"({self.account.replace('0x', 'ronin:')}). Error {e}")
9292
return
9393
if 200 <= response.status_code <= 299:
94-
signature = response.json()["blockchain_related"].get("signature")
94+
signature = response.json()["blockchainRelated"].get("signature")
9595
if not signature or not signature["signature"]:
9696
logging.critical(f"Important: Account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) had no signature "
97-
"in blockchain_related")
97+
"in blockchainRelated")
9898
return
9999
else:
100100
logging.info(f"Important: Claim for account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) "
@@ -161,18 +161,18 @@ def execute(self):
161161
"User-Agent": self.user_agent,
162162
"authorization": f"Bearer {jwt}"
163163
}
164-
url = f"https://game-api.skymavis.com/game-api/clients/{self.account}/items/1/claim"
164+
url = "http://game-api-pre.skymavis.com/v1/players/me/items/1/claim"
165165
try:
166166
response = self.request.post(url, headers=headers, json="")
167167
except RetryError as e:
168168
logging.critical(f"Important: Error! Executing SLP claim API call for account {self.acc_name}"
169169
f"({self.account.replace('0x', 'ronin:')}). Error {e}")
170170
return
171171
if 200 <= response.status_code <= 299:
172-
signature = response.json()["blockchain_related"].get("signature")
172+
signature = response.json()["blockchainRelated"].get("signature")
173173
if not signature or not signature["signature"]:
174174
logging.critical(f"Important: Account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) had no signature "
175-
"in blockchain_related")
175+
"in blockchainRelated")
176176
return
177177
else:
178178
logging.info(f"Important: Claim for account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) "
@@ -248,10 +248,9 @@ def localize_date(self, date_utc):
248248
def humanize_date(self, date):
249249
local_date = self.localize_date(date)
250250
return local_date.strftime("%m/%d/%Y, %H:%M")
251-
252-
251+
253252
def has_unclaimed_slp(self):
254-
url = f"https://game-api.skymavis.com/game-api/clients/{self.account}/items/1"
253+
url = f"http://game-api-pre.skymavis.com/v1/players/{self.account}/items/1"
255254
try:
256255
response = self.request.get(url, headers={"User-Agent": self.user_agent})
257256
except RetryError:
@@ -260,18 +259,17 @@ def has_unclaimed_slp(self):
260259
return None
261260
if 200 <= response.status_code <= 299:
262261
data = response.json()
263-
last_claimed = datetime.utcfromtimestamp(data['last_claimed_item_at'])
262+
last_claimed = datetime.utcfromtimestamp(data['lastClaimedItemAt'])
264263
next_claim_date = last_claimed + timedelta(days=14)
265264
utcnow = datetime.utcnow()
266265
if utcnow < next_claim_date and not self.force:
267266
logging.critical(f"Important: This account will be claimable again on {self.humanize_date(next_claim_date)}.")
268267
return None
269268
elif self.force:
270269
logging.info('Important: Skipping check of dates, --force option was selected')
271-
wallet_total = check_balance(self.account)
272-
in_game_total = int(data['total'])
273-
if in_game_total > wallet_total:
274-
return in_game_total - wallet_total
270+
claimable_total = int(data['rawClaimableTotal'])
271+
if claimable_total > 0:
272+
return claimable_total
275273
return None
276274

277275
async def async_execute(self):
@@ -291,18 +289,18 @@ async def async_execute(self):
291289
"User-Agent": self.user_agent,
292290
"authorization": f"Bearer {jwt}"
293291
}
294-
url = f"https://game-api.skymavis.com/game-api/clients/{self.account}/items/1/claim"
292+
url = "http://game-api-pre.skymavis.com/v1/players/me/items/1/claim"
295293
try:
296294
response = self.request.post(url, headers=headers, json="")
297295
except RetryError as e:
298296
logging.critical(f"Important: Error! Executing SLP claim API call for account {self.acc_name}"
299297
f"({self.account.replace('0x', 'ronin:')}). Error {e}")
300298
return
301299
if 200 <= response.status_code <= 299:
302-
signature = response.json()["blockchain_related"].get("signature")
300+
signature = response.json()["blockchainRelated"].get("signature")
303301
if not signature or not signature["signature"]:
304302
logging.critical(f"Important: Account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) had no signature "
305-
"in blockchain_related")
303+
"in blockchainRelated")
306304
return
307305
else:
308306
logging.info(f"Important: Claim for account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) "
@@ -383,18 +381,18 @@ def execute(self):
383381
"User-Agent": self.user_agent,
384382
"authorization": f"Bearer {jwt}"
385383
}
386-
url = f"https://game-api.skymavis.com/game-api/clients/{self.account}/items/1/claim"
384+
url = "http://game-api-pre.skymavis.com/v1/players/me/items/1/claim"
387385
try:
388386
response = self.request.post(url, headers=headers, json="")
389387
except RetryError as e:
390388
logging.critical(f"Important: Error! Executing SLP claim API call for account {self.acc_name}"
391389
f"({self.account.replace('0x', 'ronin:')}). Error {e}")
392390
return
393391
if 200 <= response.status_code <= 299:
394-
signature = response.json()["blockchain_related"].get("signature")
392+
signature = response.json()["blockchainRelated"].get("signature")
395393
if not signature or not signature["signature"]:
396394
logging.critical(f"Important: Account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) had no signature "
397-
"in blockchain_related")
395+
"in blockchainRelated")
398396
return
399397
else:
400398
logging.info(f"Important: Claim for account {self.acc_name} ({self.account.replace('0x', 'ronin:')}) "

0 commit comments

Comments
 (0)