Skip to content

Commit 9b310f1

Browse files
committed
pr cleanup for chunks
1 parent 6050284 commit 9b310f1

File tree

6 files changed

+1
-178
lines changed

6 files changed

+1
-178
lines changed

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

Lines changed: 0 additions & 37 deletions
This file was deleted.

apps/iframe/src/requests/approved.ts

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import {
66
type EIP1193RequestResult,
77
EIP1193UnauthorizedError,
88
EIP1193UnsupportedMethodError,
9-
HappyWalletCapability,
109
type Msgs,
1110
type PopupMsgs,
1211
getEIP1193ErrorObjectFromCode,
1312
requestPayloadIsHappyMethod,
1413
} from "@happy.tech/wallet-common"
15-
import { type Address, type Client, type Hex, InternalRpcError, InvalidAddressError, isAddress } from "viem"
14+
import { type Client, InvalidAddressError, isAddress } from "viem"
1615
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"
1716
import {
1817
checkIsSessionKeyModuleInstalled,
@@ -178,57 +177,6 @@ export async function dispatchHandlers(request: PopupMsgs[Msgs.PopupApprove]) {
178177
return accountSessionKey.address
179178
}
180179

181-
// EIP-5792
182-
case "wallet_sendCalls": {
183-
if (!user) throw new EIP1193UnauthorizedError()
184-
185-
const callsData = request.payload.params?.[0]
186-
if (!callsData) throw new InternalRpcError(new Error("Invalid request payload"))
187-
188-
if (user.address !== callsData.from) {
189-
// MAY reject the request if the from address does not match the enabled account
190-
throw new InternalRpcError(new Error("Sender address does not match enabled account"))
191-
}
192-
193-
// validate that no unsupported capability is sent through
194-
const allowedCapabilities = new Set([HappyWalletCapability.BoopPaymaster])
195-
if (callsData.capabilities) {
196-
for (const capability of Object.keys(callsData.capabilities)) {
197-
if (!allowedCapabilities.has(capability as HappyWalletCapability)) {
198-
throw new InternalRpcError(new Error("Invalid capability"))
199-
}
200-
}
201-
}
202-
203-
// extract specified paymaster address from capabilities
204-
const boopPaymasterAddress: Address | undefined = callsData.capabilities?.boopPaymaster?.address
205-
let userOpHash: Hex | null = null
206-
207-
for (const call of callsData.calls) {
208-
const { to, value, data, chainId } = call
209-
210-
if (chainId !== getCurrentChain().chainId)
211-
throw new InternalRpcError(new Error("Invalid chainId detected"))
212-
213-
if (!to) throw new Error("Missing 'to' address in transaction call")
214-
215-
userOpHash = await sendUserOp({
216-
user,
217-
tx: { to, value, data },
218-
validator: contractAddresses.ECDSAValidator,
219-
paymaster: boopPaymasterAddress,
220-
signer: async (userOp, smartAccountClient) =>
221-
await smartAccountClient.account.signUserOperation(userOp),
222-
})
223-
}
224-
225-
return userOpHash
226-
}
227-
228-
case "wallet_showCallsStatus": {
229-
return undefined
230-
}
231-
232180
default:
233181
return await sendToWalletClient(request)
234182
}

apps/iframe/src/requests/modules/boop-batcher/helpers.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

