Skip to content

Commit

Permalink
Merge pull request #251 from picsoritdidnthappen/multichain-staging
Browse files Browse the repository at this point in the history
open graph + blacklist Multichain staging
  • Loading branch information
picsoritdidnthappen authored Jul 21, 2024
2 parents 6b07fce + 64ee37e commit 8760512
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 49 deletions.
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();

0 comments on commit 8760512

Please sign in to comment.