@web3-onboard/trust
Version:
Trust 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 standardized spec compliant web3 providers for all supported wallets, framework agnostic m
33 lines (32 loc) • 1.25 kB
JavaScript
import { createDownloadMessage } from '@web3-onboard/common';
function trust() {
if (typeof window === 'undefined')
return () => null;
return () => {
return {
label: 'Trust Wallet',
getIcon: async () => (await import('./icon.js')).default,
getInterface: async () => {
const ethereumInjectionExists = window.hasOwnProperty('ethereum');
let provider;
// check if trust is injected into window.ethereum
if (ethereumInjectionExists && window['ethereum'].isTrust) {
provider = window['ethereum'];
}
else if (window['trustwallet']) {
// directly use the window.trustwallet injection
provider = window['trustwallet'];
}
else {
// trustwallet extension is not installed
// send user to install page
throw new Error(createDownloadMessage('Trust Wallet', 'https://trustwallet.com/browser-extension'));
}
return {
provider
};
}
};
};
}
export default trust;