From 15df2341e6ac2be326512a3bb7b00597d1820451 Mon Sep 17 00:00:00 2001 From: aryan Date: Tue, 3 Dec 2024 05:24:01 +0530 Subject: [PATCH 01/11] feat: invite member --- .../components/steps/InviteMembersForm.tsx | 72 +++++++++++++- package.json | 1 + utils/domains.ts | 94 ++++++++++++------- yarn.lock | 83 +++++++++++++++- 4 files changed, 207 insertions(+), 43 deletions(-) diff --git a/components/NewRealmWizard/components/steps/InviteMembersForm.tsx b/components/NewRealmWizard/components/steps/InviteMembersForm.tsx index 46f5ba6ec..f6ed1611e 100644 --- a/components/NewRealmWizard/components/steps/InviteMembersForm.tsx +++ b/components/NewRealmWizard/components/steps/InviteMembersForm.tsx @@ -14,6 +14,10 @@ import { updateUserInput, validateSolAddress } from '@utils/formValidation' import { FORM_NAME as MULTISIG_FORM } from 'pages/realms/new/multisig' import { textToAddressList } from '@utils/textToAddressList' import useWalletOnePointOh from '@hooks/useWalletOnePointOh' +import { resolveDomain } from '@utils/domains' +import { Connection } from '@solana/web3.js' +// import { DEFAULT_RPC_ENDPOINT } from '@constants/endpoints' +import { useConnection } from '@solana/wallet-adapter-react' /** * Convert a list of addresses into a list of uniques and duplicates @@ -131,6 +135,58 @@ export interface InviteMembers { memberAddresses: string[] } +/** + * Convert a list of addresses/domains into a list of resolved addresses + */ +async function resolveAddressList(connection: Connection, textBlock: string) { + const items = textBlock.split(/[\n,]+/).map((item) => item.trim()).filter(Boolean) + console.log('Resolving items:', items) + + const results = await Promise.all( + items.map(async (item) => { + try { + // If it's already a valid address, return it + if (validateSolAddress(item)) { + console.log(`${item} is already a valid address`) + return { input: item, resolved: item } + } + + // Try to resolve as domain + console.log(`Attempting to resolve domain: ${item}`) + const resolved = await resolveDomain(connection, item) + console.log('Resolved:', resolved) + console.log(`Domain ${item} resolved to:`, resolved?.toBase58() || 'null') + return { + input: item, + resolved: resolved?.toBase58() + } + } catch (error) { + console.error(`Error resolving ${item}:`, error) + return { input: item, resolved: undefined } + } + }) + ) + + const valid: string[] = [] + const invalid: string[] = [] + + results.forEach(({ input, resolved }) => { + if (resolved && validateSolAddress(resolved)) { + valid.push(resolved) + } else { + invalid.push(input) + } + }) + + console.log('Final resolution results:', { + valid, + invalid, + results + }) + + return { valid, invalid } +} + export default function InviteMembersForm({ visible, type, @@ -146,6 +202,7 @@ export default function InviteMembersForm({ const [inviteList, setInviteList] = useState([]) const [invalidAddresses, setInvalidAddresses] = useState([]) const [lacksMintAuthority, setLackMintAuthority] = useState(false) + const { connection } = useConnection() const schema = yup.object(InviteMembersSchema) const { @@ -211,12 +268,15 @@ export default function InviteMembersForm({ onSubmit({ step: currentStep, data: values }) } - function addToAddressList(textBlock: string) { + /** + * Update the addToAddressList function to be async + */ + async function addToAddressList(textBlock: string) { if (lacksMintAuthority) { return } - const { valid, invalid } = textToAddressList(textBlock) + const { valid, invalid } = await resolveAddressList(connection, textBlock) const { unique, duplicate } = splitUniques(inviteList.concat(valid)) setInviteList(unique) setInvalidAddresses((currentList) => @@ -224,6 +284,9 @@ export default function InviteMembersForm({ ) } + /** + * Update the event handlers to handle async addToAddressList + */ function handleBlur(ev) { addToAddressList(ev.currentTarget.value) ev.currentTarget.value = '' @@ -232,13 +295,12 @@ export default function InviteMembersForm({ function handlePaste(ev: React.ClipboardEvent) { addToAddressList(ev.clipboardData.getData('text')) ev.clipboardData.clearData() - // Don't allow the paste event to populate the input field ev.preventDefault() } function handleKeyDown(ev) { if (ev.defaultPrevented) { - return // Do nothing if the event was already processed + return } if (ev.key === 'Enter') { @@ -323,7 +385,7 @@ export default function InviteMembersForm({ { try { // Get the public key for the domain - const { pubkey } = await getDomainKey(domainName.replace('.sol', '')) + if (domainName.includes('.sol')) { + const { pubkey } = await getDomainKey(domainName) - // Check if the domain is an NFT - const [nftMintAddress] = await PublicKey.findProgramAddress( - [MINT_PREFIX, pubkey.toBuffer()], - NAME_TOKENIZER_ID - ) + // Check if the domain is an NFT + const [nftMintAddress] = await PublicKey.findProgramAddress( + [MINT_PREFIX, pubkey.toBuffer()], + NAME_TOKENIZER_ID + ) - const nftAccountData = await connection.getParsedAccountInfo(nftMintAddress) - - if ( - nftAccountData.value?.data && - !Buffer.isBuffer(nftAccountData.value.data) - ) { - const parsedData: ParsedAccountData = nftAccountData.value.data + const nftAccountData = await connection.getParsedAccountInfo( + nftMintAddress + ) if ( - parsedData.parsed.info.supply === '1' && - parsedData.parsed.info.isInitialized + nftAccountData.value?.data && + !Buffer.isBuffer(nftAccountData.value.data) ) { - const { value } = await connection.getTokenLargestAccounts( - nftMintAddress - ) - const nftHolder = value.find((e) => e.amount === '1')?.address + const parsedData: ParsedAccountData = nftAccountData.value.data - if (!nftHolder) return undefined + if ( + parsedData.parsed.info.supply === '1' && + parsedData.parsed.info.isInitialized + ) { + const { value } = await connection.getTokenLargestAccounts( + nftMintAddress + ) + const nftHolder = value.find((e) => e.amount === '1')?.address - const holderInfo = await connection.getAccountInfo(nftHolder) + if (!nftHolder) return undefined - if (!holderInfo || !holderInfo.data) { - return undefined - } + const holderInfo = await connection.getAccountInfo(nftHolder) + + if (!holderInfo || !holderInfo.data) { + return undefined + } - return new PublicKey(holderInfo.data.slice(32, 64)) + return new PublicKey(holderInfo.data.slice(32, 64)) + } } - } - // Retrieve the domain's registry information - const { registry } = await NameRegistryState.retrieve(connection, pubkey) + console.log('Pubkey:', pubkey.toBase58()) + + // Retrieve the domain's registry information + const { registry } = await NameRegistryState.retrieve(connection, pubkey) - return registry.owner + return registry.owner + } else { + const parser = new TldParser(connection) + const owner = await parser.getOwnerFromDomainTld(domainName) + return owner + } } catch (error) { + console.error('Error resolving domain:', error) return undefined } } @@ -70,16 +83,29 @@ export const fetchDomainsByPubkey = async ( pubkey: PublicKey | undefined ) => { if (!pubkey) return [] - const domains = await getAllDomains(connection, pubkey) + const parser = new TldParser(connection) + const sns_domains = await getAllDomains(connection, pubkey) + const tld_domains = await parser.getParsedAllUserDomains(pubkey) const results: Domain[] = [] - if (domains.length > 0) { - const reverse = await performReverseLookupBatch(connection, domains) + if (sns_domains.length > 0) { + const reverse = await performReverseLookupBatch(connection, sns_domains) - for (let i = 0; i < domains.length; i++) { + for (let i = 0; i < sns_domains.length; i++) { results.push({ - domainAddress: domains[i].toBase58(), + domainAddress: sns_domains[i].toBase58(), domainName: reverse[i], + type: 'sns', + }) + } + } + + if (tld_domains.length > 0) { + for (let i = 0; i < tld_domains.length; i++) { + results.push({ + domainAddress: tld_domains[i].domain, + domainName: tld_domains[i].nameAccount.toBase58(), + type: 'alldomains', }) } } diff --git a/yarn.lock b/yarn.lock index 4de48b7d5..99dfaac84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -710,7 +710,7 @@ dependencies: ajv "^8.12.0" -"@coral-xyz/anchor-30@npm:@coral-xyz/anchor@0.30.1", "@coral-xyz/anchor@0.30.1", "@coral-xyz/anchor@^0.30.1", "switchboard-anchor@npm:@coral-xyz/anchor@0.30.1": +"@coral-xyz/anchor-30@npm:@coral-xyz/anchor@0.30.1": version "0.30.1" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d" integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ== @@ -756,6 +756,27 @@ superstruct "^0.15.4" toml "^3.0.0" +"@coral-xyz/anchor@0.30.1", "@coral-xyz/anchor@^0.30.1": + version "0.30.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d" + integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ== + dependencies: + "@coral-xyz/anchor-errors" "^0.30.1" + "@coral-xyz/borsh" "^0.30.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.68.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + crypto-hash "^1.3.0" + eventemitter3 "^4.0.7" + pako "^2.0.3" + snake-case "^3.0.4" + superstruct "^0.15.4" + toml "^3.0.0" + "@coral-xyz/borsh@0.27.0", "@coral-xyz/borsh@^0.26.0", "@coral-xyz/borsh@^0.28.0", "@coral-xyz/borsh@^0.29.0", "@coral-xyz/borsh@^0.30.1": version "0.27.0" resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.27.0.tgz#700c647ea5262b1488957ac7fb4e8acf72c72b63" @@ -2759,6 +2780,14 @@ node-gyp "^7.1.0" read-package-json-fast "^2.0.1" +"@onsol/tldparser@0.6.6": + version "0.6.6" + resolved "https://registry.yarnpkg.com/@onsol/tldparser/-/tldparser-0.6.6.tgz#e88f38e9bfa6058d0eacf18ad606f463f3760597" + integrity sha512-ArVxgBV4+9j1U8ja3JRogzFpOsVpFITV3DwN3lcwpbBt00NpmMIcMTdiR6swkfQLthDE3dI19tKmQBuKrN4wyA== + dependencies: + "@ethersproject/sha2" "^5.7.0" + "@metaplex-foundation/beet-solana" "^0.4.0" + "@parcel/watcher-android-arm64@2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.0.tgz#9c93763794153e4f76920994a423b6ea3257059d" @@ -16001,7 +16030,7 @@ string-similarity@^4.0.3: resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b" integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -16019,6 +16048,15 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -16122,7 +16160,7 @@ stringify-object@^3.3.0: is-obj "^1.0.1" is-regexp "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -16150,6 +16188,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -16296,6 +16341,27 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +"switchboard-anchor@npm:@coral-xyz/anchor@0.30.1": + version "0.30.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d" + integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ== + dependencies: + "@coral-xyz/anchor-errors" "^0.30.1" + "@coral-xyz/borsh" "^0.30.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.68.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + crypto-hash "^1.3.0" + eventemitter3 "^4.0.7" + pako "^2.0.3" + snake-case "^3.0.4" + superstruct "^0.15.4" + toml "^3.0.0" + swr@1.3.0, swr@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/swr/-/swr-1.3.0.tgz#c6531866a35b4db37b38b72c45a63171faf9f4e8" @@ -17487,7 +17553,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -17513,6 +17579,15 @@ wrap-ansi@^5.1.0: string-width "^3.0.0" strip-ansi "^5.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From 3638c74495f4a8decd8eb8547c473c0a07643741 Mon Sep 17 00:00:00 2001 From: aryan Date: Tue, 3 Dec 2024 05:57:43 +0530 Subject: [PATCH 02/11] feat: members page --- components/Profile/ProfileName.tsx | 12 +++++++++++- utils/domains.ts | 25 ++++++++++++++----------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/components/Profile/ProfileName.tsx b/components/Profile/ProfileName.tsx index 75c5be6f9..7360c0d19 100644 --- a/components/Profile/ProfileName.tsx +++ b/components/Profile/ProfileName.tsx @@ -3,6 +3,9 @@ import { useProfile } from '@components/Profile/useProfile'; import { PublicKey } from '@solana/web3.js'; import ContentLoader from "react-content-loader"; import {ShortAddress} from "@components/Profile/ShortAddress"; +import { fetchDomainsByPubkey } from '@utils/domains' +import { useConnection } from '@solana/wallet-adapter-react' +import { useEffect, useState } from 'react' type Props = { publicKey?: PublicKey, height?: string; width?: string; @@ -13,6 +16,13 @@ export const ProfileName: FC = ({ publicKey, height = "13", dark = false, style, }) => { const { profile, loading } = useProfile(publicKey) + const { connection } = useConnection() + const [domains, setDomains] = useState([]) + useEffect(() => { + if (publicKey) { + fetchDomainsByPubkey(connection, publicKey).then(setDomains) + } + }, [publicKey, connection]) if (!publicKey) return <>; @@ -34,7 +44,7 @@ export const ProfileName: FC = ({ publicKey, height = "13", ) : (
- {profile?.name?.value || } + {domains.length > 0 ? domains[0].domainName : profile?.name?.value || }
); } diff --git a/utils/domains.ts b/utils/domains.ts index 8f3bcee16..94bd75739 100644 --- a/utils/domains.ts +++ b/utils/domains.ts @@ -88,17 +88,8 @@ export const fetchDomainsByPubkey = async ( const tld_domains = await parser.getParsedAllUserDomains(pubkey) const results: Domain[] = [] - if (sns_domains.length > 0) { - const reverse = await performReverseLookupBatch(connection, sns_domains) - - for (let i = 0; i < sns_domains.length; i++) { - results.push({ - domainAddress: sns_domains[i].toBase58(), - domainName: reverse[i], - type: 'sns', - }) - } - } + console.log('SNS domains:', sns_domains) + console.log('TLD domains:', tld_domains) if (tld_domains.length > 0) { for (let i = 0; i < tld_domains.length; i++) { @@ -109,5 +100,17 @@ export const fetchDomainsByPubkey = async ( }) } } + + if (sns_domains.length > 0) { + const reverse = await performReverseLookupBatch(connection, sns_domains) + + for (let i = 0; i < sns_domains.length; i++) { + results.push({ + domainAddress: sns_domains[i].toBase58(), + domainName: reverse[i] + '.sol', + type: 'sns', + }) + } + } return results } From dee1d33f550fb7051d81ac03e88ac9d6f3acb0c6 Mon Sep 17 00:00:00 2001 From: aryan Date: Tue, 3 Dec 2024 06:07:58 +0530 Subject: [PATCH 03/11] feat: add member resolve --- components/Members/AddMemberForm.tsx | 77 ++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/components/Members/AddMemberForm.tsx b/components/Members/AddMemberForm.tsx index 672de73e3..520728874 100644 --- a/components/Members/AddMemberForm.tsx +++ b/components/Members/AddMemberForm.tsx @@ -21,6 +21,7 @@ import AddMemberIcon from '@components/AddMemberIcon' import { ArrowCircleDownIcon, ArrowCircleUpIcon, + RefreshIcon, } from '@heroicons/react/outline' import useCreateProposal from '@hooks/useCreateProposal' import { AssetAccount } from '@utils/uiTypes/assets' @@ -33,6 +34,8 @@ import { useRealmQuery } from '@hooks/queries/realm' import { DEFAULT_GOVERNANCE_PROGRAM_VERSION } from '@components/instructions/tools' import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext' import {useVoteByCouncilToggle} from "@hooks/useVoteByCouncilToggle"; +import { resolveDomain } from '@utils/domains' +import debounce from 'lodash/debounce' interface AddMemberForm extends Omit { description: string @@ -95,6 +98,44 @@ const AddMemberForm: FC<{ close: () => void; mintAccount: AssetAccount }> = ({ // note the lack of space is not a typo const proposalTitle = `Add ${govpop}member ${abbrevAddress}` + const [isResolvingDomain, setIsResolvingDomain] = useState(false) + + const resolveDomainDebounced = useMemo( + () => + debounce(async (domain: string) => { + try { + console.log('Attempting to resolve domain:', domain) + const resolved = await resolveDomain(connection.current, domain) + console.log('Domain resolved to:', resolved?.toBase58() || 'null') + + if (resolved) { + handleSetForm({ + value: resolved.toBase58(), + propertyName: 'destinationAccount', + }) + } + } catch (error) { + console.error('Error resolving domain:', error) + } finally { + setIsResolvingDomain(false) + } + }, 500), + [connection] + ) + + const handleDestinationAccountChange = async (event) => { + const value = event.target.value + handleSetForm({ + value, + propertyName: 'destinationAccount', + }) + + if (value.includes('.')) { + setIsResolvingDomain(true) + resolveDomainDebounced(value) + } + } + const setAmount = (event) => { const value = event.target.value @@ -264,23 +305,25 @@ const AddMemberForm: FC<{ close: () => void; mintAccount: AssetAccount }> = ({

