@stableops/wallet-ui 0.1.6 → 0.3.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.
- package/dist/index.css +77 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.js +140 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -44
- package/dist/index.mjs.map +1 -1
- package/dist/walletconnect-dialog.css +77 -1
- package/dist/walletconnect-dialog.css.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// src/walletconnect-dialog.tsx
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { createPortal } from "react-dom";
|
|
4
2
|
import { ArrowLeft, Check, CircleAlert, Copy, ExternalLink, Loader2, RotateCw, X } from "lucide-react";
|
|
5
3
|
|
|
6
|
-
// src/walletconnect-dialog-css.ts
|
|
7
|
-
var WALLETCONNECT_DIALOG_CSS = "/* \u8BED\u4E49\u8272 token\uFF1A\u4F18\u5148\u8BFB\u53D6 dashboard/shadcn \u7684 CSS \u53D8\u91CF\uFF1B\u672A\u63A5\u5165\u8FD9\u4E9B\u53D8\u91CF\u7684\u5BBF\u4E3B\u4F7F\u7528\n dashboard \u5F53\u524D light/dark \u9ED8\u8BA4\u503C\u4F5C\u4E3A fallback\u3002\u4E3B\u9898\u8272\u53EA\u6709 --stableops-wc-brand\n \u4E00\u4E2A\uFF0C\u53EF\u88AB themeColor prop \u5185\u8054\u8986\u76D6\u3002 */\n:root {\n --stableops-wc-backdrop: rgb(0 0 0 / 80%);\n --stableops-wc-surface: var(--background, oklch(1 0 0));\n --stableops-wc-text: var(--foreground, oklch(0.141 0.005 285.823));\n --stableops-wc-muted: var(--muted-foreground, oklch(0.552 0.016 285.938));\n --stableops-wc-border: var(--border, oklch(0.92 0.004 286.32));\n --stableops-wc-strong-border: var(--input, oklch(0.92 0.004 286.32));\n --stableops-wc-subtle: var(--muted, oklch(0.967 0.001 286.375));\n --stableops-wc-hover: var(--accent, #e8faf7);\n --stableops-wc-hover-text: var(--accent-foreground, #0f766e);\n --stableops-wc-shade: #000000;\n --stableops-wc-brand: var(--primary, #12233a);\n --stableops-wc-brand-text: var(--primary-foreground, oklch(0.985 0 0));\n --stableops-wc-copy-done-bg: var(--accent, #e8faf7);\n --stableops-wc-danger: var(--destructive, oklch(0.577 0.245 27.325));\n --stableops-wc-danger-text: var(--destructive-foreground, oklch(0.985 0 0));\n --stableops-wc-danger-border: color-mix(in oklab, var(--stableops-wc-danger) 25%, transparent);\n --stableops-wc-danger-bg: color-mix(\n in oklab,\n var(--stableops-wc-danger) 8%,\n var(--stableops-wc-surface)\n );\n}\n\n@media (prefers-color-scheme: dark) {\n :root {\n --stableops-wc-surface: var(--background, oklch(0.141 0.005 285.823));\n --stableops-wc-text: var(--foreground, oklch(0.985 0 0));\n --stableops-wc-muted: var(--muted-foreground, oklch(0.705 0.015 286.067));\n --stableops-wc-border: var(--border, oklch(1 0 0 / 10%));\n --stableops-wc-strong-border: var(--input, oklch(1 0 0 / 15%));\n --stableops-wc-subtle: var(--muted, oklch(0.274 0.006 286.033));\n --stableops-wc-hover: var(--accent, oklch(0.274 0.006 286.033));\n --stableops-wc-hover-text: var(--accent-foreground, oklch(0.985 0 0));\n --stableops-wc-shade: #ffffff;\n --stableops-wc-brand: var(--primary, oklch(0.92 0.004 286.32));\n --stableops-wc-brand-text: var(--primary-foreground, oklch(0.21 0.006 285.885));\n --stableops-wc-copy-done-bg: var(--accent, oklch(0.274 0.006 286.033));\n --stableops-wc-danger: var(--destructive, oklch(0.704 0.191 22.216));\n --stableops-wc-danger-text: var(--destructive-foreground, oklch(0.985 0 0));\n }\n}\n\n@keyframes stableops-walletconnect-backdrop-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes stableops-walletconnect-sheet-in {\n from {\n opacity: 0;\n transform: translateY(1.25rem);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (min-width: 640px) {\n @keyframes stableops-walletconnect-sheet-in {\n from {\n opacity: 0;\n transform: translateY(0.375rem) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n}\n\n.stableops-wc-backdrop {\n position: fixed;\n inset: 0;\n z-index: 50;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n margin: 0;\n padding: 0;\n background: var(--stableops-wc-backdrop);\n animation: stableops-walletconnect-backdrop-in 160ms ease-out both;\n}\n\n.stableops-wc-sheet {\n position: relative;\n width: 100%;\n max-width: 28rem;\n max-height: min(90dvh, calc(100vh - 1rem));\n overflow: hidden;\n border: 1px solid var(--stableops-wc-border);\n border-radius: 1rem 1rem 0 0;\n padding-bottom: max(0.75rem, env(safe-area-inset-bottom));\n background: var(--stableops-wc-surface);\n color: var(--stableops-wc-text);\n box-shadow:\n 0 10px 15px -3px rgb(0 0 0 / 10%),\n 0 4px 6px -4px rgb(0 0 0 / 10%);\n animation: stableops-walletconnect-sheet-in 220ms cubic-bezier(0.2, 0, 0, 1) both;\n}\n\n.stableops-wc-sheet,\n.stableops-wc-sheet * {\n box-sizing: border-box;\n}\n\n.stableops-wc-sheet :where(button, a, p, img) {\n margin: 0;\n font: inherit;\n color: inherit;\n text-decoration: none;\n}\n\n.stableops-wc-sheet :where(img) {\n display: block;\n max-width: 100%;\n height: auto;\n}\n\n.stableops-wc-header {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 1.5rem 1.5rem 0;\n}\n\n.stableops-wc-title {\n min-width: 0;\n flex: 1;\n overflow: hidden;\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 0.875rem;\n font-weight: 600;\n}\n\n.stableops-wc-icon-button {\n position: absolute;\n display: flex;\n width: 2rem;\n height: 2rem;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 0.375rem;\n background: transparent;\n color: var(--stableops-wc-muted);\n}\n\n.stableops-wc-icon-button:hover {\n background: var(--stableops-wc-hover);\n color: var(--stableops-wc-text);\n}\n\n.stableops-wc-back-button {\n left: 1.25rem;\n}\n\n.stableops-wc-close-button {\n right: 1.25rem;\n}\n\n.stableops-wc-icon,\n.stableops-wc-action-icon {\n width: 1rem;\n height: 1rem;\n}\n\n.stableops-wc-body {\n padding: 1.5rem;\n}\n\n.stableops-wc-qr-frame {\n position: relative;\n width: 100%;\n max-width: 12rem;\n aspect-ratio: 1 / 1;\n margin: 0 auto;\n border: 1px solid rgb(15 28 46 / 8%);\n border-radius: 1rem;\n padding: 1rem;\n background: #ffffff;\n overflow: hidden;\n}\n\n.stableops-wc-qr-image {\n width: 100%;\n height: 100%;\n object-fit: contain;\n}\n\n.stableops-wc-qr-placeholder {\n opacity: 0.9;\n}\n\n.stableops-wc-centered-overlay,\n.stableops-wc-loading-overlay {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.stableops-wc-loading-overlay {\n inset: 0.5rem;\n border-radius: 0.5rem;\n background: rgb(255 255 255 / 60%);\n backdrop-filter: blur(4px);\n}\n\n.stableops-wc-wallet-chip {\n border-radius: 0.75rem;\n padding: 0.25rem;\n background: #ffffff;\n box-shadow:\n 0 4px 6px -1px rgb(0 0 0 / 10%),\n 0 2px 4px -2px rgb(0 0 0 / 10%);\n outline: 1px solid rgb(0 0 0 / 5%);\n}\n\n.stableops-wc-refresh-button {\n display: inline-flex;\n min-width: 6.5rem;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n gap: 0.375rem;\n border: 1px solid rgb(0 0 0 / 8%);\n border-radius: 0.75rem;\n padding: 0.625rem 0.75rem;\n background: #ffffff;\n color: var(--stableops-wc-text);\n box-shadow:\n 0 4px 6px -1px rgb(0 0 0 / 10%),\n 0 2px 4px -2px rgb(0 0 0 / 10%);\n font-size: 0.8125rem;\n font-weight: 600;\n}\n\n.stableops-wc-refresh-button:hover {\n background: var(--stableops-wc-hover);\n}\n\n.stableops-wc-refresh-icon {\n width: 1rem;\n height: 1rem;\n color: var(--stableops-wc-brand);\n}\n\n.stableops-wc-wallet-logo,\n.stableops-wc-wallet-fallback {\n display: flex;\n width: 3rem;\n height: 3rem;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n border-radius: 0.5rem;\n box-shadow: 0 1px 2px 0 rgb(0 0 0 / 5%);\n outline: 1px solid rgb(0 0 0 / 5%);\n}\n\n.stableops-wc-wallet-logo {\n object-fit: cover;\n}\n\n.stableops-wc-wallet-chip .stableops-wc-wallet-logo,\n.stableops-wc-wallet-chip .stableops-wc-wallet-fallback {\n width: 2.25rem;\n height: 2.25rem;\n border-radius: 0.375rem;\n}\n\n.stableops-wc-wallet-fallback {\n color: #ffffff;\n font-size: 0.75rem;\n font-weight: 600;\n}\n\n.stableops-wc-empty-qr {\n display: flex;\n width: 100%;\n height: 100%;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n padding: 0 0.75rem;\n text-align: center;\n font-size: 0.75rem;\n color: var(--stableops-wc-muted);\n}\n\n.stableops-wc-spinner {\n width: 1.5rem;\n height: 1.5rem;\n animation: stableops-wc-spin 1s linear infinite;\n}\n\n@keyframes stableops-wc-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.stableops-wc-muted-spinner {\n color: #9ca3af;\n}\n\n.stableops-wc-error-icon {\n width: 1.75rem;\n height: 1.75rem;\n color: var(--stableops-wc-danger);\n}\n\n.stableops-wc-help-text {\n margin: 1.25rem 0 0;\n text-align: center;\n font-size: 0.875rem;\n font-weight: 500;\n}\n\n.stableops-wc-separator {\n display: flex;\n align-items: center;\n gap: 0.75rem;\n margin: 1rem 0;\n font-size: 0.75rem;\n color: var(--stableops-wc-muted);\n}\n\n.stableops-wc-line {\n height: 1px;\n flex: 1;\n background: var(--stableops-wc-border);\n}\n\n.stableops-wc-spacer {\n height: 1rem;\n}\n\n.stableops-wc-actions {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n}\n\n.stableops-wc-primary-action,\n.stableops-wc-secondary-action {\n display: inline-flex;\n min-height: 2.5rem;\n flex: 1;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n border-radius: 0.5rem;\n padding: 0.5rem 1rem;\n text-align: center;\n font-size: 0.875rem;\n font-weight: 500;\n text-decoration: none;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.stableops-wc-primary-action {\n border: 1px solid transparent;\n background: var(--stableops-wc-brand);\n color: var(--stableops-wc-brand-text);\n box-shadow:\n 0 1px 3px 0 rgb(0 0 0 / 10%),\n 0 1px 2px -1px rgb(0 0 0 / 10%);\n}\n\n.stableops-wc-button-action {\n font: inherit;\n}\n\n.stableops-wc-primary-action:hover {\n background: color-mix(in srgb, var(--stableops-wc-brand) 82%, var(--stableops-wc-shade));\n}\n\n.stableops-wc-secondary-action {\n border: 1px solid var(--stableops-wc-strong-border);\n background: var(--stableops-wc-surface);\n color: var(--stableops-wc-text);\n}\n\n.stableops-wc-secondary-action:hover {\n background: var(--stableops-wc-hover);\n color: var(--stableops-wc-hover-text);\n}\n\n.stableops-wc-secondary-action:disabled,\n.stableops-wc-disabled-link {\n cursor: not-allowed;\n opacity: 0.5;\n pointer-events: none;\n}\n\n.stableops-wc-check-icon {\n color: color-mix(in srgb, var(--stableops-wc-brand) 82%, var(--stableops-wc-shade));\n}\n\n.stableops-wc-copy-done {\n border-color: color-mix(in srgb, var(--stableops-wc-brand) 35%, transparent);\n background: var(--stableops-wc-copy-done-bg);\n color: color-mix(in srgb, var(--stableops-wc-brand) 82%, var(--stableops-wc-shade));\n}\n\n.stableops-wc-wallet-grid {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 0.5rem 1rem;\n overflow-y: auto;\n padding: 1rem;\n}\n\n.stableops-wc-wallet-button {\n display: flex;\n cursor: pointer;\n flex-direction: column;\n align-items: center;\n gap: 0.5rem;\n border: 1px solid transparent;\n border-radius: 0.75rem;\n background: transparent;\n padding: 1rem 0.5rem;\n text-align: center;\n color: var(--stableops-wc-text);\n}\n\n.stableops-wc-wallet-button:hover {\n border-color: color-mix(in srgb, var(--stableops-wc-brand) 40%, transparent);\n background: var(--stableops-wc-hover);\n color: var(--stableops-wc-hover-text);\n}\n\n.stableops-wc-wallet-button:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.stableops-wc-wallet-button span {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 0.75rem;\n font-weight: 500;\n}\n\n.stableops-wc-error-box {\n margin: 0 1.25rem 1.25rem;\n border: 1px solid var(--stableops-wc-danger-border);\n border-radius: 0.5rem;\n background: var(--stableops-wc-danger-bg);\n padding: 0.625rem;\n text-align: center;\n font-size: 0.75rem;\n color: var(--stableops-wc-danger);\n}\n\n@media (min-width: 640px) {\n .stableops-wc-backdrop {\n align-items: center;\n padding: 1rem;\n }\n\n .stableops-wc-sheet {\n max-height: calc(100vh - 2rem);\n border-radius: 1rem;\n padding-bottom: 0;\n }\n\n .stableops-wc-actions {\n flex-direction: row;\n }\n}\n";
|
|
8
|
-
|
|
9
4
|
// src/wallet-icon.tsx
|
|
10
5
|
import { jsx } from "react/jsx-runtime";
|
|
11
6
|
function WalletIcon({ wallet }) {
|
|
@@ -23,6 +18,126 @@ function WalletIcon({ wallet }) {
|
|
|
23
18
|
);
|
|
24
19
|
}
|
|
25
20
|
|
|
21
|
+
// src/walletconnect-dialog-copy.ts
|
|
22
|
+
var copy = {
|
|
23
|
+
zh: {
|
|
24
|
+
heading: "\u7528\u624B\u673A\u94B1\u5305\u652F\u4ED8",
|
|
25
|
+
back: "\u8FD4\u56DE",
|
|
26
|
+
close: "\u5173\u95ED",
|
|
27
|
+
qrAlt: "\u652F\u4ED8\u4E8C\u7EF4\u7801",
|
|
28
|
+
payWith: "\u7528 {wallet} \u652F\u4ED8",
|
|
29
|
+
scanWithWallet: "\u7528\u624B\u673A\u4E0A\u7684 {wallet} \u626B\u7801",
|
|
30
|
+
scanAnyWallet: "\u7528\u4EFB\u610F\u624B\u673A\u94B1\u5305\u626B\u7801",
|
|
31
|
+
openWallet: "\u6253\u5F00 {wallet}",
|
|
32
|
+
paymentPrompt: "\u5DF2\u8FDE\u63A5 {wallet}\uFF0C\u8BF7\u5728\u94B1\u5305 App \u5185\u786E\u8BA4\u4EA4\u6613\uFF1B\u5982\u679C\u6CA1\u6709\u5F39\u51FA\u652F\u4ED8\u754C\u9762\uFF0C\u53EF\u518D\u6B21\u89E6\u53D1\u652F\u4ED8\u3002",
|
|
33
|
+
retryPayment: "\u518D\u6B21\u6253\u5F00 {wallet} \u652F\u4ED8",
|
|
34
|
+
retryingPayment: "\u6B63\u5728\u6253\u5F00\u652F\u4ED8\u2026",
|
|
35
|
+
refreshConnection: "\u5237\u65B0\u4E8C\u7EF4\u7801",
|
|
36
|
+
copyUri: "\u590D\u5236\u94FE\u63A5",
|
|
37
|
+
copied: "\u5DF2\u590D\u5236",
|
|
38
|
+
or: "\u6216",
|
|
39
|
+
connectFailed: "\u8FDE\u63A5\u5931\u8D25",
|
|
40
|
+
errors: {
|
|
41
|
+
dependencyMissing: "\u5F53\u524D\u73AF\u5883\u672A\u52A0\u8F7D WalletConnect \u4F9D\u8D56\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\u3002",
|
|
42
|
+
projectIdMissing: "\u672A\u914D\u7F6E WalletConnect projectId\uFF0C\u65E0\u6CD5\u6253\u5F00\u624B\u673A\u94B1\u5305\u652F\u4ED8\u3002",
|
|
43
|
+
initFailed: "WalletConnect \u521D\u59CB\u5316\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",
|
|
44
|
+
connectFailed: "WalletConnect \u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u8FD4\u56DE\u94B1\u5305\u5217\u8868\u540E\u91CD\u8BD5\u3002",
|
|
45
|
+
noAuthorizedChains: "\u94B1\u5305\u6CA1\u6709\u6388\u6743\u8BA2\u5355\u9700\u8981\u7684\u7F51\u7EDC\uFF0C\u8BF7\u8FD4\u56DE\u91CD\u8FDE\u5E76\u52FE\u9009\u5BF9\u5E94\u7F51\u7EDC\u3002",
|
|
46
|
+
tronUnsupported: "WalletConnect \u6682\u4E0D\u652F\u6301 TRON \u652F\u4ED8\uFF0C\u8BF7\u6539\u7528\u652F\u6301\u7684\u624B\u673A\u94B1\u5305 App \u6216\u624B\u52A8\u8F6C\u8D26\u3002",
|
|
47
|
+
providerMismatch: "\u94B1\u5305\u8FD4\u56DE\u7684\u7F51\u7EDC\u548C\u8BA2\u5355\u7F51\u7EDC\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u5207\u6362\u5230\u6B63\u786E\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",
|
|
48
|
+
providerNotFound: "\u672A\u627E\u5230\u53EF\u7528\u4E8E\u672C\u8BA2\u5355\u7F51\u7EDC\u7684\u94B1\u5305\u6388\u6743\uFF0C\u8BF7\u8FD4\u56DE\u91CD\u8FDE\u5E76\u6388\u6743\u7F51\u7EDC\u3002",
|
|
49
|
+
txReverted: "\u94FE\u4E0A\u4EA4\u6613\u53D1\u751F\u56DE\u6EDA\uFF0C\u8BF7\u91CD\u65B0\u4ED8\u6B3E\u6216\u8054\u7CFB\u5546\u6237\u3002",
|
|
50
|
+
tokenContractNotFound: "\u5F53\u524D\u7F51\u7EDC\u7F3A\u5C11\u9ED8\u8BA4\u4EE3\u5E01\u5408\u7EA6\u914D\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u6D4B\u8BD5\u7F51\u914D\u7F6E\u3002",
|
|
51
|
+
paymentInstructionNotFound: "\u5F53\u524D\u8BA2\u5355\u6CA1\u6709\u53EF\u7528\u7684\u94FE\u4E0A\u652F\u4ED8\u6307\u4EE4\u3002",
|
|
52
|
+
unsupportedChain: "\u94B1\u5305 SDK \u6682\u4E0D\u652F\u6301\u5F53\u524D\u652F\u4ED8\u7F51\u7EDC\u3002"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
en: {
|
|
56
|
+
heading: "Pay with mobile wallet",
|
|
57
|
+
back: "Back",
|
|
58
|
+
close: "Close",
|
|
59
|
+
qrAlt: "Payment QR code",
|
|
60
|
+
payWith: "Pay with {wallet}",
|
|
61
|
+
scanWithWallet: "Scan with {wallet} on your phone",
|
|
62
|
+
scanAnyWallet: "Scan with any mobile wallet",
|
|
63
|
+
openWallet: "Open {wallet}",
|
|
64
|
+
paymentPrompt: "{wallet} is connected. Confirm the transaction in your wallet app; if no payment screen appears, trigger payment again.",
|
|
65
|
+
retryPayment: "Trigger {wallet} payment again",
|
|
66
|
+
retryingPayment: "Opening payment\u2026",
|
|
67
|
+
refreshConnection: "Refresh QR",
|
|
68
|
+
copyUri: "Copy link",
|
|
69
|
+
copied: "Copied",
|
|
70
|
+
or: "or",
|
|
71
|
+
connectFailed: "Connection failed",
|
|
72
|
+
errors: {
|
|
73
|
+
dependencyMissing: "WalletConnect is not loaded in this environment. Refresh the page and try again.",
|
|
74
|
+
projectIdMissing: "WalletConnect projectId is not configured, so mobile wallet pay cannot open.",
|
|
75
|
+
initFailed: "WalletConnect failed to initialize. Check your connection and retry.",
|
|
76
|
+
connectFailed: "WalletConnect failed to connect. Go back to the wallet list and retry.",
|
|
77
|
+
noAuthorizedChains: "Your wallet did not authorize the required networks. Reconnect and select the requested network.",
|
|
78
|
+
tronUnsupported: "WalletConnect does not support TRON payments yet. Use a supported mobile wallet app or manual transfer.",
|
|
79
|
+
providerMismatch: "The wallet returned a different network than the order requires. Switch networks and retry.",
|
|
80
|
+
providerNotFound: "No wallet authorization was found for this order network. Go back, reconnect, and authorize it.",
|
|
81
|
+
txReverted: "The on-chain transaction was reverted. Pay again or contact the merchant.",
|
|
82
|
+
tokenContractNotFound: "The default token contract is not configured for this network. Check the testnet config.",
|
|
83
|
+
paymentInstructionNotFound: "This order does not have an available on-chain payment instruction.",
|
|
84
|
+
unsupportedChain: "The wallet SDK does not support this payment network."
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function createWalletConnectDialogCopy(locale, copiedLabel) {
|
|
89
|
+
const t = copy[locale];
|
|
90
|
+
const errors = t.errors;
|
|
91
|
+
return {
|
|
92
|
+
heading: t.heading,
|
|
93
|
+
back: t.back,
|
|
94
|
+
close: t.close,
|
|
95
|
+
qrAlt: t.qrAlt,
|
|
96
|
+
payWith: (wallet) => t.payWith.replace("{wallet}", wallet),
|
|
97
|
+
scanWithWallet: (wallet) => t.scanWithWallet.replace("{wallet}", wallet),
|
|
98
|
+
scanAnyWallet: t.scanAnyWallet,
|
|
99
|
+
openWallet: (wallet) => t.openWallet.replace("{wallet}", wallet),
|
|
100
|
+
paymentPrompt: (wallet) => t.paymentPrompt.replace("{wallet}", wallet),
|
|
101
|
+
retryPayment: (wallet) => t.retryPayment.replace("{wallet}", wallet),
|
|
102
|
+
retryingPayment: t.retryingPayment,
|
|
103
|
+
refreshConnection: t.refreshConnection,
|
|
104
|
+
copyUri: t.copyUri,
|
|
105
|
+
copied: copiedLabel ?? t.copied,
|
|
106
|
+
or: t.or,
|
|
107
|
+
connectFailed: t.connectFailed,
|
|
108
|
+
errorMessage: (code) => {
|
|
109
|
+
switch (code) {
|
|
110
|
+
case "walletconnect_dependency_missing":
|
|
111
|
+
return errors.dependencyMissing;
|
|
112
|
+
case "walletconnect_project_id_missing":
|
|
113
|
+
return errors.projectIdMissing;
|
|
114
|
+
case "walletconnect_init_failed":
|
|
115
|
+
return errors.initFailed;
|
|
116
|
+
case "walletconnect_connect_failed":
|
|
117
|
+
return errors.connectFailed;
|
|
118
|
+
case "walletconnect_no_authorized_chains":
|
|
119
|
+
return errors.noAuthorizedChains;
|
|
120
|
+
case "walletconnect_tron_unsupported":
|
|
121
|
+
return errors.tronUnsupported;
|
|
122
|
+
case "wallet_provider_mismatch":
|
|
123
|
+
return errors.providerMismatch;
|
|
124
|
+
case "wallet_provider_not_found":
|
|
125
|
+
return errors.providerNotFound;
|
|
126
|
+
case "wallet_tx_reverted":
|
|
127
|
+
return errors.txReverted;
|
|
128
|
+
case "token_contract_not_found":
|
|
129
|
+
return errors.tokenContractNotFound;
|
|
130
|
+
case "payment_instruction_not_found":
|
|
131
|
+
return errors.paymentInstructionNotFound;
|
|
132
|
+
case "unsupported_chain":
|
|
133
|
+
return errors.unsupportedChain;
|
|
134
|
+
default:
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
26
141
|
// src/walletconnect-dialog.tsx
|
|
27
142
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
28
143
|
var PLACEHOLDER_QR_CODE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAAAklEQVR4AewaftIAAApTSURBVO3BwQ1cwW5FwaPGRMAdM2D+0TAD7piCrJ1hgKPvFt54RPlW/fj5CyKy0kFE1jqIyFoHEVnrICJrHURkrYOIrPXiN8yDLbqSG+bBpCuZmAfvdCVPMA8mXclTzIMbXcnEPJh0JU8xDyZdyRPMgy26kslBRNY6iMhaBxFZ6yAiax1EZK0Xf6Ar+Rbz4AldycQ8mHQl75gHN7qSG+bBpCuZmAdPMQ8mXclTzIMnmAeTruRGV/It5sGNg4isdRCRtQ4istZBRNY6iMhaLx5kHjyhK3mKeTDpSm6YB7e6khtdycQ8mJgHn9aVTMyDG13Jp3Uln2YePKErecJBRNY6iMhaBxFZ6yAiax1EZK0X8r/SlTzFPJh0JZ/WlUzMg4l5cKMrmZgHt7qSiXkw6Ur+vzmIyFoHEVnrICJrHURkrYOIrPXiH9eVTMyDSVfyaV3JxDx4QldyqyuZmAc3zINbXcnEPJh0JRPzYNKV/KsOIrLWQUTWOojIWgcRWesgImu9eFBXskVXMjEPJl3JO+bBE7qSJ5gH73QlE/PgRlcyMQ++pSv5tK7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0JRPz4Fu6klvmwY2uZGIePME8+LSuZGIe3DiIyFoHEVnrICJrHURkrYOIrPXj5y/8w8yDSVfyLebBja7kKebBpCuZmAeTruQp5sGkK7lhHky6kqeYB0/oSp5wEJG1DiKy1kFE1jqIyFoHEVnrxW+YB1t0JTfMg6d0JRPzYAvzYNKVTMyDG13JO13JN5gHk67kW8yDSVcyOYjIWgcRWesgImsdRGStg4is9eIPdCXfYh7c6EpumAd/G/PgRlfyFPPgRldyyzz4hq7k07qSiXnwhIOIrHUQkbUOIrLWQUTWOojIWgcRWevFg8yDJ3QlTzEPJl3JpCu5ZR58Uldywzx4Sldywzy41ZVMzIMnmAdbdCU3DiKy1kFE1jqIyFoHEVnrICJrvZD/wTyYdCWf1pXcMA9udSU3zINJVzLpSibmwRZdyS3z4EZX8oSDiKx1EJG1DiKy1kFE1jqIyFov/nFdycQ8uGEe3OpKbpgHN7qSiXnwjnlwoyuZmAdPMQ8mXcnEPJh0JRPzYNKVTMyDTzMPbnQlk4OIrHUQkbUOIrLWQUTWOojIWi8e1JVs0ZU8xTyYmAeTruRv05VMzIMbXcnEPHinK5mYB5Ou5EZXMjEPbnUlE/NgYh580kFE1jqIyFoHEVnrICJrHURkrRd/wDyQ/9aVPKEruWEeTLqSd8yDiXkw6Uom5sHEPPgW8+AJXclTupIb5sGNg4isdRCRtQ4istZBRNY6iMhaP37+goisdBCRtQ4istZBRNY6iMhaBxFZ678A0n6/7QsA5ucAAAAASUVORK5CYII=";
|
|
@@ -34,37 +149,15 @@ var walletConnectDialogClassNames = {
|
|
|
34
149
|
function walletLink(prefix, uri) {
|
|
35
150
|
return `${prefix}${encodeURIComponent(uri)}`;
|
|
36
151
|
}
|
|
37
|
-
function formatWalletConnectDialogError(error,
|
|
152
|
+
function formatWalletConnectDialogError(error, copy2) {
|
|
38
153
|
if (typeof error === "string") return error;
|
|
39
|
-
if (error.code) return
|
|
154
|
+
if (error.code) return copy2.errorMessage(error.code) ?? error.message;
|
|
40
155
|
return error.message;
|
|
41
156
|
}
|
|
42
157
|
function WalletConnectDialog({
|
|
43
|
-
useShadowRoot = false,
|
|
44
|
-
...props
|
|
45
|
-
}) {
|
|
46
|
-
if (useShadowRoot) return /* @__PURE__ */ jsx2(ShadowRootWalletConnectDialog, { ...props });
|
|
47
|
-
return /* @__PURE__ */ jsx2(WalletConnectDialogContent, { ...props });
|
|
48
|
-
}
|
|
49
|
-
function ShadowRootWalletConnectDialog(props) {
|
|
50
|
-
const hostRef = useRef(null);
|
|
51
|
-
const [shadowRoot, setShadowRoot] = useState(null);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const host = hostRef.current;
|
|
54
|
-
if (!host) return;
|
|
55
|
-
setShadowRoot(host.shadowRoot ?? host.attachShadow({ mode: "open" }));
|
|
56
|
-
}, []);
|
|
57
|
-
return /* @__PURE__ */ jsx2("span", { ref: hostRef, children: shadowRoot ? createPortal(
|
|
58
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
59
|
-
/* @__PURE__ */ jsx2("style", { children: WALLETCONNECT_DIALOG_CSS }),
|
|
60
|
-
/* @__PURE__ */ jsx2(WalletConnectDialogContent, { ...props })
|
|
61
|
-
] }),
|
|
62
|
-
shadowRoot
|
|
63
|
-
) : null });
|
|
64
|
-
}
|
|
65
|
-
function WalletConnectDialogContent({
|
|
66
158
|
open,
|
|
67
|
-
copy,
|
|
159
|
+
copy: copyProp,
|
|
160
|
+
locale = "en",
|
|
68
161
|
projectId,
|
|
69
162
|
available,
|
|
70
163
|
wallets,
|
|
@@ -86,6 +179,7 @@ function WalletConnectDialogContent({
|
|
|
86
179
|
onCopyUri
|
|
87
180
|
}) {
|
|
88
181
|
if (!open) return null;
|
|
182
|
+
const copy2 = copyProp ?? createWalletConnectDialogCopy(locale);
|
|
89
183
|
const appLink = selectedWallet?.links?.native ?? selectedWallet?.links?.universal ?? null;
|
|
90
184
|
const appLinkIsUniversal = !selectedWallet?.links?.native && Boolean(selectedWallet?.links?.universal);
|
|
91
185
|
const readyUri = state.status === "uri_ready" ? state.uri : null;
|
|
@@ -97,7 +191,7 @@ function WalletConnectDialogContent({
|
|
|
97
191
|
const disabledList = !walletLinkMode && !projectId || !available;
|
|
98
192
|
const renderIcon = renderWalletIcon ?? ((wallet) => /* @__PURE__ */ jsx2(WalletIcon, { wallet }));
|
|
99
193
|
const themeStyle = themeColor ? { "--stableops-wc-brand": themeColor } : void 0;
|
|
100
|
-
const visibleError = error !== null ? formatWalletConnectDialogError(error,
|
|
194
|
+
const visibleError = error !== null ? formatWalletConnectDialogError(error, copy2) : state.status === "failed" ? formatWalletConnectDialogError(state.error, copy2) : null;
|
|
101
195
|
return /* @__PURE__ */ jsx2("div", { className: walletConnectDialogClassNames.backdrop, style: themeStyle, onClick: onClose, children: /* @__PURE__ */ jsxs(
|
|
102
196
|
"div",
|
|
103
197
|
{
|
|
@@ -112,19 +206,19 @@ function WalletConnectDialogContent({
|
|
|
112
206
|
"button",
|
|
113
207
|
{
|
|
114
208
|
type: "button",
|
|
115
|
-
"aria-label":
|
|
209
|
+
"aria-label": copy2.back,
|
|
116
210
|
onClick: onBack,
|
|
117
211
|
className: "stableops-wc-icon-button stableops-wc-back-button",
|
|
118
212
|
children: /* @__PURE__ */ jsx2(ArrowLeft, { className: "stableops-wc-icon" })
|
|
119
213
|
}
|
|
120
214
|
),
|
|
121
|
-
/* @__PURE__ */ jsx2("div", { className: "stableops-wc-title", children:
|
|
122
|
-
] }) : /* @__PURE__ */ jsx2("div", { className: "stableops-wc-title", children:
|
|
215
|
+
/* @__PURE__ */ jsx2("div", { className: "stableops-wc-title", children: copy2.payWith(selectedWallet.name) })
|
|
216
|
+
] }) : /* @__PURE__ */ jsx2("div", { className: "stableops-wc-title", children: copy2.heading }),
|
|
123
217
|
/* @__PURE__ */ jsx2(
|
|
124
218
|
"button",
|
|
125
219
|
{
|
|
126
220
|
type: "button",
|
|
127
|
-
"aria-label":
|
|
221
|
+
"aria-label": copy2.close,
|
|
128
222
|
onClick: onClose,
|
|
129
223
|
className: "stableops-wc-icon-button stableops-wc-close-button",
|
|
130
224
|
children: /* @__PURE__ */ jsx2(X, { className: "stableops-wc-icon" })
|
|
@@ -133,7 +227,7 @@ function WalletConnectDialogContent({
|
|
|
133
227
|
] }),
|
|
134
228
|
selectedWallet ? /* @__PURE__ */ jsxs("div", { className: "stableops-wc-body", children: [
|
|
135
229
|
/* @__PURE__ */ jsx2("div", { className: walletConnectDialogClassNames.qrFrame, children: visibleQrCode ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
136
|
-
/* @__PURE__ */ jsx2("img", { src: visibleQrCode, alt:
|
|
230
|
+
/* @__PURE__ */ jsx2("img", { src: visibleQrCode, alt: copy2.qrAlt, className: "stableops-wc-qr-image" }),
|
|
137
231
|
/* @__PURE__ */ jsx2("div", { className: "stableops-wc-centered-overlay", children: /* @__PURE__ */ jsx2("div", { className: "stableops-wc-wallet-chip", children: renderIcon(selectedWallet) }) })
|
|
138
232
|
] }) : qrLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
233
|
/* @__PURE__ */ jsx2(
|
|
@@ -167,16 +261,16 @@ function WalletConnectDialogContent({
|
|
|
167
261
|
},
|
|
168
262
|
children: [
|
|
169
263
|
/* @__PURE__ */ jsx2(RotateCw, { className: "stableops-wc-refresh-icon" }),
|
|
170
|
-
|
|
264
|
+
copy2.refreshConnection
|
|
171
265
|
]
|
|
172
266
|
}
|
|
173
267
|
) : /* @__PURE__ */ jsx2("div", { className: "stableops-wc-wallet-chip", children: renderIcon(selectedWallet) }) }),
|
|
174
268
|
state.status === "failed" && !showRefreshControl ? /* @__PURE__ */ jsx2("div", { className: "stableops-wc-loading-overlay", children: /* @__PURE__ */ jsx2(CircleAlert, { className: "stableops-wc-error-icon", "aria-hidden": "true" }) }) : null
|
|
175
269
|
] }) }),
|
|
176
|
-
/* @__PURE__ */ jsx2("p", { className: "stableops-wc-help-text", children: paymentReady ?
|
|
270
|
+
/* @__PURE__ */ jsx2("p", { className: "stableops-wc-help-text", children: paymentReady ? copy2.paymentPrompt(selectedWallet.name) : walletLinkMode || selectedWallet.links ? copy2.scanWithWallet(selectedWallet.name) : copy2.scanAnyWallet }),
|
|
177
271
|
walletLinkMode || appLink ? /* @__PURE__ */ jsxs("div", { className: "stableops-wc-separator", children: [
|
|
178
272
|
/* @__PURE__ */ jsx2("div", { className: "stableops-wc-line" }),
|
|
179
|
-
/* @__PURE__ */ jsx2("span", { children:
|
|
273
|
+
/* @__PURE__ */ jsx2("span", { children: copy2.or }),
|
|
180
274
|
/* @__PURE__ */ jsx2("div", { className: "stableops-wc-line" })
|
|
181
275
|
] }) : /* @__PURE__ */ jsx2("div", { className: "stableops-wc-spacer" }),
|
|
182
276
|
/* @__PURE__ */ jsxs("div", { className: "stableops-wc-actions", children: [
|
|
@@ -190,7 +284,7 @@ function WalletConnectDialogContent({
|
|
|
190
284
|
},
|
|
191
285
|
children: [
|
|
192
286
|
paymentPending ? /* @__PURE__ */ jsx2(Loader2, { className: "stableops-wc-action-icon stableops-wc-spinner" }) : /* @__PURE__ */ jsx2(ExternalLink, { className: "stableops-wc-action-icon" }),
|
|
193
|
-
paymentPending ?
|
|
287
|
+
paymentPending ? copy2.retryingPayment : copy2.retryPayment(selectedWallet.name)
|
|
194
288
|
]
|
|
195
289
|
}
|
|
196
290
|
) : null,
|
|
@@ -203,7 +297,7 @@ function WalletConnectDialogContent({
|
|
|
203
297
|
...(walletLinkMode || appLinkIsUniversal) && walletHref ? { target: "_blank", rel: "noreferrer" } : {},
|
|
204
298
|
children: [
|
|
205
299
|
/* @__PURE__ */ jsx2(ExternalLink, { className: "stableops-wc-action-icon" }),
|
|
206
|
-
|
|
300
|
+
copy2.openWallet(selectedWallet.name)
|
|
207
301
|
]
|
|
208
302
|
}
|
|
209
303
|
) : null,
|
|
@@ -224,10 +318,10 @@ function WalletConnectDialogContent({
|
|
|
224
318
|
strokeWidth: 3
|
|
225
319
|
}
|
|
226
320
|
),
|
|
227
|
-
|
|
321
|
+
copy2.copied
|
|
228
322
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
229
323
|
/* @__PURE__ */ jsx2(Copy, { className: "stableops-wc-action-icon" }),
|
|
230
|
-
|
|
324
|
+
copy2.copyUri
|
|
231
325
|
] })
|
|
232
326
|
}
|
|
233
327
|
)
|
|
@@ -270,6 +364,7 @@ export {
|
|
|
270
364
|
WALLET_LOGOS,
|
|
271
365
|
WalletConnectDialog,
|
|
272
366
|
WalletIcon,
|
|
367
|
+
createWalletConnectDialogCopy,
|
|
273
368
|
walletConnectDialogClassNames,
|
|
274
369
|
walletLink
|
|
275
370
|
};
|