Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

adamazad
Copy link
Member

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.

@adamazad adamazad self-assigned this Jan 17, 2023
@adamazad adamazad linked an issue Jan 17, 2023 that may be closed by this pull request
@vercel
Copy link

vercel bot commented Jan 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nimi-io-app-development ❌ Failed (Inspect) Jan 17, 2023 at 11:18PM (UTC)
nimi-io-app-production ❌ Failed (Inspect) Jan 17, 2023 at 11:18PM (UTC)

@adamazad adamazad removed this from the ENS, IYK, and Nimi Partnership milestone Jan 18, 2023
Comment on lines -107 to -114
export type AchRequest = {
ethereumAddress: Scalars['EthereumAddress'];
freeTextHandle?: InputMaybe<Scalars['Boolean']>;
handle?: InputMaybe<Scalars['CreateHandle']>;
overrideAlreadyClaimed: Scalars['Boolean'];
overrideTradeMark: Scalars['Boolean'];
secret: Scalars['String'];
};
Copy link
Collaborator

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?

Copy link
Member Author

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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +67 to +123
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 };
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamazad adamazad closed this Feb 1, 2023
@adamazad adamazad deleted the feat/236-initial-deploy-flow-sucks branch May 11, 2023 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initial Deploy Flow Sucks
2 participants