Browse Source

Refactor project

refactor
Hampus Sjöberg 4 years ago
parent
commit
e0c6236f0f
  1. 2
      README.md
  2. 0
      backend/api/blocks.ts
  3. 4
      backend/api/donate.ts
  4. 0
      backend/api/index.ts
  5. 0
      backend/api/misc.ts
  6. 14
      backend/blocks/index.ts
  7. 0
      backend/jsonrpc/index.ts
  8. 2
      backend/jsonrpc/utils.ts
  9. 3
      backend/pageviews/index.ts
  10. 6
      common/interfaces.ts
  11. 0
      common/miners.ts
  12. 0
      common/utils.ts
  13. 0
      contrib/fork-explorer-screenshot.png
  14. 2
      frontend/components/Donation.tsx
  15. 1
      frontend/components/ProgressBar.tsx
  16. 1
      frontend/pages/index.tsx
  17. 1
      frontend/pages/miners.tsx
  18. 2
      frontend/state/index.ts
  19. 6
      index.ts

2
README.md

@ -2,7 +2,7 @@
Fork Explorer let's you see the status of a BIP9-style softfork. It relies on bitcoind and its JSON-RPC server.
<img width="1000" src="fork-explorer-screenshot.png" />
<img width="1000" src="contrib/fork-explorer-screenshot.png" />
# Build and run

0
api/blocks.ts → backend/api/blocks.ts

4
api/donate.ts → backend/api/donate.ts

@ -3,8 +3,8 @@ import { exec, OutputMode } from "https://deno.land/x/exec/mod.ts";
import { ensureFile } from "https://deno.land/std/fs/mod.ts";
import { sha256 } from "https://denopkg.com/chiefbiiko/sha256/mod.ts";
import config from "../config/config.ts";
import { bytesToHexString } from "../utils.ts";
import config from "../../config/config.ts";
import { bytesToHexString } from "../../common/utils.ts";
await ensureFile("./addinvoice_payload.json");

0
api/index.ts → backend/api/index.ts

0
api/misc.ts → backend/api/misc.ts

14
blocks/index.ts → backend/blocks/index.ts

@ -1,15 +1,9 @@
import { getblock, getblockcount, getblockhash, getrawtransaction } from "../jsonrpc/index.ts";
import config from "../config/config.ts";
import miners from "./miners.ts";
import { hexToAscii } from "../utils.ts";
export interface IBlock {
height: number;
signals: boolean | undefined;
miner: string | undefined;
minerWebsite: string | undefined;
}
import config from "../../config/config.ts";
import miners from "../../common/miners.ts";
import { hexToAscii } from "../../common/utils.ts";
import { IBlock } from "../../common/interfaces.ts";
let blocks: IBlock[] = [];

0
jsonrpc/index.ts → backend/jsonrpc/index.ts

2
jsonrpc/utils.ts → backend/jsonrpc/utils.ts

@ -1,6 +1,6 @@
import * as base64 from "https://denopkg.com/chiefbiiko/base64/mod.ts";
import config from "../config/config.ts";
import config from "../../config/config.ts";
const host = config.bitcoinRpc.server;
const rpcUser = config.bitcoinRpc.user;

3
pageviews/index.ts → backend/pageviews/index.ts

@ -11,8 +11,7 @@ const pageViews: IPageViews = JSON.parse((await Deno.readTextFile("./pageviews.j
const PageviewsMiddleware: Middleware = async function (_, next) {
try {
const date = format(new Date(), "yyyy-MM-dd", {});
pageViews[date] = pageViews[date] ?? 0;
pageViews[date] = pageViews[date] + 1;
pageViews[date] = (pageViews[date] ?? 0) + 1;
await Deno.writeTextFile("./pageviews.json", JSON.stringify(pageViews, null, 2));
} catch (e) {
console.log(e.message);

6
common/interfaces.ts

@ -0,0 +1,6 @@
export interface IBlock {
height: number;
signals: boolean | undefined;
miner: string | undefined;
minerWebsite: string | undefined;
}

0
blocks/miners.ts → common/miners.ts

0
utils.ts → common/utils.ts

0
fork-explorer-screenshot.png → contrib/fork-explorer-screenshot.png

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 164 KiB

2
frontend/components/Donation.tsx

@ -4,7 +4,7 @@ import { QRCode } from "https://esm.sh/react-qr-svg";
import { bech32 } from "https://esm.sh/bech32";
import config from "../back/config/config.ts";
import { bytesToString } from "../back/utils.ts";
import { bytesToString } from "../back/common/utils.ts";
export const DonateContainer = styled.div`
margin: 0 auto 100px;

1
frontend/components/ProgressBar.tsx

@ -1,7 +1,6 @@
import React from "https://esm.sh/react@17.0.2";
import styled from "https://esm.sh/styled-components";
import config from "../back/config/config.ts";
import { useStoreState } from "../state/index.ts";
export const DonateContainer = styled.div`

1
frontend/pages/index.tsx

@ -2,7 +2,6 @@ import React from "https://esm.sh/react@17.0.2";
import styled from "https://esm.sh/styled-components";
import config from "../back/config/config.ts";
import { Container } from "../components/Container.ts";
import { Content } from "../components/Content.ts";
import { BlockContainer, Block } from "../components/Block.tsx";

1
frontend/pages/miners.tsx

@ -2,7 +2,6 @@ import React, { useMemo } from "https://esm.sh/react@17.0.2";
import styled from "https://esm.sh/styled-components";
import config from "../back/config/config.ts";
import { Container } from "../components/Container.ts";
import { Content } from "../components/Content.ts";
import SiteTitle from "../components/SiteTitle.tsx";

2
frontend/state/index.ts

@ -1,7 +1,7 @@
import { action, Action, createStore, createTypedHooks, thunk, Thunk } from "https://esm.sh/easy-peasy";
import { IBlock } from "../back/blocks/index.ts";
import config from "../back/config/config.ts";
import { IBlock } from "../back/common/interfaces.ts";
export interface IStoreModel {
getBlocks: Thunk<IStoreModel>;

6
index.ts

@ -1,8 +1,8 @@
import { Application, send } from "https://deno.land/x/oak@v7.3.0/mod.ts";
import { Application } from "https://deno.land/x/oak@v7.3.0/mod.ts";
import config from "./config/config.ts";
import router from "./api/index.ts";
import { bootstrapBlocks } from "./blocks/index.ts";
import router from "./backend/api/index.ts";
import { bootstrapBlocks } from "./backend/blocks/index.ts";
bootstrapBlocks();

Loading…
Cancel
Save