@web3-onboard/mew-wallet
Version:
MEW (MyEtherWallet) Wallet SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framew
38 lines (37 loc) • 1.71 kB
JavaScript
import { ProviderRpcError, createDownloadMessage } from '@web3-onboard/common';
import { createEIP1193Provider } from '@web3-onboard/common';
function mewWallet() {
if (typeof window === 'undefined')
return () => null;
return ({ device }) => {
return device.type === 'mobile'
? {
label: 'MEW wallet',
getIcon: async () => (await import('./icon.js')).default,
getInterface: async () => {
const provider = window.hasOwnProperty('ethereum') && window.ethereum.isMEWwallet;
if (provider) {
return {
provider: createEIP1193Provider(window.ethereum, {
wallet_switchEthereumChain: async ({ params }) => {
if (device.os.name.toLowerCase() === 'ios') {
throw new ProviderRpcError({
message: 'MEW Wallet iOS only supports ETH network',
code: 4200
});
}
window.ethereum.setChainId(parseInt(params[0].chainId));
return null;
}
})
};
}
else {
throw new Error(createDownloadMessage('MEW wallet', 'https://download.mewwallet.com?source=onboard'));
}
}
}
: null;
};
}
export default mewWallet;