-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 64dee81
Showing
67 changed files
with
5,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
.DS_Store | ||
dist-ssr | ||
*.local | ||
stats.html | ||
*.env.* | ||
!default.env | ||
components.d.ts | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": true, | ||
"printWidth": 120, | ||
"plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss"], | ||
"importOrder": ["<THIRD_PARTY_MODULES>","^@/(.*)$", "^[../]", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true, | ||
"tailwindConfig": "./tailwind.config.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: 'https', | ||
hostname: 'raw.githubusercontent.com', | ||
port: '', | ||
pathname: '/cosmos/chain-registry/master/**', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "posthuman-source", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start -p 3200", | ||
"lint": "next lint" | ||
}, | ||
"dependencies": { | ||
"@geoffcodesthings/tailwind-md-base": "^1.1.0", | ||
"next": "14.1.0", | ||
"node-cache": "^5.1.2", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"react-markdown": "^9.0.1", | ||
"react-toastify": "^10.0.4", | ||
"rehype-raw": "^7.0.0", | ||
"swr": "^2.2.5" | ||
}, | ||
"devDependencies": { | ||
"@trivago/prettier-plugin-sort-imports": "^4.3.0", | ||
"@types/node": "^20", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"autoprefixer": "^10.0.1", | ||
"eslint": "^8", | ||
"eslint-config-next": "14.1.0", | ||
"postcss": "^8", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-tailwindcss": "^0.5.11", | ||
"tailwind-scrollbar": "^3.1.0", | ||
"tailwindcss": "^3.3.0", | ||
"typescript": "^5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "App", | ||
"icons": [ | ||
{ | ||
"src": "\/android-icon-36x36.png", | ||
"sizes": "36x36", | ||
"type": "image\/png", | ||
"density": "0.75" | ||
}, | ||
{ | ||
"src": "\/android-icon-48x48.png", | ||
"sizes": "48x48", | ||
"type": "image\/png", | ||
"density": "1.0" | ||
}, | ||
{ | ||
"src": "\/android-icon-72x72.png", | ||
"sizes": "72x72", | ||
"type": "image\/png", | ||
"density": "1.5" | ||
}, | ||
{ | ||
"src": "\/android-icon-96x96.png", | ||
"sizes": "96x96", | ||
"type": "image\/png", | ||
"density": "2.0" | ||
}, | ||
{ | ||
"src": "\/android-icon-144x144.png", | ||
"sizes": "144x144", | ||
"type": "image\/png", | ||
"density": "3.0" | ||
}, | ||
{ | ||
"src": "\/android-icon-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image\/png", | ||
"density": "4.0" | ||
} | ||
] | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import NodeCache from 'node-cache'; | ||
|
||
import { CONFIG_REPO, CONTRIBUTIONS_REPO } from '@/app/config'; | ||
import deepValue from '@/app/utils/deep-value'; | ||
import { IChain, IChainConfig, TChainItem } from '@/types'; | ||
|
||
const cache = new NodeCache(); | ||
|
||
export const getRegistryChain = async (chainName: string): Promise<IChain | undefined> => { | ||
if (cache.has(`registry/${chainName}`)) { | ||
return cache.get(`registry/${chainName}`); | ||
} | ||
|
||
try { | ||
const res = await fetch( | ||
`https://raw.githubusercontent.com/cosmos/chain-registry/master/${chainName}/chain.json`, | ||
).then((r) => r.json()); | ||
|
||
cache.set(`registry/${chainName}`, res, 3600); | ||
return res; | ||
} catch (e) { | ||
cache.set(`registry/${chainName}`, undefined, 3600); | ||
return; | ||
} | ||
}; | ||
|
||
export const getRepoChains = async (): Promise<IChainConfig[]> => { | ||
const cachedData = cache.get('github/chains'); | ||
if (cachedData) return cachedData as IChainConfig[]; | ||
|
||
const res = (await fetch(`${CONFIG_REPO}/networks.json`).then((r) => { | ||
return r.json(); | ||
})) as IChainConfig[]; | ||
cache.set('github/chains', res, 10); | ||
return res; | ||
}; | ||
|
||
export const getChain = async (chainName: string): Promise<TChainItem | undefined> => { | ||
const cachedData = cache.get(`chain/${chainName}`); | ||
if (cachedData) return cachedData as TChainItem; | ||
|
||
const chains = await getRepoChains(); | ||
const registry = await getRegistryChain(chainName); | ||
const chainConfig = chains.find((n) => n.name === chainName); | ||
const chain = Object.assign(registry ?? {}, chainConfig) as TChainItem; | ||
cache.set(`github/${chainName}`, chain, 10); | ||
|
||
return chain; | ||
}; | ||
|
||
export const getRepoChainService = async (chain: string, serviceName: string): Promise<string> => { | ||
const cachedData = cache.get(`github/${chain}/${serviceName}`); | ||
if (cachedData) return cachedData as string; | ||
|
||
const service = await fetch(`${CONFIG_REPO}/${chain}/${serviceName.toLowerCase()}.md`).then((r) => r.text()); | ||
cache.set(`github/${chain}/${serviceName}`, service, 10); | ||
return service; | ||
}; | ||
|
||
export const getRepoChainContributions = async (name: string): Promise<string> => { | ||
const cachedData = cache.get(`github/contributions/${name}`); | ||
if (cachedData) return cachedData as string; | ||
|
||
const contributions = await fetch(`${CONTRIBUTIONS_REPO}/main/${name}.md`).then((r) => r.text()); | ||
cache.set(`github/contributions/${name}`, contributions, 10); | ||
return contributions; | ||
}; | ||
|
||
export const getRepoChainServiceGlobal = async (chain: TChainItem, serviceName: string): Promise<string> => { | ||
const cachedData = cache.get(`github/global-service/${chain.name}/${serviceName}`); | ||
if (cachedData) return cachedData as string; | ||
|
||
let globalService = await fetch(`${CONFIG_REPO}/global/${serviceName.toLowerCase()}.md`).then((r) => r.text()); | ||
|
||
globalService = globalService.replace(/\{\{(.+?)}}/g, (_, param: string): string => { | ||
if (param[0] === ':') { | ||
const [_, path, template, separator] = param.split(':'); | ||
const arr: any = deepValue(chain, path); | ||
return arr.map((item: any) => template.replace(/{(.+?)}/g, (_, subParam) => item[subParam])).join(separator); | ||
} | ||
|
||
return deepValue(chain, param) as string; | ||
}); | ||
|
||
cache.set(`github/global-service/${chain.name}/${serviceName}`, globalService, 10); | ||
|
||
return globalService; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { getChain } from '@/app/actions/repos'; | ||
|
||
export async function GET(req: Request, ctx: any) { | ||
const { params } = ctx; | ||
const chain = await getChain(params.chainName); | ||
try { | ||
return NextResponse.json({ | ||
status: chain | ||
? ((await fetch(`${chain.endpoints.rpc}/status`, { next: { revalidate: 0 } }) | ||
.then((data) => data.json()) | ||
.then((result) => { | ||
return ( | ||
!result.result.sync_info.catching_up && | ||
Date.now() - Date.parse(result.result.sync_info.latest_block_time) <= 50000 | ||
); | ||
})) as boolean) | ||
: NextResponse.json({ status: false }), | ||
}); | ||
} catch { | ||
return NextResponse.json({ status: false }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Link from 'next/link'; | ||
import { FC } from 'react'; | ||
|
||
interface OwnProps { | ||
chain: string; | ||
} | ||
const NotFound: FC<OwnProps> = ({ chain }) => ( | ||
<div> | ||
<div className="text-base"> | ||
<div> | ||
Mainnet <span className="text-xl font-bold">{chain}</span> was not found! | ||
</div> | ||
<div> | ||
try to fine one{' '} | ||
<Link href={'/'}> | ||
<span className="text-xl underline hover:no-underline">here</span> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default NotFound; |
Oops, something went wrong.