apps/iframe/src/requests/permissionless.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
EIP1193UnauthorizedError,
66
EIP1193UnsupportedMethodError,
77
EIP1193UserRejectedRequestError,
8-
HappyWalletCapability,
98
type Msgs,
109
type ProviderMsgsFromApp,
1110
requestPayloadIsHappyMethod,
@@ -15,11 +14,9 @@ import {
1514
type Address,
1615
type Client,
1716
type Hash,
18-
InternalRpcError,
1917
InvalidAddressError,
2018
type Transaction,
2119
type TransactionReceipt,
22-
type WalletCapabilities,
2320
hexToBigInt,
2421
isAddress,
2522
parseSignature,
@@ -42,7 +39,6 @@ import { getUser } from "#src/state/user"
4239
import { getWalletClient } from "#src/state/walletClient"
4340
import type { AppURL } from "#src/utils/appURL"
4441
import { checkIfRequestRequiresConfirmation } from "#src/utils/checkIfRequestRequiresConfirmation"
45-
import { convertUserOpReceiptToCallStatus } from "./modules/boop-batcher/helpers"
4642
import { sendResponse } from "./sendResponse"
4743
import { appForSourceID, checkAuthenticated } from "./utils"
4844

@@ -273,50 +269,6 @@ export async function dispatchHandlers(request: ProviderMsgsFromApp[Msgs.Request
273269
// The app may have bypassed the permission check, but this doesn't do anything.
274270
return null
275271

276-
// EIP-5792
277-
case "wallet_getCapabilities": {
278-
// This method SHOULD return an error if the user has not
279-
// already authorized a connection between the application and
280-
// the requested address.
281-
checkAuthenticated()
282-
const queryAddress = request.payload.params?.[0]
283-
if (!queryAddress) {
284-
throw new Error("Missing address parameter")
285-
}
286-
287-
const currentChainId = getCurrentChain().chainId
288-
289-
const capabilities: WalletCapabilities = {
290-
[currentChainId]: Object.fromEntries(
291-
Object.values(HappyWalletCapability).map((capability) => [capability, { supported: true }]),
292-
),
293-
}
294-
295-
// c.f. https://www.eip5792.xyz/reference/getCapabilities#returns
296-
return capabilities
297-
}
298-
299-
// this method only returns a subset of the fields that eth_getTransactionReceipt returns
300-
case "wallet_getCallsStatus": {
301-
// TODO if the batch was atomic, this handler MUST return only a single receipt
302-
try {
303-
const [hash] = request.payload.params as Hash[]
304-
if (!hash) {
305-
throw new InternalRpcError(new Error("Transaction hash is missing."))
306-
}
307-
const smartAccountClient = (await getSmartAccountClient()) as ExtendedSmartAccountClient
308-
309-
const userOpReceipt = await smartAccountClient.waitForUserOperationReceipt({
310-
hash: hash,
311-
})
312-
313-
return convertUserOpReceiptToCallStatus(userOpReceipt ? [userOpReceipt] : null)
314-
} catch (error) {
315-
console.error(error)
316-
throw error
317-
}
318-
}
319-
320272
case HappyMethodNames.REQUEST_SESSION_KEY: {
321273
const user = getUser()
322274
const targetContractAddress = request.payload.params[0] as Address

apps/iframe/src/routes/request.lazy.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createLazyFileRoute } from "@tanstack/react-router"
44
import { useCallback, useEffect, useState } from "react"
55
import { HappyRequestSessionKey } from "#src/components/requests/HappyRequestSessionKey.js"
66
import { HappyUseAbi } from "#src/components/requests/HappyUseAbi"
7-
import { WalletSendCalls } from "#src/components/requests/WalletSendCalls"
87
import { DotLinearWaveLoader } from "../components/loaders/DotLinearWaveLoader"
98
import { EthRequestAccounts } from "../components/requests/EthRequestAccounts"
109
import { EthSendTransaction } from "../components/requests/EthSendTransaction"
@@ -137,8 +136,6 @@ function Request() {
137136
return <HappyUseAbi {...props} />
138137
case HappyMethodNames.REQUEST_SESSION_KEY:
139138
return <HappyRequestSessionKey {...props} />
140-
case "wallet_sendCalls":
141-
return <WalletSendCalls {...props} />
142139
default:
143140
return (
144141
<main>

support/wallet-common/lib/interfaces/permissions.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const safeList = new Set([
6666
"wallet_revokePermissions", // https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-2.md
6767
"web3_clientVersion",
6868
"web3_sha3",
69-
"wallet_getCapabilities",
70-
"wallet_getCallsStatus",
7169
])
7270

7371
/**
@@ -118,8 +116,6 @@ const unsafeList = new Set([
118116
// cryptography
119117
"eth_decrypt",
120118
"eth_getEncryptionPublicKey",
121-
"wallet_sendCalls",
122-
"wallet_showCallsStatus",
123119
])
124120

125121
/**

0 commit comments

Comments
 (0)