Add new member to {realmInfo?.displayName}

- - handleSetForm({ - value: event.target.value, - propertyName: 'destinationAccount', - }) - } - noMaxWidth - error={formErrors['destinationAccount']} - /> +
+ + {isResolvingDomain && ( +
+ +
+ )} +
Date: Tue, 3 Dec 2024 06:28:26 +0530 Subject: [PATCH 04/11] feat: new proposal member input support --- .../SplGov/RevokeGoverningTokens.tsx | 62 ++++++++++++++++--- .../instructions/Squads/MeshAddMember.tsx | 43 ++++++++++++- .../instructions/Squads/MeshRemoveMember.tsx | 41 +++++++++++- 3 files changed, 136 insertions(+), 10 deletions(-) diff --git a/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx b/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx index dc1610cb1..3d21edbbf 100644 --- a/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx +++ b/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx @@ -26,6 +26,10 @@ import { NewProposalContext } from '../../../new' import useMembershipTypes from './useMembershipTypes' import { useRealmQuery } from '@hooks/queries/realm' import Tooltip from '@components/Tooltip' +import { resolveDomain } from '@utils/domains' +import { RefreshIcon } from '@heroicons/react/outline' +import debounce from 'lodash/debounce' +import { useConnection } from '@solana/wallet-adapter-react' type Form = { memberKey?: string @@ -196,6 +200,34 @@ const RevokeGoverningTokens: FC<{ governance, ]) + // Add state for domain resolution + const [isResolvingDomain, setIsResolvingDomain] = useState(false) + const {connection} = useConnection() + + // Add the debounced resolve function + const resolveDomainDebounced = useMemo( + () => + debounce(async (domain: string) => { + try { + console.log('Attempting to resolve domain:', domain) + const resolved = await resolveDomain(connection, domain) + console.log('Domain resolved to:', resolved?.toBase58() || 'null') + + if (resolved) { + setForm((prevForm) => ({ + ...prevForm, + memberKey: resolved.toBase58(), + })) + } + } catch (error) { + console.error('Error resolving domain:', error) + } finally { + setIsResolvingDomain(false) + } + }, 500), + [connection] + ) + return ( <> - setForm((p) => ({ ...p, memberKey: e.target.value }))} - error={formErrors.memberKey} - /> +
+ { + const value = e.target.value + setForm((p) => ({ ...p, memberKey: value })) + + if (value.includes('.')) { + setIsResolvingDomain(true) + resolveDomainDebounced(value) + } + }} + error={formErrors.memberKey} + /> + {isResolvingDomain && ( +
+ +
+ )} +
+ debounce(async (domain: string) => { + try { + console.log('Attempting to resolve domain:', domain) + const resolved = await resolveDomain(connection.current, domain) + console.log('Domain resolved to:', resolved?.toBase58() || 'null') + + if (resolved) { + setForm((prevForm) => ({ + ...prevForm, + member: resolved.toBase58(), + })) + } + } catch (error) { + console.error('Error resolving domain:', error) + } finally { + setIsResolvingDomain(false) + } + }, 500), + [connection] + ) const validateInstruction = async (): Promise => { const { isValid, validationErrors } = await isFormValid(schema, form) @@ -128,6 +155,18 @@ const MeshAddMember = ({ type: InstructionInputType.INPUT, inputType: 'text', name: 'member', + placeholder: 'Member wallet or domain name (e.g. domain.sol)', + additionalComponent: isResolvingDomain ? ( +
+ +
+ ) : null, + onBlur: () => { + if (form.member.includes('.')) { + setIsResolvingDomain(true) + resolveDomainDebounced(form.member) + } + } }, ] diff --git a/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx b/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx index e858b7d02..da0aab5e5 100644 --- a/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx +++ b/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { useContext, useEffect, useState } from 'react' +import { useContext, useEffect, useState, useMemo } from 'react' import * as yup from 'yup' import { isFormValid, validatePubkey } from '@utils/formValidation' import { UiInstruction } from '@utils/uiTypes/proposalCreationTypes' @@ -16,6 +16,9 @@ import Squads from '@sqds/mesh' import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext' import { PublicKey } from '@solana/web3.js' import { Wallet } from '@coral-xyz/anchor' +import { resolveDomain } from '@utils/domains' +import { RefreshIcon } from '@heroicons/react/outline' +import debounce from 'lodash/debounce' const MeshRemoveMember = ({ index, @@ -35,6 +38,30 @@ const MeshRemoveMember = ({ }) const [formErrors, setFormErrors] = useState({}) const { handleSetInstructions } = useContext(NewProposalContext) + const [isResolvingDomain, setIsResolvingDomain] = useState(false) + + const resolveDomainDebounced = useMemo( + () => + debounce(async (domain: string) => { + try { + console.log('Attempting to resolve domain:', domain) + const resolved = await resolveDomain(connection.current, domain) + console.log('Domain resolved to:', resolved?.toBase58() || 'null') + + if (resolved) { + setForm((prevForm) => ({ + ...prevForm, + member: resolved.toBase58(), + })) + } + } catch (error) { + console.error('Error resolving domain:', error) + } finally { + setIsResolvingDomain(false) + } + }, 500), + [connection] + ) const validateInstruction = async (): Promise => { const { isValid, validationErrors } = await isFormValid(schema, form) @@ -128,6 +155,18 @@ const MeshRemoveMember = ({ type: InstructionInputType.INPUT, inputType: 'text', name: 'member', + placeholder: 'Member wallet or domain name (e.g. domain.sol)', + additionalComponent: isResolvingDomain ? ( +
+ +
+ ) : null, + onBlur: () => { + if (form.member.includes('.')) { + setIsResolvingDomain(true) + resolveDomainDebounced(form.member) + } + } }, ] From 0bbd96b434406d757aaa8a25ef2770d4bf759ec6 Mon Sep 17 00:00:00 2001 From: aryan Date: Tue, 3 Dec 2024 07:33:47 +0530 Subject: [PATCH 05/11] feat: domains by ad --- hooks/useTreasuryInfo/index.tsx | 29 ++++++--- pages/dao/[symbol]/treasury/v2/index.tsx | 79 +++++++++++++++++++++++- 2 files changed, 97 insertions(+), 11 deletions(-) diff --git a/hooks/useTreasuryInfo/index.tsx b/hooks/useTreasuryInfo/index.tsx index e28b235f2..633b6a691 100644 --- a/hooks/useTreasuryInfo/index.tsx +++ b/hooks/useTreasuryInfo/index.tsx @@ -9,7 +9,7 @@ import useRealm from '@hooks/useRealm' import { assembleWallets } from './assembleWallets' import { calculateTokenCountAndValue } from './calculateTokenCountAndValue' -import { getDomains } from './getDomains' +import { fetchDomainsByPubkey } from '@utils/domains' import { useRealmQuery } from '@hooks/queries/realm' import { useRealmConfigQuery } from '@hooks/queries/realmConfig' import { @@ -67,18 +67,27 @@ export default function useTreasuryInfo( if (!loadingGovernedAccounts && accounts.length && getNftsAndDomains) { setDomainsLoading(true) setBuildingWallets(true) - getDomains( - accounts.filter((acc) => acc.isSol), - connection.current - ).then((domainNames) => { - setDomains(domainNames) - setDomainsLoading(false) - }) + + Promise.all( + accounts + .filter((acc) => acc.isSol) + .map((account) => + fetchDomainsByPubkey(connection.current, account.pubkey) + ) + ).then((domainResults) => { + const allDomains = domainResults.flat().map(domain => ({ + name: domain.domainName?.replace('.sol', ''), + address: domain.domainAddress, + owner: accounts[0].pubkey.toBase58(), + type: domain.type + })); + + setDomains(allDomains); + setDomainsLoading(false); + }); } - // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO please fix, it can cause difficult bugs. You might wanna check out https://bobbyhadz.com/blog/react-hooks-exhaustive-deps for info. -@asktree }, [ loadingGovernedAccounts, - // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO please fix, it can cause difficult bugs. You might wanna check out https://bobbyhadz.com/blog/react-hooks-exhaustive-deps for info. -@asktree accounts.map((account) => account.pubkey.toBase58()).join('-'), ]) diff --git a/pages/dao/[symbol]/treasury/v2/index.tsx b/pages/dao/[symbol]/treasury/v2/index.tsx index f5346ec6a..85a6a8906 100644 --- a/pages/dao/[symbol]/treasury/v2/index.tsx +++ b/pages/dao/[symbol]/treasury/v2/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react' +import { useEffect, useRef, useState, useMemo } from 'react' import { pipe } from 'fp-ts/function' import PreviousRouteBtn from '@components/PreviousRouteBtn' @@ -10,6 +10,9 @@ import useTreasuryInfo from '@hooks/useTreasuryInfo' import { AuxiliaryWallet, Wallet } from '@models/treasury/Wallet' import { Asset } from '@models/treasury/Asset' import { useTreasurySelectState } from '@components/treasuryV2/Details/treasurySelectStore' +import { GlobeIcon } from '@heroicons/react/outline' +import { Domain } from '@models/treasury/Domain' +import { AssetType, Domains } from '@models/treasury/Asset' export default function Treasury() { const data = useTreasuryInfo() @@ -59,6 +62,32 @@ export default function Treasury() { ? selectedAsset : ('USE NON-LEGACY STATE' as const) + // Extract domains from wallets when data is available + const allDomains = useMemo(() => { + if (data._tag === Status.Ok) { + return data.data.wallets.reduce((domains, wallet) => { + const walletDomains = wallet.assets.find(asset => + asset.type === AssetType.Domain + ) as Domains | undefined; + + return walletDomains ? domains.concat(walletDomains.list) : domains; + }, [] as Domain[]); + } + return []; + }, [data]); + + // Group domains by type + const groupedDomains = useMemo(() => { + return allDomains.reduce((acc, domain) => { + const type = (domain as any).type || 'sns'; + if (!acc[type]) { + acc[type] = []; + } + acc[type].push(domain); + return acc; + }, {} as { [key: string]: Domain[] }); + }, [allDomains]); + return (
@@ -75,6 +104,54 @@ export default function Treasury() { })) )} /> + {/* Modified Domains Section */} + {allDomains.length > 0 && ( +
+
DAO Domains
+ + {/* SNS Domains */} + {groupedDomains['sns']?.length > 0 && ( + <> +
Solana Name Service Domains
+
+ {groupedDomains['sns'].map((domain) => ( +
+ +
+
{domain.name}.sol
+
{domain.address}
+
+
+ ))} +
+ + )} + + {/* AllDomains */} + {groupedDomains['alldomains']?.length > 0 && ( + <> +
AllDomains
+
+ {groupedDomains['alldomains'].map((domain) => ( +
+ +
+
{domain.name}
+
{domain.address}
+
+
+ ))} +
+ + )} +
+ )}
Date: Mon, 9 Dec 2024 21:35:10 +0530 Subject: [PATCH 06/11] fix: typos --- .../NewRealmWizard/components/steps/InviteMembersForm.tsx | 2 +- .../components/instructions/SplGov/RevokeGoverningTokens.tsx | 2 +- .../proposal/components/instructions/Squads/MeshAddMember.tsx | 2 +- .../components/instructions/Squads/MeshRemoveMember.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/NewRealmWizard/components/steps/InviteMembersForm.tsx b/components/NewRealmWizard/components/steps/InviteMembersForm.tsx index f6ed1611e..71d6184b0 100644 --- a/components/NewRealmWizard/components/steps/InviteMembersForm.tsx +++ b/components/NewRealmWizard/components/steps/InviteMembersForm.tsx @@ -385,7 +385,7 @@ export default function InviteMembersForm({ { const value = e.target.value setForm((p) => ({ ...p, memberKey: value })) diff --git a/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshAddMember.tsx b/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshAddMember.tsx index e89ac50e5..2b32b47f4 100644 --- a/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshAddMember.tsx +++ b/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshAddMember.tsx @@ -155,7 +155,7 @@ const MeshAddMember = ({ type: InstructionInputType.INPUT, inputType: 'text', name: 'member', - placeholder: 'Member wallet or domain name (e.g. domain.sol)', + placeholder: 'Member wallet or domain name (e.g. domain.solana)', additionalComponent: isResolvingDomain ? (
diff --git a/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx b/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx index da0aab5e5..668d30c94 100644 --- a/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx +++ b/pages/dao/[symbol]/proposal/components/instructions/Squads/MeshRemoveMember.tsx @@ -155,7 +155,7 @@ const MeshRemoveMember = ({ type: InstructionInputType.INPUT, inputType: 'text', name: 'member', - placeholder: 'Member wallet or domain name (e.g. domain.sol)', + placeholder: 'Member wallet or domain name (e.g. domain.solana)', additionalComponent: isResolvingDomain ? (
From fa3c6cb369fd4196de21fe53db7ff386cf529a59 Mon Sep 17 00:00:00 2001 From: aryan Date: Mon, 9 Dec 2024 21:44:00 +0530 Subject: [PATCH 07/11] fix: typo --- components/Members/AddMemberForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Members/AddMemberForm.tsx b/components/Members/AddMemberForm.tsx index 520728874..9c087b803 100644 --- a/components/Members/AddMemberForm.tsx +++ b/components/Members/AddMemberForm.tsx @@ -311,7 +311,7 @@ const AddMemberForm: FC<{ close: () => void; mintAccount: AssetAccount }> = ({ className="p-4 w-full bg-bkg-3 border border-bkg-3 default-transition text-sm text-fgd-1 rounded-md focus:border-bkg-3 focus:outline-none" wrapperClassName="my-6" label="Member's wallet" - placeholder="Member's wallet or domain name (e.g. domain.sol)" + placeholder="Member's wallet or domain name (e.g. domain.solana)" value={form.destinationAccount} type="text" onChange={handleDestinationAccountChange} From 4f8c1195954e5c53a5dc92427c2f92c56f03e40a Mon Sep 17 00:00:00 2001 From: Utkarsh <83659045+0xShuk@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:22:04 +0530 Subject: [PATCH 08/11] upgrade tldparser package --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e4c70e0b7..840db8f88 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@next/bundle-analyzer": "12.1.5", "@nivo/bar": "0.79.1", "@nivo/core": "0.79.0", - "@onsol/tldparser": "0.6.6", + "@onsol/tldparser": "0.6.7", "@parcl-oss/staking": "0.0.2", "@project-serum/common": "0.0.1-beta.3", "@project-serum/serum": "0.13.65", diff --git a/yarn.lock b/yarn.lock index 99dfaac84..1c8d2358e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2780,10 +2780,10 @@ node-gyp "^7.1.0" read-package-json-fast "^2.0.1" -"@onsol/tldparser@0.6.6": - version "0.6.6" - resolved "https://registry.yarnpkg.com/@onsol/tldparser/-/tldparser-0.6.6.tgz#e88f38e9bfa6058d0eacf18ad606f463f3760597" - integrity sha512-ArVxgBV4+9j1U8ja3JRogzFpOsVpFITV3DwN3lcwpbBt00NpmMIcMTdiR6swkfQLthDE3dI19tKmQBuKrN4wyA== +"@onsol/tldparser@0.6.7": + version "0.6.7" + resolved "https://registry.yarnpkg.com/@onsol/tldparser/-/tldparser-0.6.7.tgz#f949865b4d6d46e4c8cc22816c4cfab8a8270163" + integrity sha512-QwkRDLyC514pxeplCCXZ2kTiRcJSeUrpp+9o2XqLbePy/qzZGGG8I0UbXUKuWVD/bUL1zAm21+D+Eu30OKwcQg== dependencies: "@ethersproject/sha2" "^5.7.0" "@metaplex-foundation/beet-solana" "^0.4.0" From 0e30d8cd3d2c49d8a550eb75de7a4a803fcde013 Mon Sep 17 00:00:00 2001 From: Utkarsh <83659045+0xShuk@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:00:08 +0530 Subject: [PATCH 09/11] fix undefined error --- components/Profile/ProfileName.tsx | 10 +--------- hooks/useTreasuryInfo/index.tsx | 2 +- utils/domains.ts | 10 ++++------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/components/Profile/ProfileName.tsx b/components/Profile/ProfileName.tsx index 7360c0d19..9fe024603 100644 --- a/components/Profile/ProfileName.tsx +++ b/components/Profile/ProfileName.tsx @@ -16,14 +16,6 @@ export const ProfileName: FC = ({ publicKey, height = "13", dark = false, style, }) => { const { profile, loading } = useProfile(publicKey) - const { connection } = useConnection() - const [domains, setDomains] = useState([]) - useEffect(() => { - if (publicKey) { - fetchDomainsByPubkey(connection, publicKey).then(setDomains) - } - }, [publicKey, connection]) - if (!publicKey) return <>; return loading ? ( @@ -44,7 +36,7 @@ export const ProfileName: FC = ({ publicKey, height = "13",
) : (
- {domains.length > 0 ? domains[0].domainName : profile?.name?.value || } + {profile?.name?.value || }
); } diff --git a/hooks/useTreasuryInfo/index.tsx b/hooks/useTreasuryInfo/index.tsx index 633b6a691..e1f725f76 100644 --- a/hooks/useTreasuryInfo/index.tsx +++ b/hooks/useTreasuryInfo/index.tsx @@ -78,7 +78,7 @@ export default function useTreasuryInfo( const allDomains = domainResults.flat().map(domain => ({ name: domain.domainName?.replace('.sol', ''), address: domain.domainAddress, - owner: accounts[0].pubkey.toBase58(), + owner: domain.domainOwner, type: domain.type })); diff --git a/utils/domains.ts b/utils/domains.ts index 94bd75739..a3ece921b 100644 --- a/utils/domains.ts +++ b/utils/domains.ts @@ -12,6 +12,7 @@ import { Connection, ParsedAccountData, PublicKey } from '@solana/web3.js' interface Domain { domainName: string | undefined domainAddress: string + domainOwner: string type: 'sns' | 'alldomains' } @@ -61,8 +62,6 @@ export const resolveDomain = async ( } } - console.log('Pubkey:', pubkey.toBase58()) - // Retrieve the domain's registry information const { registry } = await NameRegistryState.retrieve(connection, pubkey) @@ -87,15 +86,13 @@ export const fetchDomainsByPubkey = async ( const sns_domains = await getAllDomains(connection, pubkey) const tld_domains = await parser.getParsedAllUserDomains(pubkey) const results: Domain[] = [] - - console.log('SNS domains:', sns_domains) - console.log('TLD domains:', tld_domains) - + if (tld_domains.length > 0) { for (let i = 0; i < tld_domains.length; i++) { results.push({ domainAddress: tld_domains[i].domain, domainName: tld_domains[i].nameAccount.toBase58(), + domainOwner: pubkey.toBase58(), type: 'alldomains', }) } @@ -108,6 +105,7 @@ export const fetchDomainsByPubkey = async ( results.push({ domainAddress: sns_domains[i].toBase58(), domainName: reverse[i] + '.sol', + domainOwner: pubkey.toBase58(), type: 'sns', }) } From d5142dd34dc1369a789c0e1db832d298bc5332fe Mon Sep 17 00:00:00 2001 From: aryan Date: Thu, 12 Dec 2024 03:56:09 +0530 Subject: [PATCH 10/11] revert: domains in treasury page --- pages/dao/[symbol]/treasury/v2/index.tsx | 81 +----------------------- 1 file changed, 2 insertions(+), 79 deletions(-) diff --git a/pages/dao/[symbol]/treasury/v2/index.tsx b/pages/dao/[symbol]/treasury/v2/index.tsx index 85a6a8906..3e9e3da64 100644 --- a/pages/dao/[symbol]/treasury/v2/index.tsx +++ b/pages/dao/[symbol]/treasury/v2/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState, useMemo } from 'react' +import { useEffect, useRef, useState } from 'react' import { pipe } from 'fp-ts/function' import PreviousRouteBtn from '@components/PreviousRouteBtn' @@ -10,9 +10,6 @@ import useTreasuryInfo from '@hooks/useTreasuryInfo' import { AuxiliaryWallet, Wallet } from '@models/treasury/Wallet' import { Asset } from '@models/treasury/Asset' import { useTreasurySelectState } from '@components/treasuryV2/Details/treasurySelectStore' -import { GlobeIcon } from '@heroicons/react/outline' -import { Domain } from '@models/treasury/Domain' -import { AssetType, Domains } from '@models/treasury/Asset' export default function Treasury() { const data = useTreasuryInfo() @@ -62,32 +59,6 @@ export default function Treasury() { ? selectedAsset : ('USE NON-LEGACY STATE' as const) - // Extract domains from wallets when data is available - const allDomains = useMemo(() => { - if (data._tag === Status.Ok) { - return data.data.wallets.reduce((domains, wallet) => { - const walletDomains = wallet.assets.find(asset => - asset.type === AssetType.Domain - ) as Domains | undefined; - - return walletDomains ? domains.concat(walletDomains.list) : domains; - }, [] as Domain[]); - } - return []; - }, [data]); - - // Group domains by type - const groupedDomains = useMemo(() => { - return allDomains.reduce((acc, domain) => { - const type = (domain as any).type || 'sns'; - if (!acc[type]) { - acc[type] = []; - } - acc[type].push(domain); - return acc; - }, {} as { [key: string]: Domain[] }); - }, [allDomains]); - return (
@@ -104,54 +75,6 @@ export default function Treasury() { })) )} /> - {/* Modified Domains Section */} - {allDomains.length > 0 && ( -
-
DAO Domains
- - {/* SNS Domains */} - {groupedDomains['sns']?.length > 0 && ( - <> -
Solana Name Service Domains
-
- {groupedDomains['sns'].map((domain) => ( -
- -
-
{domain.name}.sol
-
{domain.address}
-
-
- ))} -
- - )} - - {/* AllDomains */} - {groupedDomains['alldomains']?.length > 0 && ( - <> -
AllDomains
-
- {groupedDomains['alldomains'].map((domain) => ( -
- -
-
{domain.name}
-
{domain.address}
-
-
- ))} -
- - )} -
- )}
) -} +} \ No newline at end of file From 77773001ffd089dfc00e6f7c2347bc903ebb853a Mon Sep 17 00:00:00 2001 From: Utkarsh <83659045+0xShuk@users.noreply.github.com> Date: Mon, 16 Dec 2024 20:42:40 +0530 Subject: [PATCH 11/11] remove tld domains from the hook --- utils/domains.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/utils/domains.ts b/utils/domains.ts index a3ece921b..67cf2b47b 100644 --- a/utils/domains.ts +++ b/utils/domains.ts @@ -82,22 +82,9 @@ export const fetchDomainsByPubkey = async ( pubkey: PublicKey | undefined ) => { if (!pubkey) return [] - const parser = new TldParser(connection) const sns_domains = await getAllDomains(connection, pubkey) - const tld_domains = await parser.getParsedAllUserDomains(pubkey) const results: Domain[] = [] - if (tld_domains.length > 0) { - for (let i = 0; i < tld_domains.length; i++) { - results.push({ - domainAddress: tld_domains[i].domain, - domainName: tld_domains[i].nameAccount.toBase58(), - domainOwner: pubkey.toBase58(), - type: 'alldomains', - }) - } - } - if (sns_domains.length > 0) { const reverse = await performReverseLookupBatch(connection, sns_domains)