Skip to content

Commit

Permalink
fix: linting errs
Browse files Browse the repository at this point in the history
  • Loading branch information
anshss committed Jan 2, 2025
1 parent 94c091a commit 429b95c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
45 changes: 23 additions & 22 deletions packages/auth-browser/src/lib/chains/eth.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { Buffer as BufferPolyfill } from 'buffer';
import depd from 'depd';

import { hexlify } from '@ethersproject/bytes';
import { Web3Provider, JsonRpcSigner } from '@ethersproject/providers';
import { toUtf8Bytes } from '@ethersproject/strings';

import { verifyMessage } from '@ethersproject/wallet';
import { injected, walletConnect } from '@wagmi/connectors';
import {
connect as wagmiConnect,
disconnect as wagmiDisconnect,
getWalletClient,
Config,
} from '@wagmi/core';
import depd from 'depd';
import { ethers } from 'ethers';
import { getAddress } from 'ethers/lib/utils';
import { SiweMessage } from 'siwe';

// @ts-ignore: If importing 'nacl' directly, the built files will use .default instead
import * as nacl from 'tweetnacl';
import * as naclUtil from 'tweetnacl-util';
import { http } from 'viem';
import { createConfig } from 'wagmi';

// @ts-ignore: If importing 'nacl' directly, the built files will use .default instead
import {
ELeft,
ERight,
Expand All @@ -40,13 +45,6 @@ import {
import { getStorageItem } from '@lit-protocol/misc-browser';
import { AuthSig, AuthCallbackParams, LITEVMChain } from '@lit-protocol/types';

import {
createConfig,
} from 'wagmi';
import { connect as wagmiConnect, disconnect as wagmiDisconnect, getWalletClient, Config } from '@wagmi/core';
import { injected, walletConnect } from '@wagmi/connectors'
import { http } from 'viem';

const deprecated = depd('lit-js-sdk:auth-browser:index');

if (globalThis && typeof globalThis.Buffer === 'undefined') {
Expand Down Expand Up @@ -321,8 +319,11 @@ export const decodeCallResult = deprecated.function(
'decodeCallResult will be removed.'
);

const getWagmiProvider = async (chainId: number, walletConnectProjectId?: string) => {
const chain = Object.values(LIT_CHAINS).find(c => c.chainId === chainId);
const getWagmiProvider = async (
chainId: number,
walletConnectProjectId?: string
) => {
const chain = Object.values(LIT_CHAINS).find((c) => c.chainId === chainId);
if (!chain) {
throw new Error(`Chain ID ${chainId} not supported`);
}
Expand All @@ -347,18 +348,18 @@ const getWagmiProvider = async (chainId: number, walletConnectProjectId?: string
const config = createConfig({
chains: [litChain],
transports: {
[litChain.id]: http(litChain.rpcUrls.default.http[0])
[litChain.id]: http(litChain.rpcUrls.default.http[0]),
},
connectors: [
injected(),
...(walletConnectProjectId
? [
walletConnect({
projectId: walletConnectProjectId
})
projectId: walletConnectProjectId,
}),
]
: []),
]
],
});

return config;
Expand Down Expand Up @@ -386,27 +387,27 @@ export const connectWeb3 = async ({

const config = await getWagmiProvider(chainId, walletConnectProjectId);
wagmiConfig = config;

const result = await wagmiConnect(config, {
connector: config.connectors[0],
chainId,
});


log('got provider');
if (!result) {
throw new Error('Failed to connect wallet');
}

const walletClient = await getWalletClient(config);

if (!walletClient) {
throw new Error('No wallet client found');
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - Create Web3Provider from wallet client
const web3 = new Web3Provider(walletClient);

log('listing accounts');
const accounts = await web3.listAccounts();
log('accounts', accounts);
Expand Down
5 changes: 1 addition & 4 deletions packages/auth-browser/src/lib/chains/sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import {
NoWalletException,
UnknownError,
} from '@lit-protocol/constants';

import { IProvider, AuthSig } from '@lit-protocol/types';
import { log } from '@lit-protocol/misc';
import { getStorageItem } from '@lit-protocol/misc-browser';
// import { toString as uint8arrayToString } from 'uint8arrays';

import { IProvider, AuthSig } from '@lit-protocol/types';
import {
uint8arrayFromString,
uint8arrayToString,
Expand Down

0 comments on commit 429b95c

Please sign in to comment.