You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's helpful for the dapp to provide one of more provider urls. We already support this on wallet constructor, but have some more ideas too. ie.
// setup wallet on polygon with infura host const wallet = new sequence.Wallet('https://polygon-mainnet.infura.io/etc')
// setup wallet with multiple networks
const wallet = new sequence.Wallet({
polygon: 'https://polygon-mainnet.infura.io/etc',
bsc: 'https://bsc.infura.io/etc'
})
note, currently in master we have.. const wallet = new sequence.Wallet('polygon', { networkRpcUrl: 'https://polygon-mainnet.infura.io/etc' }) .. this is clean enough, but, for simplicity for new developers, its nice to provide the url up front.
alternatively, can keep new sequence.Wallet() simple, or just as a place where we pass the provider urls + networks, like in first example, then on wallet.connect({ }) we pass wallet.connect({ network: 'polygon', ... })
we should also think to support wallet.switchNetwork('polygon') as well. and wallet.listNetworks()
On-demand wallet usage with window.ethereum
Many developers integrate with window.ethereum / window.ethereum.providers (which is great). With the sequence package, we don't use this since we have the instance directly on-demand. However, for simplicity of integrations, we could do the following..
sequence.enable()
which will then add the sequence wallet provider into existing window.ethereum.providers array, or instantiate a new one.
we can also pass params like, sequence.enable({ configStuffLikeProviderUrlsetc: '' }
of course, enable() will have to check if window is even defined, otherwise it should throw.
as well, we can put the enable method as a static method on Wallet in @0xsequence/provider .. so that alternative syntax works as..
import { sequence } from '0xsequence'
sequence.Wallet.enable()
Chrome extension -- append to window.ethereum.providers
As well, in the wallet app, we need to append the sequence provider to window.ethereum.providers instead of overwriting it. I believe we have work on this + PR already.
Utils for developers to more easily connect multiple wallets in a dapp
Many dapps like to connect many wallets (makes sense). Let's consider a few simple utility functions which are generic from Sequence to allow these developers some helper utilities to find out which wallets are registered, so they can present their own simple interface, and we can also return a simple provider equivalent of window.ethereum.provider .. which we already have btw from wallet.getProvider(), but its not clear to other developers, and its nice to consider other wallets.. ie.
like... @0xsequence/utils and call it "ethereum-sign-in.ts" or.. "sign-in-with-ethereum.ts" or "ethereum-enable.ts" or "ethereum-connect.ts" .. and we have..
EthereumConnect.listWallets()
EthereumConnect.connect('metamask') or EthereumConnect.connect('sequence'), and will return a provider
EthereumConnect.getProvider('metamask') or EthereumConnect.connect('sequence') and will provider a provider liek above
etc..
The text was updated successfully, but these errors were encountered:
Wallet connect + passing your own provider
It's helpful for the dapp to provide one of more provider urls. We already support this on wallet constructor, but have some more ideas too. ie.
// setup wallet on polygon with infura host
const wallet = new sequence.Wallet('https://polygon-mainnet.infura.io/etc')
// setup wallet with multiple networks
note, currently in master we have..
const wallet = new sequence.Wallet('polygon', { networkRpcUrl: 'https://polygon-mainnet.infura.io/etc' })
.. this is clean enough, but, for simplicity for new developers, its nice to provide the url up front.other syntax ideas..
const wallet = new sequence.Wallet(['polygon', 'mainnet'], { networkUrls: { polygon: 'https://...', mainnet: 'https://...' })
alternatively, can keep
new sequence.Wallet()
simple, or just as a place where we pass the provider urls + networks, like in first example, then onwallet.connect({ })
we passwallet.connect({ network: 'polygon', ... })
we should also think to support
wallet.switchNetwork('polygon')
as well. andwallet.listNetworks()
On-demand wallet usage with window.ethereum
Many developers integrate with
window.ethereum
/window.ethereum.providers
(which is great). With the sequence package, we don't use this since we have the instance directly on-demand. However, for simplicity of integrations, we could do the following..sequence.enable()
which will then add the sequence wallet provider into existing
window.ethereum.providers
array, or instantiate a new one.we can also pass params like,
sequence.enable({ configStuffLikeProviderUrlsetc: '' }
of course,
enable()
will have to check if window is even defined, otherwise it should throw.as well, we can put the enable method as a static method on Wallet in @0xsequence/provider .. so that alternative syntax works as..
Chrome extension -- append to window.ethereum.providers
As well, in the wallet app, we need to append the sequence provider to window.ethereum.providers instead of overwriting it. I believe we have work on this + PR already.
Utils for developers to more easily connect multiple wallets in a dapp
Many dapps like to connect many wallets (makes sense). Let's consider a few simple utility functions which are generic from Sequence to allow these developers some helper utilities to find out which wallets are registered, so they can present their own simple interface, and we can also return a simple provider equivalent of window.ethereum.provider .. which we already have btw from wallet.getProvider(), but its not clear to other developers, and its nice to consider other wallets.. ie.
like...
@0xsequence/utils
and call it "ethereum-sign-in.ts" or.. "sign-in-with-ethereum.ts" or "ethereum-enable.ts" or "ethereum-connect.ts" .. and we have..The text was updated successfully, but these errors were encountered: