Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/early-queens-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Improve EIP5792 support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Expand the changeset description to reflect the scope of changes.

The current description "Improve EIP5792 support" is too vague. Based on the PR changes, this should detail the specific improvements made, such as adding sendCalls, getCallsStatus, and getCapabilities methods to wallet accounts and refactoring the EIP-5792 implementation.

-Improve EIP5792 support
+Improve EIP5792 support
+
+- Add `sendCalls`, `getCallsStatus`, and `getCapabilities` methods to wallet Account interface
+- Implement EIP-5792 methods for injected, Coinbase, smart, in-app, and enclave wallets
+- Refactor core EIP-5792 functions to delegate to wallet account methods
+- Add in-app wallet with EIP-5792 execution mode support to playground
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Improve EIP5792 support
Improve EIP5792 support
- Add `sendCalls`, `getCallsStatus`, and `getCapabilities` methods to wallet Account interface
- Implement EIP-5792 methods for injected, Coinbase, smart, in-app, and enclave wallets
- Refactor core EIP-5792 functions to delegate to wallet account methods
- Add in-app wallet with EIP-5792 execution mode support to playground
🤖 Prompt for AI Agents
In the .changeset/early-queens-drive.md file at line 5, the changeset
description is too vague. Update the description to explicitly mention the
specific improvements made, including the addition of sendCalls, getCallsStatus,
and getCapabilities methods to wallet accounts, as well as the refactoring of
the EIP-5792 implementation, to clearly reflect the scope of changes.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useCapabilities,
useWalletInfo,
} from "thirdweb/react";
import { createWallet } from "thirdweb/wallets";
import { createWallet, inAppWallet } from "thirdweb/wallets";
import { THIRDWEB_CLIENT } from "../../lib/client";
import CodeClient from "../code/code.client";

Expand All @@ -29,6 +29,12 @@ export function Eip5792GetCapabilitiesPreview() {
label: "Login to view wallet capabilities",
}}
wallets={[
inAppWallet({
executionMode: {
mode: "EIP7702",
sponsorGas: true,
},
}),
createWallet("io.metamask"),
createWallet("com.coinbase.wallet"),
]}
Expand Down
66 changes: 66 additions & 0 deletions packages/thirdweb/src/wallets/coinbase/coinbase-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@
stringToHex,
uint8ArrayToHex,
} from "../../utils/encoding/hex.js";
import { stringify } from "../../utils/json.js";
import { parseTypedData } from "../../utils/signatures/helpers/parse-typed-data.js";
import { COINBASE } from "../constants.js";
import { toGetCallsStatusResponse } from "../eip5792/get-calls-status.js";
import { toGetCapabilitiesResult } from "../eip5792/get-capabilities.js";
import { toProviderCallParams } from "../eip5792/send-calls.js";
import type {
GetCallsStatusRawResponse,
WalletCapabilities,
} from "../eip5792/types.js";
import type {
Account,
SendTransactionOption,
Expand Down Expand Up @@ -269,6 +277,64 @@
}
return res;
},
sendCalls: async (options) => {
try {
const { callParams, chain } = await toProviderCallParams(
options,
account,
);
const callId = await provider.request({
method: "wallet_sendCalls",
params: callParams,
});
if (callId && typeof callId === "object" && "id" in callId) {
return { chain, client, id: callId.id as string };
}
return { chain, client, id: callId as string };
} catch (error) {
if (/unsupport|not support/i.test((error as Error).message)) {
throw new Error(
`${COINBASE} errored calling wallet_sendCalls, with error: ${error instanceof Error ? error.message : stringify(error)}`,
);
}
throw error;
}
},

Check warning on line 302 in packages/thirdweb/src/wallets/coinbase/coinbase-web.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L281-L302

Added lines #L281 - L302 were not covered by tests
async getCallsStatus(options) {
try {
const rawResponse = (await provider.request({
method: "wallet_getCallsStatus",
params: [options.id],
})) as GetCallsStatusRawResponse;
return toGetCallsStatusResponse(rawResponse);
} catch (error) {
if (/unsupport|not support/i.test((error as Error).message)) {
throw new Error(
`${COINBASE} does not support wallet_getCallsStatus, reach out to them directly to request EIP-5792 support.`,
);
}
throw error;
}
},

