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

[BRO-39] Migrate away from injecting API (Draft example of chrome API) #477

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

Conversation

Ivan-Mahda
Copy link
Contributor

Example of forwarding requests to walletApi with Proxy

The general concept of this example is quite simple

In api-helper
We need a proxy with an empty object of WalletApi type
new Proxy({} as WalletApi, proxyHandler)
This enables TS annotations

And we can intercept all requests and forward them through the chrome API
With chrome.runtime.sendMessage

In background.js
With chrome.runtime.onMessageExternal listen to this requests

Main difficulty I encountered is the inability to simply import the walletApi.
A new class needs to be created, which in turn requires many additional changes to BW.
In this case, it looks like a lot of risky changes.

Example of forwarding requests to walletApi with proxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant