-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Adamant-im/dev
v1.6.0: Support LSK and new code style
- Loading branch information
Showing
52 changed files
with
4,482 additions
and
3,079 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
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 |
---|---|---|
@@ -1,44 +1,31 @@ | ||
module.exports = { | ||
"parserOptions": { | ||
"ecmaVersion": 8, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
quotes: ["error", "single"], | ||
"semi": "warn", // обязательно ; | ||
"semi-spacing": ["error", {"before": false, "after": true}], | ||
"indent": ["error", "tab"], | ||
"space-infix-ops": "error",// отступы вокруг + - * / = и тд | ||
"eqeqeq": "error", // обязательно === и !== (нельзя == и !=) | ||
// "no-eq-null": "error", // обязательно === и !== (нельзя == и !=) но тоько в отношении null | ||
"curly": "error", // проверка шаблонов `${name}` | ||
// "space-before-function-paren": [ // отступ до и после function | ||
// "error", { | ||
// "anonymous": "always", | ||
// "named": "always", | ||
// "asyncArrow": "ignore" | ||
// } | ||
// ], | ||
"key-spacing": ["error", { "mode": "strict" }], // оформление обЪекта | ||
"space-in-parens": ["error", "never"], // запрет отступов ( a,b) | ||
"computed-property-spacing": ["error", "never"], // запрет лишних отступов в выражениях a[ i] | ||
"array-bracket-spacing": ["error", "never"], | ||
"no-multi-spaces": "error", // запрет лишних пробелов var a = 2 | ||
"no-sparse-arrays": "warn", // предупреждение при дырке в массиве | ||
"no-mixed-spaces-and-tabs": "error", // нельзя миксовать табы и пробелы | ||
"keyword-spacing": ["error", { "after": true }], | ||
"comma-spacing": ["error", { "before": false, "after": true }], // отступ после запятой, а перед нельзя | ||
"no-undef":"error", | ||
"array-callback-return": "error" // коллбек методов массива типа arr.map arr.filter должны иметь return в коллбеке | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"globals": { | ||
"Vue":true, | ||
"Symbol":true, | ||
"Promise":true, | ||
}, | ||
"plugins": [] | ||
} | ||
module.exports = { | ||
env: { | ||
commonjs: true, | ||
es2021: true, | ||
browser: true, | ||
node: true, | ||
'jest/globals': true, | ||
}, | ||
extends: ['eslint:recommended', 'google'], | ||
plugins: ['jest'], | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
}, | ||
rules: { | ||
'max-len': [ | ||
'error', | ||
{ | ||
code: 200, | ||
ignoreTrailingComments: true, | ||
ignoreUrls: true, | ||
ignoreStrings: true, | ||
ignoreTemplateLiterals: true, | ||
ignoreRegExpLiterals: true, | ||
}, | ||
], | ||
'require-jsdoc': 'off', | ||
'quote-props': 'off', | ||
'camelcase': 'off', | ||
'no-empty': 'off', | ||
}, | ||
}; |
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 |
---|---|---|
|
@@ -4,3 +4,5 @@ logs/ | |
package-lock.json | ||
tests.js | ||
config.test | ||
.idea | ||
.editorconfig |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no -- commitlint --edit |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run lint |
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,83 @@ | ||
# Contributing Guide | ||
|
||
Before submitting your contribution, please make sure to take a moment and read through the following guidelines: | ||
|
||
- [Pull Request Guidelines](#pull-request-guidelines) | ||
- [Development Setup](#development-setup) | ||
- [Scripts](#scripts) | ||
- [Project Structure](#project-structure) | ||
- [Contributing Tests](#contributing-tests) | ||
|
||
## Pull Request Guidelines | ||
|
||
- The master branch is just a snapshot of the latest stable release. All development should be done in dedicated branches. Do not submit PRs against the master branch. | ||
|
||
- Checkout a topic branch from a base branch, e.g. `master`, and merge back against that branch. | ||
|
||
- If adding a new feature add accompanying test case. | ||
|
||
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging. | ||
|
||
- Make sure tests pass! | ||
|
||
- Commit messages must follow the [commit message convention](https://github.com/conventional-changelog/commitlint/blob/master/README.md). Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [husky](https://github.com/typicode/husky)). | ||
|
||
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [husky](https://github.com/typicode/husky)). | ||
|
||
## Development Setup | ||
|
||
You will need [Node.js](https://nodejs.org) **version 16+**. | ||
|
||
After cloning the repo, run: | ||
|
||
```bash | ||
$ npm i # install the dependencies of the project | ||
``` | ||
|
||
A high level overview of tools used: | ||
|
||
- [Jest](https://jestjs.io/) for unit testing | ||
|
||
## Scripts | ||
|
||
### `npm run lint` | ||
|
||
The `lint` script runs linter. | ||
|
||
```bash | ||
# lint files | ||
$ npm run lint | ||
# fix linter errors | ||
$ npm run lint:fix | ||
``` | ||
|
||
### `npm run test` | ||
|
||
The `test` script simply calls the `jest` binary, so all [Jest CLI Options](https://jestjs.io/docs/en/cli) can be used. Some examples: | ||
|
||
```bash | ||
# run all tests | ||
$ npm run test | ||
# run all tests under the runtime-core package | ||
$ npm run test -- runtime-core | ||
# run tests in a specific file | ||
$ npm run test -- fileName | ||
# run a specific test in a specific file | ||
$ npm run test -- fileName -t 'test name' | ||
``` | ||
|
||
## Project Structure | ||
|
||
- **`modules`**: contains logic that handles requests to bounty-bot. | ||
|
||
- **`helpers`**: contains utilities shared across the entire codebase. | ||
|
||
- **`tests`**: contains tests for the application. | ||
|
||
## Contributing Tests | ||
|
||
Unit tests are collocated with the code being tested inside directories named `tests`. Consult the [Jest docs](https://jestjs.io/docs/en/using-matchers) and existing test cases for how to write new test specs. Here are some additional guidelines: | ||
|
||
- Use the minimal API needed for a test case. For example, if a test can be written without involving the reactivity system or a component, it should be written so. This limits the test's exposure to changes in unrelated parts and makes it more stable. | ||
|
||
- Only use platform-specific runtimes if the test is asserting platform-specific behavior. |
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
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 |
---|---|---|
@@ -1,56 +1,56 @@ | ||
const notify = require('./helpers/notify'); | ||
const db = require('./modules/DB'); | ||
const Store = require('./modules/Store'); | ||
const checker = require('./modules/checkerTransactions'); | ||
const doClearDB = process.argv.includes('clear_db'); | ||
const config = require('./modules/configReader'); | ||
const txParser = require('./modules/incomingTxsParser'); | ||
|
||
// Socket connection | ||
const api = require('./modules/api'); | ||
api.socket.initSocket({socket: config.socket, wsType: config.ws_type, onNewMessage: txParser, admAddress: Store.user.ADM.address}); | ||
|
||
setTimeout(init, 5000); | ||
|
||
function init() { | ||
require('./helpers/utils/erc20_utils'); | ||
require('./server'); | ||
require('./modules/checkTwitterFollow'); | ||
require('./modules/apiTester'); | ||
require('./modules/checkTwitterRetweet'); | ||
require('./modules/checkAdamantContacts'); | ||
require('./modules/checkAll'); | ||
require('./modules/outAddressFetcher'); | ||
require('./modules/rewardsPayer'); | ||
require('./modules/sentTxValidator'); | ||
try { | ||
|
||
if (doClearDB) { | ||
console.log('Clearing database..'); | ||
db.systemDb.db.drop(); | ||
db.incomingTxsDb.db.drop(); | ||
db.usersDb.db.drop(); | ||
db.paymentsDb.db.drop(); | ||
notify(`*${config.notifyName}: database cleared*. Manually stop the Bot now.`, 'info'); | ||
} else { | ||
|
||
db.systemDb.findOne().then(system => { | ||
if (system) { | ||
Store.lastBlock = system.lastBlock; | ||
} else { // if 1st start | ||
Store.updateLastBlock(); | ||
} | ||
checker(); | ||
notify(`*${config.notifyName} started* for address _${Store.user.ADM.address}_ (ver. ${Store.version}).`, 'info'); | ||
}); | ||
} | ||
|
||
} catch (e) { | ||
let message = `${config.notifyName} is not started. Error: ${e}`; | ||
if (e.message.includes('findOne')) { | ||
message = `${config.notifyName} is not started. Unable to connect to MongoDB. Check if Mongo server is running and available.`; | ||
} | ||
notify(message, 'error'); | ||
setTimeout(() => {process.exit(1);}, 2000); | ||
} | ||
} | ||
const notify = require('./helpers/notify'); | ||
const db = require('./modules/DB'); | ||
const Store = require('./modules/Store'); | ||
const checker = require('./modules/checkerTransactions'); | ||
const doClearDB = process.argv.includes('clear_db'); | ||
const config = require('./modules/configReader'); | ||
const txParser = require('./modules/incomingTxsParser'); | ||
|
||
// Socket connection | ||
const api = require('./modules/api'); | ||
api.socket.initSocket({socket: config.socket, wsType: config.ws_type, onNewMessage: txParser, admAddress: Store.user.ADM.address}); | ||
|
||
setTimeout(init, 5000); | ||
|
||
function init() { | ||
require('./helpers/cryptos/erc20_utils'); | ||
require('./server'); | ||
require('./modules/checkTwitterFollow'); | ||
require('./modules/apiTester'); | ||
require('./modules/checkTwitterReqs'); | ||
require('./modules/checkTwitterRetweet'); | ||
require('./modules/checkAdamantContacts'); | ||
require('./modules/checkAll'); | ||
require('./modules/outAddressFetcher'); | ||
require('./modules/rewardsPayer'); | ||
require('./modules/sentTxValidator'); | ||
try { | ||
if (doClearDB) { | ||
console.log('Clearing database…'); | ||
db.systemDb.db.drop(); | ||
db.IncomingTxsDb.db.drop(); | ||
db.UsersDb.db.drop(); | ||
db.PaymentsDb.db.drop(); | ||
notify(`*${config.notifyName}: database cleared*. Manually stop the Bot now.`, 'info'); | ||
} else { | ||
db.systemDb.findOne().then((system) => { | ||
if (system) { | ||
Store.lastBlock = system.lastBlock; | ||
} else { // if 1st start | ||
Store.updateLastBlock(); | ||
} | ||
checker(); | ||
notify(`*${config.notifyName} started* for address _${Store.user.ADM.address}_ (ver. ${Store.version}).`, 'info'); | ||
}); | ||
} | ||
} catch (e) { | ||
let message = `${config.notifyName} is not started. Error: ${e}`; | ||
if (e.message.includes('findOne')) { | ||
message = `${config.notifyName} is not started. Unable to connect to MongoDB. Check if Mongo server is running and available.`; | ||
} | ||
notify(message, 'error'); | ||
setTimeout(() => { | ||
process.exit(1); | ||
}, 2000); | ||
} | ||
} |
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,3 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
}; |
Oops, something went wrong.