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

Setup project basics #2

Merged
merged 10 commits into from
Dec 13, 2022
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain
# consistent coding styles between different editors and IDEs.

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REACT_APP_BUILD_DATETIME=0
REACT_APP_BUILD_SHA=sha0000000000000000000000000000000000000
REACT_APP_BUILD_VERSION=
3 changes: 3 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REACT_APP_BUILD_DATETIME=
REACT_APP_BUILD_SHA=
REACT_APP_BUILD_VERSION=
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Don't check auto-generated stuff into git
.parcel-cache/
coverage/
build/
build-dev/
node_modules/
.vscode/
.idea/

# misc
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*~
\#*
.\#*
6 changes: 6 additions & 0 deletions internals/getBuildData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @ts-check
const buildSha = require('child_process').execSync('git rev-parse HEAD').toString().trim()
const buildVersion = require('child_process').execSync('git describe --tags --abbrev=0').toString().trim()
const buildDatetime = Date.now().toString()

module.exports = { buildSha, buildVersion, buildDatetime }
10 changes: 10 additions & 0 deletions internals/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @ts-check
const execSync = require('child_process').execSync
const { buildDatetime, buildSha, buildVersion } = require('../getBuildData')

process.env.REACT_APP_BUILD_DATETIME = buildDatetime
process.env.REACT_APP_BUILD_SHA = buildSha
process.env.REACT_APP_BUILD_VERSION = buildVersion

execSync('yarn clean && parcel build --target web --dist-dir build', { stdio: 'inherit' })
execSync('cp public/robots.txt build/robots.txt', { encoding: 'utf8' })
51 changes: 51 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://raw.githubusercontent.com/lukaw3d/parcel-bundler-json-schemas/main/package_schema.json",
"name": "explorer-frontend",
"version": "0.0.0-development",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/oasisprotocol/explorer-frontend.git"
},
"scripts": {
"build": "node ./internals/scripts/build.js",
"clean": "rm -rf build/ .parcel-cache",
"start": "parcel --dist-dir build-dev",
"checkTs": "tsc --noEmit"
},
"targets": {
"web": {
"source": "public/index.html",
"distDir": "./build",
"context": "browser",
"scopeHoist": false
}
},
"browserslist": {
"production": [
"defaults",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.4.5"
},
"devDependencies": {
"@parcel/packager-raw-url": "^2.8.1",
"@parcel/transformer-webmanifest": "^2.8.1",
"@types/node": "^18.11.13",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"parcel": "^2.8.1",
"process": "^0.11.10",
"typescript": "^4.9.4"
}
}
26 changes: 26 additions & 0 deletions public/app.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
"short_name": "Oasis Network Explorer",
"name": "The official Oasis Network Explorer.",
"icons": [
{
"src": "./favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "./logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "./logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Binary file added public/favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="/" />
<link rel="icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="./logo192.png" />
<link rel="manifest" href="./app.webmanifest" />
<meta property="og:title" content="Oasis Network Explorer" />
<meta property="og:description" content="The official Oasis Network Explorer." />
<meta property="og:image" content="./logo512.png" />
<title>Oasis Network Explorer</title>
<meta name="description" content="The official Oasis Network Explorer." />
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="../src/index.tsx"></script>
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
87 changes: 87 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
export const consensusDecimals = 9

type ParaTimeNetwork = {
address: string | undefined
runtimeId: string | undefined
}

type ParaTimeConfig = {
mainnet: ParaTimeNetwork
testnet: ParaTimeNetwork
local: ParaTimeNetwork
decimals: number
type: RuntimeTypes
}

export enum RuntimeTypes {
Evm = 'evm',
Oasis = 'oasis',
}

const emeraldConfig: ParaTimeConfig = {
mainnet: {
address: 'oasis1qzvlg0grjxwgjj58tx2xvmv26era6t2csqn22pte',
runtimeId: '000000000000000000000000000000000000000000000000e2eaa99fc008f87f',
},
testnet: {
address: 'oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run',
runtimeId: '00000000000000000000000000000000000000000000000072c8215e60d5bca7',
},
local: {
address: undefined,
runtimeId: undefined,
},
decimals: 18,
type: RuntimeTypes.Evm,
}

const cipherConfig: ParaTimeConfig = {
mainnet: {
address: 'oasis1qrnu9yhwzap7rqh6tdcdcpz0zf86hwhycchkhvt8',
runtimeId: '000000000000000000000000000000000000000000000000e199119c992377cb',
},
testnet: {
address: 'oasis1qqdn25n5a2jtet2s5amc7gmchsqqgs4j0qcg5k0t',
runtimeId: '0000000000000000000000000000000000000000000000000000000000000000',
},
local: {
address: undefined,
runtimeId: undefined,
},
decimals: 9,
type: RuntimeTypes.Oasis,
}

const sapphireConfig: ParaTimeConfig = {
mainnet: {
address: undefined,
runtimeId: undefined,
},
testnet: {
address: 'oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd',
runtimeId: '000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c',
},
local: {
address: undefined,
runtimeId: undefined,
},

decimals: 18,
type: RuntimeTypes.Evm,
}

export enum ParaTime {
Cipher = 'cipher',
Emerald = 'emerald',
Sapphire = 'sapphire',
}

type ParaTimesConfig = {
[key in ParaTime]: ParaTimeConfig
}

export const paraTimesConfig: ParaTimesConfig = {
[ParaTime.Cipher]: cipherConfig,
[ParaTime.Emerald]: emeraldConfig,
[ParaTime.Sapphire]: sapphireConfig,
}
31 changes: 31 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import {
createBrowserRouter,
RouterProvider,
RouteObject,
} from 'react-router-dom';
import logotype from '../public/logo192.png'

export const routes: RouteObject[] = [
{
path: '/',
element: <div><img src={logotype} alt="Oasis" /> root</div>,
},
{
path: '/dashboard',
element: <div>dashboard {process.env.REACT_APP_BUILD_SHA}</div>,
},
];

const router = createBrowserRouter(routes);

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);

root.render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>
);
5 changes: 5 additions & 0 deletions src/types/images.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.png' {
/** Image URL */
const url: string
export default url
}
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["esnext", "dom"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"jsx": "react-jsx",
"baseUrl": "./src"
},
"include": ["src"]
}
Loading