Skip to content

Commit be88f94

Browse files
committed
update handlers to strip unexpected chain IDs but emit a warning for the same
1 parent 5486ce0 commit be88f94

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

apps/iframe/src/components/requests/WalletSwitchEthereumChain.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const WalletSwitchEthereumChain = ({
1919
if (import.meta.env.PROD)
2020
return <RequestDisabled
2121
headline={headline}
22-
description="The Happy Wallet is an HappyChain exclusive 🤠"
22+
description="The Happy Wallet is a HappyChain exclusive 🤠"
2323
reject={reject}
2424
/>
2525

apps/iframe/src/requests/handlers/injected.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,23 @@ export async function dispatchInjectedRequest(request: ProviderMsgsFromApp[Msgs.
224224

225225
case "wallet_getCapabilities": {
226226
checkAuthenticated()
227-
if (!request.payload?.params?.[0]) {
228-
throw new EIP1474InvalidInput("Missing payload")
227+
if (!request.payload?.params?.[0] || !request.payload?.params?.[1]) {
228+
throw new EIP1474InvalidInput("Missing payload parameters")
229229
}
230-
231230
checkAndChecksumAddress(request.payload.params[0])
232231

233232
const currentChainId = getCurrentChain().chainId
233+
if (request.payload.params[1].length > 1) {
234+
const requestedChainIds = request.payload.params[1]
235+
for (const chainId of requestedChainIds) {
236+
if (chainId !== currentChainId) {
237+
console.warn(
238+
`Unsupported chain ID requested: ${chainId}. The Happy Wallet is a HappyChain exclusive 🤠!`,
239+
)
240+
}
241+
}
242+
}
243+
234244
const capabilities: Capabilities = {
235245
[currentChainId]: Object.fromEntries(
236246
Object.values(HappyWalletCapability).map((capability) => [capability, { supported: true }]),

apps/iframe/src/requests/handlers/permissionless.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,23 @@ export async function dispatchedPermissionlessRequest(request: ProviderMsgsFromA
102102

103103
case "wallet_getCapabilities": {
104104
checkAuthenticated()
105-
if (!request.payload?.params?.[0]) {
106-
throw new EIP1474InvalidInput("Missing payload")
105+
if (!request.payload?.params?.[0] || !request.payload?.params?.[1]) {
106+
throw new EIP1474InvalidInput("Missing payload parameters")
107107
}
108-
109108
checkAndChecksumAddress(request.payload.params[0])
110109

111110
const currentChainId = getCurrentChain().chainId
111+
if (request.payload.params[1].length > 1) {
112+
const requestedChainIds = request.payload.params[1]
113+
for (const chainId of requestedChainIds) {
114+
if (chainId !== currentChainId) {
115+
console.warn(
116+
`Unsupported chain ID requested: ${chainId}. The Happy Wallet is a HappyChain exclusive 🤠!`,
117+
)
118+
}
119+
}
120+
}
121+
112122
const capabilities: Capabilities = {
113123
[currentChainId]: Object.fromEntries(
114124
Object.values(HappyWalletCapability).map((capability) => [capability, { supported: true }]),

apps/submitter/bin/benchmarkLatency.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
BoopClient,
3-
CreateAccount,
4-
type ExecuteSuccess,
5-
GetNonce,
6-
Onchain,
7-
computeBoopHash,
8-
} from "@happy.tech/boop-sdk"
1+
import { BoopClient, CreateAccount, computeBoopHash } from "@happy.tech/boop-sdk"
92
import { delayed, stringify } from "@happy.tech/common"
103
import { type PrivateKeyAccount, generatePrivateKey, privateKeyToAccount } from "viem/accounts"
114
import { createAndSignMintBoop } from "#lib/utils/test/helpers"

0 commit comments

Comments
 (0)