-
Notifications
You must be signed in to change notification settings - Fork 191
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
fix: ship our own metamask stub #443
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/shapeshift/web/6PpGF4YDcsCUVnkCY1E9QHhnHv1d |
ca5a4d5
to
a4a54c4
Compare
a4a54c4
to
2aa9585
Compare
Deployment failed with the following error:
|
2aa9585
to
d54a9c4
Compare
d54a9c4
to
38ccdf3
Compare
38ccdf3
to
d7d5c87
Compare
d7d5c87
to
42cd14f
Compare
42cd14f
to
563fdf3
Compare
563fdf3
to
265d59e
Compare
265d59e
to
9bd65bb
Compare
this prevents the need for 'unsafe-inline' in the CSP to talk to MM on Firefox
9bd65bb
to
3b72d54
Compare
function universalProxy(pseudoTarget: object) { | ||
return { | ||
proxy: new Proxy( | ||
{}, | ||
new Proxy( | ||
{}, | ||
{ | ||
get(_, p) { | ||
return (_t: any, p2: any, r: any) => { | ||
switch (p) { | ||
case 'get': { | ||
const out = Reflect.get(pseudoTarget, p2, r) | ||
if (typeof out === 'function') return out.bind(pseudoTarget) | ||
return out | ||
} | ||
case 'getOwnPropertyDescriptor': { | ||
const out = Reflect.getOwnPropertyDescriptor(pseudoTarget, p2) | ||
if (out) out.configurable = true | ||
return out | ||
} | ||
case 'isExtensible': | ||
return true | ||
case 'preventExtensions': | ||
return false | ||
default: | ||
return (Reflect as any)[p](pseudoTarget, p2, r) | ||
} | ||
} | ||
} | ||
} | ||
) | ||
), | ||
getPseudoTarget() { | ||
return pseudoTarget | ||
}, | ||
setPseudoTarget(value: object) { | ||
pseudoTarget = value | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is built on the universalProxyHandler
code in hdwallet's revocable()
, so it should be pretty robust; a similar wrappers are around everything returned from a native vault. The difference here is that the (pseudo-)target can be changed after creation, which lets us return a "placeholder" proxy object for any on-load references to window.ethereum
, which can be filled in later once we decide which stub to use.
This is a change that I think requires more discussion about the reason behind it. FF is not an officially supported browser. |
Deployment failed with the following error:
|
Description
This prevents the need for
'unsafe-inline'
in the CSP to talk to MM on Firefox: MetaMask/metamask-extension#3133(Further reference: https://bugzilla.mozilla.org/show_bug.cgi?id=1267027)
Notice
Before submitting a pull request, please make sure you have answered the following:
Pull Request Type