@medialane/ui 0.178.0 → 0.179.0
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.
|
@@ -27,6 +27,7 @@ __export(describe_error_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(describe_error_exports);
|
|
28
28
|
var import_sdk = require("@medialane/sdk");
|
|
29
29
|
var import_wallet_error = require("./wallet-error.js");
|
|
30
|
+
var import_wallet_failure = require("./wallet-failure.js");
|
|
30
31
|
const NOT_SUBMITTED = "Request not completed. Nothing was submitted.";
|
|
31
32
|
const GENERIC = "Something went wrong. Please try again.";
|
|
32
33
|
const NETWORK_BUSY = "The network is busy right now. Nothing was submitted. Please try again in a moment.";
|
|
@@ -62,6 +63,9 @@ function describeError(error, fallback) {
|
|
|
62
63
|
isUserRejection: true
|
|
63
64
|
};
|
|
64
65
|
}
|
|
66
|
+
if ((0, import_wallet_failure.passkeyUnsupportedReason)(error)) {
|
|
67
|
+
return notice("Passkey not supported", (0, import_wallet_failure.describeWalletFailure)(error).message);
|
|
68
|
+
}
|
|
65
69
|
if (error instanceof import_wallet_error.WrongNetworkError) {
|
|
66
70
|
return notice(
|
|
67
71
|
"Wrong network",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/describe-error.ts"],"sourcesContent":["import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from \"@medialane/sdk\";\nimport { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from \"./wallet-error.js\";\n\nexport const NOT_SUBMITTED = \"Request not completed. Nothing was submitted.\";\nexport const GENERIC = \"Something went wrong. Please try again.\";\nexport const NETWORK_BUSY =\n \"The network is busy right now. Nothing was submitted. Please try again in a moment.\";\n\nexport interface ErrorNotice {\n title: string;\n message: string;\n description?: string;\n isUserRejection: boolean;\n}\n\nconst notice = (title: string, message: string, description?: string): ErrorNotice => ({\n title,\n message,\n description,\n isUserRejection: false,\n});\n\nfunction isTransient(error: unknown): boolean {\n if (error instanceof MedialaneApiError) {\n return error.status === 408 || error.status === 429 || error.status >= 500;\n }\n return /-32001|unable to complete request|service unavailable|temporarily unavailable|rate.?limit|too many requests|gateway time-?out|bad gateway|failed to fetch|fetch failed|network ?error|load failed/i.test(\n collectErrorText(error),\n );\n}\n\nfunction apiReason(error: MedialaneApiError): string | undefined {\n const body = error.details;\n if (body && typeof body === \"object\" && \"error\" in body) {\n const reason = (body as { error?: unknown }).error;\n if (typeof reason === \"string\" && reason.trim() !== \"\") return reason;\n }\n return undefined;\n}\n\nexport function describeError(error: unknown, fallback?: string): ErrorNotice {\n if (error instanceof PasskeyCancelledError || isUserRejectedRequest(error)) {\n const unclear = isBareExecuteFailure(error) || error instanceof PasskeyCancelledError;\n return {\n title: \"Request not completed\",\n message: NOT_SUBMITTED,\n description: unclear\n ? \"Your wallet didn't complete this request. You may have closed or declined it, it may need extra verification such as 2FA before it can sign, or it may have hit a temporary network hiccup. Try again in a moment.\"\n : \"Your wallet didn't complete this request. You may have closed or declined it, or it may need extra verification before it can sign.\",\n isUserRejection: true,\n };\n }\n\n if (error instanceof WrongNetworkError) {\n return notice(\n \"Wrong network\",\n \"Your wallet is connected to the wrong network. Nothing was submitted.\",\n \"Switch your wallet to Starknet Mainnet, then try again.\",\n );\n }\n\n if (isTransient(error)) {\n return notice(\"Network busy\", NETWORK_BUSY);\n }\n\n if (error instanceof UserFacingError) {\n return notice(\"Something went wrong\", error.message);\n }\n\n if (error instanceof MedialaneApiError) {\n return notice(\"Something went wrong\", apiReason(error) ?? fallback ?? GENERIC);\n }\n\n const text = collectErrorText(error).toLowerCase();\n if (text.includes(\"insufficient\") && /balance|allowance|funds/.test(text)) {\n return notice(\n \"Insufficient balance\",\n \"You don't have enough balance to complete this transaction.\",\n \"Add funds to your wallet, then try again.\",\n );\n }\n\n return notice(\"Something went wrong\", fallback ?? GENERIC);\n}\n\nexport { UserFacingError };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0E;AAC1E,0BAAiG;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/describe-error.ts"],"sourcesContent":["import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from \"@medialane/sdk\";\nimport { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from \"./wallet-error.js\";\nimport { describeWalletFailure, passkeyUnsupportedReason } from \"./wallet-failure.js\";\n\nexport const NOT_SUBMITTED = \"Request not completed. Nothing was submitted.\";\nexport const GENERIC = \"Something went wrong. Please try again.\";\nexport const NETWORK_BUSY =\n \"The network is busy right now. Nothing was submitted. Please try again in a moment.\";\n\nexport interface ErrorNotice {\n title: string;\n message: string;\n description?: string;\n isUserRejection: boolean;\n}\n\nconst notice = (title: string, message: string, description?: string): ErrorNotice => ({\n title,\n message,\n description,\n isUserRejection: false,\n});\n\nfunction isTransient(error: unknown): boolean {\n if (error instanceof MedialaneApiError) {\n return error.status === 408 || error.status === 429 || error.status >= 500;\n }\n return /-32001|unable to complete request|service unavailable|temporarily unavailable|rate.?limit|too many requests|gateway time-?out|bad gateway|failed to fetch|fetch failed|network ?error|load failed/i.test(\n collectErrorText(error),\n );\n}\n\nfunction apiReason(error: MedialaneApiError): string | undefined {\n const body = error.details;\n if (body && typeof body === \"object\" && \"error\" in body) {\n const reason = (body as { error?: unknown }).error;\n if (typeof reason === \"string\" && reason.trim() !== \"\") return reason;\n }\n return undefined;\n}\n\nexport function describeError(error: unknown, fallback?: string): ErrorNotice {\n if (error instanceof PasskeyCancelledError || isUserRejectedRequest(error)) {\n const unclear = isBareExecuteFailure(error) || error instanceof PasskeyCancelledError;\n return {\n title: \"Request not completed\",\n message: NOT_SUBMITTED,\n description: unclear\n ? \"Your wallet didn't complete this request. You may have closed or declined it, it may need extra verification such as 2FA before it can sign, or it may have hit a temporary network hiccup. Try again in a moment.\"\n : \"Your wallet didn't complete this request. You may have closed or declined it, or it may need extra verification before it can sign.\",\n isUserRejection: true,\n };\n }\n\n if (passkeyUnsupportedReason(error)) {\n return notice(\"Passkey not supported\", describeWalletFailure(error).message);\n }\n\n if (error instanceof WrongNetworkError) {\n return notice(\n \"Wrong network\",\n \"Your wallet is connected to the wrong network. Nothing was submitted.\",\n \"Switch your wallet to Starknet Mainnet, then try again.\",\n );\n }\n\n if (isTransient(error)) {\n return notice(\"Network busy\", NETWORK_BUSY);\n }\n\n if (error instanceof UserFacingError) {\n return notice(\"Something went wrong\", error.message);\n }\n\n if (error instanceof MedialaneApiError) {\n return notice(\"Something went wrong\", apiReason(error) ?? fallback ?? GENERIC);\n }\n\n const text = collectErrorText(error).toLowerCase();\n if (text.includes(\"insufficient\") && /balance|allowance|funds/.test(text)) {\n return notice(\n \"Insufficient balance\",\n \"You don't have enough balance to complete this transaction.\",\n \"Add funds to your wallet, then try again.\",\n );\n }\n\n return notice(\"Something went wrong\", fallback ?? GENERIC);\n}\n\nexport { UserFacingError };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0E;AAC1E,0BAAiG;AACjG,4BAAgE;AAEzD,MAAM,gBAAgB;AACtB,MAAM,UAAU;AAChB,MAAM,eACX;AASF,MAAM,SAAS,CAAC,OAAe,SAAiB,iBAAuC;AAAA,EACrF;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AACnB;AAEA,SAAS,YAAY,OAAyB;AAC5C,MAAI,iBAAiB,8BAAmB;AACtC,WAAO,MAAM,WAAW,OAAO,MAAM,WAAW,OAAO,MAAM,UAAU;AAAA,EACzE;AACA,SAAO,qMAAqM;AAAA,QAC1M,sCAAiB,KAAK;AAAA,EACxB;AACF;AAEA,SAAS,UAAU,OAA8C;AAC/D,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,OAAO,SAAS,YAAY,WAAW,MAAM;AACvD,UAAM,SAAU,KAA6B;AAC7C,QAAI,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,GAAI,QAAO;AAAA,EACjE;AACA,SAAO;AACT;AAEO,SAAS,cAAc,OAAgB,UAAgC;AAC5E,MAAI,iBAAiB,wCAAyB,2CAAsB,KAAK,GAAG;AAC1E,UAAM,cAAU,0CAAqB,KAAK,KAAK,iBAAiB;AAChE,WAAO;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa,UACT,uNACA;AAAA,MACJ,iBAAiB;AAAA,IACnB;AAAA,EACF;AAEA,UAAI,gDAAyB,KAAK,GAAG;AACnC,WAAO,OAAO,6BAAyB,6CAAsB,KAAK,EAAE,OAAO;AAAA,EAC7E;AAEA,MAAI,iBAAiB,uCAAmB;AACtC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,YAAY,KAAK,GAAG;AACtB,WAAO,OAAO,gBAAgB,YAAY;AAAA,EAC5C;AAEA,MAAI,iBAAiB,4BAAiB;AACpC,WAAO,OAAO,wBAAwB,MAAM,OAAO;AAAA,EACrD;AAEA,MAAI,iBAAiB,8BAAmB;AACtC,WAAO,OAAO,wBAAwB,UAAU,KAAK,KAAK,YAAY,OAAO;AAAA,EAC/E;AAEA,QAAM,WAAO,sCAAiB,KAAK,EAAE,YAAY;AACjD,MAAI,KAAK,SAAS,cAAc,KAAK,0BAA0B,KAAK,IAAI,GAAG;AACzE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,wBAAwB,YAAY,OAAO;AAC3D;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from "@medialane/sdk";
|
|
2
2
|
import { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from "./wallet-error.js";
|
|
3
|
+
import { describeWalletFailure, passkeyUnsupportedReason } from "./wallet-failure.js";
|
|
3
4
|
const NOT_SUBMITTED = "Request not completed. Nothing was submitted.";
|
|
4
5
|
const GENERIC = "Something went wrong. Please try again.";
|
|
5
6
|
const NETWORK_BUSY = "The network is busy right now. Nothing was submitted. Please try again in a moment.";
|
|
@@ -35,6 +36,9 @@ function describeError(error, fallback) {
|
|
|
35
36
|
isUserRejection: true
|
|
36
37
|
};
|
|
37
38
|
}
|
|
39
|
+
if (passkeyUnsupportedReason(error)) {
|
|
40
|
+
return notice("Passkey not supported", describeWalletFailure(error).message);
|
|
41
|
+
}
|
|
38
42
|
if (error instanceof WrongNetworkError) {
|
|
39
43
|
return notice(
|
|
40
44
|
"Wrong network",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/describe-error.ts"],"sourcesContent":["import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from \"@medialane/sdk\";\nimport { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from \"./wallet-error.js\";\n\nexport const NOT_SUBMITTED = \"Request not completed. Nothing was submitted.\";\nexport const GENERIC = \"Something went wrong. Please try again.\";\nexport const NETWORK_BUSY =\n \"The network is busy right now. Nothing was submitted. Please try again in a moment.\";\n\nexport interface ErrorNotice {\n title: string;\n message: string;\n description?: string;\n isUserRejection: boolean;\n}\n\nconst notice = (title: string, message: string, description?: string): ErrorNotice => ({\n title,\n message,\n description,\n isUserRejection: false,\n});\n\nfunction isTransient(error: unknown): boolean {\n if (error instanceof MedialaneApiError) {\n return error.status === 408 || error.status === 429 || error.status >= 500;\n }\n return /-32001|unable to complete request|service unavailable|temporarily unavailable|rate.?limit|too many requests|gateway time-?out|bad gateway|failed to fetch|fetch failed|network ?error|load failed/i.test(\n collectErrorText(error),\n );\n}\n\nfunction apiReason(error: MedialaneApiError): string | undefined {\n const body = error.details;\n if (body && typeof body === \"object\" && \"error\" in body) {\n const reason = (body as { error?: unknown }).error;\n if (typeof reason === \"string\" && reason.trim() !== \"\") return reason;\n }\n return undefined;\n}\n\nexport function describeError(error: unknown, fallback?: string): ErrorNotice {\n if (error instanceof PasskeyCancelledError || isUserRejectedRequest(error)) {\n const unclear = isBareExecuteFailure(error) || error instanceof PasskeyCancelledError;\n return {\n title: \"Request not completed\",\n message: NOT_SUBMITTED,\n description: unclear\n ? \"Your wallet didn't complete this request. You may have closed or declined it, it may need extra verification such as 2FA before it can sign, or it may have hit a temporary network hiccup. Try again in a moment.\"\n : \"Your wallet didn't complete this request. You may have closed or declined it, or it may need extra verification before it can sign.\",\n isUserRejection: true,\n };\n }\n\n if (error instanceof WrongNetworkError) {\n return notice(\n \"Wrong network\",\n \"Your wallet is connected to the wrong network. Nothing was submitted.\",\n \"Switch your wallet to Starknet Mainnet, then try again.\",\n );\n }\n\n if (isTransient(error)) {\n return notice(\"Network busy\", NETWORK_BUSY);\n }\n\n if (error instanceof UserFacingError) {\n return notice(\"Something went wrong\", error.message);\n }\n\n if (error instanceof MedialaneApiError) {\n return notice(\"Something went wrong\", apiReason(error) ?? fallback ?? GENERIC);\n }\n\n const text = collectErrorText(error).toLowerCase();\n if (text.includes(\"insufficient\") && /balance|allowance|funds/.test(text)) {\n return notice(\n \"Insufficient balance\",\n \"You don't have enough balance to complete this transaction.\",\n \"Add funds to your wallet, then try again.\",\n );\n }\n\n return notice(\"Something went wrong\", fallback ?? GENERIC);\n}\n\nexport { UserFacingError };\n"],"mappings":"AAAA,SAAS,mBAAmB,uBAAuB,uBAAuB;AAC1E,SAAS,mBAAmB,sBAAsB,uBAAuB,wBAAwB;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/describe-error.ts"],"sourcesContent":["import { MedialaneApiError, PasskeyCancelledError, UserFacingError } from \"@medialane/sdk\";\nimport { WrongNetworkError, isBareExecuteFailure, isUserRejectedRequest, collectErrorText } from \"./wallet-error.js\";\nimport { describeWalletFailure, passkeyUnsupportedReason } from \"./wallet-failure.js\";\n\nexport const NOT_SUBMITTED = \"Request not completed. Nothing was submitted.\";\nexport const GENERIC = \"Something went wrong. Please try again.\";\nexport const NETWORK_BUSY =\n \"The network is busy right now. Nothing was submitted. Please try again in a moment.\";\n\nexport interface ErrorNotice {\n title: string;\n message: string;\n description?: string;\n isUserRejection: boolean;\n}\n\nconst notice = (title: string, message: string, description?: string): ErrorNotice => ({\n title,\n message,\n description,\n isUserRejection: false,\n});\n\nfunction isTransient(error: unknown): boolean {\n if (error instanceof MedialaneApiError) {\n return error.status === 408 || error.status === 429 || error.status >= 500;\n }\n return /-32001|unable to complete request|service unavailable|temporarily unavailable|rate.?limit|too many requests|gateway time-?out|bad gateway|failed to fetch|fetch failed|network ?error|load failed/i.test(\n collectErrorText(error),\n );\n}\n\nfunction apiReason(error: MedialaneApiError): string | undefined {\n const body = error.details;\n if (body && typeof body === \"object\" && \"error\" in body) {\n const reason = (body as { error?: unknown }).error;\n if (typeof reason === \"string\" && reason.trim() !== \"\") return reason;\n }\n return undefined;\n}\n\nexport function describeError(error: unknown, fallback?: string): ErrorNotice {\n if (error instanceof PasskeyCancelledError || isUserRejectedRequest(error)) {\n const unclear = isBareExecuteFailure(error) || error instanceof PasskeyCancelledError;\n return {\n title: \"Request not completed\",\n message: NOT_SUBMITTED,\n description: unclear\n ? \"Your wallet didn't complete this request. You may have closed or declined it, it may need extra verification such as 2FA before it can sign, or it may have hit a temporary network hiccup. Try again in a moment.\"\n : \"Your wallet didn't complete this request. You may have closed or declined it, or it may need extra verification before it can sign.\",\n isUserRejection: true,\n };\n }\n\n if (passkeyUnsupportedReason(error)) {\n return notice(\"Passkey not supported\", describeWalletFailure(error).message);\n }\n\n if (error instanceof WrongNetworkError) {\n return notice(\n \"Wrong network\",\n \"Your wallet is connected to the wrong network. Nothing was submitted.\",\n \"Switch your wallet to Starknet Mainnet, then try again.\",\n );\n }\n\n if (isTransient(error)) {\n return notice(\"Network busy\", NETWORK_BUSY);\n }\n\n if (error instanceof UserFacingError) {\n return notice(\"Something went wrong\", error.message);\n }\n\n if (error instanceof MedialaneApiError) {\n return notice(\"Something went wrong\", apiReason(error) ?? fallback ?? GENERIC);\n }\n\n const text = collectErrorText(error).toLowerCase();\n if (text.includes(\"insufficient\") && /balance|allowance|funds/.test(text)) {\n return notice(\n \"Insufficient balance\",\n \"You don't have enough balance to complete this transaction.\",\n \"Add funds to your wallet, then try again.\",\n );\n }\n\n return notice(\"Something went wrong\", fallback ?? GENERIC);\n}\n\nexport { UserFacingError };\n"],"mappings":"AAAA,SAAS,mBAAmB,uBAAuB,uBAAuB;AAC1E,SAAS,mBAAmB,sBAAsB,uBAAuB,wBAAwB;AACjG,SAAS,uBAAuB,gCAAgC;AAEzD,MAAM,gBAAgB;AACtB,MAAM,UAAU;AAChB,MAAM,eACX;AASF,MAAM,SAAS,CAAC,OAAe,SAAiB,iBAAuC;AAAA,EACrF;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AACnB;AAEA,SAAS,YAAY,OAAyB;AAC5C,MAAI,iBAAiB,mBAAmB;AACtC,WAAO,MAAM,WAAW,OAAO,MAAM,WAAW,OAAO,MAAM,UAAU;AAAA,EACzE;AACA,SAAO,qMAAqM;AAAA,IAC1M,iBAAiB,KAAK;AAAA,EACxB;AACF;AAEA,SAAS,UAAU,OAA8C;AAC/D,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,OAAO,SAAS,YAAY,WAAW,MAAM;AACvD,UAAM,SAAU,KAA6B;AAC7C,QAAI,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,GAAI,QAAO;AAAA,EACjE;AACA,SAAO;AACT;AAEO,SAAS,cAAc,OAAgB,UAAgC;AAC5E,MAAI,iBAAiB,yBAAyB,sBAAsB,KAAK,GAAG;AAC1E,UAAM,UAAU,qBAAqB,KAAK,KAAK,iBAAiB;AAChE,WAAO;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa,UACT,uNACA;AAAA,MACJ,iBAAiB;AAAA,IACnB;AAAA,EACF;AAEA,MAAI,yBAAyB,KAAK,GAAG;AACnC,WAAO,OAAO,yBAAyB,sBAAsB,KAAK,EAAE,OAAO;AAAA,EAC7E;AAEA,MAAI,iBAAiB,mBAAmB;AACtC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,YAAY,KAAK,GAAG;AACtB,WAAO,OAAO,gBAAgB,YAAY;AAAA,EAC5C;AAEA,MAAI,iBAAiB,iBAAiB;AACpC,WAAO,OAAO,wBAAwB,MAAM,OAAO;AAAA,EACrD;AAEA,MAAI,iBAAiB,mBAAmB;AACtC,WAAO,OAAO,wBAAwB,UAAU,KAAK,KAAK,YAAY,OAAO;AAAA,EAC/E;AAEA,QAAM,OAAO,iBAAiB,KAAK,EAAE,YAAY;AACjD,MAAI,KAAK,SAAS,cAAc,KAAK,0BAA0B,KAAK,IAAI,GAAG;AACzE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,wBAAwB,YAAY,OAAO;AAC3D;","names":[]}
|