diff --git a/.husky/pre-push b/.husky/pre-push index 224d7b1d9..3b614330e 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -make lint +yarn run lint diff --git a/Makefile b/Makefile deleted file mode 100644 index aa47aba2c..000000000 --- a/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -build: - yarn workspace @ckb-lumos/bi build - yarn workspace @ckb-lumos/toolkit build - yarn workspace @ckb-lumos/config-manager build - yarn workspace @ckb-lumos/helpers build - yarn workspace @ckb-lumos/rpc build - yarn workspace @ckb-lumos/common-scripts build - yarn workspace @ckb-lumos/hd build - yarn workspace @ckb-lumos/hd-cache build - yarn workspace @ckb-lumos/ckb-indexer build - yarn workspace @ckb-lumos/lumos build - -build-release: build - yarn workspace @ckb-lumos/lumos build:umd - -test: - yarn workspace @ckb-lumos/bi test - yarn workspace @ckb-lumos/toolkit test - yarn workspace @ckb-lumos/base test - yarn workspace @ckb-lumos/common-scripts test - yarn workspace @ckb-lumos/config-manager test - yarn workspace @ckb-lumos/hd test - yarn workspace @ckb-lumos/hd-cache test - yarn workspace @ckb-lumos/helpers test - yarn workspace @ckb-lumos/indexer test - yarn workspace @ckb-lumos/transaction-manager test - yarn workspace @ckb-lumos/rpc test - -test-coverage: - yarn c8 --reporter=cobertura --reporter=html --clean -o coverage make test - -lint: - yarn workspaces run fmt - yarn workspaces run lint - git diff --exit-code \ No newline at end of file diff --git a/README.md b/README.md index af874c429..dc2adb91e 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,42 @@ As of now, lumos contains the following components: * [hd](./packages/hd): an HD wallet manager for CKB. It support mnemonic and keystore, compatible with `Neuron` and `ckb-cli`, you can load keystore from `Neuron` or `ckb-cli` directly and import mnemonic generated by `Neuron`. * [hd-cache](./packages/hd-cache): an HD cache manager for CKB. It build a memory cache for derived addresses and live cells of these addresses. * [rpc](./packages/rpc): RPC module for CKB RPC. Provide type definations for CKB RPC interface. + +## Building + +### Requirements +- [Node.js](https://nodejs.org) +- [Yarn](https://yarnpkg.com/) +- [node-gyp](https://github.com/nodejs/node-gyp) + +```bash +sudo apt-get update +sudo apt install nodejs +npm install --global yarn +sudo apt install build-essential +``` + +### Build +```bash +yarn run build +``` + +### Test (ava) +```bash +yarn run test +``` + +### Test Coverage (c8) +```bash +yarn run test-coverage +``` + +### Format & Lint +```bash +yarn run lint +``` + +### Clean +```bash +yarn run clean +``` diff --git a/package.json b/package.json index 477b04745..a897ee481 100644 --- a/package.json +++ b/package.json @@ -45,15 +45,18 @@ "scripts": { "docs": "typedoc .", "prepare": "husky install", - "test": "lerna run test", + "test": "lerna run test --parallel --ignore \"**/*/*indexer*\"", + "test-coverage": "yarn c8 --reporter=cobertura --reporter=html --clean -o coverage yarn run test", "build:types": "lerna run build:types", "build:js": "lerna run build:js --parallel", "build": "run-p build:*", + "build-release": "lerna run --scope @ckb-lumos/lumos build:umd", + "lint": "lerna run fmt && lerna run lint && git diff --exit-code", "clean": "lerna run clean" }, "husky": { "hooks": { - "pre-push": "make lint" + "pre-push": "yarn run lint" } } } diff --git a/packages/bi/package.json b/packages/bi/package.json index 1323f7f13..3d3e95606 100644 --- a/packages/bi/package.json +++ b/packages/bi/package.json @@ -32,7 +32,7 @@ "scripts": { "fmt": "prettier --write \"{src,tests,examples}/**/*.ts\" package.json", "lint": "eslint -c ../../.eslintrc.js \"{src,tests,examples}/**/*.ts\"", - "test": "ava **/*.test.ts", + "test": "ava **/*.test.ts --timeout=2m", "build": "npm run build:types && npm run build:js", "build:types": "tsc --declaration --emitDeclarationOnly", "build:js": "babel --root-mode upward src --out-dir lib --extensions .ts -s", diff --git a/packages/ckb-indexer/src/transaction_collector.ts b/packages/ckb-indexer/src/transaction_collector.ts index da2ecf307..1b92d2e4b 100644 --- a/packages/ckb-indexer/src/transaction_collector.ts +++ b/packages/ckb-indexer/src/transaction_collector.ts @@ -118,22 +118,24 @@ export class CKBIndexerTransactionCollector extends BaseIndexerModule.Transactio }); } }); - await services - .requestBatch(this.CKBRpcUrl, txIoTypeInputOutPointList) - .then((response: GetTransactionRPCResult[]) => { - response.forEach((item: GetTransactionRPCResult) => { - const itemId = item.id.toString(); - const [cellIndex, transactionHash] = itemId.split("-"); - const output: Output = - item.result.transaction.outputs[parseInt(cellIndex)]; - const targetTx = transactionList.find( - (tx) => tx.transaction.hash === transactionHash - ); - if (targetTx) { - targetTx.inputCell = output; - } + if (txIoTypeInputOutPointList.length > 0) { + await services + .requestBatch(this.CKBRpcUrl, txIoTypeInputOutPointList) + .then((response: GetTransactionRPCResult[]) => { + response.forEach((item: GetTransactionRPCResult) => { + const itemId = item.id.toString(); + const [cellIndex, transactionHash] = itemId.split("-"); + const output: Output = + item.result.transaction.outputs[parseInt(cellIndex)]; + const targetTx = transactionList.find( + (tx) => tx.transaction.hash === transactionHash + ); + if (targetTx) { + targetTx.inputCell = output; + } + }); }); - }); + } //filter by ScriptWrapper.argsLen transactionList = transactionList.filter( diff --git a/packages/common-scripts/package.json b/packages/common-scripts/package.json index 6e517a2ee..0e04a638f 100644 --- a/packages/common-scripts/package.json +++ b/packages/common-scripts/package.json @@ -38,7 +38,7 @@ "scripts": { "fmt": "prettier --write \"{src,tests,examples}/**/*.ts\" package.json", "lint": "eslint -c ../../.eslintrc.js \"{src,tests,examples}/**/*.ts\"", - "test": "ava **/*.test.ts", + "test": "ava **/*.test.ts --timeout=2m", "build": "npm run build:types && npm run build:js", "build:types": "tsc --declaration --emitDeclarationOnly", "build:js": "babel --root-mode upward src --out-dir lib --extensions .ts -s", diff --git a/packages/helpers/package.json b/packages/helpers/package.json index 604eb0b44..2c93a8e1e 100644 --- a/packages/helpers/package.json +++ b/packages/helpers/package.json @@ -30,7 +30,7 @@ "scripts": { "fmt": "prettier --write \"{src,tests}/**/*.ts\" package.json", "lint": "eslint -c ../../.eslintrc.js \"{src,tests}/**/*.ts\"", - "test": "ava tests/**/*.test.ts", + "test": "ava tests/**/*.test.ts --timeout=2m", "build": "npm run build:types && npm run build:js", "build:types": "tsc --declaration --emitDeclarationOnly", "build:js": "babel --root-mode upward src --out-dir lib --extensions .ts -s",