diff --git a/src/Managing.Api/appsettings.Oda.json b/src/Managing.Api/appsettings.Oda.json index b7f3cee..9851253 100644 --- a/src/Managing.Api/appsettings.Oda.json +++ b/src/Managing.Api/appsettings.Oda.json @@ -39,5 +39,7 @@ "AllowedHosts": "*", "WorkerBotManager": true, "WorkerBalancesTracking": false, - "WorkerNotifyBundleBacktest": true + "WorkerNotifyBundleBacktest": true, + "KAIGEN_SECRET_KEY": "KaigenXCowchain", + "KAIGEN_CREDITS_ENABLED": true } \ No newline at end of file diff --git a/src/Managing.Api/appsettings.Sandbox.json b/src/Managing.Api/appsettings.Sandbox.json index d0484ba..d2c082a 100644 --- a/src/Managing.Api/appsettings.Sandbox.json +++ b/src/Managing.Api/appsettings.Sandbox.json @@ -12,7 +12,7 @@ "AppSecret": "63Chz2z5M8TgR5qc8dznSLRAGTHTyPU4cjdQobrBF1Cx5tszZpTuFgyrRd7hZ2k6HpwDz3GEwQZzsCqHb8Z311bF" }, "Kaigen": { - "BaseUrl": "https://kaigen-back-development.up.railway.app/", + "BaseUrl": "https://kaigen-back-development.up.railway.app", "DebitEndpoint": "/api/credits/debit", "RefundEndpoint": "/api/credits/refund" }, diff --git a/src/Managing.Api/appsettings.json b/src/Managing.Api/appsettings.json index eb37ef0..dbfa6c6 100644 --- a/src/Managing.Api/appsettings.json +++ b/src/Managing.Api/appsettings.json @@ -24,7 +24,7 @@ "BaseUrl": "http://localhost:4111" }, "Kaigen": { - "BaseUrl": "https://api.kaigen.managing.live", + "BaseUrl": "https://kaigen-back-development.up.railway.app", "DebitEndpoint": "/api/credits/debit", "RefundEndpoint": "/api/credits/refund" }, diff --git a/src/Managing.Infrastructure.Web3/Services/KaigenService.cs b/src/Managing.Infrastructure.Web3/Services/KaigenService.cs index 99e8f9c..6e46d08 100644 --- a/src/Managing.Infrastructure.Web3/Services/KaigenService.cs +++ b/src/Managing.Infrastructure.Web3/Services/KaigenService.cs @@ -92,7 +92,6 @@ public class KaigenService : IKaigenService var requestPayload = new { requestId = requestId, - walletAddress = walletAddress, debitAmount = debitAmount }; @@ -114,6 +113,13 @@ public class KaigenService : IKaigenService } var result = await response.Content.ReadFromJsonAsync(_jsonOptions); + + if (result == null || !result.Success) + { + _logger.LogError("Debit request failed: {Message}", result?.Message ?? "Unknown error"); + throw new Exception($"Debit request failed: {result?.Message}"); + } + _logger.LogInformation( "Successfully debited {Amount} credits for user {UserName} (wallet: {WalletAddress})", debitAmount, user.Name, walletAddress); @@ -145,7 +151,6 @@ public class KaigenService : IKaigenService var requestPayload = new { requestId = requestId, - walletAddress = walletAddress }; _logger.LogInformation( @@ -180,21 +185,21 @@ public class KaigenService : IKaigenService { // Create the auth token: "walletaddress-username" var authToken = $"{GetUserWalletAddress(user)}-{user.Name}"; - + // Encrypt the auth token using AES-256-GCM var encryptedToken = CryptoHelpers.EncryptAesGcm(authToken, _settings.SecretKey); - + // Create Basic Auth header with the encrypted token var basicAuthString = $"{encryptedToken}:"; var base64Auth = Convert.ToBase64String(Encoding.ASCII.GetBytes(basicAuthString)); - + // Create a new request with the auth header var request = new HttpRequestMessage(HttpMethod.Put, url) { Content = JsonContent.Create(payload, options: _jsonOptions) }; request.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64Auth); - + return await _httpClient.SendAsync(request); } diff --git a/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx b/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx index 98a796c..bf772c5 100644 --- a/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx +++ b/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx @@ -111,7 +111,6 @@ const LogIn = () => {