Check warning on line 318 in packages/thirdweb/src/wallets/coinbase/coinbase-web.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L304-L318

Added lines #L304 - L318 were not covered by tests
async getCapabilities(options) {
const chainId = options.chainId;
try {
const result = (await provider.request({
method: "wallet_getCapabilities",
params: [getAddress(account.address)],
})) as Record<string, WalletCapabilities>;
return toGetCapabilitiesResult(result, chainId);
} catch (error: unknown) {
if (
/unsupport|not support|not available/i.test((error as Error).message)
) {
return {
message: `${COINBASE} does not support wallet_getCapabilities, reach out to them directly to request EIP-5792 support.`,
};
}
throw error;
}
},

Check warning on line 337 in packages/thirdweb/src/wallets/coinbase/coinbase-web.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L320-L337

Added lines #L320 - L337 were not covered by tests
Comment on lines +280 to +337
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Add test coverage for Coinbase EIP-5792 methods

Static analysis indicates these critical EIP-5792 methods lack test coverage.

Would you like me to create test cases for the Coinbase wallet's EIP-5792 implementation?


🏁 Script executed:

#!/bin/bash
# Check if there are any tests for Coinbase wallet EIP-5792 functionality
fd -e test.ts -e test.tsx . | xargs rg -l "coinbase.*sendCalls|coinbase.*getCallsStatus|coinbase.*getCapabilities" -i

Length of output: 119


🏁 Script executed:

#!/bin/bash
# Further verify test coverage for Coinbase EIP-5792 methods
# Search across all .test.ts and .test.tsx files for both wrapper and raw RPC method names
rg -l "sendCalls|getCallsStatus|getCapabilities|wallet_sendCalls|wallet_getCallsStatus|wallet_getCapabilities" -g "*.test.ts" -g "*.test.tsx"

Length of output: 395


Add tests for Coinbase wallet’s EIP-5792 wrapper methods

We have core EIP-5792 utilities covered under src/wallets/eip5792/*.test.ts, but the Coinbase‐specific wrapper in packages/thirdweb/src/wallets/coinbase/coinbase-web.ts still lacks direct test coverage. Please add tests to validate:

• sendCalls
– correct provider.request parameters for wallet_sendCalls
– handling of both object‐ID and string‐ID responses
– error mapping when unsupported

• getCallsStatus
– provider.request is called with wallet_getCallsStatus and the passed ID
– correct transformation via toGetCallsStatusResponse
– error mapping when unsupported

• getCapabilities
– provider.request is called with wallet_getCapabilities and the account address
– correct transformation via toGetCapabilitiesResult
– fallback message when unsupported

Suggested location:
– Create packages/thirdweb/src/wallets/coinbase/coinbase-web.test.ts to cover these methods.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 281-302: packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L281-L302
Added lines #L281 - L302 were not covered by tests


[warning] 304-318: packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L304-L318
Added lines #L304 - L318 were not covered by tests


[warning] 320-337: packages/thirdweb/src/wallets/coinbase/coinbase-web.ts#L320-L337
Added lines #L320 - L337 were not covered by tests

🤖 Prompt for AI Agents
In packages/thirdweb/src/wallets/coinbase/coinbase-web.ts around lines 280 to
337, the Coinbase wallet's EIP-5792 wrapper methods lack direct test coverage.
Add a new test file packages/thirdweb/src/wallets/coinbase/coinbase-web.test.ts
and write tests for sendCalls to verify correct provider.request calls with
"wallet_sendCalls", handling both object-ID and string-ID responses, and error
mapping for unsupported errors. Similarly, test getCallsStatus to ensure
provider.request is called with "wallet_getCallsStatus" and the passed ID,
correct transformation via toGetCallsStatusResponse, and error mapping. For
getCapabilities, test that provider.request is called with
"wallet_getCapabilities" and the account address, the correct transformation via
toGetCapabilitiesResult, and the fallback message when unsupported. Mock
dependencies and provider requests as needed to isolate and validate behavior.

};

return account;
Expand Down
Loading
Loading