Skip to content

Commit 84fd3b6

Browse files
committed
☀️3.3. Cleanup & Optimization
1 parent bbfc07b commit 84fd3b6

File tree

18 files changed

+2616
-1784
lines changed

18 files changed

+2616
-1784
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
/node_modules

.eslintrc.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
node: true
6+
},
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:react/recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended'
12+
],
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
ecmaFeatures: {
16+
jsx: true
17+
},
18+
ecmaVersion: 13,
19+
sourceType: 'module'
20+
},
21+
plugins: ['react', '@typescript-eslint', 'simple-import-sort', 'prettier'],
22+
rules: {
23+
'prettier/prettier': [
24+
'warn',
25+
{
26+
semi: false,
27+
singleQuote: true,
28+
trailingComma: 'none'
29+
}
30+
],
31+
'simple-import-sort/imports': 'warn',
32+
'simple-import-sort/exports': 'warn'
33+
},
34+
35+
settings: {
36+
react: {
37+
version: 'detect'
38+
}
39+
}
40+
}

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
22
module.exports = {
33
verbose: true,
4-
modulePaths: ["<rootDir>/"],
5-
preset: "ts-jest",
6-
testEnvironment: "node",
7-
};
4+
modulePaths: ['<rootDir>/'],
5+
preset: 'ts-jest',
6+
testEnvironment: 'node'
7+
}

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pancakeswap-prediction-winner",
3-
"version": "3.2.0",
3+
"version": "3.3.0",
44
"description": "This bot wins almost every 5 minute BNB-USD option on PancakeSwap",
55
"author": "Egor Gavrilov",
66
"license": "MIT",
@@ -13,7 +13,8 @@
1313
"cg-eth": "ts-node ./src/candlegenie-eth.ts",
1414
"test": "jest",
1515
"build": "sh ./scripts/build-extension.sh",
16-
"watch": "nodemon --watch 'src/**/*' -e ts,tsx --exec 'yarn build'"
16+
"watch": "nodemon --watch 'src/**/*' -e ts,tsx --exec 'yarn build'",
17+
"lint": "eslint . --fix"
1718
},
1819
"dependencies": {
1920
"@chakra-ui/icons": "^1.0.16",
@@ -34,9 +35,17 @@
3435
"@types/node": "^16.11.1",
3536
"@types/react": "^17.0.33",
3637
"@types/react-dom": "^17.0.10",
38+
"@typescript-eslint/eslint-plugin": "^5.7.0",
39+
"@typescript-eslint/parser": "^5.7.0",
3740
"esbuild": "^0.13.8",
41+
"eslint": "^8.4.1",
42+
"eslint-config-prettier": "^8.3.0",
43+
"eslint-plugin-prettier": "^4.0.0",
44+
"eslint-plugin-react": "^7.27.1",
45+
"eslint-plugin-simple-import-sort": "^7.0.0",
3846
"jest": "^27.3.1",
3947
"nodemon": "^2.0.14",
48+
"prettier": "^2.5.1",
4049
"ts-jest": "^27.0.7",
4150
"ts-node": "^10.3.0",
4251
"typescript": "^4.4.4"

src/candlegenie-bnb.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import dotenv from "dotenv";
2-
import { parseStrategy, PLATFORMS, startPolling } from "./lib";
1+
import dotenv from 'dotenv'
32

4-
dotenv.config();
3+
import { parseStrategy, PLATFORMS, startPolling } from './lib'
54

6-
const strategy = parseStrategy(process.argv);
5+
dotenv.config()
6+
7+
const strategy = parseStrategy(process.argv)
78

89
startPolling(
910
process.env.PRIVATE_KEY,
@@ -12,5 +13,5 @@ startPolling(
1213
false,
1314
PLATFORMS.CandleGenieBNB
1415
).catch((error) => {
15-
console.error(error);
16-
});
16+
console.error(error)
17+
})

src/candlegenie-btc.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import dotenv from "dotenv";
2-
import { parseStrategy, PLATFORMS, startPolling } from "./lib";
1+
import dotenv from 'dotenv'
32

4-
dotenv.config();
3+
import { parseStrategy, PLATFORMS, startPolling } from './lib'
54

6-
const strategy = parseStrategy(process.argv);
5+
dotenv.config()
6+
7+
const strategy = parseStrategy(process.argv)
78

89
startPolling(
910
process.env.PRIVATE_KEY,
@@ -12,5 +13,5 @@ startPolling(
1213
false,
1314
PLATFORMS.CandleGenieBTC
1415
).catch((error) => {
15-
console.error(error);
16-
});
16+
console.error(error)
17+
})

src/candlegenie-eth.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import dotenv from "dotenv";
2-
import { parseStrategy, PLATFORMS, startPolling } from "./lib";
1+
import dotenv from 'dotenv'
32

4-
dotenv.config();
3+
import { parseStrategy, PLATFORMS, startPolling } from './lib'
54

6-
const strategy = parseStrategy(process.argv);
5+
dotenv.config()
6+
7+
const strategy = parseStrategy(process.argv)
78

