Closed saberistic closed 3 weeks ago
Sorry, didn't see this before.
Your issue here is that the registration of the Standard Wallet, and indeed all of the Wallet API, doesn't go in the contentScript. It needs to go in an asset .js file that is injected onto the page via insertion of a script
tag, and listed in the manifest.json of the extension.
The contentScript does not have direct access to the JS environment of the page, and that's why even though it can receive events on the window, it cannot access a JS object (like the api
on the event).
It's generally a thin bridge between your extension and the page. To get access to JS on the page, the contentScript has to inject JS, and then communicate from the JS on the page to itself via events, postMessage
, or other mechanisms.
Here's (at a high level) how a wallet extension (Backpack) does this:
Describe the bug I have created following adapter repo and created an extension here with it while loading the extension, on
wallet-standard:app-ready
event it attempts to decunstruct a variable which is null so it throws this error:https://github.com/Spiral-Safe/wallet-adapter/blob/main/src/register.ts#L21
To Reproduce Steps to reproduce the behavior:
Expected behavior shows wallet as a detected wallet in the list
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):