Skip to content

Commit

Permalink
Merge branch 'develop' into feature/swap-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Polyakov authored Jul 23, 2024
2 parents 94335ab + 3e76408 commit 060b036
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
3 changes: 3 additions & 0 deletions public/wallet/Fearless.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 13 additions & 17 deletions src/components/shared/Dialog/SelectProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,22 @@ export default class SelectProviderDialog extends Mixins(WalletConnectMixin) {
return [Provider.WalletConnect];
}
return [Provider.Metamask, Provider.SubWallet, Provider.TrustWallet, Provider.WalletConnect];
return Object.keys(Provider).map((key) => Provider[key]);
}
get wallets(): WalletInfo[] {
return Object.keys(Provider)
.filter((key) => this.allowedProviders.includes(key as Provider))
.map((key) => {
const provider = Provider[key];
return {
extensionName: provider,
title: provider,
chromeUrl: '',
mozillaUrl: '',
logo: {
src: this.getEvmProviderIcon(provider),
alt: provider,
},
};
});
return this.allowedProviders.map((provider) => {
return {
extensionName: provider,
title: provider,
chromeUrl: '',
mozillaUrl: '',
logo: {
src: this.getEvmProviderIcon(provider),
alt: provider,
},
};
});
}
get selectedProvider(): Nullable<Provider> {
Expand Down
10 changes: 8 additions & 2 deletions src/utils/ethers-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let ethereumProvider!: any;
let ethersInstance: ethersProvider | null = null;

export enum Provider {
Fearless = 'Fearless',
Metamask = 'Metamask',
SubWallet = 'SubWallet',
TrustWallet = 'TrustWallet',
Expand Down Expand Up @@ -103,17 +104,22 @@ function createWeb3Instance(provider: any) {
}

async function useExtensionProvider(provider: Provider): Promise<string> {
const injectedWindow = window as any;

let ethereumProvider!: any;

switch (provider) {
case Provider.Metamask:
ethereumProvider = await detectEthereumProvider({ mustBeMetaMask: true, timeout: 0 });
break;
case Provider.SubWallet:
ethereumProvider = (window as any).SubWallet;
ethereumProvider = injectedWindow.SubWallet;
break;
case Provider.TrustWallet:
ethereumProvider = (window as any).trustwallet;
ethereumProvider = injectedWindow.trustwallet;
break;
case Provider.Fearless:
ethereumProvider = injectedWindow.fearlessWallet;
break;
default:
throw new Error('Unknown provider');
Expand Down

0 comments on commit 060b036

Please sign in to comment.