Skip to content

Commit

Permalink
fix cast response
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevinOConnell committed Oct 17, 2024
1 parent 10f81ab commit 480d8f3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
53 changes: 28 additions & 25 deletions src/components/NetworkResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ const NetworkResponse = ({ identifier }: any) => {
warpcastCastHubMissing
)}
{renderHeader(
'Neynar hub',
'Neynar hub-api',
neynarHubAuthor,
neynarAuthorHubMissing
)}
{renderHeader(
'Neynar hub',
'Neynar hub-api',
neynarHubCast,
neynarCastHubMissing
)}
Expand Down Expand Up @@ -326,29 +326,32 @@ const NetworkResponse = ({ identifier }: any) => {
</button>
)}
{showOtherHubs && (
<div>
{hubs.slice(2).map((hub, index) => {
const hubData = data?.hubData?.[index + 2];
const hubAuthor = hubData?.author;
const hubCast = hubData?.cast;
const missingObjectsAuthor = checkWarning(hubAuthor);
const missingObjectsCast: any[] = [];
return (
<div key={index}>
{renderHeader(
`${capitalizeNickname(hub.shortname)}`,
hubAuthor,
missingObjectsAuthor
)}
{renderHeader(
`${capitalizeNickname(hub.shortname)}`,
hubCast,
missingObjectsCast
)}
</div>
);
})}
</div>
<>
{data?.hubData
.slice(2)
.map((hub: any, index: number) => {
const hubData = hub;
const hubAuthor = hubData?.author;
const hubCast = hubData?.cast;
const missingObjectsAuthor =
checkWarning(hubAuthor);
const missingObjectsCast: any[] = [];
return (
<div key={index}>
{renderHeader(
`${capitalizeNickname(hub.name)}`,
hubAuthor,
missingObjectsAuthor
)}
{renderHeader(
`${capitalizeNickname(hub.name)}`,
hubCast,
missingObjectsCast
)}
</div>
);
})}
</>
)}
</>
)}
Expand Down
23 changes: 21 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ export const seo = {
url: 'https://explorer.neynar.com',
};

export const hubs = [
const additionalHubs =
process.env.ADDITIONAL_HUBS?.split(',').map((hub) => hub.trim()) || [];

const extractFirstLetter = (hubUrl: string) => {
const hubName = hubUrl.match(/https?:\/\/([^.]+)\.hubs\.neynar\.com/);
return hubName ? hubName[1].charAt(0).toUpperCase() : 'Unknown';
};

const defaultHubs = [
{
shortname: 'Warpcast hub (Lamia)',
url: 'https://lamia.farcaster.xyz:2281',
Expand All @@ -14,8 +22,19 @@ export const hubs = [
{ shortname: 'Warpcast hub (Hoyt)', url: 'https://hoyt.farcaster.xyz:2281' },
];

export const hubs = [
...defaultHubs,
...additionalHubs.map((hubUrl) => {
const firstLetter = extractFirstLetter(hubUrl);
return {
shortname: `Neynar hub ${firstLetter}`,
url: hubUrl,
};
}),
];

export const neynarHub = {
shortname: 'Neynar hub',
shortname: 'Neynar hub-api',
url: 'https://hub-api.neynar.com',
};
export const defaultHash = '0x3e7326f8da760ed926c1fe82e1444cd528fe6c78';
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export async function fetchCastFromHub(
api_key?: string;
'x-airstack-hubs'?: string;
} = { 'Content-Type': 'application/json' };
if (hub.shortname === 'Neynar hub') {
if (hub.shortname.includes('Neynar hub')) {
headers.api_key = `${process.env.NEXT_PUBLIC_NEYNAR_API_KEY}`;
}
const response = await axios.get(
Expand Down Expand Up @@ -392,7 +392,7 @@ async function fetchLink(hub: HubType, fid: string, target_fid: string) {
'Content-Type': string;
api_key?: string;
} = { 'Content-Type': 'application/json' };
if (hub.shortname === 'Neynar hub') {
if (hub.shortname.includes('Neynar')) {
headers.api_key = `${process.env.NEXT_PUBLIC_NEYNAR_API_KEY}`;
}
try {
Expand Down Expand Up @@ -439,7 +439,7 @@ export async function fetchFidFromHub(
api_key?: string;
'x-airstack-hubs'?: string;
} = { 'Content-Type': 'application/json' };
if (hub.shortname === 'Neynar hub') {
if (hub.shortname.includes('Neynar')) {
headers.api_key = `${process.env.NEXT_PUBLIC_NEYNAR_API_KEY}`;
}
if (followRelationship) {
Expand Down

0 comments on commit 480d8f3

Please sign in to comment.