Skip to content

Commit 5484d90

Browse files
committed
login retry optimize
1 parent 8abd978 commit 5484d90

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

StarSharksTool/AccountManagement.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ private Label GenerateLabel(string text)
388388

389389
private async Task<AccountInfoModel> GetAccountInfo(string token)
390390
{
391-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "https://www.starsharks.com/go/auth-api/account/base");
391+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, $"https://www.starsharks.com/go/auth-api/account/base?nonce={Global.Nonce()}");
392392
httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
393393
var client = Global.HTTPCLIENT;
394394
{
@@ -406,11 +406,11 @@ private async Task<AccountInfoModel> GetAccountInfo(string token)
406406

407407
private async Task<IList<SharkModel>> GetSharks(string token, string address)
408408
{
409+
RETRY:
409410
var query = new QuerySharksModel();
410-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "https://www.starsharks.com/go/auth-api/account/sharks");
411+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, $"https://www.starsharks.com/go/auth-api/account/sharks?nonce={Global.Nonce()}");
411412
httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
412413
httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(query), Encoding.UTF8, "application/json");
413-
RETRY:
414414
try
415415
{
416416
var client = Global.HTTPCLIENT;

StarSharksTool/Global.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,10 @@ internal static ILogger GetLogger(string? fullName)
9090
{
9191
return LoggerFactory.CreateLogger(fullName);
9292
}
93+
public static int nonce { get; set; } = 0;
94+
internal static object Nonce()
95+
{
96+
return ++nonce;
97+
}
9398
}
9499
}

StarSharksTool/Services/Service.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ internal async static Task<MarketRentResponseModel> GetMarketplace(int maxPrice,
134134
{
135135
try
136136
{
137-
var url = "https://www.starsharks.com/go/api/market/sharks";
137+
var url = $"https://www.starsharks.com/go/api/market/sharks?nonce={Global.Nonce()}";
138138
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, url);
139139
//httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", account.JWTToken);
140140
var req = new MarketRentRequestModel();
@@ -187,7 +187,7 @@ internal async static Task<MarketRentResponseModel> GetMarketplace(int maxPrice,
187187
}
188188
internal async static Task<WithdrawResponseModel> GetSharkWithdrawInfo(AccountModel account)
189189
{
190-
var url = "https://www.starsharks.com/go/auth-api/account/withdraw-sea-v2";
190+
var url = $"https://www.starsharks.com/go/auth-api/account/withdraw-sea-v2?nonce={Global.Nonce()}";
191191
var sharkResp = new WithdrawResponseModel();
192192
//Global.HTTPCLIENT
193193
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, url);
@@ -211,7 +211,7 @@ internal async static Task<RentModel> GetSharkRentInfo(AccountModel account, int
211211
{
212212
var sharkResp = new RentModel();
213213
//Global.HTTPCLIENT
214-
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "https://www.starsharks.com/go/auth-api/market/rent-in");
214+
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, $"https://www.starsharks.com/go/auth-api/market/rent-in?nonce={Global.Nonce()}");
215215
httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", account.WebsiteToken);
216216
httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(new { shark_id = sharkId }), Encoding.UTF8, "application/json");
217217
var client = Global.HTTPCLIENT;
@@ -245,7 +245,7 @@ public static async Task<Dictionary<int, SharkModel>> GetSharkDetails(IEnumerabl
245245

246246
public static async Task<SharkModel> GetSharkDetail(int sharkId)
247247
{
248-
var uri = $"https://www.starsharks.com/go/api/market/shark-detail?shark_id={sharkId}";
248+
var uri = $"https://www.starsharks.com/go/api/market/shark-detail?shark_id={sharkId}&nonce={Global.Nonce()}";
249249
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
250250
var client = Global.HTTPCLIENT;
251251
{

0 commit comments

Comments
 (0)