-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: single-step IPNS setup #285
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
export type AchRequest = { | ||
ethereumAddress: Scalars['EthereumAddress']; | ||
freeTextHandle?: InputMaybe<Scalars['Boolean']>; | ||
handle?: InputMaybe<Scalars['CreateHandle']>; | ||
overrideAlreadyClaimed: Scalars['Boolean']; | ||
overrideTradeMark: Scalars['Boolean']; | ||
secret: Scalars['String']; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to change generated files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were changed after doing npm run i
and npm run codegen
. They should be in .gitignore tbh
"react-frame-component": "^5.2.3", | ||
"react-frame-component": "^5.2.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes ryanseddon/react-frame-component#236
export async function getServerSideProps( | ||
context: GetServerSidePropsContext<{ | ||
domain: string; | ||
}> | ||
): Promise<{ | ||
props: CreateNimiPageProps; | ||
}> { | ||
let props = { | ||
availableThemes: [], | ||
domain: context?.params?.domain, | ||
initialNimi: {} as Nimi, | ||
poapList: [], | ||
} as CreateNimiPageProps; | ||
|
||
try { | ||
if (!context?.params?.domain || context?.params?.domain === '[object Object]') { | ||
throw new Error('No domain provided'); | ||
} | ||
|
||
const domain = context.params.domain; | ||
// Nimi Snapshot from the API | ||
const nimiIPNSSnapshot = await fetchNimiIPNS(domain); | ||
// If the user has a Nimi IPNS, redirect to the Nimi page | ||
if (nimiIPNSSnapshot.ipns && nimiIPNSSnapshot.nimi) { | ||
props = { | ||
...props, | ||
ipnsKey: nimiIPNSSnapshot.ipns, | ||
nimiSnapshot: nimiIPNSSnapshot.nimi, | ||
initialNimi: nimiIPNSSnapshot.nimi.nimi, | ||
}; | ||
} else { | ||
const { nimi } = await generateNimiFromENS(domain); | ||
props['initialNimi'] = nimi; | ||
} | ||
|
||
if (!props.initialNimi) { | ||
throw new Error('No Nimi found'); | ||
} | ||
|
||
// Attempt to load | ||
const poapList = await fetchUserPOAPs(props.initialNimi.ensAddress as string); | ||
const availableThemes = getAvailableThemesByPOAPs(poapList); | ||
|
||
if (poapList) { | ||
props = { | ||
...props, | ||
poapList, | ||
availableThemes, | ||
}; | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
// If the user doesn't have a Nimi IPNS, generate a Nimi from the ENS name | ||
return { props }; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is still a way to use reactQuery with ssr here is article https://tanstack.com/query/latest/docs/react/guides/ssr?from=reactQueryV3&original=https%3A%2F%2Freact-query-v3.tanstack.com%2Fguides%2Fssr#using-initialdata
Summary
Breaking changes. This requires using of the Nimi API v2.0.
The single setup works by creating a temporary IPNS record. Then, convert it to a permanent record once the user submits the on-chain IPNS record as their ENS name's
contentHash
.This works because only the owner and controller can update the ENS names, there's no need to verify the IPNS record ownership using signatures.
Besides addressing #236, this PR includes some fixes to the next.js hydration problems reported by @bejzik8.