Skip to content

Commit 35421b8

Browse files
authored
fix: initialize lens client only with valid address (#12221)
1 parent 863f8de commit 35421b8

File tree

1 file changed

+11
-10
lines changed
  • packages/web3-providers/src/LensV3

1 file changed

+11
-10
lines changed

packages/web3-providers/src/LensV3/index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,24 @@ import {
1717
follow as lensFollow,
1818
unfollow as lensUnfollow,
1919
} from '@lens-protocol/client/actions'
20-
import { gql } from 'graphql-request'
21-
import { sortBy, uniqBy } from 'lodash-es'
22-
import { fetchJSON } from '../helpers/fetchJSON.js'
23-
import { LENS_ROOT_API } from './constants.js'
24-
import { fragments } from './fragments/index.js'
25-
import type { FollowPair } from './types.js'
2620
import {
2721
createIndicator,
2822
createNextIndicator,
2923
createPageable,
3024
EMPTY_LIST,
3125
type PageIndicator,
3226
} from '@masknet/shared-base'
33-
import { formatLensPost, getAccountAvatar } from './helpers.js'
34-
import { isZero } from '@masknet/web3-shared-base'
35-
import type { LensV3BaseAPI } from '@masknet/web3-providers/types'
3627
import { EVMWeb3 } from '@masknet/web3-providers'
28+
import type { LensV3BaseAPI } from '@masknet/web3-providers/types'
29+
import { isZero } from '@masknet/web3-shared-base'
30+
import { isValidAddress } from '@masknet/web3-shared-evm'
31+
import { gql } from 'graphql-request'
32+
import { sortBy, uniqBy } from 'lodash-es'
33+
import { fetchJSON } from '../helpers/fetchJSON.js'
34+
import { LENS_ROOT_API } from './constants.js'
35+
import { fragments } from './fragments/index.js'
36+
import { formatLensPost, getAccountAvatar } from './helpers.js'
37+
import type { FollowPair } from './types.js'
3738

3839
export class LensV3 {
3940
private signMessage: (message: string) => Promise<string>
@@ -46,7 +47,7 @@ export class LensV3 {
4647
storage: window.localStorage,
4748
fragments,
4849
})
49-
if (account) this.account = evmAddress(account)
50+
if (account && isValidAddress(account)) this.account = evmAddress(account)
5051
this.signMessage = signMessage || ((message: string) => EVMWeb3.signMessage('message', message))
5152
}
5253

0 commit comments

Comments
 (0)