fix wallet verify proxy resilience

This commit is contained in:
2569718930@qq.com
2026-06-13 22:09:11 +08:00
parent e0cbe57071
commit 1ceeb7e7e0
3 changed files with 102 additions and 18 deletions
@@ -243,10 +243,30 @@ export function runTests() {
walletChallengeRouteSource.includes("retryable: true"),
"wallet challenge proxy exception response must mark transient failures as retryable",
);
const walletVerifyRouteSource = fs.readFileSync(
path.join(projectRoot, "app/api/payments/wallets/verify/route.ts"),
"utf8",
);
assert(
walletVerifyRouteSource.includes("fetchWalletVerifyWithRetry"),
"wallet verify proxy must retry a transient backend connection failure before blocking wallet binding",
);
assert(
walletVerifyRouteSource.includes("Invalid wallet verify request"),
"wallet verify proxy must return a client error for malformed JSON instead of a generic payment failure",
);
assert(
walletVerifyRouteSource.includes("retryable: true"),
"wallet verify proxy exception response must mark transient failures as retryable",
);
assert(
walletBindSource.includes("readPaymentApiErrorMessage"),
"wallet binding errors must show the API error message instead of raw JSON",
);
assert(
walletBindSource.includes("钱包验证服务暂时不可用"),
"wallet binding HTML/50x fallback should stay localized in the Chinese account UI",
);
assert(
paymentUtilsSource.includes("looksLikeHtmlDocument") &&
paymentUtilsSource.includes("Payment service is temporarily unavailable") &&
+12 -2
View File
@@ -304,7 +304,12 @@ export function useWalletBind(params: UseWalletBindParams) {
method: "POST", headers: authHeaders, body: JSON.stringify({ address }),
});
if (!challengeRes.ok) {
const message = await readPaymentApiErrorMessage(challengeRes);
const message = await readPaymentApiErrorMessage(
challengeRes,
isEn
? "Wallet challenge service is temporarily unavailable."
: "钱包验证服务暂时不可用。",
);
throw new Error(copy.challengeFailed.replace("{raw}", message));
}
@@ -318,7 +323,12 @@ export function useWalletBind(params: UseWalletBindParams) {
method: "POST", headers: authHeaders, body: JSON.stringify({ address, nonce, signature }),
});
if (!verifyRes.ok) {
const message = await readPaymentApiErrorMessage(verifyRes);
const message = await readPaymentApiErrorMessage(
verifyRes,
isEn
? "Wallet verify service is temporarily unavailable."
: "钱包验证服务暂时不可用。",
);
throw new Error(copy.verifyFailedRaw.replace("{raw}", message));
}