Skip to content

Commit

Permalink
clients: Support Brave wallet default
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm committed Oct 25, 2024
1 parent 5b37986 commit 837734d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion clients/js/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,16 @@ export function makeTaggedProxyObject<T extends object>(
if (prop === propname) return options;
if (hooks && prop in hooks) return Reflect.get(hooks, prop);
const value = Reflect.get(upstream, prop);
return typeof value === 'function' ? value.bind(upstream) : value;
// Brave wallet web3provider properties are read only and throw typeerror
// https://github.com/brave/brave-core/blob/74bf470a0291ea3719f1a75af066ee10b7057dbd/components/brave_wallet/resources/ethereum_provider.js#L13-L27
// https://github.com/wevm/wagmi/blob/86c42248c2f34260a52ee85183c607315ae63ce8/packages/core/src/connectors/injected.ts#L327-L335
if (
typeof value === 'function' &&
Object.getOwnPropertyDescriptor(upstream, prop)?.writable
) {
return value.bind(upstream);
}
return value;
},
});
}

0 comments on commit 837734d

Please sign in to comment.