89
startPolling(
910
process.env.PRIVATE_KEY,
@@ -12,5 +13,5 @@ startPolling(
1213
false,
1314
PLATFORMS.CandleGenieETH
1415
).catch((error) => {
15-
console.error(error);
16-
});
16+
console.error(error)
17+
})

src/extension/background.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import { PLATFORMS, sleep, startPolling, STRATEGIES } from "src/lib";
1+
import { PLATFORMS, sleep, startPolling, STRATEGIES } from 'src/lib'
22

33
interface Message {
4-
type: string;
4+
type: string
55
data: {
66
platforms: {
7-
[PLATFORMS.PancakeSwap]: boolean;
8-
[PLATFORMS.CandleGenieBTC]: boolean;
9-
[PLATFORMS.CandleGenieBNB]: boolean;
10-
[PLATFORMS.CandleGenieETH]: boolean;
11-
};
12-
strategy: STRATEGIES;
13-
};
7+
[PLATFORMS.PancakeSwap]: boolean
8+
[PLATFORMS.CandleGenieBTC]: boolean
9+
[PLATFORMS.CandleGenieBNB]: boolean
10+
[PLATFORMS.CandleGenieETH]: boolean
11+
}
12+
strategy: STRATEGIES
13+
}
1414
}
1515

1616
chrome.runtime.onMessage.addListener(async (message: Message) => {
17-
if (message.type === "START") {
17+
if (message.type === 'START') {
1818
const { privateKey, betAmount } = await chrome.storage.sync.get([
19-
"privateKey",
20-
"betAmount",
21-
]);
19+
'privateKey',
20+
'betAmount'
21+
])
2222

2323
if (message.data.platforms[PLATFORMS.PancakeSwap]) {
2424
startPolling(
@@ -27,8 +27,8 @@ chrome.runtime.onMessage.addListener(async (message: Message) => {
2727
message.data.strategy,
2828
true,
2929
PLATFORMS.PancakeSwap
30-
).catch();
31-
await sleep(3000);
30+
).catch()
31+
await sleep(3000)
3232
}
3333

3434
if (message.data.platforms[PLATFORMS.CandleGenieBTC]) {
@@ -38,8 +38,8 @@ chrome.runtime.onMessage.addListener(async (message: Message) => {
3838
message.data.strategy,
3939
true,
4040
PLATFORMS.CandleGenieBTC
41-
).catch();
42-
await sleep(3000);
41+
).catch()
42+
await sleep(3000)
4343
}
4444

4545
if (message.data.platforms[PLATFORMS.CandleGenieBNB]) {
@@ -49,8 +49,8 @@ chrome.runtime.onMessage.addListener(async (message: Message) => {
4949
message.data.strategy,
5050
true,
5151
PLATFORMS.CandleGenieBNB
52-
).catch();
53-
await sleep(3000);
52+
).catch()
53+
await sleep(3000)
5454
}
5555

5656
if (message.data.platforms[PLATFORMS.CandleGenieETH]) {
@@ -60,7 +60,7 @@ chrome.runtime.onMessage.addListener(async (message: Message) => {
6060
message.data.strategy,
6161
true,
6262
PLATFORMS.CandleGenieETH
63-
).catch();
63+
).catch()
6464
}
6565
}
66-
});
66+
})

src/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "PancakeSwap Prediction Winner",
44
"description": "IMPORTANT! Open Extensions -> PancakeSwap Prediction Winner -> Developer Mode ON -> service worker. Otherwise the bot will sleep.",
5-
"version": "0.0.0.5",
5+
"version": "0.0.1.1",
66

77
"background": {
88
"service_worker": "background.js"

src/extension/popup/app.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { ColorModeScript } from "@chakra-ui/color-mode";
2-
import { Box } from "@chakra-ui/layout";
3-
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
4-
import React from "react";
5-
import ReactDOM from "react-dom";
6-
import Main from "./components/Main";
1+
import { ColorModeScript } from '@chakra-ui/color-mode'
2+
import { Box } from '@chakra-ui/layout'
3+
import { ChakraProvider, extendTheme } from '@chakra-ui/react'
4+
import React from 'react'
5+
import ReactDOM from 'react-dom'
6+
7+
import Main from './components/Main'
78

89
const config = {
9-
initialColorMode: "dark",
10-
useSystemColorMode: false,
11-
};
10+
initialColorMode: 'dark',
11+
useSystemColorMode: false
12+
}
1213

13-
const theme = extendTheme({ config });
14+
const theme = extendTheme({ config })
1415

1516
function App() {
1617
return (
@@ -19,13 +20,13 @@ function App() {
1920
<Main />
2021
</Box>
2122
</ChakraProvider>
22-
);
23+
)
2324
}
2425

2526
ReactDOM.render(
2627
<>
2728
<ColorModeScript initialColorMode={theme.config.initialColorMode} />
2829
<App />
2930
</>,
30-
document.getElementById("root")
31-
);
31+
document.getElementById('root')
32+
)

0 commit comments

Comments
 (0)