Skip to content

Comments

feat(iframe): implement wallet_getCapabilities method#525

Open
ultraviolet10 wants to merge 5 commits intomasterfrom
aritra/5792_get_capabilities
Open

feat(iframe): implement wallet_getCapabilities method#525
ultraviolet10 wants to merge 5 commits intomasterfrom
aritra/5792_get_capabilities

Conversation

@ultraviolet10
Copy link
Contributor

@ultraviolet10 ultraviolet10 commented Mar 14, 2025

Linked Issues

Description

Implements the spec for wallet_getCapabilities for the wallet to be able to specify the same to developers.

spec | porto docs for the same

🎲 demo(react): the demo's namesake button prompts the user to check the console for the expected payload.
Screenshot 2025-03-20 at 4 46 59 PM

Checklist

Basics

  • B1. I have applied the proper label & proper branch name (e.g. norswap/build-system-caching).
  • B2. This PR is not so big that it should be split & addresses only one concern.
  • B3. The PR targets the lowest branch it can (ideally master).

Reminder: PR review guidelines

Correctness

  • C1. Builds and passes tests.
  • C2. The code is properly parameterized & compatible with different environments (e.g. local,
    testnet, mainnet, standalone wallet, ...).
  • C3. I have manually tested my changes & connected features.

< INDICATE BROWSER, DEMO APP & OTHER ENV DETAILS USED FOR TESTING HERE >

< INDICATE TESTED SCENARIOS (USER INTERFACE INTERACTION, CODE FLOWS) HERE >

  • C4. I have performed a thorough self-review of my code after submitting the PR,
    and have updated the code & comments accordingly.

Architecture & Documentation

  • D1. I made it easy to reason locally about the code, by (1) using proper abstraction boundaries,
    (2) commenting these boundaries correctly, (3) adding inline comments for context when needed.
  • D2. All public-facing APIs & meaningful (non-local) internal APIs are properly documented in code
    comments.
  • D3. If appropriate, the general architecture of the code is documented in a code comment or
    in a Markdown document.
  • D4. An appropriate Changeset has been generated (and committed) for changes that touch npm published packages (currently pacakges/core and packages/react), see here for more info.

Copy link
Contributor Author

ultraviolet10 commented Mar 14, 2025

@@ -0,0 +1,3 @@
export enum HappyWalletCapability {
BoopPaymaster = "boopPaymaster",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

only capability we currently support!

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 14, 2025

Deploying happychain with  Cloudflare Pages  Cloudflare Pages

Latest commit: be88f94
Status: ✅  Deploy successful!
Preview URL: https://b7e710ff.happychain.pages.dev
Branch Preview URL: https://aritra-5792-get-capabilities.happychain.pages.dev

View logs

@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from fcdfc53 to 3f44845 Compare March 15, 2025 09:59
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from 3f44845 to 11ef2c8 Compare March 20, 2025 11:06
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792-base branch 2 times, most recently from 937da6c to 439b03a Compare March 24, 2025 12:15
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from 11ef2c8 to 7502930 Compare March 24, 2025 12:15
@ultraviolet10 ultraviolet10 added the updating Updating after review label Apr 24, 2025
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from 7502930 to 06f22f5 Compare April 28, 2025 12:05
@ultraviolet10 ultraviolet10 added reviewing-1 Ready for, or undergoing first-line review and removed updating Updating after review labels Apr 28, 2025
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from d1589ca to a60eeb7 Compare May 9, 2025 11:05
@ultraviolet10 ultraviolet10 changed the base branch from aritra/5792-base to graphite-base/525 May 12, 2025 12:27
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from a60eeb7 to af3fd5b Compare May 12, 2025 12:34
@ultraviolet10 ultraviolet10 changed the base branch from graphite-base/525 to aritra/5792-base May 12, 2025 12:34
@ultraviolet10 ultraviolet10 requested a review from not-reed May 12, 2025 13:10
@ultraviolet10 ultraviolet10 changed the base branch from aritra/5792-base to graphite-base/525 May 22, 2025 11:59
@ultraviolet10 ultraviolet10 changed the title feat(iframe): implement wallet_getCapabilities method feat(iframe): implement wallet_getCapabilities method May 22, 2025
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from af3fd5b to dfe3f5a Compare May 22, 2025 12:43
@ultraviolet10 ultraviolet10 changed the base branch from graphite-base/525 to aritra/5792-base May 22, 2025 12:43
@ultraviolet10 ultraviolet10 changed the base branch from aritra/5792-base to graphite-base/525 May 27, 2025 11:41
@ultraviolet10 ultraviolet10 force-pushed the aritra/5792_get_capabilities branch from dfe3f5a to be88f94 Compare May 29, 2025 07:10
@ultraviolet10 ultraviolet10 changed the base branch from graphite-base/525 to master May 29, 2025 07:10
@ultraviolet10 ultraviolet10 requested a review from not-reed May 29, 2025 11:19
checkAndChecksumAddress(request.payload.params[0])

const currentChainId = getCurrentChain().chainId
if (request.payload.params[1].length > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i guess should also check if the length is one, and if any of the chains are happyChain/currentChain (if they only request mainnet right now, it would not behave correctly)

Comment on lines +123 to +125
[currentChainId]: Object.fromEntries(
Object.values(HappyWalletCapability).map((capability) => [capability, { supported: true }]),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

you could compute this once at a global level, instead on each request

// support/wallet-common/lib/interfaces/eip5792.ts
export const walletCapabilities = Object.fromEntries(
    Object.values(HappyWalletCapability)
        .map((capability) => [capability, { supported: true }])
)
Suggested change
[currentChainId]: Object.fromEntries(
Object.values(HappyWalletCapability).map((capability) => [capability, { supported: true }]),
),
[currentChainId]: walletCapabilities,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority-post-testnet reviewing-1 Ready for, or undergoing first-line review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants