Work in progress
This commit is contained in:
parent
07c6bbebad
commit
b87217ea9e
|
@ -0,0 +1,2 @@
|
|||
"This is a valid JSON text with one value"
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,48 @@
|
|||
# https://circleci.com/docs/2.0/language-javascript/
|
||||
version: 2
|
||||
jobs:
|
||||
"node-8":
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
working_directory: ~/typescript-starter
|
||||
steps:
|
||||
- checkout
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "package.json" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
- run: npm install
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v1-dependencies-{{ checksum "package.json" }}
|
||||
- run: npm test
|
||||
- run: npx nyc report --reporter=lcov | npx codecov
|
||||
- run: npm run cov:check
|
||||
"node-latest":
|
||||
docker:
|
||||
- image: circleci/node:latest
|
||||
working_directory: ~/typescript-starter
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "package.json" }}
|
||||
- v1-dependencies-
|
||||
- run: npm install
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v1-dependencies-{{ checksum "package.json" }}
|
||||
- run: npm test
|
||||
- run: npx nyc report --reporter=lcov | npx codecov
|
||||
- run: npm run cov:check
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- "node-8"
|
||||
- "node-latest"
|
|
@ -0,0 +1,3 @@
|
|||
# Example Contributing Guidelines
|
||||
|
||||
This is an example of GitHub's contributing guidelines file. Check out GitHub's [CONTRIBUTING.md help center article](https://help.github.com/articles/setting-guidelines-for-repository-contributors/) for more information.
|
|
@ -0,0 +1,11 @@
|
|||
* **I'm submitting a ...**
|
||||
[ ] bug report
|
||||
[ ] feature request
|
||||
[ ] question about the decisions made in the repository
|
||||
[ ] question about how to use this project
|
||||
|
||||
* **Summary**
|
||||
|
||||
|
||||
|
||||
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
|
|
@ -0,0 +1,13 @@
|
|||
* **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
|
||||
|
||||
|
||||
|
||||
* **What is the current behavior?** (You can also link to an open issue here)
|
||||
|
||||
|
||||
|
||||
* **What is the new behavior (if this is a feature change)?**
|
||||
|
||||
|
||||
|
||||
* **Other information**:
|
|
@ -0,0 +1,11 @@
|
|||
node_modules
|
||||
build
|
||||
test
|
||||
src/**.js
|
||||
.idea/*
|
||||
|
||||
coverage
|
||||
.nyc_output
|
||||
*.log
|
||||
|
||||
package-lock.json
|
|
@ -0,0 +1,14 @@
|
|||
src
|
||||
test
|
||||
tsconfig.json
|
||||
tsconfig.module.json
|
||||
tslint.json
|
||||
.travis.yml
|
||||
.github
|
||||
.prettierignore
|
||||
.vscode
|
||||
build/docs
|
||||
**/*.spec.*
|
||||
coverage
|
||||
.nyc_output
|
||||
*.log
|
|
@ -0,0 +1,2 @@
|
|||
# package.json is formatted by package managers, so we ignore it here
|
||||
package.json
|
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
const meow = require('meow');
|
||||
const path = require('path');
|
||||
|
||||
const tsFile = getTSFile();
|
||||
const jsFile = TS2JS(tsFile);
|
||||
|
||||
replaceCLIArg(tsFile, jsFile);
|
||||
|
||||
// Ava debugger
|
||||
require('ava/profile');
|
||||
|
||||
/**
|
||||
* get ts file path from CLI args
|
||||
*
|
||||
* @return string path
|
||||
*/
|
||||
function getTSFile() {
|
||||
const cli = meow();
|
||||
return cli.input[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* get associated compiled js file path
|
||||
*
|
||||
* @param tsFile path
|
||||
* @return string path
|
||||
*/
|
||||
function TS2JS(tsFile) {
|
||||
const srcFolder = path.join(__dirname, '..', 'src');
|
||||
const distFolder = path.join(__dirname, '..', 'build', 'main');
|
||||
|
||||
const tsPathObj = path.parse(tsFile);
|
||||
|
||||
return path.format({
|
||||
dir: tsPathObj.dir.replace(srcFolder, distFolder),
|
||||
ext: '.js',
|
||||
name: tsPathObj.name,
|
||||
root: tsPathObj.root
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* replace a value in CLI args
|
||||
*
|
||||
* @param search value to search
|
||||
* @param replace value to replace
|
||||
* @return void
|
||||
*/
|
||||
function replaceCLIArg(search, replace) {
|
||||
process.argv[process.argv.indexOf(search)] = replace;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Debug Project",
|
||||
// we test in `build` to make cleanup fast and easy
|
||||
"cwd": "${workspaceFolder}/build",
|
||||
// Replace this with your project root. If there are multiple, you can
|
||||
// automatically run the currently visible file with: "program": ${file}"
|
||||
"program": "${workspaceFolder}/src/cli/cli.ts",
|
||||
// "args": ["--no-install"],
|
||||
"outFiles": ["${workspaceFolder}/build/main/**/*.js"],
|
||||
"skipFiles": [
|
||||
"<node_internals>/**/*.js",
|
||||
"${workspaceFolder}/node_modules/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "npm: build",
|
||||
"stopOnEntry": true,
|
||||
"smartStep": true,
|
||||
"runtimeArgs": ["--nolazy"],
|
||||
"env": {
|
||||
"TYPESCRIPT_STARTER_REPO_URL": "${workspaceFolder}"
|
||||
},
|
||||
"console": "externalTerminal"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Debug Spec",
|
||||
"program": "${workspaceRoot}/.vscode/debug-ts.js",
|
||||
"args": ["${file}"],
|
||||
"skipFiles": ["<node_internals>/**/*.js"],
|
||||
// Consider using `npm run watch` or `yarn watch` for faster debugging
|
||||
// "preLaunchTask": "npm: build",
|
||||
// "smartStep": true,
|
||||
"runtimeArgs": ["--nolazy"]
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
// "typescript.implementationsCodeLens.enabled": true
|
||||
// "typescript.referencesCodeLens.enabled": true
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 YOUR_NAME
|
||||
|
||||
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.
|
|
@ -0,0 +1,3 @@
|
|||
# gaia9000
|
||||
|
||||
Convert a gaia8000 json to gaia9000
|
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"name": "gaia9000",
|
||||
"version": "1.0.0",
|
||||
"description": "Convert a gaia8000 json to gaia9000",
|
||||
"main": "build/main/index.js",
|
||||
"typings": "build/main/index.d.ts",
|
||||
"module": "build/module/index.js",
|
||||
"repository": "https://github.com/YOUR_GITHUB_USER_NAME/gaia9000",
|
||||
"license": "MIT",
|
||||
"keywords": [],
|
||||
"scripts": {
|
||||
"exe": "run-p build && node build/main/index.js",
|
||||
"info": "npm-scripts-info",
|
||||
"build": "run-s clean && run-p build:*",
|
||||
"build:main": "tsc -p tsconfig.json",
|
||||
"build:module": "tsc -p tsconfig.module.json",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier \"src/**/*.ts\" --write",
|
||||
"fix:tslint": "tslint --fix --project .",
|
||||
"test": "run-s build test:*",
|
||||
"test:lint": "tslint --project . && prettier \"src/**/*.ts\" --list-different",
|
||||
"test:unit": "nyc --silent ava",
|
||||
"watch": "run-s clean build:main && run-p \"build:main -- -w\" \"test:unit -- --watch\"",
|
||||
"cov": "run-s build test:unit cov:html && opn coverage/index.html",
|
||||
"cov:html": "nyc report --reporter=html",
|
||||
"cov:send": "nyc report --reporter=lcov > coverage.lcov && codecov",
|
||||
"cov:check": "nyc report && nyc check-coverage --lines 100 --functions 100 --branches 100",
|
||||
"doc": "run-s doc:html && opn build/docs/index.html",
|
||||
"doc:html": "typedoc src/ --target ES6 --mode file --out build/docs",
|
||||
"doc:json": "typedoc src/ --target ES6 --mode file --json build/docs/typedoc.json",
|
||||
"doc:publish": "gh-pages -m \"[ci skip] Updates\" -d build/docs",
|
||||
"version": "standard-version",
|
||||
"reset": "git clean -dfx && git reset --hard && npm i",
|
||||
"clean": "trash build test",
|
||||
"all": "run-s reset test cov:check doc:html",
|
||||
"prepare-release": "run-s all version doc:publish",
|
||||
"preinstall": "node -e \"if(process.env.npm_execpath.indexOf('yarn') === -1) throw new Error('gaia9000 must be installed with Yarn: https://yarnpkg.com/')\""
|
||||
},
|
||||
"scripts-info": {
|
||||
"info": "Display information about the package scripts",
|
||||
"build": "Clean and rebuild the project",
|
||||
"fix": "Try to automatically fix any linting problems",
|
||||
"test": "Lint and unit test the project",
|
||||
"watch": "Watch and rebuild the project on save, then rerun relevant tests",
|
||||
"cov": "Rebuild, run tests, then create and open the coverage report",
|
||||
"doc": "Generate HTML API documentation and open it in a browser",
|
||||
"doc:json": "Generate API documentation in typedoc JSON format",
|
||||
"version": "Bump package.json version, update CHANGELOG.md, tag release",
|
||||
"reset": "Delete all untracked files and reset the repo to the last commit",
|
||||
"prepare-release": "One-step: clean, build, test, publish docs, and prep a release"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^10.12.0",
|
||||
"bech32": "^1.1.3",
|
||||
"bignumber.js": "^7.2.1",
|
||||
"sha.js": "^2.4.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "1.0.0-beta.7",
|
||||
"codecov": "^3.1.0",
|
||||
"cz-conventional-changelog": "^2.1.0",
|
||||
"gh-pages": "^2.0.0",
|
||||
"npm-run-all": "^4.1.3",
|
||||
"nyc": "^13.0.1",
|
||||
"opn-cli": "^3.1.0",
|
||||
"prettier": "^1.14.3",
|
||||
"standard-version": "^4.4.0",
|
||||
"trash-cli": "^1.4.0",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0",
|
||||
"tslint-immutable": "^4.7.0",
|
||||
"typedoc": "^0.13.0",
|
||||
"typescript": "^3.0.3"
|
||||
},
|
||||
"ava": {
|
||||
"failFast": true,
|
||||
"files": [
|
||||
"build/main/**/*.spec.js"
|
||||
],
|
||||
"sources": [
|
||||
"build/main/**/*.js"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"**/*.spec.js"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
import * as fs from 'fs';
|
||||
import * as util from 'util';
|
||||
import {BigNumber} from "bignumber.js"
|
||||
import * as bech32 from "bech32"
|
||||
|
||||
// Convert fs.readFile into Promise version of same
|
||||
const readFile = util.promisify(fs.readFile);
|
||||
|
||||
function parseFraction(fraction: string):string{
|
||||
let parts = fraction.split("/")
|
||||
|
||||
if( parts.length == 2){
|
||||
return new BigNumber(parts[0]).div(new BigNumber(parts[1])).toFixed(2)
|
||||
}
|
||||
return fraction
|
||||
|
||||
}
|
||||
|
||||
function fractionToDecimal(fraction: string):string{
|
||||
return parseFraction(fraction)
|
||||
}
|
||||
|
||||
|
||||
function convertBech32(encoded:string):string{
|
||||
let data = bech32.decode(encoded)
|
||||
return bech32.encode("cosmos",data.words)
|
||||
}
|
||||
|
||||
async function getStuff() {
|
||||
return await readFile('../gaia8001.json');
|
||||
}
|
||||
|
||||
|
||||
|
||||
getStuff().then(data => {
|
||||
let genesis = JSON.parse(data.toString());
|
||||
let validators = genesis.app_state.stake.validators;
|
||||
for (let val of validators){
|
||||
val.tokens = fractionToDecimal(val.tokens)
|
||||
val.delegator_shares = fractionToDecimal(val.delegator_shares)
|
||||
val.jailed = val.revoked
|
||||
delete val.revoked
|
||||
}
|
||||
let accounts = genesis.app_state.accounts
|
||||
for (let account of accounts){
|
||||
account.address = convertBech32(account.address)
|
||||
}
|
||||
console.log(accounts)
|
||||
|
||||
|
||||
}
|
||||
)
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2017",
|
||||
"outDir": "build/main",
|
||||
"rootDir": "src",
|
||||
"moduleResolution": "node",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"inlineSourceMap": true,
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||
|
||||
// "strict": true /* Enable all strict type-checking options. */,
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
// "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||
// "strictNullChecks": true /* Enable strict null checks. */,
|
||||
// "strictFunctionTypes": true /* Enable strict checking of function types. */,
|
||||
// "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
|
||||
// "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
|
||||
// "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
|
||||
|
||||
/* Additional Checks */
|
||||
"noUnusedLocals": true /* Report errors on unused locals. */,
|
||||
"noUnusedParameters": true /* Report errors on unused parameters. */,
|
||||
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
|
||||
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
|
||||
|
||||
/* Debugging Options */
|
||||
"traceResolution": false /* Report module resolution log messages. */,
|
||||
"listEmittedFiles": false /* Print names of generated files part of the compilation. */,
|
||||
"listFiles": false /* Print names of files part of the compilation. */,
|
||||
"pretty": true /* Stylize errors and messages using color and context. */,
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
|
||||
// "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
|
||||
|
||||
"lib": ["es2017"],
|
||||
"types": ["node"],
|
||||
"typeRoots": ["node_modules/@types", "src/types"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules/**"],
|
||||
"compileOnSave": false
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"outDir": "build/module",
|
||||
"module": "esnext"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules/**"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier", "tslint-immutable"],
|
||||
"rules": {
|
||||
"interface-name": [true, "never-prefix"],
|
||||
// TODO: allow devDependencies only in **/*.spec.ts files:
|
||||
// waiting on https://github.com/palantir/tslint/pull/3708
|
||||
"no-implicit-dependencies": [true, "dev"],
|
||||
|
||||
/* tslint-immutable rules */
|
||||
// Recommended built-in rules
|
||||
"no-var-keyword": true,
|
||||
"no-parameter-reassignment": true,
|
||||
"typedef": [true, "call-signature"],
|
||||
|
||||
// Immutability rules
|
||||
"readonly-keyword": true,
|
||||
"readonly-array": true,
|
||||
"no-let": true,
|
||||
"no-object-mutation": true,
|
||||
"no-delete": true,
|
||||
"no-method-signature": true,
|
||||
|
||||
// Functional style rules
|
||||
"no-this": true,
|
||||
"no-class": true,
|
||||
"no-mixed-interface": true,
|
||||
"no-expression-statement": [
|
||||
true,
|
||||
{ "ignore-prefix": ["console.", "process.exit"] }
|
||||
],
|
||||
"no-if-statement": true
|
||||
/* end tslint-immutable rules */
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"systemParams": "darwin-x64-64",
|
||||
"modulesFolders": [],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [],
|
||||
"lockfileEntries": {},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
Loading…
Reference in New Issue