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

open graph + blacklist Multichain staging #251

Merged
merged 3 commits into from
Jul 21, 2024
Merged
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
39 changes: 15 additions & 24 deletions src/app/[netname]/bounty/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Metadata } from 'next';
import * as React from 'react';
import { fetchBountyById } from '@/app/context/web3';
import chainStatusStore from '@/store/chainStatus.store';
import Head from 'next/head';

import '@/styles/colors.css';

Expand All @@ -16,42 +17,26 @@ function weiToEther(weiValue: string | number | bigint): string {

export async function generateMetadata({ params }: Props): Promise<Metadata> {
try {
// read route params
const id = params?.id;
let token = null;
try {
token = params.netname;
} catch (error) {
console.log('params?.netname open graph error: ', error);
return {};
}
let currency = 'degen';
const token = params?.netname || null;

let currency = 'degen';
let netName = 'base';
if (
token &&
(token === 'base' || token === 'degen' || token === 'arbitrum')
) {

if (token && ['base', 'degen', 'arbitrum'].includes(token)) {
netName = token;
}

if (
!netName ||
netName === '' ||
netName == 'arbitrum' ||
netName == 'base'
) {
if (!netName || netName === 'arbitrum' || netName === 'base') {
currency = 'eth';
}

// fetch data
chainStatusStore.setCurrentChainFromNetwork(netName);
await chainStatusStore.setCurrentChainFromNetwork(netName, true);
const bountyData = await fetchBountyById(id);

return {
title: bountyData?.name || '',
description: bountyData?.description || '',

openGraph: {
title: bountyData?.name || '',
description: bountyData?.description || '',
Expand All @@ -73,11 +58,17 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
}

// Ensure that the layout component is correctly exporting the children
export default function BountyLayout({
children,
}: {
children: React.ReactNode;
}) {
return <>{children}</>;
return (
<>
<Head>
<></> {/* Ensure Head has children */}
</Head>
{children}
</>
);
}
4 changes: 4 additions & 0 deletions src/constant/blacklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export const blacklist: Blacklist = {
bountyId: 392,
claims: [1499, 1509, 1514, 1515, 1539],
},
{
bountyId: 575,
claims: [1760],
},
],
base: [
{
Expand Down
78 changes: 53 additions & 25 deletions src/store/chainStatus.store.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,62 @@
import { action,makeObservable, observable } from "mobx";

import { action, makeObservable, observable } from 'mobx';
import chains from '../app/context/config';

class ChainStatusStore {
currentChain = chains.base;
currentChain = chains.base;

constructor() {
makeObservable(this, {
currentChain: observable,
setCurrentChain: action,
})
}
constructor() {
makeObservable(this, {
currentChain: observable,
setCurrentChain: action,
});
}

setCurrentChain(chain: any) {
this.currentChain = chain;
}
setCurrentChain(chain: any) {
this.currentChain = chain;
}

async setCurrentChainFromNetwork(
network?: string,
asyncMode: boolean = false
) {
const setChain = (chain: any) => {
this.setCurrentChain(chain);
};

setCurrentChainFromNetwork(network?: string) {
switch (network) {
case 'degen':
this.setCurrentChain(chains.degen);
break;
case 'base':
this.setCurrentChain(chains.base);
break;
case 'arbitrum':
this.setCurrentChain(chains.arbitrum);
break;
}
if (asyncMode) {
switch (network) {
case 'degen':
return new Promise<void>((resolve) => {
setChain(chains.degen);
resolve();
});
case 'base':
return new Promise<void>((resolve) => {
setChain(chains.base);
resolve();
});
case 'arbitrum':
return new Promise<void>((resolve) => {
setChain(chains.arbitrum);
resolve();
});
default:
return Promise.resolve();
}
} else {
switch (network) {
case 'degen':
setChain(chains.degen);
break;
case 'base':
setChain(chains.base);
break;
case 'arbitrum':
setChain(chains.arbitrum);
break;
}
}
}
}

export default new ChainStatusStore();
export default new ChainStatusStore();
Loading