anza-xyz / wallet-standard

Solana extensions to the Wallet Standard.
Apache License 2.0
80 stars 42 forks source link

The window.walletName global may be dangerous, and we should remove it from the docs. #18

Closed mikemaccana closed 8 months ago

mikemaccana commented 1 year ago

Describe the bug https://github.com/solana-labs/wallet-standard/blob/master/WALLET.md states, after registering the wallet implementation:

// Attach the reference to the window, guarding against errors.
try {
    Object.defineProperty(window, 'uniqueNewYork', { value: uniqueNewYork });
}
catch (error) {
    console.error(error);
}

We should probably remove this:

jordaaash commented 1 year ago

Thanks Mike.

The Ghost wallet example isn't a suggestion that wallets should implement window globals. That code demonstrates for wallets that already do this (almost all of them, especially ones that approximate Phantom's API) how to do it somewhat more safely, but primarily it demonstrates how to add support for the Wallet Standard (in a nonbreaking way for applications that may rely on the globals they already have).

To drive adoption for the Wallet Standard, we have to meet wallets where they are and make it easy to adopt. On the Wallet Adapter side, we have already stopped accepting PRs for new adapters that can instead use the Wallet Standard.

mikemaccana commented 1 year ago

Got it. I've made a small PR making this explicit in the docs.