Skip to content

Commit 4b668f0

Browse files
committed
feat: update twitter verifier params
1 parent d0ba579 commit 4b668f0

File tree

29 files changed

+114
-95
lines changed

29 files changed

+114
-95
lines changed

UI/layouts/Header/Actions/NFT3Register/form/useForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from 'react'
22
import { useFormik } from 'formik'
33
import * as yup from 'yup'
4-
// import type { ENSTextRecord } from '@nft3sdk/client'
4+
// import type { ENSTextRecord } from '@rootlabs/client'
55
interface ENSTextRecord {
66
snapshot: string
77
email: string

UI/layouts/Header/Actions/WalletSelect/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import List from '@mui/material/List'
44
import ListItem from '@mui/material/ListItem'
55
import ListItemText from '@mui/material/ListItemText'
66
import ListItemIcon from '@mui/material/ListItemIcon'
7-
import type { WalletType } from '@nft3sdk/did-manager'
7+
import type { WalletType } from '@rootlabs/did-manager'
88
import { useTheme } from '@mui/material/styles'
9-
import { useNFT3 } from '@nft3sdk/did-manager'
9+
import { useROOT } from '@rootlabs/did-manager'
1010

1111
import { useUser } from 'domains/data'
1212
import { createToastifyPromise } from 'app/utils/promise/toastify'
@@ -57,7 +57,7 @@ const wallets: IWalletItem[] = [
5757

5858
const WalletSelect: FC = () => {
5959
const theme = useTheme()
60-
const { client } = useNFT3()
60+
const { client } = useROOT()
6161
const { selectDialog, selectWallet, login, registerDialog, logout, disconnect } = useUser()
6262
const onLogout = useCallback(() => {
6363
logout()

UI/layouts/Header/Search/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ListItemText from '@mui/material/ListItemText'
88
import { TransitionGroup } from 'react-transition-group'
99
import Collapse from '@mui/material/Collapse'
1010
import debounce from '@mui/utils/debounce'
11-
import { useNFT3 } from '@nft3sdk/did-manager'
11+
import { useROOT } from '@rootlabs/did-manager'
1212

1313
import { useDialog } from 'app/hooks/useDialog'
1414
import SearchInput from 'components/input-fields/SearchInput'
@@ -27,7 +27,7 @@ const ROOT = styled('div')`
2727

2828
const Search = () => {
2929
const router = useRouter()
30-
const { client } = useNFT3()
30+
const { client } = useROOT()
3131
const [value, setValue] = useState('')
3232
const [loading, setLoading] = useState(false)
3333
const { visible, open, close } = useDialog({

UI/profile-board/Timeline/Actions/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import IconButton from '@mui/material/IconButton'
44
import MenuItem from '@mui/material/MenuItem'
55
import ListItemText from '@mui/material/ListItemText'
66
import MoreVertRoundedIcon from '@mui/icons-material/MoreVertRounded'
7-
import type { TimelineRecord } from '@nft3sdk/client'
7+
import type { TimelineRecord } from '@rootlabs/client'
88

99
import { safeGet } from 'app/utils/get'
1010
import { useAnchorMenu } from 'app/hooks/useAnchor'

UI/profile-board/Timeline/Chip.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { StackTypeMap } from '@mui/material/Stack'
33
import Stack from '@mui/material/Stack'
44
import Chip from '@mui/material/Chip'
55
import Box from '@mui/material/Box'
6-
import type { TimelineRecord } from '@nft3sdk/client'
6+
import type { TimelineRecord } from '@rootlabs/client'
77
import { NETWORK_MAP } from './netwrok'
88

99
export const ChipStack: FC<StackTypeMap<{}, 'div'>['props']> = (props) => (

UI/profile-board/Timeline/TimelineCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Paragraph, H4, Tiny } from 'components/Typography'
1111
import { useNFT3Profile, useNFT3, useNFT3Wallet } from 'domains/data'
1212
import { format as formatData } from 'date-fns'
1313
import { safeGet } from 'app/utils/get'
14-
import type { TimelineRecord, TxRecord, POAPRecord } from '@nft3sdk/client'
14+
import type { TimelineRecord, TxRecord, POAPRecord } from '@rootlabs/client'
1515
import TokenIcon from '@mui/icons-material/Token'
1616
import GroupsRoundedIcon from '@mui/icons-material/GroupsRounded'
1717
import { DisplayNumber } from 'components/Number'

UI/profile/useForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useCallback, useEffect } from 'react'
33

44
import { useFormik } from 'formik'
55
import * as yup from 'yup'
6-
import type { ProfileModel, WithMeta } from '@nft3sdk/client'
6+
import type { ProfileModel, WithMeta } from '@rootlabs/client'
77

88
import { createToastifyPromise } from 'app/utils/promise/toastify'
99
import { useNFT3, useNFT3Profile } from 'domains/data'

UI/referral-program/Invitees/Invitee.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Stack from '@mui/material/Stack'
66
import { useNFT3Social, useUser, useNFT3 } from 'domains/data'
77
import { useMount } from 'app/hooks/useMount'
88
import { useCallback, useState } from 'react'
9-
import type { ProfileModel, DIDInfo, WithMeta } from '@nft3sdk/client'
9+
import type { ProfileModel, WithMeta } from '@rootlabs/client'
1010
import { getProfile } from 'domains/data/nft3/profile/adapter'
1111
import Avatar from '@mui/material/Avatar'
1212

@@ -26,7 +26,6 @@ const Invitee: FC<{ inviter: ReferrerModel }> = ({ inviter: { createdAt, __owner
2626
const identifier = __owner
2727
const [twitter, setTwitter] = useState<any>()
2828
const [profile, setProfile] = useState<WithMeta<ProfileModel>>({} as any)
29-
const [didinfo, setDidinfo] = useState<DIDInfo>()
3029

3130
const updateProfile = useCallback(() => {
3231
if (!identifier) return
@@ -38,10 +37,7 @@ const Invitee: FC<{ inviter: ReferrerModel }> = ({ inviter: { createdAt, __owner
3837

3938
const updateDidInfo = useCallback(() => {
4039
if (!identifier) return
41-
return client.did.info(identifier).then((didinfo) => {
42-
setDidinfo(didinfo)
43-
})
44-
}, [client.did, identifier])
40+
}, [identifier])
4541

4642
const updateTwitter = useCallback(async () => {
4743
const items = await client.socialAccount.list(identifier)

components/Twitter/BindTwitter/VerifyTwitter/index.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
import { useState } from 'react'
22
import Button from '@mui/material/Button'
3+
import Input from '@mui/material/Input'
34
import FlexBetween from 'components/flexbox/FlexBetween'
45

56
import type { StepProps } from '../type'
67

78
type VerifyTwitterProps = StepProps & {
8-
verify: () => any
9+
verify: (link: string) => any
910
reset: () => any
1011
}
1112
const VerifyTwitter: FC<VerifyTwitterProps> = (props) => {
1213
const { activeStep, value, verify, reset } = props
1314
const [loading, setLoading] = useState(false)
15+
const [link, setLink] = useState('')
1416
if (activeStep !== value) return null
17+
1518
return (
16-
<FlexBetween>
19+
<FlexBetween gap={4}>
1720
<Button color="inherit" onClick={reset} sx={{ mr: 1 }}>
1821
Reset
1922
</Button>
23+
<Input placeholder="Tweet link" fullWidth value={link} onChange={(e) => setLink(e.target.value)} />
2024
<Button
2125
variant="contained"
2226
onClick={() => {
2327
setLoading(true)
24-
verify().finally(() => {
28+
verify(link).finally(() => {
2529
setLoading(false)
2630
})
2731
}}
28-
disabled={loading}
32+
disabled={!link || loading}
2933
>
3034
Verify
3135
</Button>

components/Twitter/BindTwitter/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ const BindTwitter: FC<BindTwitterProps> = ({ visible, close }) => {
3636
setActiveStep(0)
3737
}
3838

39-
const verify = () => {
40-
close()
39+
const verify = (link: string) => {
4140
return createToastifyPromise(
42-
twitter.verify(account!, info!.msghash).then((verify) => {
43-
if (!verify.result) return Promise.reject()
41+
twitter.verify(account!, info!.msghash, link).then((verify) => {
42+
close()
43+
if (!verify.result) return Promise.reject('Twitter verify failed')
4444
return twitter
4545
.add({
4646
account: account!,
4747
type: 'twitter',
4848
proof: verify.proof,
4949
verifier_key: verify.verifier_key,
50-
msghash: info!.msghash,
50+
msghash: info!.msghash
5151
})
5252
.then(() => {
5353
setInfo(undefined)

domains/data/nft3/assets/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createContext } from 'app/utils/createContext'
22
import { useNFT3, useNFT3Profile } from 'domains/data'
33
import { useState, useCallback, useEffect } from 'react'
4-
import type { TokenRecord, OpenseaAssetsRecord, ENSRecord, TimelineRecord, POAPRecord } from '@nft3sdk/client'
4+
import type { TokenRecord, OpenseaAssetsRecord, ENSRecord, TimelineRecord, POAPRecord } from '@rootlabs/client'
55
import { useTimeline } from './timeline'
66

77
const useAssetsService = () => {

domains/data/nft3/assets/timeline/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useCallback, useEffect, useMemo, useState } from 'react'
2-
import type { NFT3Queryer, TimelineRecord } from '@nft3sdk/client'
2+
import type { ROOTQueryer, TimelineRecord } from '@rootlabs/client'
33

44
const REQUEST_LIMIT = 10
55
type TimelineProps = {
6-
queryer: NFT3Queryer
6+
queryer: ROOTQueryer
77
baseData: TimelineRecord[]
88
baseLoading: boolean
99
identifier: any

domains/data/nft3/featuredPeoples/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ const useFeaturedPeoplesService = () => {
2424
limit,
2525
},
2626
})
27-
.then((data) => {
27+
.then((data: any) => {
2828
setFeaturedPeoples((featuredPeoples) => {
2929
return featuredPeoples.concat(
3030
data.nft3Featured
31-
.filter((item) => item && item.profile)
32-
.map((item, index) => {
31+
.filter((item: any) => item && item.profile)
32+
.map((item: any, index: number) => {
3333
return {
3434
identifier: item.did,
3535
name: item.profile.name,

domains/data/nft3/follow/hooks/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useCallback, useState } from 'react'
2-
import { useNFT3 } from '@nft3sdk/did-manager'
2+
import { useROOT } from '@rootlabs/did-manager'
33
import type { FollowMember } from 'components/Follow/types'
44
import { useDebounceMemo } from 'app/hooks/useDebounceMemo'
55

66
export const useFollow = (identifier: string) => {
7-
const { client } = useNFT3()
7+
const { client } = useROOT()
88
const [count, setCount] = useState({
99
following: 0,
1010
followers: 0,

domains/data/nft3/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo } from 'react'
2-
import { NFT3Queryer } from '@nft3sdk/client'
2+
import { ROOTQueryer } from '@rootlabs/client'
33
import { createContext } from 'app/utils/createContext'
44

55
import useIpfs from './hooks/useIpfs'
@@ -17,7 +17,7 @@ const useNFT3Service = () => {
1717
const { format, upload } = useIpfs()
1818

1919
const queryer = useMemo(() => {
20-
return new NFT3Queryer('https://t0.onebitdev.com/nft3-queryer/')
20+
return new ROOTQueryer('https://t0.onebitdev.com/nft3-queryer/')
2121
}, [])
2222

2323
return {

domains/data/nft3/profile/adapter/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ProfileModel, WithMeta } from '@nft3sdk/client'
1+
import type { ProfileModel, WithMeta } from '@rootlabs/client'
22

33
import { getDefaultProfileAvatar } from './profileAvatar'
44

domains/data/nft3/profile/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback, useEffect, useMemo, useState } from 'react'
2-
import type { ProfileModel, DIDInfo, WithMeta } from '@nft3sdk/client'
2+
import type { ProfileModel, DIDInfo, WithMeta } from '@rootlabs/client'
33
import { createContext } from 'app/utils/createContext'
44
import { merge } from 'lodash'
55

@@ -21,14 +21,14 @@ const useProfileService = () => {
2121
const [profile, setProfileInternal] = useState<WithMeta<ProfileModel>>({} as any)
2222

2323
const updateProfile = useCallback(() => {
24-
return client.profile.info(did).then((profile) => {
24+
return client.profile.info(did).then((profile: any) => {
2525
if (!profile) return
2626
setProfileInternal(getProfile(profile) as any)
2727
})
2828
}, [client.profile, did])
2929

3030
const updateDidInfo = useCallback(() => {
31-
return client.did.info(did).then((didinfo) => {
31+
return client.did.info(did).then((didinfo: any) => {
3232
setDidinfo(didinfo)
3333
})
3434
}, [client.did, did])

domains/data/nft3/referrerStats/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const useReferrerStatsService = () => {
2525
did: identifier,
2626
},
2727
})
28-
.then((data) => {
28+
.then((data: any) => {
2929
setReferrerStats(data.nft3ReferrerStats)
3030
})
3131
.finally(() => {

domains/data/nft3/social/hooks/index.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import { useCallback, useMemo } from 'react'
2-
import { useNFT3 } from '@nft3sdk/did-manager'
3-
import type { NFT3Verifier, SocialAccountModel } from '@nft3sdk/client'
2+
import { useROOT } from '@rootlabs/did-manager'
3+
import type { ROOTVerifier, SocialAccountModel } from '@rootlabs/client'
44
import type { SocialRecord } from '../types'
55

66
type TwitterProps = {
7-
verifier: NFT3Verifier
7+
verifier: ROOTVerifier
88
socials: SocialRecord[]
99
}
1010

1111
export const useTwitter = (props: TwitterProps) => {
1212
const { verifier, socials } = props
13-
const { client } = useNFT3()
13+
const { client } = useROOT()
1414
const request = useCallback(() => {
1515
const info = verifier.requestTwitter()
1616
return info
1717
}, [verifier])
1818

1919
const verify = useCallback(
20-
async (account: string, msghash: string) => {
21-
const result = await verifier.verifyTwitter(account, msghash)
20+
async (account: string, msghash: string, link: string) => {
21+
const regex = /^https?:\/\/(twitter\.com|x\.com)\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$/
22+
if (regex.test(link) !== true) {
23+
throw new Error('Invalid tweet link')
24+
}
25+
const result = await verifier.verifyTwitter(account, msghash, link)
2226
return result
2327
},
2428
[verifier]

domains/data/nft3/social/hooks/useSocial.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { useNFT3 } from '@nft3sdk/did-manager'
2-
import { NFT3Verifier } from '@nft3sdk/client'
1+
import { useROOT } from '@rootlabs/did-manager'
2+
import { ROOTVerifier } from '@rootlabs/client'
33
import { useState, useMemo, useCallback, useEffect } from 'react'
44
import { useTwitter } from '.'
55
import type { SocialRecord } from '../types'
66

77
export const useSocial = (did: string) => {
8-
const { client } = useNFT3()
8+
const { client } = useROOT()
99
const [socials, setSocials] = useState<SocialRecord[]>([])
1010

1111
const verifier = useMemo(() => {
12-
return new NFT3Verifier(client, 'https://t0.onebitdev.com/nft3-verifier/')
12+
return new ROOTVerifier(client, 'https://t0.onebitdev.com/nft3-verifier/')
1313
}, [client])
1414

1515
const update = useCallback(
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SocialAccountModel, WithMeta } from '@nft3sdk/client'
1+
import type { SocialAccountModel, WithMeta } from '@rootlabs/client'
22
export interface SocialRecord extends WithMeta<SocialAccountModel> {
33
verified: boolean
44
}

domains/data/nft3/stats/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useCallback, useEffect, useState } from 'react'
2-
import type { NFT3Stats } from '@nft3sdk/client'
2+
import type { ROOTStats } from '@rootlabs/client'
33
import { createContext } from 'app/utils/createContext'
44
import { useNFT3 } from 'domains/data'
55

66
const useStatsService = () => {
77
const { queryer } = useNFT3()
88

99
const [loading, setLoading] = useState(false)
10-
const [stats, setStats] = useState<NFT3Stats>({} as any)
10+
const [stats, setStats] = useState<ROOTStats>({} as any)
1111

1212
const request = useCallback(
1313
() => {
@@ -17,8 +17,8 @@ const useStatsService = () => {
1717
.query({
1818
nft3Stats: {},
1919
})
20-
.then((data) => {
21-
setStats(data.nft3Stats)
20+
.then((data: any) => {
21+
setStats(data.ROOTStats)
2222
})
2323
.finally(() => {
2424
setLoading(false)

domains/data/nft3/wallet/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createContext } from 'app/utils/createContext'
22
import { useState, useEffect, useCallback, useMemo } from 'react'
33
import { useNFT3Profile, useUser } from 'domains/data'
4-
import { useNFT3 } from '@nft3sdk/did-manager'
4+
import { useROOT } from '@rootlabs/did-manager'
55
import { safeGet } from 'app/utils/get'
66
import ETHImg from 'public/eth.svg'
77
import SolanaImg from 'public/solana.svg'
@@ -14,7 +14,7 @@ import AptosImg from 'public/aptos.svg'
1414
import type { AccountRecord } from './types'
1515

1616
const useWalletService = () => {
17-
const { client } = useNFT3()
17+
const { client } = useROOT()
1818
const { account } = useUser()
1919
const { isUser, didinfo, didname, updateDidInfo } = useNFT3Profile()
2020
const [value, setValue] = useState('')

0 commit comments

Comments
 (0)