From 4fb8f480879e4ffa34847dc7562291146e2139af Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Mon, 8 Jun 2020 12:32:54 +0200 Subject: [PATCH 1/2] :seedling: Add lisk-genesis package --- elements/lisk-genesis/.eslintignore | 2 + elements/lisk-genesis/.eslintrc.js | 7 +++ elements/lisk-genesis/.npmignore | 1 + elements/lisk-genesis/.npmrc | 1 + elements/lisk-genesis/.prettierignore | 1 + elements/lisk-genesis/.prettierrc.json | 1 + elements/lisk-genesis/README.md | 40 ++++++++++++++++ elements/lisk-genesis/jest.config.js | 1 + elements/lisk-genesis/package.json | 58 +++++++++++++++++++++++ elements/lisk-genesis/scripts | 1 + elements/lisk-genesis/src/create.ts | 41 ++++++++++++++++ elements/lisk-genesis/src/index.ts | 15 ++++++ elements/lisk-genesis/test/.eslintrc.js | 7 +++ elements/lisk-genesis/test/_setup.js | 3 ++ elements/lisk-genesis/test/create.spec.ts | 19 ++++++++ elements/lisk-genesis/test/tsconfig.json | 1 + elements/lisk-genesis/tsconfig.json | 1 + 17 files changed, 200 insertions(+) create mode 100644 elements/lisk-genesis/.eslintignore create mode 100644 elements/lisk-genesis/.eslintrc.js create mode 120000 elements/lisk-genesis/.npmignore create mode 120000 elements/lisk-genesis/.npmrc create mode 120000 elements/lisk-genesis/.prettierignore create mode 120000 elements/lisk-genesis/.prettierrc.json create mode 100644 elements/lisk-genesis/README.md create mode 120000 elements/lisk-genesis/jest.config.js create mode 100644 elements/lisk-genesis/package.json create mode 120000 elements/lisk-genesis/scripts create mode 100644 elements/lisk-genesis/src/create.ts create mode 100644 elements/lisk-genesis/src/index.ts create mode 100644 elements/lisk-genesis/test/.eslintrc.js create mode 100644 elements/lisk-genesis/test/_setup.js create mode 100644 elements/lisk-genesis/test/create.spec.ts create mode 120000 elements/lisk-genesis/test/tsconfig.json create mode 120000 elements/lisk-genesis/tsconfig.json diff --git a/elements/lisk-genesis/.eslintignore b/elements/lisk-genesis/.eslintignore new file mode 100644 index 00000000000..18f63c615af --- /dev/null +++ b/elements/lisk-genesis/.eslintignore @@ -0,0 +1,2 @@ +dist-node +jest.config.js diff --git a/elements/lisk-genesis/.eslintrc.js b/elements/lisk-genesis/.eslintrc.js new file mode 100644 index 00000000000..8b7fd410b8d --- /dev/null +++ b/elements/lisk-genesis/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + extends: '../../.eslintrc.js', + parserOptions: { + project: './tsconfig.json', + tsconfigRootDir: __dirname, + }, +}; diff --git a/elements/lisk-genesis/.npmignore b/elements/lisk-genesis/.npmignore new file mode 120000 index 00000000000..8a0be70f3ed --- /dev/null +++ b/elements/lisk-genesis/.npmignore @@ -0,0 +1 @@ +../../templates/.npmignore.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/.npmrc b/elements/lisk-genesis/.npmrc new file mode 120000 index 00000000000..5cc817c4313 --- /dev/null +++ b/elements/lisk-genesis/.npmrc @@ -0,0 +1 @@ +../../templates/.npmrc.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/.prettierignore b/elements/lisk-genesis/.prettierignore new file mode 120000 index 00000000000..044e4a3df69 --- /dev/null +++ b/elements/lisk-genesis/.prettierignore @@ -0,0 +1 @@ +../../templates/.prettierignore.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/.prettierrc.json b/elements/lisk-genesis/.prettierrc.json new file mode 120000 index 00000000000..00ecd510aaf --- /dev/null +++ b/elements/lisk-genesis/.prettierrc.json @@ -0,0 +1 @@ +../../templates/.prettierrc.json.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/README.md b/elements/lisk-genesis/README.md new file mode 100644 index 00000000000..b93c271ad8d --- /dev/null +++ b/elements/lisk-genesis/README.md @@ -0,0 +1,40 @@ +# @liskhq/lisk-genesis + +@liskhq/lisk-genesis contains genesis block creation functions according to the Lisk protocol. + +## Installation + +```sh +$ npm install --save @liskhq/lisk-genesis +``` + +## License + +Copyright 2016-2019 Lisk Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--- + +Copyright © 2016-2019 Lisk Foundation + +Copyright © 2015 Crypti + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +[lisk core github]: https://github.com/LiskHQ/lisk +[lisk documentation site]: https://lisk.io/documentation/lisk-elements diff --git a/elements/lisk-genesis/jest.config.js b/elements/lisk-genesis/jest.config.js new file mode 120000 index 00000000000..475ff02b18a --- /dev/null +++ b/elements/lisk-genesis/jest.config.js @@ -0,0 +1 @@ +../../templates/jest.config.js.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/package.json b/elements/lisk-genesis/package.json new file mode 100644 index 00000000000..632de1bbc1d --- /dev/null +++ b/elements/lisk-genesis/package.json @@ -0,0 +1,58 @@ +{ + "name": "@liskhq/lisk-genesis", + "version": "0.1.0", + "description": "Library containing genesis block creation functions according to the Lisk protocol", + "author": "Lisk Foundation , lightcurve GmbH ", + "license": "Apache-2.0", + "keywords": [ + "lisk", + "blockchain" + ], + "homepage": "https://github.com/LiskHQ/lisk-sdk/tree/master/elements/lisk-genesis#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/LiskHQ/lisk-sdk.git" + }, + "bugs": { + "url": "https://github.com/LiskHQ/lisk-sdk/issues" + }, + "engines": { + "node": ">=12.13.0 <=12", + "npm": ">=6.12.0" + }, + "main": "dist-node/index.js", + "scripts": { + "clean": "./scripts/clean.sh", + "format": "prettier --write '**/*'", + "lint": "eslint --ext .js,.ts .", + "lint:fix": "eslint --fix --ext .js,.ts .", + "test": "jest", + "test:watch": "npm test -- --watch", + "prebuild": "rm -r dist-node/* || mkdir dist-node || true", + "build": "tsc", + "build:check": "node -e \"require('./dist-node')\"", + "prepublishOnly": "npm run lint && npm test && npm run build && npm run build:check" + }, + "dependencies": {}, + "devDependencies": { + "@types/node": "12.12.11", + "@types/jest": "25.1.3", + "@types/jest-when": "2.7.0", + "@typescript-eslint/eslint-plugin": "2.28.0", + "@typescript-eslint/parser": "2.28.0", + "eslint": "6.8.0", + "eslint-config-lisk-base": "1.2.2", + "eslint-config-prettier": "6.10.0", + "eslint-plugin-import": "2.20.1", + "eslint-plugin-jest": "23.8.2", + "jest": "25.1.0", + "jest-extended": "0.11.5", + "jest-when": "2.7.0", + "prettier": "1.19.1", + "source-map-support": "0.5.16", + "ts-jest": "25.2.1", + "ts-node": "8.6.2", + "tsconfig-paths": "3.9.0", + "typescript": "3.8.3" + } +} diff --git a/elements/lisk-genesis/scripts b/elements/lisk-genesis/scripts new file mode 120000 index 00000000000..f81ccd0a763 --- /dev/null +++ b/elements/lisk-genesis/scripts @@ -0,0 +1 @@ +../../templates/scripts.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/src/create.ts b/elements/lisk-genesis/src/create.ts new file mode 100644 index 00000000000..b3db44ee086 --- /dev/null +++ b/elements/lisk-genesis/src/create.ts @@ -0,0 +1,41 @@ +/* + * Copyright © 2020 Lisk Foundation + * + * See the LICENSE file at the top-level directory of this distribution + * for licensing information. + * + * Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, + * no part of this software, including this file, may be copied, modified, + * propagated, or distributed except according to the terms contained in the + * LICENSE file. + * + * Removal or modification of this copyright notice is prohibited. + */ + +interface GeneisAccountState { + readonly publicKey?: Buffer; + readonly address: Buffer; + readonly balance: bigint; + readonly keys: ReadonlyArray; + readonly delegate?: { + readonly username: string; + readonly lastForgedHeight: bigint; + }; +} + +interface GenesisBlockParams { + // List of accounts in the genesis + readonly accounts: ReadonlyArray; + // List fo initial delegate addresses used during the bootstrap period to forge blocks + readonly initDelegates: ReadonlyArray; + // Number of rounds for bootstrap period, default is 3 + readonly initRounds?: number; + readonly height?: number; + readonly timestamp?: number; + readonly previousBlockId?: Buffer; +} + +// eslint-disable-next-line +export const createGenesisBlock = (_params: GenesisBlockParams) => { + return {}; +}; diff --git a/elements/lisk-genesis/src/index.ts b/elements/lisk-genesis/src/index.ts new file mode 100644 index 00000000000..d45c92a392c --- /dev/null +++ b/elements/lisk-genesis/src/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright © 2020 Lisk Foundation + * + * See the LICENSE file at the top-level directory of this distribution + * for licensing information. + * + * Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, + * no part of this software, including this file, may be copied, modified, + * propagated, or distributed except according to the terms contained in the + * LICENSE file. + * + * Removal or modification of this copyright notice is prohibited. + */ + +export * from './create'; diff --git a/elements/lisk-genesis/test/.eslintrc.js b/elements/lisk-genesis/test/.eslintrc.js new file mode 100644 index 00000000000..a98dfb6d823 --- /dev/null +++ b/elements/lisk-genesis/test/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + extends: '../../../.eslintrc.test.js', + parserOptions: { + project: './tsconfig.json', + tsconfigRootDir: __dirname, + }, +}; diff --git a/elements/lisk-genesis/test/_setup.js b/elements/lisk-genesis/test/_setup.js new file mode 100644 index 00000000000..e2a8f3c32b8 --- /dev/null +++ b/elements/lisk-genesis/test/_setup.js @@ -0,0 +1,3 @@ +require('jest-extended'); + +process.env.NODE_ENV = 'test'; diff --git a/elements/lisk-genesis/test/create.spec.ts b/elements/lisk-genesis/test/create.spec.ts new file mode 100644 index 00000000000..3234aa87fd5 --- /dev/null +++ b/elements/lisk-genesis/test/create.spec.ts @@ -0,0 +1,19 @@ +/* + * Copyright © 2020 Lisk Foundation + * + * See the LICENSE file at the top-level directory of this distribution + * for licensing information. + * + * Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, + * no part of this software, including this file, may be copied, modified, + * propagated, or distributed except according to the terms contained in the + * LICENSE file. + * + * Removal or modification of this copyright notice is prohibited. + */ + +describe('create', () => { + it('should create genesis block', () => { + expect(true).toBeTrue(); + }); +}); diff --git a/elements/lisk-genesis/test/tsconfig.json b/elements/lisk-genesis/test/tsconfig.json new file mode 120000 index 00000000000..c73c54e77b4 --- /dev/null +++ b/elements/lisk-genesis/test/tsconfig.json @@ -0,0 +1 @@ +../../../templates/test/tsconfig.json.tmpl \ No newline at end of file diff --git a/elements/lisk-genesis/tsconfig.json b/elements/lisk-genesis/tsconfig.json new file mode 120000 index 00000000000..900bb05c680 --- /dev/null +++ b/elements/lisk-genesis/tsconfig.json @@ -0,0 +1 @@ +../../templates/tsconfig.json.tmpl \ No newline at end of file From 476a90394c22926bfd83214779925ae6e9583af3 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Mon, 8 Jun 2020 14:40:28 +0200 Subject: [PATCH 2/2] :recycle: Update readme --- elements/lisk-genesis/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/elements/lisk-genesis/README.md b/elements/lisk-genesis/README.md index b93c271ad8d..c80375649d3 100644 --- a/elements/lisk-genesis/README.md +++ b/elements/lisk-genesis/README.md @@ -10,7 +10,7 @@ $ npm install --save @liskhq/lisk-genesis ## License -Copyright 2016-2019 Lisk Foundation +Copyright 2016-2020 Lisk Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,9 +26,7 @@ limitations under the License. --- -Copyright © 2016-2019 Lisk Foundation - -Copyright © 2015 Crypti +Copyright © 2016-2020 Lisk Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: