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
Closed
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
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"presets": ["next/babel"],
"plugins": [["styled-components", { "ssr": true }]]
"plugins": [["styled-components", { "ssr": true, "displayName": true }]]
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"path-browserify": "^1.0.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"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.

"react-hook-form": "^7.30.0",
"react-i18next": "^12.1.1",
"react-router-dom": "^6.3.0",
Expand Down
48 changes: 0 additions & 48 deletions src/api/GraphQl/schemas/generated/lens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ export type AccessConditionOutput = {
token?: Maybe<Erc20OwnershipOutput>;
};

export type AchRequest = {
ethereumAddress: Scalars['EthereumAddress'];
freeTextHandle?: InputMaybe<Scalars['Boolean']>;
handle?: InputMaybe<Scalars['CreateHandle']>;
overrideAlreadyClaimed: Scalars['Boolean'];
overrideTradeMark: Scalars['Boolean'];
secret: Scalars['String'];
};
Comment on lines -107 to -114
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


/** The request object to add interests to a profile */
export type AddProfileInterestsRequest = {
/** The profile interest to add */
Expand Down Expand Up @@ -934,10 +925,6 @@ export type CreateUnfollowBroadcastItemResult = {
typedData: CreateBurnEip712TypedData;
};

export type CurRequest = {
secret: Scalars['String'];
};

/** The custom filters types */
export enum CustomFiltersTypes {
Gardeners = 'GARDENERS'
Expand Down Expand Up @@ -1541,12 +1528,6 @@ export type HasTxHashBeenIndexedRequest = {
txId?: InputMaybe<Scalars['TxId']>;
};

export type HelRequest = {
handle: Scalars['Handle'];
remove: Scalars['Boolean'];
secret: Scalars['String'];
};

export type HidePublicationRequest = {
/** Publication id */
publicationId: Scalars['InternalPublicationId'];
Expand Down Expand Up @@ -1863,7 +1844,6 @@ export type ModuleInfo = {

export type Mutation = {
__typename?: 'Mutation';
ach?: Maybe<Scalars['Void']>;
/** Adds profile interests to the given profile */
addProfileInterests?: Maybe<Scalars['Void']>;
addReaction?: Maybe<Scalars['Void']>;
Expand All @@ -1890,7 +1870,6 @@ export type Mutation = {
createSetProfileMetadataViaDispatcher: RelayResult;
createToggleFollowTypedData: CreateToggleFollowBroadcastItemResult;
createUnfollowTypedData: CreateUnfollowBroadcastItemResult;
hel?: Maybe<Scalars['Void']>;
hidePublication?: Maybe<Scalars['Void']>;
idKitPhoneVerifyWebhook: IdKitPhoneVerifyWebhookResultStatusType;
proxyAction: Scalars['ProxyActionId'];
Expand All @@ -1902,11 +1881,6 @@ export type Mutation = {
};


export type MutationAchArgs = {
request: AchRequest;
};


export type MutationAddProfileInterestsArgs = {
request: AddProfileInterestsRequest;
};
Expand Down Expand Up @@ -2046,11 +2020,6 @@ export type MutationCreateUnfollowTypedDataArgs = {
};


export type MutationHelArgs = {
request: HelRequest;
};


export type MutationHidePublicationArgs = {
request: HidePublicationRequest;
};
Expand Down Expand Up @@ -3089,7 +3058,6 @@ export type Query = {
challenge: AuthChallengeResult;
claimableHandles: ClaimableHandles;
claimableStatus: ClaimStatus;
cur: Array<Scalars['String']>;
defaultProfile?: Maybe<Profile>;
doesFollow: Array<DoesFollowResponse>;
enabledModuleCurrencies: Array<Erc20>;
Expand Down Expand Up @@ -3127,7 +3095,6 @@ export type Query = {
publicationRevenue?: Maybe<PublicationRevenue>;
publications: PaginatedPublicationResult;
recommendedProfiles: Array<Profile>;
rel?: Maybe<Scalars['Void']>;
search: SearchResult;
/** @deprecated You should be using feed, this will not be supported after 15th November 2021, please migrate. */
timeline: PaginatedTimelineResult;
Expand Down Expand Up @@ -3156,11 +3123,6 @@ export type QueryChallengeArgs = {
};


export type QueryCurArgs = {
request: CurRequest;
};


export type QueryDefaultProfileArgs = {
request: DefaultProfileRequest;
};
Expand Down Expand Up @@ -3316,11 +3278,6 @@ export type QueryRecommendedProfilesArgs = {
};


export type QueryRelArgs = {
request: RelRequest;
};


export type QuerySearchArgs = {
request: SearchQueryRequest;
};
Expand Down Expand Up @@ -3413,11 +3370,6 @@ export type RefreshRequest = {
refreshToken: Scalars['Jwt'];
};

export type RelRequest = {
ethereumAddress: Scalars['EthereumAddress'];
secret: Scalars['String'];
};

export type RelayError = {
__typename?: 'RelayError';
reason: RelayErrorReasons;
Expand Down
20 changes: 12 additions & 8 deletions src/api/RestAPI/hooks/useDeployedPageData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
import { useRainbow } from '../../../hooks/useRainbow';
import { nimiClient } from '../utils';

interface DeployedNimiPageType {
interface NimiSnapshot {
publisher: string;
cid: string | null;
cidV1: string | null;
Expand All @@ -22,18 +22,22 @@ export function useDeployedPageData(ensName: string) {
const { chainId } = useRainbow();

const getDeployedPageData = async () => {
const params = {
ens: ensName,
};

const { data } = await nimiClient.get<{ data: DeployedNimiPageType[] }>(`/nimi/by`, { params });
const { data } = await nimiClient.get<{
data: {
ipns?: string;
nimi?: NimiSnapshot;
};
}>(`/ens/has-nimi-ipns`, {
params: {
domain: ensName,
},
});
return data;
};

return useQuery(['fetchDeployedNimiData', ensName, chainId], getDeployedPageData, {
select: ({ data }) => {
if (data.length) return data[0];
else return undefined;
return data;
},
});
}
35 changes: 7 additions & 28 deletions src/api/RestAPI/hooks/usePoapsFromUser.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
import { POAPToken } from '@nimi.io/card/types';
import { useQuery } from '@tanstack/react-query';

import { getPOAPAPIClient } from '../utils';

type Poap = {
city: string;
country: string;
desciption: string;
end_date: string;
event_url?: string;
expiry_date: string;
fancy_id: string;
id: number;
image_url: string;
name: string;
start_date: string;
supply: number;
year: number;
};

export interface PoapData {
chain: string;
created: string;
event: Poap;
owner: string;
tokenId: string;
export async function fetchUserPOAPs(account: string) {
const poapClient = getPOAPAPIClient();
const { data } = await poapClient.get<POAPToken[]>(`/actions/scan/${account.toLowerCase()}`);
return data;
}

/**
* Returns query for fetching poaps user owns
*/
export function usePoapsFromUser(account?: string) {
const getPoapsFromUser = async () => {
if (!account) {
return [];
}
const poapClient = getPOAPAPIClient();
const { data } = await poapClient.get<PoapData[]>(`/actions/scan/${account.toLowerCase()}`);
return data;
if (!account) return [];
return fetchUserPOAPs(account);
};

return useQuery(['fetchUserPoaps', account], getPoapsFromUser);
Expand Down
23 changes: 20 additions & 3 deletions src/api/RestAPI/hooks/usePublishNimiIPNS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { useMutation } from '@tanstack/react-query';

import { nimiClient } from '../utils';

interface PublishNimiViaIPNSParams {
export interface PublishNimiViaIPNSParams {
chainId: number;
nimi: Nimi;
signature: string;
}

type UpdateNimiViaIPNSParams = PublishNimiViaIPNSParams & {
signature: string;
};

interface PublishNimiIPNSResponse {
cidV1: string;
cid: string;
ipns: string;
}

Expand All @@ -21,9 +24,23 @@ const postUserData = async (params: PublishNimiViaIPNSParams) => {
return data.data;
};

const updateNimiIPNS = async (params: UpdateNimiViaIPNSParams) => {
const { data } = await nimiClient.put<{
data: PublishNimiIPNSResponse;
}>('/nimi/publish/ipns', params);
return data.data;
};

/**
* Returns mutation for getting IPNS hash
*/
export function usePublishNimiIPNS() {
return useMutation(['publishNimiIPNS'], postUserData);
}

/**
* Returns mutation for getting IPNS hash
*/
export function useUpdateNimiIPNS() {
return useMutation(['updateNimiIPNS'], updateNimiIPNS);
}
Loading