Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
h0ngcha0 committed Nov 28, 2023
1 parent 01370da commit 2edb193
Show file tree
Hide file tree
Showing 25 changed files with 1,473 additions and 1,058 deletions.
33 changes: 33 additions & 0 deletions client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"plugins": ["security", "header", "jest"],
"extends": [
"prettier",
"plugin:prettier/recommended",
"plugin:security/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/require-await": ["error"],
"no-var": ["error"],
"object-curly-spacing": ["error", "always"]
},
"overrides": [
{
"files": ["*.ts"],
"rules": {
"security/detect-non-literal-fs-filename": "off"
}
}
],
"parserOptions": {
"ecmaVersion": "es5",
"sourceType": "module",
"project": ["./tsconfig.json"]
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
24 changes: 18 additions & 6 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
"@types/react-helmet": "^6.1.9",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"prettier": "^2.8.8",
"eslint": "^8.37.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-security": "^1.7.1",
"prettier": "^3.1.0",
"react-scripts": "^5.0.1",
"typescript": "^4.9.5"
},
Expand Down Expand Up @@ -44,15 +50,21 @@
"start": "./node_modules/.bin/react-scripts start",
"build": "./node_modules/.bin/react-scripts build",
"test": "./node_modules/.bin/react-scripts test --env=jsdom",
"eject": "./node_modules/.bin/react-scripts eject"
"eject": "./node_modules/.bin/react-scripts eject",
"lint": "eslint . --ext ts,.tsx",
"lint:fix": "eslint . --fix --ext .ts,.tsx"
},
"resolutions": {
"@types/react": "^18.2.0"
},
"eslintConfig": {
"extends": [
"react-app"
]
"prettier": {
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"bracketSameLine": false,
"trailingComma": "none"
},
"browserslist": {
"production": [
Expand Down
113 changes: 58 additions & 55 deletions client/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from 'axios';
import axios from 'axios'

interface InterpreterResultOut {
value?: boolean,
value?: boolean
type: string
}

interface ScriptElement {
type: string,
type: string
value: boolean
}

Expand All @@ -15,46 +15,46 @@ interface ScriptExecutionStage {
}

interface InterpreterStateOut {
scriptPubKey: ScriptElement[],
scriptSig: ScriptElement[],
currentScript: ScriptElement[],
scriptP2sh: ScriptElement[] | undefined,
scriptWitness: ScriptElement[] | undefined,
scriptWitnessStack: ScriptElement[] | undefined,
stack: ScriptElement[],
altStack: ScriptElement[],
scriptPubKey: ScriptElement[]
scriptSig: ScriptElement[]
currentScript: ScriptElement[]
scriptP2sh: ScriptElement[] | undefined
scriptWitness: ScriptElement[] | undefined
scriptWitnessStack: ScriptElement[] | undefined
stack: ScriptElement[]
altStack: ScriptElement[]
stage: ScriptExecutionStage
}

export interface InterpreterOutcome {
result: InterpreterResultOut,
state: InterpreterStateOut,
result: InterpreterResultOut
state: InterpreterStateOut
step: number | undefined
}

export interface OutPointRaw {
hash: string,
hash: string
index: string
}

export interface TxInRaw {
previousOutput: OutPointRaw,
sigScript: string,
previousOutput: OutPointRaw
sigScript: string
sequence: string
}

export interface TxInsRaw {
count: string,
count: string
txIns: TxInRaw[]
}

export interface TxOutRaw {
value: string,
value: string
pkScript: string
}

export interface TxOutsRaw {
count: string,
count: string
txOuts: TxOutRaw[]
}

Expand All @@ -63,67 +63,70 @@ export interface TxWitnessRaw {
}

export interface TxWitnessesRaw {
count: number,
count: number
txWitnesses: TxWitnessRaw[]
}

export interface TxRaw {
version: string,
flag?: string,
txIns: TxInsRaw,
txOuts: TxOutsRaw,
txWitnesses: TxWitnessesRaw[],
lockTime: String
version: string
flag?: string
txIns: TxInsRaw
txOuts: TxOutsRaw
txWitnesses: TxWitnessesRaw[]
lockTime: string
}

export interface TransactionInput {
prevHash: string,
outputIndex: number,
script?: string,
parsedScript?: ScriptElement[],
outputValue: number,
sequence: number,
scriptType: number,
addresses: string[],
prevHash: string
outputIndex: number
script?: string
parsedScript?: ScriptElement[]
outputValue: number
sequence: number
scriptType: number
addresses: string[]
witness?: string[]
}

export interface TransactionOutput {
value: number,
script: number,
parsedScript?: ScriptElement[],
spentBy?: string[],
addresses: string[],
value: number
script: number
parsedScript?: ScriptElement[]
spentBy?: string[]
addresses: string[]
scriptType: string
}

export interface Transaction {
hash: string,
hex: string,
txRaw?: TxRaw,
total: number,
size: number,
version: number,
lockTime: number,
inputs: TransactionInput[],
hash: string
hex: string
txRaw?: TxRaw
total: number
size: number
version: number
lockTime: number
inputs: TransactionInput[]
outputs: TransactionOutput[]
}

function extractResponseData<T>(response: { data: T }): T {
return response.data;
return response.data
}

export function interpretTransactionInput(transactionId: string, inputIndex: number) {
return axios.get(`/api/transaction/${transactionId}/input/${inputIndex}/interpret`)
.then(extractResponseData);
return axios.get(`/api/transaction/${transactionId}/input/${inputIndex}/interpret`).then(extractResponseData)
}

export function interpretTransactionInputWithSteps(transactionId: string, inputIndex: number, step: number): Promise<InterpreterOutcome | undefined> {
return axios.get(`/api/transaction/${transactionId}/input/${inputIndex}/interpret-with-steps/${step}`)
.then(extractResponseData);
export function interpretTransactionInputWithSteps(
transactionId: string,
inputIndex: number,
step: number
): Promise<InterpreterOutcome | undefined> {
return axios
.get(`/api/transaction/${transactionId}/input/${inputIndex}/interpret-with-steps/${step}`)
.then(extractResponseData)
}

export function fetchTransaction(transactionId): Promise<Transaction | undefined> {
return axios.get(`/api/transaction/${transactionId}`)
.then(extractResponseData);
return axios.get(`/api/transaction/${transactionId}`).then(extractResponseData)
}
20 changes: 0 additions & 20 deletions client/src/assets/icons/BeerIcon.js

This file was deleted.

42 changes: 42 additions & 0 deletions client/src/assets/icons/BeerIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react'

const BeerIcon = (props) => {
return (
<svg width="20px" height="20px" viewBox="0 0 60 60" version="1.1">
<g id="colored" stroke="none" fill="none" fillRule="evenodd">
<g id="Kitchen_sliced" transform="translate(-120.000000, 0.000000)"></g>
<g id="Kitchen" transform="translate(-103.000000, -1.000000)" stroke="#314E55">
<g id="Beer" transform="translate(114.000000, 4.000000)">
<path
d="M36.3670978,13 L37.9909131,47.1001213 C38.1986742,51.4631038 34.8185003,55 30.4469246,55 L11.287271,55 C6.91308014,55 3.535893,51.4553008 3.7432825,47.1001213 L5.35113932,15.5440824"
id="Rectangle-683"
strokeLinecap="round"
fill="#E5D85A"
></path>
<path
d="M35.6087474,20.1114339 C35.6087474,20.1114339 40.9848663,16.3011845 43.648943,19.8556186 C46.3130197,23.4100527 44.5572871,33.4128311 43.0223953,34.6259555 C41.4875035,35.8390798 36.966767,35.8390797 36.966767,35.8390797"
id="Path-1412"
strokeLinecap="round"
></path>
<path d="M28,22 L30,48" id="Line" strokeLinecap="square"></path>
<path
d="M12,22 L14,48"
id="Line"
strokeLinecap="square"
transform="translate(13.000000, 35.000000) scale(-1, 1) translate(-13.000000, -35.000000) "
></path>
<path d="M21,23 L21,47" id="Line" strokeLinecap="square"></path>
<path
d="M9.91675649,13.3952991 C10.4829841,14.9164352 11.9482853,16 13.6666667,16 C15.1161446,16 16.3855522,15.2290273 17.0871819,14.0747895 L17.0871819,14.0747895 C17.8166722,14.8495867 18.8518435,15.3333333 20,15.3333333 C20.6607805,15.3333333 21.2841385,15.1731083 21.8333422,14.88939 L21.8333422,14.88939 C23.2299013,16.7765135 25.4720704,18 28,18 C31.5246012,18 34.4936918,15.6215766 35.3898503,12.3821514 C37.4897718,11.6656348 39,9.6758504 39,7.33333333 C39,4.38781467 36.6121853,2 33.6666667,2 C32.4636174,2 31.3536032,2.39833081 30.4613173,3.07029936 C29.6887691,2.80858316 28.8609577,2.66666667 28,2.66666667 C26.4815395,2.66666667 25.066184,3.10811124 23.8752685,3.86966518 C22.9360068,2.34767904 21.2531266,1.33333333 19.3333333,1.33333333 C17.4159864,1.33333333 15.7349492,2.34509558 14.7949924,3.86384938 C14.1569342,1.63294436 12.1024977,0 9.66666667,0 C6.721148,0 4.33333333,2.38781467 4.33333333,5.33333333 C4.33333333,5.36454504 4.33360144,5.39569413 4.33413548,5.42677842 C1.86621036,5.89453398 0,8.06266193 0,10.6666667 C0,13.6121853 2.38781467,16 5.33333333,16 C7.28173148,16 8.9861039,14.9552017 9.91675649,13.3952991 Z"
id="Oval-636"
strokeLinecap="round"
fill="#E4AD40"
></path>
</g>
</g>
</g>
</svg>
)
}

export default BeerIcon
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import React from 'react'

const BitcoinIcon = props =>
const BitcoinIcon = (props) => (
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24">
<path d="M11 24v-3.022h-1v3.022h-2v-3.022h-4.969l.5-2.978h1.079c.884 0 1.39-.851 1.39-1.707v-8.889c0-.833-.485-1.404-1.365-1.404h-1.635v-3h5v-3h2v3h1v-3h2v3.053c4.315.146 6.024 1.781 6.514 3.625.58 2.18-.857 4.01-2.093 4.456 1.501.382 3.579 1.491 3.579 4.05 0 3.483-2.688 5.816-8 5.816v3h-2zm-1-11.006v5.006c3.969 0 6.688-.375 6.688-2.516 0-2.296-2.938-2.49-6.688-2.49zm0-1.994c2.211 0 5.578-.156 5.578-2.5 0-2-2.078-2.5-5.578-2.5v5z"/>
</svg>;
<path d="M11 24v-3.022h-1v3.022h-2v-3.022h-4.969l.5-2.978h1.079c.884 0 1.39-.851 1.39-1.707v-8.889c0-.833-.485-1.404-1.365-1.404h-1.635v-3h5v-3h2v3h1v-3h2v3.053c4.315.146 6.024 1.781 6.514 3.625.58 2.18-.857 4.01-2.093 4.456 1.501.382 3.579 1.491 3.579 4.05 0 3.483-2.688 5.816-8 5.816v3h-2zm-1-11.006v5.006c3.969 0 6.688-.375 6.688-2.516 0-2.296-2.938-2.49-6.688-2.49zm0-1.994c2.211 0 5.578-.156 5.578-2.5 0-2-2.078-2.5-5.578-2.5v5z" />
</svg>
)

export default BitcoinIcon;
export default BitcoinIcon
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import React from 'react';
import React from 'react'

const BitcoinIconYellow = props =>
const BitcoinIconYellow = (props) => (
<svg width="20px" height="20px" viewBox="0 0 256 256" version="1.1">
<defs>
<linearGradient x1="49.9733228%" y1="-0.0235524798%" x2="49.9733228%" y2="99.9898856%" id="linearGradient-1">
<stop stopColor="#F9AA4B" offset="0%"/>
<stop stopColor="#F7931A" offset="100%"/>
</linearGradient>
<linearGradient x1="49.9733228%" y1="-0.0235524798%" x2="49.9733228%" y2="99.9898856%" id="linearGradient-1">
<stop stopColor="#F9AA4B" offset="0%" />
<stop stopColor="#F7931A" offset="100%" />
</linearGradient>
</defs>
<g>
<path d="M252.171181,158.953845 C235.068666,227.562366 165.558445,269.267547 97.0483714,252.165422 C28.4382829,235.063298 -13.2678496,165.554665 3.83466519,97.0461553 C20.93718,28.4376335 90.3473861,-13.2675466 158.957475,3.83457763 C227.467548,20.8366894 269.273696,90.345323 252.171181,158.953845 L252.171181,158.953845 L252.171181,158.953845 Z" fill="url(#linearGradient-1)"/>
<path d="M188.944877,112.05 C191.444877,95.05 178.544877,85.85 160.744877,79.75 L166.544877,56.65 L152.544877,53.15 L146.944877,75.65 C143.244877,74.75 139.444877,73.85 135.644877,73.05 L141.244877,50.45 L127.244877,46.95 L121.544877,69.95 C118.444877,69.25 115.444877,68.55 112.544877,67.85 L112.544877,67.75 L93.1448775,62.95 L89.4448775,77.95 C89.4448775,77.95 99.8448775,80.35 99.6448775,80.45 C105.344877,81.85 106.344877,85.65 106.144877,88.65 L99.5448775,114.95 C99.9448775,115.05 100.444877,115.15 101.044877,115.45 C100.544877,115.35 100.044877,115.25 99.5448775,115.05 L90.3448775,151.85 C89.6448775,153.55 87.8448775,156.15 83.9448775,155.15 C84.0448775,155.35 73.7448775,152.65 73.7448775,152.65 L66.7448775,168.75 L85.0448775,173.35 C88.4448775,174.25 91.7448775,175.05 95.0448775,175.95 L89.2448775,199.25 L103.244877,202.75 L109.044877,179.65 C112.844877,180.65 116.644877,181.65 120.244877,182.55 L114.544877,205.55 L128.544877,209.05 L134.344877,185.75 C158.344877,190.25 176.344877,188.45 183.844877,166.75 C189.944877,149.35 183.544877,139.25 170.944877,132.65 C180.244877,130.55 187.144877,124.45 188.944877,112.05 L188.944877,112.05 L188.944877,112.05 Z M156.844877,157.05 C152.544877,174.45 123.144877,165.05 113.644877,162.65 L121.344877,131.75 C130.844877,134.15 161.444877,138.85 156.844877,157.05 L156.844877,157.05 Z M161.244877,111.75 C157.244877,127.65 132.844877,119.55 124.944877,117.55 L131.944877,89.55 C139.844877,91.55 165.344877,95.25 161.244877,111.75 L161.244877,111.75 Z" fill="#FFFFFF"/>
</g>
</svg>;
<g>
<path
d="M252.171181,158.953845 C235.068666,227.562366 165.558445,269.267547 97.0483714,252.165422 C28.4382829,235.063298 -13.2678496,165.554665 3.83466519,97.0461553 C20.93718,28.4376335 90.3473861,-13.2675466 158.957475,3.83457763 C227.467548,20.8366894 269.273696,90.345323 252.171181,158.953845 L252.171181,158.953845 L252.171181,158.953845 Z"
fill="url(#linearGradient-1)"
/>
<path
d="M188.944877,112.05 C191.444877,95.05 178.544877,85.85 160.744877,79.75 L166.544877,56.65 L152.544877,53.15 L146.944877,75.65 C143.244877,74.75 139.444877,73.85 135.644877,73.05 L141.244877,50.45 L127.244877,46.95 L121.544877,69.95 C118.444877,69.25 115.444877,68.55 112.544877,67.85 L112.544877,67.75 L93.1448775,62.95 L89.4448775,77.95 C89.4448775,77.95 99.8448775,80.35 99.6448775,80.45 C105.344877,81.85 106.344877,85.65 106.144877,88.65 L99.5448775,114.95 C99.9448775,115.05 100.444877,115.15 101.044877,115.45 C100.544877,115.35 100.044877,115.25 99.5448775,115.05 L90.3448775,151.85 C89.6448775,153.55 87.8448775,156.15 83.9448775,155.15 C84.0448775,155.35 73.7448775,152.65 73.7448775,152.65 L66.7448775,168.75 L85.0448775,173.35 C88.4448775,174.25 91.7448775,175.05 95.0448775,175.95 L89.2448775,199.25 L103.244877,202.75 L109.044877,179.65 C112.844877,180.65 116.644877,181.65 120.244877,182.55 L114.544877,205.55 L128.544877,209.05 L134.344877,185.75 C158.344877,190.25 176.344877,188.45 183.844877,166.75 C189.944877,149.35 183.544877,139.25 170.944877,132.65 C180.244877,130.55 187.144877,124.45 188.944877,112.05 L188.944877,112.05 L188.944877,112.05 Z M156.844877,157.05 C152.544877,174.45 123.144877,165.05 113.644877,162.65 L121.344877,131.75 C130.844877,134.15 161.444877,138.85 156.844877,157.05 L156.844877,157.05 Z M161.244877,111.75 C157.244877,127.65 132.844877,119.55 124.944877,117.55 L131.944877,89.55 C139.844877,91.55 165.344877,95.25 161.244877,111.75 L161.244877,111.75 Z"
fill="#FFFFFF"
/>
</g>
</svg>
)

export default BitcoinIconYellow;
export default BitcoinIconYellow
Loading

0 comments on commit 2edb193

Please sign in to comment.