Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/ens/ensProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface ENSProfile {
owner: {
address: string
}
resolvedAddress: {
address: string
}
texts: ENSProfileText[]
}

Expand All @@ -32,6 +35,9 @@ export async function getENSProfile(ensName: string): Promise<ENSProfile> {
owner: {
address: AddressZero,
},
resolvedAddress: {
address: AddressZero,
},
texts: [],
}

Expand All @@ -45,6 +51,9 @@ export async function getENSProfile(ensName: string): Promise<ENSProfile> {
owner {
address: id
}
resolvedAddress {
address: id
}
name
resolver {
texts
Expand All @@ -63,6 +72,10 @@ export async function getENSProfile(ensName: string): Promise<ENSProfile> {
ensProfile.owner.address = data.data.domain.owner.address
}

if (data.data.domain.resolvedAddress?.address !== AddressZero) {
ensProfile.resolvedAddress.address = data.data.domain.owner.address
}

// Fetch domain texts from the resolver
const domainTexts: string[] = data.data?.domain?.resolver?.texts ?? []

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"memoizee": "^0.4.15",
"multiformats": "^9.7.0",
"next": "12.1.6",
"nimi-card": "^0.7.11-beta",
"nimi-card": "^0.8.4-rc.0",
"node-cache": "^5.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
17 changes: 10 additions & 7 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import Head from 'next/head'
import {
Container as NimiCardContainer,
Nimi,
NimiCard,
NimiLink,
NimiLinkType,
NimiLinkBaseDetails,
NimiWidgetType,
} from 'nimi-card'
Expand Down Expand Up @@ -42,17 +41,17 @@ const NimiCardApp = dynamic(
{ ssr: false }
)

function getNimiLinkFromENSText(text: string): NimiLink | undefined {
function getNimiLinkFromENSText(text: string): NimiLinkType | undefined {
if (supportedKeys.includes(text.toLowerCase())) {
if (text.toLowerCase() === 'email') {
return 'email'
return NimiLinkType.EMAIL;
}

if (text.toLowerCase() === 'url') {
return 'website'
return NimiLinkType.URL
}

return text.split('.')[1] as NimiLink
return text.split('.')[1] as NimiLinkType;
}
}

Expand Down Expand Up @@ -121,6 +120,9 @@ export async function getServerSideProps({

const ensAddress =
ensProfile?.owner?.address ?? '0x0000000000000000000000000000000000000000'
const resolvedAddress =
ensProfile?.resolvedAddress?.address ??
"0x0000000000000000000000000000000000000000";
let description: undefined | string = undefined
const links: NimiLinkBaseDetails[] = []

Expand All @@ -130,7 +132,7 @@ export async function getServerSideProps({
if (nimiLinkType) {
const link = {
type: nimiLinkType,
url: value,
content: value,
}
links.push(link)
} else if (text.toLowerCase() === 'description') {
Expand All @@ -143,6 +145,7 @@ export async function getServerSideProps({
displayName: ensName,
addresses: [],
ensAddress,
resolvedAddress,
links,
widgets: [
{
Expand Down