diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fe45a33..6f7ca97d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,21 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + + +### Features + +* **rpc:** add get_cellbase_output_capacity_details rpc ([fa3aea3](https://github.com/nervosnetwork/ckb-sdk-js/commit/fa3aea3)) +* **rpc:** add get_header rpc ([d2a6bbb](https://github.com/nervosnetwork/ckb-sdk-js/commit/d2a6bbb)) +* **rpc:** add get_header_by_number rpc ([54f9d19](https://github.com/nervosnetwork/ckb-sdk-js/commit/54f9d19)) +* **rpc:** add new rpc of set ban ([416e7fd](https://github.com/nervosnetwork/ckb-sdk-js/commit/416e7fd)) +* **rpc:** add rpc of get banned addresses ([323b8ac](https://github.com/nervosnetwork/ckb-sdk-js/commit/323b8ac)) + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) diff --git a/lerna.json b/lerna.json index 047239b1..4f476be6 100644 --- a/lerna.json +++ b/lerna.json @@ -2,5 +2,5 @@ "packages": [ "packages/*" ], - "version": "0.17.1" + "version": "0.18.0" } diff --git a/packages/ckb-cli/CHANGELOG.md b/packages/ckb-cli/CHANGELOG.md index 0e2ef051..832556b7 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.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + +**Note:** Version bump only for package @nervosnetwork/ckb-cli + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) **Note:** Version bump only for package @nervosnetwork/ckb-cli diff --git a/packages/ckb-cli/package.json b/packages/ckb-cli/package.json index a288cade..1cee076c 100644 --- a/packages/ckb-cli/package.json +++ b/packages/ckb-cli/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-cli", - "version": "0.17.1", + "version": "0.18.0", "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.17.1", + "@nervosnetwork/ckb-sdk-core": "0.18.0", "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": "9862d5b3582be18a4af9e2d4ab34f069f5e15efb" + "gitHead": "6665c3cecb0a2b242722a58d83c8ac420ba0107b" } diff --git a/packages/ckb-sdk-address/CHANGELOG.md b/packages/ckb-sdk-address/CHANGELOG.md index 8077a72b..819a63f6 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.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-address + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) **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 62ec65a3..8056f893 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.17.1", + "version": "0.18.0", "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.17.1", - "@nervosnetwork/ckb-types": "0.17.1" + "@nervosnetwork/ckb-sdk-utils": "0.18.0", + "@nervosnetwork/ckb-types": "0.18.0" }, - "gitHead": "9862d5b3582be18a4af9e2d4ab34f069f5e15efb" + "gitHead": "6665c3cecb0a2b242722a58d83c8ac420ba0107b" } diff --git a/packages/ckb-sdk-core/CHANGELOG.md b/packages/ckb-sdk-core/CHANGELOG.md index 17cf3120..92509e05 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.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-core + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) diff --git a/packages/ckb-sdk-core/package.json b/packages/ckb-sdk-core/package.json index 266bab0a..d5d53a7e 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.17.1", + "version": "0.18.0", "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.17.1", - "@nervosnetwork/ckb-sdk-rpc": "0.17.1", - "@nervosnetwork/ckb-sdk-utils": "0.17.1", - "@nervosnetwork/ckb-types": "0.17.1" + "@nervosnetwork/ckb-sdk-address": "0.18.0", + "@nervosnetwork/ckb-sdk-rpc": "0.18.0", + "@nervosnetwork/ckb-sdk-utils": "0.18.0", + "@nervosnetwork/ckb-types": "0.18.0" }, "devDependencies": { "@types/crypto-js": "3.1.43" }, - "gitHead": "9862d5b3582be18a4af9e2d4ab34f069f5e15efb" + "gitHead": "6665c3cecb0a2b242722a58d83c8ac420ba0107b" } diff --git a/packages/ckb-sdk-rpc/CHANGELOG.md b/packages/ckb-sdk-rpc/CHANGELOG.md index 131c6c62..a751d538 100644 --- a/packages/ckb-sdk-rpc/CHANGELOG.md +++ b/packages/ckb-sdk-rpc/CHANGELOG.md @@ -3,6 +3,21 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + + +### Features + +* **rpc:** add get_cellbase_output_capacity_details rpc ([fa3aea3](https://github.com/nervosnetwork/ckb-sdk-js/commit/fa3aea3)) +* **rpc:** add get_header rpc ([d2a6bbb](https://github.com/nervosnetwork/ckb-sdk-js/commit/d2a6bbb)) +* **rpc:** add get_header_by_number rpc ([54f9d19](https://github.com/nervosnetwork/ckb-sdk-js/commit/54f9d19)) +* **rpc:** add new rpc of set ban ([416e7fd](https://github.com/nervosnetwork/ckb-sdk-js/commit/416e7fd)) +* **rpc:** add rpc of get banned addresses ([323b8ac](https://github.com/nervosnetwork/ckb-sdk-js/commit/323b8ac)) + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) diff --git a/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js b/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js index ff763d47..9281f820 100644 --- a/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js +++ b/packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js @@ -40,8 +40,8 @@ describe('ckb-rpc settings and helpers', () => { expect(rpc.node).toEqual(node) }) - it('has 22 default rpc', () => { - expect(rpc.methods.length).toBe(22) + it('has 27 default rpc', () => { + expect(rpc.methods.length).toBe(27) }) it('set node url to http://test.localhost:8114', () => { diff --git a/packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js b/packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js index 552f9860..63bc2d35 100644 --- a/packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js +++ b/packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js @@ -95,6 +95,36 @@ describe('ckb-rpc success', () => { it('get transactions by lock hash', async () => {}) it('index lock hash', async () => {}) + + it('get banned addresses', async () => { + const addresses = await rpc.getBannedAddresses() + expect(Array.isArray(addresses)).toBe(true) + }) + + it('set address to be banned', async () => { + expect.assertions(1) + await expect(rpc.setBan('192.168.0.2', 'insert', null)).resolves.toEqual(null) + }) + + it('get banned address', async () => { + const addresses = await rpc.getBannedAddresses() + expect(Array.isArray(addresses)).toBe(true) + }) + + it('get header', async () => { + const zeroBlock = await rpc.getBlockByNumber('0') + const zeroBlockHeader = zeroBlock.header + const zeroBlockHash = zeroBlockHeader.hash + const header = await rpc.getHeader(zeroBlockHash) + expect(header).toEqual(zeroBlockHeader) + }) + + it('get header by number', async () => { + const zeroBlock = await rpc.getBlockByNumber('0') + const zeroBlockHeader = zeroBlock.header + const header = await rpc.getHeaderByNumber('0') + expect(header).toEqual(zeroBlockHeader) + }) }) describe('send transaction', () => { diff --git a/packages/ckb-sdk-rpc/__tests__/formatters/result.json b/packages/ckb-sdk-rpc/__tests__/formatters/result.json index 31119b84..0d6fc552 100644 --- a/packages/ckb-sdk-rpc/__tests__/formatters/result.json +++ b/packages/ckb-sdk-rpc/__tests__/formatters/result.json @@ -248,43 +248,45 @@ { "source": { "header": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000", + "difficulty": "0x3e8", "epoch": "0", - "parent_hash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d", + "number": "1024", + "parent_hash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactions_root": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b", "uncles_count": "0", "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnesses_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnesses_root": "0x688c1ff7df5b9b454bd76a031d40e13b4e462aeee5f8497d0f9f6f1dbd5d8111" }, "proposals": [] }, "target": { "header": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000", + "difficulty": "0x3e8", "epoch": "0", - "parentHash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d", + "number": "1024", + "parentHash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87", "proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactionsRoot": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b", "unclesCount": "0", "unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnessesRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnessesRoot": "0x688c1ff7df5b9b454bd76a031d40e13b4e462aeee5f8497d0f9f6f1dbd5d8111" }, "proposals": [] } @@ -294,22 +296,23 @@ { "source": { "header": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000", + "difficulty": "0x3e8", "epoch": "0", - "parent_hash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d", + "number": "1024", + "parent_hash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactions_root": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b", "uncles_count": "0", "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnesses_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnesses_root": "0x688c1ff7df5b9b454bd76a031d40e13b4e462aeee5f8497d0f9f6f1dbd5d8111" }, "proposals": [], "transactions": [ @@ -348,22 +351,23 @@ }, "target": { "header": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000", + "difficulty": "0x3e8", "epoch": "0", - "parentHash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d", + "number": "1024", + "parentHash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87", "proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactionsRoot": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b", "unclesCount": "0", "unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnessesRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnessesRoot": "0x688c1ff7df5b9b454bd76a031d40e13b4e462aeee5f8497d0f9f6f1dbd5d8111" }, "proposals": [], "transactions": [ @@ -404,43 +408,45 @@ { "source": { "header": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000", + "difficulty": "0x3e8", "epoch": "0", - "parent_hash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d", + "number": "1024", + "parent_hash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactions_root": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b", "uncles_count": "0", "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnesses_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnesses_root": "0x688c1ff7df5b9b454bd76a031d40e13b4e462aeee5f8497d0f9f6f1dbd5d8111" }, "proposals": [] }, "target": { "header": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000", + "difficulty": "0x3e8", "epoch": "0", - "parentHash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d", + "number": "1024", + "parentHash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87", "proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactionsRoot": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b", "unclesCount": "0", "unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnessesRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnessesRoot": "0x688c1ff7df5b9b454bd76a031d40e13b4e462aeee5f8497d0f9f6f1dbd5d8111" }, "proposals": [], "transactions": [], @@ -779,40 +785,42 @@ "toHeader": [ { "source": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x01000000000000000000c16ff286230000203d88792d0000000961f400000000", + "difficulty": "0x3e8", "epoch": "0", - "parent_hash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0xba0d878d2c3711d38b5ddc2bc917312ca3898cad98457cc7960e28ec31f26e7f", + "number": "1024", + "parent_hash": "0x3533d5f0882a60d3b25b7dd57002a5d9eb591e89a98231e8abc5bf48f7ee0592", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactions_root": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactions_root": "0x81389ffabda2d1658c75a81e390a82b335d4cb849b2269d134b042fea9cb9513", "uncles_count": "0", "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnesses_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnesses_root": "0xb36423f72fd5cdbf6297c189b9d74e970bf0b971a537f41b8334088afe27900a" }, "target": { - "difficulty": "0x100", - "hash": "0xe5f2d07b747f38718293987a9175764d4c03229a8a69d0bd48f7bea6c18930b1", - "number": "2", + "dao": "0x01000000000000000000c16ff286230000203d88792d0000000961f400000000", + "difficulty": "0x3e8", "epoch": "0", - "parentHash": "0xa1dba96cdebaa25f2be69316c943269e23c23fcc6e90eedd94ecd88b43f77170", + "hash": "0xba0d878d2c3711d38b5ddc2bc917312ca3898cad98457cc7960e28ec31f26e7f", + "number": "1024", + "parentHash": "0x3533d5f0882a60d3b25b7dd57002a5d9eb591e89a98231e8abc5bf48f7ee0592", "proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "seal": { - "nonce": "9828930232171500901", - "proof": "0x7408000066230000942c00004735000028420000f046000059550000d56200005f640000f96a000043730000d3750000" + "nonce": "0", + "proof": "0x" }, - "timestamp": "1556199760706", - "transactionsRoot": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8", + "timestamp": "1557311767", + "transactionsRoot": "0x81389ffabda2d1658c75a81e390a82b335d4cb849b2269d134b042fea9cb9513", "unclesCount": "0", "unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0", - "witnessesRoot": "0x0000000000000000000000000000000000000000000000000000000000000000" + "witnessesRoot": "0xb36423f72fd5cdbf6297c189b9d74e970bf0b971a537f41b8334088afe27900a" } } ], @@ -1067,6 +1075,60 @@ } ] } + ], + "toBannedAddress": [ + { + "source": { + "address": "192.168.0.2/32", + "ban_reason": "", + "ban_until": "1840546800000", + "created_at": "1562803123000" + }, + "target": { + "address": "192.168.0.2/32", + "banReason": "", + "banUntil": "1840546800000", + "createdAt": "1562803123000" + } + } + ], + "toBannedAddresses": [ + { + "source": [ + { + "address": "192.168.0.2/32", + "ban_reason": "", + "ban_until": "1840546800000", + "created_at": "1562803123000" + } + ], + "target": [ + { + "address": "192.168.0.2/32", + "banReason": "", + "banUntil": "1840546800000", + "createdAt": "1562803123000" + } + ] + } + ], + "toCellbaseOutputCapacityDetails": [ + { + "source": { + "primary": "100000000000", + "proposal_reward": "0", + "secondary": "1346505683", + "total": "101346505683", + "tx_fee": "0" + }, + "target": { + "primary": "100000000000", + "proposalReward": "0", + "secondary": "1346505683", + "total": "101346505683", + "txFee": "0" + } + } ] }, "failure": {} diff --git a/packages/ckb-sdk-rpc/package.json b/packages/ckb-sdk-rpc/package.json index df337483..d8836ce3 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.17.1", + "version": "0.18.0", "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.17.1", + "@nervosnetwork/ckb-sdk-utils": "0.18.0", "axios": "0.19.0" }, "devDependencies": { - "@nervosnetwork/ckb-types": "0.17.1", + "@nervosnetwork/ckb-types": "0.18.0", "@types/crypto-js": "3.1.43" }, - "gitHead": "9862d5b3582be18a4af9e2d4ab34f069f5e15efb" + "gitHead": "6665c3cecb0a2b242722a58d83c8ac420ba0107b" } diff --git a/packages/ckb-sdk-rpc/src/defaultRPC.ts b/packages/ckb-sdk-rpc/src/defaultRPC.ts index e3d31d7a..e2fc207d 100644 --- a/packages/ckb-sdk-rpc/src/defaultRPC.ts +++ b/packages/ckb-sdk-rpc/src/defaultRPC.ts @@ -131,6 +131,35 @@ const defaultRPC: CKBComponents.Method[] = [ paramsFormatters: [paramsFmts.toHash], resultFormatters: resultFmts.toLockHashIndexState, }, + { + name: 'getBannedAddresses', + method: 'get_banned_addresses', + paramsFormatters: [], + resultFormatters: resultFmts.toBannedAddresses, + }, + { + name: 'setBan', + method: 'set_ban', + paramsFormatters: [], + }, + { + name: 'getHeader', + method: 'get_header', + paramsFormatters: [paramsFmts.toHash], + resultFormatters: resultFmts.toHeader, + }, + { + name: 'getHeaderByNumber', + method: 'get_header_by_number', + paramsFormatters: [paramsFmts.toNumber], + resultFormatters: resultFmts.toHeader, + }, + { + name: 'getCellbaseOutputCapacityDetails', + method: 'get_cellbase_output_capacity_details', + paramsFormatters: [paramsFmts.toHash], + resultFormatters: resultFmts.toCellbaseOutputCapacityDetails, + }, ] export class DefaultRPC { @@ -364,6 +393,61 @@ export class DefaultRPC { lockHash: CKBComponents.Hash, indexFrom?: CKBComponents.BlockNumber ) => Promise + + /** + * @method getBannedAddresses + * @memberof DefaultRPC + * @description Returns all banned IPs/Subnets + */ + public getBannedAddresses!: () => Promise + /** + * @method setBan + * @memberof DefaultRPC + * @description insert or delete an IP/Subnet from the banned list + * @param {string} address, The IP/Subnet with an optional netmask (default is /32 = single IP) + * @param {insert|delete} command, `insert` to insert an IP/Subnet to the list, `delete` to delete an IP/Subnet + * from the list + * @param {string|null} ban_time, Time in milliseconds how long (or until when if [absolute] is set) the IP is banned, + * optional parameter, null means using the default time of 24h + * @param {[boolean]} absolute, If set, the `ban_time` must be an absolute timestamp in milliseconds since epoch, + * optional parameter + * @param {[string]} reason, Ban reason, optional parameter + */ + + public setBan!: ( + address: string, + command: 'insert' | 'delete', + banTime: string | null, + absolute?: boolean, + reason?: string + ) => Promise + + /** + * @method getHeader + * @memberof DefaultRPC + * @description Returns the information about a block header by hash. + * @params {string} block hash + */ + public getHeader!: (blockHash: CKBComponents.Hash) => Promise + + /** + * @method getHeaderByNumber + * @memberof DefaultRPC + * @description Returns the information about a block header by block number + * @params {string} block number + */ + public getHeaderByNumber!: (blockNumber: CKBComponents.BlockNumber) => Promise + + /** + * @method getCellbaseOutputCapacityDetails + * @memberof DefaultRPC + * @description Returns each component of the created CKB in this block's cellbase, which is issued to + * a block N - 1 - ProposalWindow.farthest, where this block's height is N. + * @param {string} blockHash + */ + public getCellbaseOutputCapacityDetails!: ( + blockHash: CKBComponents.Hash + ) => Promise } export default DefaultRPC diff --git a/packages/ckb-sdk-rpc/src/resultFormatter.ts b/packages/ckb-sdk-rpc/src/resultFormatter.ts index 240f4f69..4ff4a8fb 100644 --- a/packages/ckb-sdk-rpc/src/resultFormatter.ts +++ b/packages/ckb-sdk-rpc/src/resultFormatter.ts @@ -237,6 +237,31 @@ const formatter = { if (!states) return states return states.map(formatter.toLockHashIndexState) }, + toBannedAddress: (bannedAddress: CKB_RPC.BannedAddress): CKBComponents.BannedAddress => { + if (!bannedAddress) return bannedAddress + const { ban_reason: banReason, ban_until: banUntil, created_at: createdAt, ...rest } = bannedAddress + return { + banReason, + banUntil, + createdAt, + ...rest, + } + }, + toBannedAddresses: (bannedAddresses: CKB_RPC.BannedAddresses): CKBComponents.BannedAddresses => { + if (!bannedAddresses) return bannedAddresses + return bannedAddresses.map(banAddr => formatter.toBannedAddress(banAddr)) + }, + toCellbaseOutputCapacityDetails: ( + details: CKB_RPC.CellbaseOutputCapacityDetails + ): CKBComponents.CellbaseOutputCapacityDetails => { + if (!details) return details + const { proposal_reward: proposalReward, tx_fee: txFee, ...rest } = details + return { + proposalReward, + txFee, + ...rest, + } + }, } export default formatter diff --git a/packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts b/packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts index 92f65081..b097ba81 100644 --- a/packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts +++ b/packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts @@ -105,19 +105,20 @@ declare module CKB_RPC { export type Seal = CKBComponents.Seal export interface Header { - version: Version + dao: DAO + difficulty: Difficulty + epoch: EpochInHeader + hash: Hash256 + number: BlockNumber parent_hash: Hash256 + proposals_hash: Hash256 + seal: Seal timestamp: Timestamp - number: BlockNumber - epoch: EpochInHeader transactions_root: Hash256 - proposals_hash: Hash256 - witnesses_root: Hash256 - difficulty: Difficulty - uncles_hash: Hash256 uncles_count: Count - seal: Seal - hash: Hash256 + uncles_hash: Hash256 + witnesses_root: Hash256 + version: Version } export interface UncleBlock { @@ -185,5 +186,21 @@ declare module CKB_RPC { } export type LockHashIndexStates = LockHashIndexState[] + + export interface BannedAddress { + address: string + ban_reason: string + ban_until: Timestamp + created_at: Timestamp + } + export type BannedAddresses = BannedAddress[] + + export interface CellbaseOutputCapacityDetails { + primary: string + proposal_reward: string + secondary: string + total: string + tx_fee: string + } } /* eslint-enable camelcase */ diff --git a/packages/ckb-sdk-utils/CHANGELOG.md b/packages/ckb-sdk-utils/CHANGELOG.md index 3aebdc33..71f94229 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.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-utils + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) **Note:** Version bump only for package @nervosnetwork/ckb-sdk-utils diff --git a/packages/ckb-sdk-utils/package.json b/packages/ckb-sdk-utils/package.json index be6b9673..367e7e16 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.17.1", + "version": "0.18.0", "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.17.1", + "@nervosnetwork/ckb-types": "0.18.0", "blake2b-wasm": "1.1.7", "elliptic": "6.4.1" }, @@ -39,5 +39,5 @@ "@types/elliptic": "6.4.8", "@types/utf8": "2.1.6" }, - "gitHead": "9862d5b3582be18a4af9e2d4ab34f069f5e15efb" + "gitHead": "6665c3cecb0a2b242722a58d83c8ac420ba0107b" } diff --git a/packages/ckb-types/CHANGELOG.md b/packages/ckb-types/CHANGELOG.md index f8e647aa..ea30b9e6 100644 --- a/packages/ckb-types/CHANGELOG.md +++ b/packages/ckb-types/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.18.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.1...v0.18.0) (2019-08-10) + + +### Features + +* **rpc:** add get_cellbase_output_capacity_details rpc ([fa3aea3](https://github.com/nervosnetwork/ckb-sdk-js/commit/fa3aea3)) +* **rpc:** add get_header rpc ([d2a6bbb](https://github.com/nervosnetwork/ckb-sdk-js/commit/d2a6bbb)) +* **rpc:** add rpc of get banned addresses ([323b8ac](https://github.com/nervosnetwork/ckb-sdk-js/commit/323b8ac)) + + + + + ## [0.17.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.17.0...v0.17.1) (2019-07-29) diff --git a/packages/ckb-types/index.d.ts b/packages/ckb-types/index.d.ts index 75228411..698e298f 100644 --- a/packages/ckb-types/index.d.ts +++ b/packages/ckb-types/index.d.ts @@ -3,6 +3,7 @@ */ declare namespace CKBComponents { + export type DAO = string export type Hash = string export type Hash256 = string export type UInt32 = number @@ -178,33 +179,36 @@ declare namespace CKBComponents { /** * @typedef BlockHeader, header of a block - * @property version + * @property dao + * @property difficulty + * @property epoch + * @property hash + * @property number * @property parentHash + * @property proposalsHash + * @property seal * @property timestamp - * @property number - * @property epoch * @property transactionsRoot - * @property proposalsHash - * @property difficulty - * @property unclesHash * @property unclesCount - * @property seal - * @property hash + * @property unclesHash + * @property witnessesRoot + * @property version */ export interface BlockHeader { - version: Version + dao: DAO + difficulty: Difficulty + epoch: EpochInHeader + hash: Hash256 + number: BlockNumber parentHash: Hash256 + proposalsHash: Hash256 + seal: Seal timestamp: Timestamp - number: BlockNumber - epoch: EpochInHeader transactionsRoot: Hash256 - proposalsHash: Hash256 - witnessesRoot: Hash256 - difficulty: Difficulty - unclesHash: Hash256 unclesCount: Count - seal: Seal - hash: Hash256 + unclesHash: Hash256 + witnessesRoot: Hash256 + version: Version } /** @@ -328,4 +332,21 @@ declare namespace CKBComponents { } export type LockHashIndexStates = LockHashIndexState[] + + export interface BannedAddress { + address: string + banReason: string + banUntil: Timestamp + createdAt: Timestamp + } + + export type BannedAddresses = BannedAddress[] + + export interface CellbaseOutputCapacityDetails { + primary: string + proposalReward: string + secondary: string + total: string + txFee: string + } } diff --git a/packages/ckb-types/package.json b/packages/ckb-types/package.json index a417e607..10a1792c 100644 --- a/packages/ckb-types/package.json +++ b/packages/ckb-types/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-types", - "version": "0.17.1", + "version": "0.18.0", "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": "9862d5b3582be18a4af9e2d4ab34f069f5e15efb" + "gitHead": "6665c3cecb0a2b242722a58d83c8ac420ba0107b" } diff --git a/yarn.lock b/yarn.lock index 191e56cb..270a8c20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1242,9 +1242,9 @@ integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== "@types/node@*", "@types/node@^12.0.0": - version "12.6.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.4.tgz#e0b5ac3ccbf183cd3c230967c323632d6cf927ae" - integrity sha512-ZKrDzI6KhrqtLpccI1YxMh4d+qzNnftNtp6iL9c4mLTNgzguFu7VR7pXH/C/MfzikMeoXjvISL9mlIGNGGDXDg== + version "12.6.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.9.tgz#ffeee23afdc19ab16e979338e7b536fdebbbaeaf" + integrity sha512-+YB9FtyxXGyD54p8rXwWaN1EWEyar5L58GlGWgtH2I9rGmLGBQcw63+0jw+ujqVavNuO47S1ByAjm9zdHMnskw== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -1280,7 +1280,7 @@ regexpp "^2.0.1" tsutils "^3.7.0" -"@typescript-eslint/experimental-utils@1.13.0": +"@typescript-eslint/experimental-utils@1.13.0", "@typescript-eslint/experimental-utils@^1.13.0": version "1.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz#b08c60d780c0067de2fb44b04b432f540138301e" integrity sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg== @@ -2667,9 +2667,11 @@ eslint-plugin-import@^2.14.0: resolve "^1.11.0" eslint-plugin-jest@^22.1.2: - version "22.9.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.9.0.tgz#2573dbcb4f1066b96a6e6d3b9aa439c80b28975a" - integrity sha512-V89BUiwf76FHlhj1mlNhNyvpzTy8VbWCh2RZpKYz/XDSl/pcuwFiE/LMt7r3q1sRKygzEMjbYeDob8MMuvakXg== + version "22.14.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.14.1.tgz#32287dade9bc0a1920c61e25a71cf11363d78015" + integrity sha512-mpLjhADl+HjagrlaGNx95HIji089S18DhnU/Ee8P8VP+dhEnuEzb43BXEaRmDgQ7BiSUPcSCvt1ydtgPkjOF/Q== + dependencies: + "@typescript-eslint/experimental-utils" "^1.13.0" eslint-plugin-prettier@^3.0.0: version "3.1.0"