@coti-io/coti-wallet-plugin 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3673,6 +3673,17 @@ var usePrivateTokenBalance = () => {
|
|
|
3673
3673
|
if (error instanceof CotiPluginError) {
|
|
3674
3674
|
throw error;
|
|
3675
3675
|
}
|
|
3676
|
+
const message = error instanceof Error ? error.message : String(error?.message ?? error ?? "");
|
|
3677
|
+
const code = error?.code;
|
|
3678
|
+
const isDecryptPayloadFailure = message.includes("Invalid encrypted payload") || code === -32603 && /encrypt|decrypt|ciphertext/i.test(message);
|
|
3679
|
+
if (isDecryptPayloadFailure || canUseSnapDecrypt) {
|
|
3680
|
+
logger.error(`\u274C Failed to decrypt private balance for ${contractAddress}`, error);
|
|
3681
|
+
throw new CotiPluginError(
|
|
3682
|
+
"AES_KEY_MISMATCH" /* AES_KEY_MISMATCH */,
|
|
3683
|
+
isDecryptPayloadFailure ? "Could not decrypt private balances. The Snap AES key may be missing or invalid \u2014 re-onboarding is required." : "Could not decrypt private balances via Snap. Re-onboarding may be required.",
|
|
3684
|
+
message
|
|
3685
|
+
);
|
|
3686
|
+
}
|
|
3676
3687
|
logger.error(`\u274C Failed to fetch/decrypt for ${contractAddress}`, error);
|
|
3677
3688
|
return "0.00";
|
|
3678
3689
|
}
|
|
@@ -4073,7 +4084,7 @@ var useBalanceUpdater = ({
|
|
|
4073
4084
|
return { symbol: token.symbol, value, isMismatch: false };
|
|
4074
4085
|
} catch (e) {
|
|
4075
4086
|
const msg = e?.message || "";
|
|
4076
|
-
const isMismatch = msg.includes("AES key mismatch") || msg.includes("onboarding") || msg.includes("ACCOUNT_NOT_ONBOARDED") || msg.includes("implausible decrypted balance");
|
|
4087
|
+
const isMismatch = e instanceof CotiPluginError && (e.code === "AES_KEY_MISMATCH" /* AES_KEY_MISMATCH */ || e.code === "ACCOUNT_NOT_ONBOARDED" /* ACCOUNT_NOT_ONBOARDED */) || msg.includes("AES key mismatch") || msg.includes("Invalid encrypted payload") || msg.includes("onboarding") || msg.includes("ACCOUNT_NOT_ONBOARDED") || msg.includes("implausible decrypted balance");
|
|
4077
4088
|
if (isMismatch) {
|
|
4078
4089
|
logger.warn(`\u26A0\uFE0F Private token decrypt mismatch for ${tokenAddress}. Falling back to 0.`);
|
|
4079
4090
|
return { symbol: token.symbol, value: "0", isMismatch: true };
|