Skip to content
Open
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
26 changes: 2 additions & 24 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import("next").NextConfig} */
const nextConfig = {
output: 'standalone',
output: 'export',
trailingSlash: true,

reactStrictMode: false,

Expand All @@ -24,29 +25,6 @@ const nextConfig = {

return config;
},

async rewrites() {
return [
{
source: '/ipfs/:path*',
destination: '/api/proxy?path=:path*',
},
];
},

async headers() {
return [
{
source: '/:all*(svg|png|jpg|jpeg|woff2|ttf|eot|svg)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
];
},
};

export default nextConfig;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next build && next export",
"prettier": "npx prettier --write **/*.{ts,js,tsx,json}",
"lint:ts": "eslint \"./src/**/*.{ts,tsx}\"",
"lint:ts:fix": "eslint \"./src/**/*.{ts,tsx}\" --fix",
Expand Down
38 changes: 0 additions & 38 deletions src/app/api/proxy/route.js

This file was deleted.

18 changes: 18 additions & 0 deletions src/app/borrow/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import { BorrowDetailsPage } from '@/modules/borrow/page/page-details';
import { NetworksNames, contractsConfig } from '@/shared/web3/chainConfig';

interface StaticParam {
id: string;
}

export async function generateStaticParams(): Promise<StaticParam[]> {
const paths: StaticParam[] = [];
// Generate paths for each network and its tokens
Object.entries(contractsConfig.token).forEach(([chainId, tokens]) => {
Object.keys(tokens).forEach((asset) => {
paths.push({
id: `${asset.toLowerCase()}-${NetworksNames[Number(chainId)].toLowerCase()}`,
});
});
});
return paths;
}

export default function BorrowId() {
return <BorrowDetailsPage />;
Expand Down
21 changes: 20 additions & 1 deletion src/app/lend/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { LendDetailsPage } from '@/modules/lend/page/page-details';
import { NetworksNames } from '@/shared/web3/chainConfig';
import { NetworksNames, contractsConfig } from '@/shared/web3/chainConfig';
import { DEFAULT_CHAIN_ID } from '@/shared/web3/wagmiConfig';

interface PageProps {
Expand All @@ -10,6 +10,25 @@ interface PageProps {
};
}

interface StaticParam {
id: string;
}

export async function generateStaticParams(): Promise<StaticParam[]> {
const paths: StaticParam[] = [];

// Generate paths for each network and its tokens
Object.entries(contractsConfig.token).forEach(([chainId, tokens]) => {
Object.keys(tokens).forEach((asset) => {
paths.push({
id: `${asset.toLowerCase()}-${NetworksNames[Number(chainId)].toLowerCase()}`,
});
});
});

return paths;
}

export async function generateMetadata({ params }: PageProps) {
const [asset, chainId] = params.id.split('-');

Expand Down
21 changes: 20 additions & 1 deletion src/app/market/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MarketDetailsPage } from '@/modules/market/page/market-details';
import { NetworksNames } from '@/shared/web3/chainConfig';
import { NetworksNames, contractsConfig } from '@/shared/web3/chainConfig';
import { DEFAULT_CHAIN_ID } from '@/shared/web3/wagmiConfig';

interface PageProps {
Expand All @@ -8,6 +8,25 @@ interface PageProps {
};
}

interface StaticParam {
id: string;
}

export async function generateStaticParams(): Promise<StaticParam[]> {
const paths: StaticParam[] = [];

// Generate paths for each network and its tokens
Object.entries(contractsConfig.token).forEach(([chainId, tokens]) => {
Object.keys(tokens).forEach((asset) => {
paths.push({
id: `${asset.toLowerCase()}-${NetworksNames[Number(chainId)].toLowerCase()}`,
});
});
});

return paths;
}

export async function generateMetadata({ params }: PageProps) {
const [asset, chainId] = params.id.split('-');

Expand Down
122 changes: 12 additions & 110 deletions src/shared/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,157 +1,59 @@
import axios from 'axios';
import { fetchFromIPFS } from '@/utils/ipfs';

import { AllTransactionsType, AllUsersDataTypes, AprTransactionType, ChartDataINT } from './types';

export const getChartData = (): Promise<ChartDataINT> =>
axios
.get('/ipfs/?path=bafkreihc5f7c4q3dp7avt4x53j5x5d4uhx7zsm6ziowuwdqfjfkfusefii', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
fetchFromIPFS('bafkreihc5f7c4q3dp7avt4x53j5x5d4uhx7zsm6ziowuwdqfjfkfusefii');

export const getAllTransactions = (): Promise<{
updatedAt: Date;
transactionsHistory: Record<string, AllTransactionsType[]>;
}> =>
axios
.get('/ipfs/?path=QmZqpyDmSCdCxRjHPUYRNiSTnZ9QUJfRXjUvAR5pophHaC', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('QmZqpyDmSCdCxRjHPUYRNiSTnZ9QUJfRXjUvAR5pophHaC');

export const findUserIpfsHash = (): Promise<{
[key: string]: string[];
}> =>
axios
.get('/ipfs/?path=bafybeifsmv4cinepjiiofkx4otvn77ljqyb7djsmaeok6np6slhrb5xmky', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafybeifsmv4cinepjiiofkx4otvn77ljqyb7djsmaeok6np6slhrb5xmky');

export const getUserData = (hash: string): Promise<AllUsersDataTypes> =>
axios
.get(`/ipfs/?path=${hash}`, {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
export const getUserData = (hash: string): Promise<AllUsersDataTypes> => fetchFromIPFS(hash);

export const getScrollAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreial3rbjom2bvtetngqanrvpx6w2zr2j2lyf3jw47cdhsvt4xs2444', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreial3rbjom2bvtetngqanrvpx6w2zr2j2lyf3jw47cdhsvt4xs2444');

export const getPolygonAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreiacq3gdjslfpwkc3fiq7q446sesnfap74x2mmu5kmxkz5by2p4qhu', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreiacq3gdjslfpwkc3fiq7q446sesnfap74x2mmu5kmxkz5by2p4qhu');

export const getOptimismAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreiapaw6bktlwgnlwvox7zh3eiysnwlo4icn4zdh6bvdonjkestxzx4', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreiapaw6bktlwgnlwvox7zh3eiysnwlo4icn4zdh6bvdonjkestxzx4');

export const getMainnetAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreifz3m25aw6fip6i3y75cjhv7lyukpow6vv4nduoyxfxj7saspshkm', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreifz3m25aw6fip6i3y75cjhv7lyukpow6vv4nduoyxfxj7saspshkm');

export const getBaseAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreiahbik5c2apc5zpulm2nunspe6gyzwf7xiql3g462cq4ttm3akywe', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreiahbik5c2apc5zpulm2nunspe6gyzwf7xiql3g462cq4ttm3akywe');

export const getArbitrumAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreian3waw7ndsrkh7oth32v25tiv5kqel4a2k22pkmfyfc5gmqsie3y', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreian3waw7ndsrkh7oth32v25tiv5kqel4a2k22pkmfyfc5gmqsie3y');

export const getMantleAPR = (): Promise<{
networkId: number;
updatedAt: Date;
markets: Record<string, AprTransactionType[]>;
}> =>
axios
.get('/ipfs/?path=bafkreicdjvgtt5pj24byos3ca4qis4xtbbh7d76fccy5ubexpcvbnudyl4', {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
},
timeout: 10000,
})
.then((r) => r.data);
}> => fetchFromIPFS('bafkreicdjvgtt5pj24byos3ca4qis4xtbbh7d76fccy5ubexpcvbnudyl4');
21 changes: 21 additions & 0 deletions src/utils/ipfs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import axios from 'axios';

export async function fetchFromIPFS(path) {
if (!path) {
throw new Error('Missing IPFS path parameter');
}

// const url = `https://teal-nearby-swift-686.mypinata.cloud/ipfs/${path}`; //dev
// const url = `https://api.compoundcrypto.finance/ipfs/${path}`; //prod
const url = `https://backend.mypinata.cloud/ipfs/${path}`; //stage

try {
const response = await axios.get(url, {
headers: { 'Content-Type': 'application/json' },
});
return response.data;
} catch (error) {
console.error('Error fetching data:', error.message);
throw error;
}
}
Loading