Open Zergity opened 3 years ago
Some thoughts about this:
But solution 2 need more understanding and effort from dapp team side which may cause confusion.
Good point. I have added Solution 3 to address this.
Solution 3 is better, but all inject wallets need to follow the rules:
I've updated #11 so the provider object can be passed directly to the constructor, so it works with any of the solutions above. Dapp code can use new Wallet('solet.io')
or new Wallet(window.solana)
or new Wallet(window.anything)
as long as it's injected.
Been trying to use solflare extension wallet and receive error saying "provider parameter must be an injected provider or a URL string" when doing new Wallet(window.solflare). any hints on whats causing the issue? phantom and sollet work without issues, for coin98 wallet had to build a wrapper for it to work
We need an injected interface design so dapps can interact with browser extension wallets (MathWallet, eDeFi, etc.)
Goals:
Ethereum dapps rely on a single injection point (
window.ethereum
) for wallet interaction. All wallet extensions (MetaMask, ezDeFi, etc.) must compete for the chance to get injected since there's only 1 extension is active at a time. This is very simple for dapp to use but dapp also doesn't know which wallet is used (for display).Solution 1: single interface - single wallet (same with Ethereum with extra info)
window.solana
for all wallet extensions. The name of the wallet can be queried inwindow.solana.name
andwindow.solana.desc
, but they're optional for both dapp and wallets.window.solana.name
or justinjected
.Solution 2: single interface - multiple wallets
window.solana[walletname]
, and dapps can use any of the wallets in the array they preferred, using the same interface as the currentwindow.solana
. Or just select the first one if they don't care.Solution 3: single dispatcher - multiple wallets
window.solana
is injected to be a dispatcher, so it can be used just likewindow.ethereum
window.solana.wallet[name]
is injected by each extensions.window.solana.selectWallet(name)
tells the dispatcher to redirect all requests towindow.solana.wallets[name]
. If none is set, the first wallet will be used.window.solana.getWallets()
returns all injected wallets.Please discuss.
Related PRs: #11 #8