Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clients: Support Brave wallet default #411

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aefhm
Copy link
Contributor

@aefhm aefhm commented Sep 24, 2024

Description

Close #385 maybe.

Problem

Wagmi is concerned with bad implementations of EIP-1193 and wants to check that the removeListener function exists. However, the Brave wallet overrides ethereum properties and does not like the way we currently use Proxy objects, giving a typeerror upon a get call.

Our current implementation is a classic Proxy pattern in order to preserve this.

const proxy = new Proxy(aSecret, {
  get(target, prop, receiver) {
    const value = target[prop];
    if (value instanceof Function) {
      return function (...args) {
        return value.apply(this === receiver ? target : this, args);
      };
    }
    return value;
  },
});

simplified to:

return typeof value === 'function' ? value.bind(upstream) : value;

One solution is to not forward context in order to maintain the function signature for Brave browsers as noted in this PR.

Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for oasisprotocol-sapphire-paratime canceled.

Name Link
🔨 Latest commit 60e355a
🔍 Latest deploy log https://app.netlify.com/sites/oasisprotocol-sapphire-paratime/deploys/66f2477eb705020008cc549d

@aefhm aefhm self-assigned this Sep 24, 2024
@aefhm aefhm added p:1 Priority: high client javascript Pull requests that update JavaScript code bug integrations labels Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug client integrations javascript Pull requests that update JavaScript code p:1 Priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sapphire-viem-v2: ProxyObject throws error due to changed function signature
1 participant