Skip to content

Commit b12873a

Browse files
committed
chore: changed warning msgs workflow
1 parent 1e680a7 commit b12873a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/components/WalletButton.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ export const WalletButton = () => {
1717
const { address, isPending, balances, walletWarnings } = useWallet()
1818
const buttonLabel = isPending ? "Loading..." : "Connect"
1919

20-
// Build warning message based on wallet issues
21-
const getWarningMessage = () => {
22-
const warnings: string[] = []
23-
if (walletWarnings.popupAlways) {
24-
warnings.push("This wallet triggers a popup on every interaction")
25-
}
26-
if (walletWarnings.noGetNetworkSupport) {
27-
warnings.push("This wallet doesn't support network detection")
28-
}
29-
return warnings.join(". ")
30-
}
31-
3220
const warningIconStyles = {
3321
display: "flex",
3422
alignItems: "center",
@@ -164,7 +152,7 @@ export const WalletButton = () => {
164152
)}
165153
>
166154
<div style={{ maxWidth: "15em" }}>
167-
{getWarningMessage()}
155+
{walletWarnings.messages.join(". ")}
168156
{walletWarnings.helpUrl ? ". Click to learn more." : ""}
169157
</div>
170158
</Tooltip>

src/providers/WalletProvider.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export interface WalletWarnings {
8686
hasWarnings: boolean
8787
popupAlways: boolean
8888
noGetNetworkSupport: boolean
89+
messages: string[]
8990
helpUrl?: string
9091
}
9192

@@ -98,17 +99,27 @@ function getWalletWarnings(walletId: string | null): WalletWarnings {
9899
hasWarnings: false,
99100
popupAlways: false,
100101
noGetNetworkSupport: false,
102+
messages: [],
101103
}
102104
}
103105

104106
const behavior = getWalletBehavior(walletId)
105107
const popupAlways = behavior.getAddressBehavior === "popup-always"
106108
const noGetNetworkSupport = !behavior.supportsGetNetwork
107109

110+
const messages: string[] = []
111+
if (popupAlways) {
112+
messages.push("This wallet triggers a popup on every interaction")
113+
}
114+
if (noGetNetworkSupport) {
115+
messages.push("This wallet doesn't support network detection")
116+
}
117+
108118
return {
109119
hasWarnings: popupAlways || noGetNetworkSupport,
110120
popupAlways,
111121
noGetNetworkSupport,
122+
messages,
112123
helpUrl: behavior.helpUrl,
113124
}
114125
}
@@ -158,6 +169,7 @@ export const WalletContext = // @ts-ignore
158169
hasWarnings: false,
159170
popupAlways: false,
160171
noGetNetworkSupport: false,
172+
messages: [],
161173
},
162174
})
163175

0 commit comments

Comments
 (0)