Skip to content

Commit

Permalink
fix wallet connet error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
XueMoMo committed Oct 17, 2024
1 parent 809d8a1 commit 743d8aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 10 additions & 6 deletions lib/wallet/MWalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class MWalletConnect extends BaseWallet {
this.ethereumProvider = await EthereumProvider.init({
projectId,
showQrModal: true,
qrModalOptions: { themeMode: "light" , explorerRecommendedWalletIds: "NONE", explorerExcludedWalletIds: "ALL" },
qrModalOptions: { themeMode: "light", explorerRecommendedWalletIds: "NONE", explorerExcludedWalletIds: "ALL" },
optionalChains: [1],
disableProviderPing: true,
// methods: ["eth_sendTransaction", "personal_sign"],
Expand All @@ -44,10 +44,14 @@ export class MWalletConnect extends BaseWallet {
}

async fetchAccounts(): Promise<string[]> {
if (!this.ethereumProvider) return [];
const accounts = await this.ethereumProvider.request<string[]>({ method: "eth_accounts", params: [] });
// this.accounts = accounts;
return accounts;
try {
if (!this.ethereumProvider) return [];
const accounts = await this.ethereumProvider.request<string[]>({ method: "eth_accounts", params: [] });
// this.accounts = accounts;
return accounts;
} catch (error) {
return [];
}
}

public async connect(): Promise<LoginUser> {
Expand Down Expand Up @@ -75,7 +79,7 @@ export class MWalletConnect extends BaseWallet {
]);
console.info("connectEnd:", this.ethereumProvider.accounts);
// await this.ethereumProvider.connect()
if (_.isEmpty(this.ethereumProvider.accounts)) throw "You rejected";
if (_.isEmpty(this.ethereumProvider.accounts)) throw "";
this.account = this.ethereumProvider.accounts[0];
this.accounts = this.ethereumProvider.accounts;
this.isConnected = true;
Expand Down
8 changes: 6 additions & 2 deletions lib/wallet/SolanaM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ export class SolanaM extends BaseWallet {
}

async fetchAccounts(): Promise<string[]> {
if (this.solana?.publicKey) return [this.solana?.publicKey.toBase58()];
try {
if (this.solana?.publicKey) return [this.solana?.publicKey.toBase58()];
} catch (error) {
console.info(error)
}
return [];
}

public async connect(): Promise<LoginUser> {
if (!this.isConnected) {
if (!this.solana) throw "Solana (Phantom Wallet) not installed";
Expand Down

0 comments on commit 743d8aa

Please sign in to comment.