From 340c310edb21ed32d49ea92e0920c97756fee59c Mon Sep 17 00:00:00 2001 From: William Chong Date: Fri, 12 Jan 2024 01:52:52 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Auto=20fix=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connection-method-selection-dialog.tsx | 3 ++- src/index.tsx | 8 +++----- src/utils/web3auth.ts | 20 +++++++++++++------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/connection-method-selection-dialog.tsx b/src/components/connection-method-selection-dialog.tsx index 694e563..212e052 100644 --- a/src/components/connection-method-selection-dialog.tsx +++ b/src/components/connection-method-selection-dialog.tsx @@ -91,7 +91,8 @@ const connectionMethodMap = [ isMobileOk: true, url: '', description: 'connect_wallet_method_description_wallet_connect_v2', - }, { + }, + { type: LikeCoinWalletConnectorMethodType.Web3Auth, name: 'Web3Auth', defaultTier: 2, diff --git a/src/index.tsx b/src/index.tsx index 0ed6e2d..a8854b4 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -40,10 +40,7 @@ import { listenLeapKeyStoreChange, removeLeapKeyStoreChangeListener, } from './utils/leap'; -import { - initWeb3Auth, - disconnectWeb3Auth, -} from './utils/web3auth'; +import { initWeb3Auth, disconnectWeb3Auth } from './utils/web3auth'; import { deserializePublicKey, serializePublicKey } from './utils/wallet'; import { @@ -136,7 +133,8 @@ export class LikeCoinWalletConnector { onEvent: options.onEvent || (() => {}), - blockExplorerURL: options.blockExplorerURL || 'https://mintscan.io/likecoin', + blockExplorerURL: + options.blockExplorerURL || 'https://mintscan.io/likecoin', web3AuthClientId: options.web3AuthClientId || '', web3AuthNetwork: options.web3AuthNetwork || 'mainnet', }; diff --git a/src/utils/web3auth.ts b/src/utils/web3auth.ts index 7beccbd..ba29749 100644 --- a/src/utils/web3auth.ts +++ b/src/utils/web3auth.ts @@ -1,7 +1,7 @@ import { DirectSecp256k1Wallet, OfflineSigner } from '@cosmjs/proto-signing'; import { Secp256k1Wallet } from '@cosmjs/amino'; -import { Web3Auth, Web3AuthOptions } from "@web3auth/modal"; -import { CHAIN_NAMESPACES } from "@web3auth/base"; +import { Web3Auth, Web3AuthOptions } from '@web3auth/modal'; +import { CHAIN_NAMESPACES } from '@web3auth/base'; import { LikeCoinWalletConnectorInitResponse, @@ -11,7 +11,7 @@ import { let web3auth: Web3Auth | null = null; export async function initWeb3Auth( - options: LikeCoinWalletConnectorOptions, + options: LikeCoinWalletConnectorOptions ): Promise { const web3AuthOptions = { clientId: options.web3AuthClientId, @@ -38,10 +38,18 @@ export async function initWeb3Auth( if (!provider) { throw new Error('Failed to connect to wallet'); } - const privateKeyStr = await (provider as any).request({ method: 'private_key' }); + const privateKeyStr = await (provider as any).request({ + method: 'private_key', + }); const privateKey = Buffer.from(privateKeyStr, 'hex'); - const aminoSigner = await Secp256k1Wallet.fromKey(privateKey, options.bech32PrefixAccAddr); - const directSigner = await DirectSecp256k1Wallet.fromKey(privateKey, options.bech32PrefixAccAddr); + const aminoSigner = await Secp256k1Wallet.fromKey( + privateKey, + options.bech32PrefixAccAddr + ); + const directSigner = await DirectSecp256k1Wallet.fromKey( + privateKey, + options.bech32PrefixAccAddr + ); const accounts = [...(await aminoSigner.getAccounts())]; if (!accounts.length) { throw new Error('WALLETCONNECT_ACCOUNT_NOT_FOUND');