diff --git a/CHANGELOG.md b/CHANGELOG.md index a9acdc79..7e9fbb9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + + +### Features + +* **rpc:** enable custom http agent and https agent ([34fca52](https://github.com/nervosnetwork/ckb-sdk-js/commit/34fca52)) + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) diff --git a/README.md b/README.md index 667957b7..c021d9a8 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,28 @@ After that you can use the `core` object to generate addresses, send requests, e # RPC +## Default RPC + Please see [Default RPC](https://github.com/nervosnetwork/ckb-sdk-js/blob/develop/packages/ckb-sdk-rpc/src/defaultRPC.ts#L165) +## Persistent Connection + +Please add `httpAgent` or `httpsAgent` to enable the persistent connection. + +If the SDK is running in Node.js, the following steps make the persistent connection available. + +```javascript +// HTTP Agent +const http = require('http') +const httpAgent = new http.Agent({ keepAlive: true }) +core.rpc.setNode({ httpAgent }) + +// HTTPS Agent +const https = require('https') +const httpsAgent = new https.Agent({ keepAlive: true }) +core.rpc.setNode({ httpsAgent }) +``` + # Errors 1. RPC Errors diff --git a/lerna.json b/lerna.json index 62a3bdfc..1b978ec8 100644 --- a/lerna.json +++ b/lerna.json @@ -2,5 +2,5 @@ "packages": [ "packages/*" ], - "version": "0.19.0" + "version": "0.19.1" } diff --git a/packages/ckb-cli/CHANGELOG.md b/packages/ckb-cli/CHANGELOG.md index 787c7e01..6a6574fb 100644 --- a/packages/ckb-cli/CHANGELOG.md +++ b/packages/ckb-cli/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + +**Note:** Version bump only for package @nervosnetwork/ckb-cli + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) diff --git a/packages/ckb-cli/package.json b/packages/ckb-cli/package.json index 1b878028..0591b369 100644 --- a/packages/ckb-cli/package.json +++ b/packages/ckb-cli/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-cli", - "version": "0.19.0", + "version": "0.19.1", "description": "Command line package based on @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", @@ -34,7 +34,7 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-sdk-core": "0.19.0", + "@nervosnetwork/ckb-sdk-core": "0.19.1", "blessed": "0.1.81", "blessed-contrib": "4.8.16", "commander": "2.20.0", @@ -45,5 +45,5 @@ "@types/crypto-js": "3.1.43", "@types/inquirer": "6.0.0" }, - "gitHead": "1f9603b54fe5cf20077bc0aa3542706566866209" + "gitHead": "94daf197d31ea697adcdcdf0b2d6875ce8946066" } diff --git a/packages/ckb-sdk-address/CHANGELOG.md b/packages/ckb-sdk-address/CHANGELOG.md index 16c3b638..0133c172 100644 --- a/packages/ckb-sdk-address/CHANGELOG.md +++ b/packages/ckb-sdk-address/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-address + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) **Note:** Version bump only for package @nervosnetwork/ckb-sdk-address diff --git a/packages/ckb-sdk-address/package.json b/packages/ckb-sdk-address/package.json index 8fe6762e..cd5cec31 100644 --- a/packages/ckb-sdk-address/package.json +++ b/packages/ckb-sdk-address/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-address", - "version": "0.19.0", + "version": "0.19.1", "description": "Address module of @nervosnetwork/ckb-sdk-core", "keywords": [ "CKB", @@ -33,8 +33,8 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-sdk-utils": "0.19.0", - "@nervosnetwork/ckb-types": "0.19.0" + "@nervosnetwork/ckb-sdk-utils": "0.19.1", + "@nervosnetwork/ckb-types": "0.19.1" }, - "gitHead": "1f9603b54fe5cf20077bc0aa3542706566866209" + "gitHead": "94daf197d31ea697adcdcdf0b2d6875ce8946066" } diff --git a/packages/ckb-sdk-core/CHANGELOG.md b/packages/ckb-sdk-core/CHANGELOG.md index c9b2cf05..e7aaf0bf 100644 --- a/packages/ckb-sdk-core/CHANGELOG.md +++ b/packages/ckb-sdk-core/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-core + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) diff --git a/packages/ckb-sdk-core/package.json b/packages/ckb-sdk-core/package.json index 943f33e4..d56ced90 100644 --- a/packages/ckb-sdk-core/package.json +++ b/packages/ckb-sdk-core/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-core", - "version": "0.19.0", + "version": "0.19.1", "description": "JavaScript SDK for Nervos Network CKB Project", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", @@ -29,13 +29,13 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-sdk-address": "0.19.0", - "@nervosnetwork/ckb-sdk-rpc": "0.19.0", - "@nervosnetwork/ckb-sdk-utils": "0.19.0", - "@nervosnetwork/ckb-types": "0.19.0" + "@nervosnetwork/ckb-sdk-address": "0.19.1", + "@nervosnetwork/ckb-sdk-rpc": "0.19.1", + "@nervosnetwork/ckb-sdk-utils": "0.19.1", + "@nervosnetwork/ckb-types": "0.19.1" }, "devDependencies": { "@types/crypto-js": "3.1.43" }, - "gitHead": "1f9603b54fe5cf20077bc0aa3542706566866209" + "gitHead": "94daf197d31ea697adcdcdf0b2d6875ce8946066" } diff --git a/packages/ckb-sdk-rpc/CHANGELOG.md b/packages/ckb-sdk-rpc/CHANGELOG.md index db94aa32..d3f3a4a9 100644 --- a/packages/ckb-sdk-rpc/CHANGELOG.md +++ b/packages/ckb-sdk-rpc/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + + +### Features + +* **rpc:** enable custom http agent and https agent ([34fca52](https://github.com/nervosnetwork/ckb-sdk-js/commit/34fca52)) + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) diff --git a/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js b/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js index 9281f820..67a1f7f4 100644 --- a/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js +++ b/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js @@ -1,4 +1,6 @@ const path = require('path') +const http = require('http') +const https = require('https') const env = path.join(__dirname, '../.env') @@ -32,7 +34,7 @@ describe('ckb-rpc settings and helpers', () => { rpc.setDebugLevel(DebugLevel.Off) }) - it('set node', () => { + it('set node url', () => { const node = { url: 'http://localhost:8114', } @@ -40,6 +42,24 @@ describe('ckb-rpc settings and helpers', () => { expect(rpc.node).toEqual(node) }) + it('set http agent', () => { + const httpAgent = new http.Agent() + const node = { + httpAgent, + } + rpc.setNode(node) + expect(rpc.node.httpAgent).toBeDefined() + }) + + it('set https agent', () => { + const httpsAgent = new https.Agent() + const node = { + httpsAgent, + } + rpc.setNode(node) + expect(rpc.node.httpsAgent).toBeDefined() + }) + it('has 27 default rpc', () => { expect(rpc.methods.length).toBe(27) }) diff --git a/packages/ckb-sdk-rpc/package.json b/packages/ckb-sdk-rpc/package.json index 9ee067c3..fe9907e9 100644 --- a/packages/ckb-sdk-rpc/package.json +++ b/packages/ckb-sdk-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-rpc", - "version": "0.19.0", + "version": "0.19.1", "description": "RPC module of @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js/packages/ckb-rpc#readme", @@ -32,12 +32,12 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-sdk-utils": "0.19.0", + "@nervosnetwork/ckb-sdk-utils": "0.19.1", "axios": "0.19.0" }, "devDependencies": { - "@nervosnetwork/ckb-types": "0.19.0", + "@nervosnetwork/ckb-types": "0.19.1", "@types/crypto-js": "3.1.43" }, - "gitHead": "1f9603b54fe5cf20077bc0aa3542706566866209" + "gitHead": "94daf197d31ea697adcdcdf0b2d6875ce8946066" } diff --git a/packages/ckb-sdk-rpc/src/method.ts b/packages/ckb-sdk-rpc/src/method.ts index 76ff7c17..81336181 100644 --- a/packages/ckb-sdk-rpc/src/method.ts +++ b/packages/ckb-sdk-rpc/src/method.ts @@ -34,6 +34,8 @@ class Method { }, data: payload, url: this.node.url, + httpAgent: this.node.httpAgent, + httpsAgent: this.node.httpsAgent, }).then(res => { if (res.data.id !== id) { throw new Error('JSONRPC id not match') diff --git a/packages/ckb-sdk-utils/CHANGELOG.md b/packages/ckb-sdk-utils/CHANGELOG.md index 822ccba5..19dc44fb 100644 --- a/packages/ckb-sdk-utils/CHANGELOG.md +++ b/packages/ckb-sdk-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-utils + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) diff --git a/packages/ckb-sdk-utils/package.json b/packages/ckb-sdk-utils/package.json index 218b55db..8acb73ec 100644 --- a/packages/ckb-sdk-utils/package.json +++ b/packages/ckb-sdk-utils/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-utils", - "version": "0.19.0", + "version": "0.19.1", "description": "Utils module of @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", @@ -30,7 +30,7 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-types": "0.19.0", + "@nervosnetwork/ckb-types": "0.19.1", "blake2b-wasm": "1.1.7", "elliptic": "6.4.1" }, @@ -39,5 +39,5 @@ "@types/elliptic": "6.4.8", "@types/utf8": "2.1.6" }, - "gitHead": "1f9603b54fe5cf20077bc0aa3542706566866209" + "gitHead": "94daf197d31ea697adcdcdf0b2d6875ce8946066" } diff --git a/packages/ckb-types/CHANGELOG.md b/packages/ckb-types/CHANGELOG.md index ada3b612..ebf9ca52 100644 --- a/packages/ckb-types/CHANGELOG.md +++ b/packages/ckb-types/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.19.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.0...v0.19.1) (2019-08-28) + + +### Features + +* **rpc:** enable custom http agent and https agent ([34fca52](https://github.com/nervosnetwork/ckb-sdk-js/commit/34fca52)) + + + + + # [0.19.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.18.0...v0.19.0) (2019-08-27) diff --git a/packages/ckb-types/index.d.ts b/packages/ckb-types/index.d.ts index 1a50e17c..fc68baa2 100644 --- a/packages/ckb-types/index.d.ts +++ b/packages/ckb-types/index.d.ts @@ -38,6 +38,8 @@ declare namespace CKBComponents { export type Since = string export interface Node { url: string + httpAgent?: any + httpsAgent?: any } export interface Method { name: string diff --git a/packages/ckb-types/package.json b/packages/ckb-types/package.json index a47a1345..ca4145a9 100644 --- a/packages/ckb-types/package.json +++ b/packages/ckb-types/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-types", - "version": "0.19.0", + "version": "0.19.1", "description": "Type module of @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", @@ -26,5 +26,5 @@ "devDependencies": { "@types/crypto-js": "3.1.43" }, - "gitHead": "1f9603b54fe5cf20077bc0aa3542706566866209" + "gitHead": "94daf197d31ea697adcdcdf0b2d6875ce8946066" } diff --git a/yarn.lock b/yarn.lock index 80302ffa..1eb584a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2713,9 +2713,9 @@ eslint-plugin-import@^2.14.0: resolve "^1.11.0" eslint-plugin-jest@^22.1.2: - version "22.15.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.15.1.tgz#54c4a752a44c4bc5a564ecc22b32e1cd16a2961a" - integrity sha512-CWq/RR/3tLaKFB+FZcCJwU9hH5q/bKeO3rFP8G07+q7hcDCFNqpvdphVbEbGE6o6qo1UbciEev4ejUWv7brUhw== + version "22.15.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.15.2.tgz#e3c10d9391f787744e31566f69ebb70c3a98e398" + integrity sha512-p4NME9TgXIt+KgpxcXyNBvO30ZKxwFAO1dJZBc2OGfDnXVEtPwEyNs95GSr6RIE3xLHdjd8ngDdE2icRRXrbxg== dependencies: "@typescript-eslint/experimental-utils" "^1.13.0" @@ -2735,14 +2735,16 @@ eslint-scope@^4.0.0, eslint-scope@^4.0.3: estraverse "^4.1.1" eslint-utils@^1.3.1: - version "1.3.1" - resolved "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz#9a851ba89ee7c460346f97cf8939c7298827e512" - integrity sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q== + version "1.4.2" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.2.tgz#166a5180ef6ab7eb462f162fd0e6f2463d7309ab" + integrity sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q== + dependencies: + eslint-visitor-keys "^1.0.0" eslint-visitor-keys@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" - integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ== + version "1.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" + integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== eslint@^5.10.0: version "5.16.0" @@ -3113,7 +3115,7 @@ fn-name@~2.0.1: for-in@^1.0.2: version "1.0.2" - resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= forever-agent@~0.6.1: @@ -3874,7 +3876,7 @@ is-extendable@^0.1.0, is-extendable@^0.1.1: is-extendable@^1.0.1: version "1.0.1" - resolved "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== dependencies: is-plain-object "^2.0.4" @@ -3974,7 +3976,7 @@ is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" - resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== dependencies: isobject "^3.0.1" @@ -4080,7 +4082,7 @@ isobject@^2.0.0: isobject@^3.0.0, isobject@^3.0.1: version "3.0.1" - resolved "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= isobject@^4.0.0: @@ -5221,9 +5223,9 @@ mississippi@^3.0.0: through2 "^2.0.0" mixin-deep@^1.2.0: - version "1.3.1" - resolved "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" - integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== dependencies: for-in "^1.0.2" is-extendable "^1.0.1"