Open
Description
I try to connect the sequence wallet to the bnb network, but the resulting web3 provider object always connects to the polygon network.
This makes it impossible to use the provider directly (which is much simpler to adapt our code to implement the sequence wallet).
Symptoms:
- this happens both for testnet or mainnet
- every once in a while I will refresh the page and try again and it will connect to the bnb network, this happens apparently randomly, then I refresh again and it connects to polygon again
a(this was likely a symptom of Events are not triggering #326 , although I'm not sure why I had 4001's, but I can't reproduce those anymore at least)wallet_switchEthereumChain
to try to switch it to the wanted network always fails with a 4001 code, apparently rejected by the sequence wallet itself (I'm assuming this is by design due to how the sequence wallet handles multinetwork, however makes it impossible to control the provider object in this way)- if I try it directly from the browser console, it always connects to the correct network, which is a bit maddening as it's the exact same code...
Code:
import { sequence } from '0xsequence';
let provider;
const getSequenceName = chainId => {
switch (chainId) {
case 97:
return 'bsc-testnet';
case 56:
default:
return 'bsc';
}
};
// For debugging in console
if (typeof window !== 'undefined') {
window.Oxsequence = sequence;
}
const connect = async ({ chainId }) => {
const name = getSequenceName(chainId);
console.log({ chainId, name });
provider = await sequence.initWallet(name);
console.log({ provider, name });
try {
// const connection = await provider.connect();
// The `networkId` parameter in here was me trying to select the network once again, the same thing happens
// regardless of if passing it or calling connect without it.
const connection = await provider.connect({ networkId: chainId });
console.log({ connection });
console.log({ chainId: await provider?.transport.provider.getChainId() });
return !!connection?.connected && provider?.transport.provider;
}
catch (ex) {
// eslint-disable-next-line
console.error(ex);
return null;
}
};
Metadata
Metadata
Assignees
Labels
No labels