Skip to content

Commit

Permalink
Merge pull request #529 from nervosnetwork/rc/v0.39.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Jan 13, 2021
2 parents 83b4e2d + 6c2c9ff commit 1792227
Show file tree
Hide file tree
Showing 23 changed files with 842 additions and 61 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.39.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.2...v0.39.0) (2021-01-13)


### Features

* **rpc:** add rpc#getRawTxPool, rpc#getConsensus and deprecate rpc#getCellbaseOutputCapacityDetails, rpc#getPeersState ([#528](https://github.com/nervosnetwork/ckb-sdk-js/pull/528))





## [0.38.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.1...v0.38.2) (2020-11-30)


Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ The ckb-sdk-js is still under development and NOT production ready. You should g
- [Modules](#modules)
- [CORE](#core)
- [RPC](#rpc)
- [Utils](#utils)
- [Errors](#errors)
- [Examples](#examples)
- [Troubleshooting](#troubleshooting)
- [Development Process](#development-process)

<p>
Expand Down Expand Up @@ -213,6 +215,10 @@ const httpsAgent = new https.Agent({ keepAlive: true })
ckb.rpc.setNode({ httpsAgent })
```

# Utils

[Most used utilities](https://github.com/nervosnetwork/ckb-sdk-js/blob/develop/packages/ckb-sdk-utils/README.md)

# Errors

1. RPC Errors
Expand All @@ -228,6 +234,13 @@ The rpc module will throw an error when the result contains an error field, you
5. [Send Transaction with Lumos Collector](https://github.com/nervosnetwork/ckb-sdk-js/blob/develop/packages/ckb-sdk-core/examples/sendTransactionWithLumosCollector.js)
6. [SUDT](https://github.com/nervosnetwork/ckb-sdk-js/blob/develop/packages/ckb-sdk-core/examples/sudt.js)

# Troubleshooting

## Indexer Module

The Indexer Module in CKB has been deprecated since [v0.36.0](https://github.com/nervosnetwork/ckb/releases/tag/v0.36.0), please use [ckb-indexer](https://github.com/nervosnetwork/ckb-indexer) or [lumos-indexer](https://github.com/nervosnetwork/lumos/tree/develop/packages/indexer) instead.

A simple example [sendTransactionWithLumosCollector](https://github.com/nervosnetwork/ckb-sdk-js/blob/develop/packages/ckb-sdk-core/examples/sendTransactionWithLumosCollector.js) of wokring with lumos has beed added.

# Development Process

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.38.2"
"version": "0.39.0"
}
8 changes: 8 additions & 0 deletions packages/ckb-sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.39.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.2...v0.39.0) (2021-01-13)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-core





## [0.38.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.1...v0.38.2) (2020-11-30)


Expand Down
10 changes: 5 additions & 5 deletions packages/ckb-sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-sdk-core",
"version": "0.38.2",
"version": "0.39.0",
"description": "JavaScript SDK for Nervos Network CKB Project",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme",
Expand Down Expand Up @@ -31,10 +31,10 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-rpc": "0.38.2",
"@nervosnetwork/ckb-sdk-utils": "0.38.2",
"@nervosnetwork/ckb-types": "0.38.2",
"@nervosnetwork/ckb-sdk-rpc": "0.39.0",
"@nervosnetwork/ckb-sdk-utils": "0.39.0",
"@nervosnetwork/ckb-types": "0.39.0",
"tslib": "2.0.1"
},
"gitHead": "919d9b9eeecca2e65e4e3fdb49763401a62a46bd"
"gitHead": "94af87551108a40f79c1cead0db5d3cc5c679302"
}
11 changes: 11 additions & 0 deletions packages/ckb-sdk-rpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.39.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.2...v0.39.0) (2021-01-13)


### Features

* **rpc:** add rpc#getRawTxPool, rpc#getConsensus and deprecate rpc#getCellbaseOutputCapacityDetails, rpc#getPeersState ([#528](https://github.com/nervosnetwork/ckb-sdk-js/pull/528))





## [0.38.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.1...v0.38.2) (2020-11-30)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-rpc
Expand Down
4 changes: 2 additions & 2 deletions packages/ckb-sdk-rpc/__tests__/ckb-rpc-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ describe('ckb-rpc settings and helpers', () => {
expect(rpc.node.httpsAgent).toBeDefined()
})

it('has 37 basic rpc', () => {
expect(Object.values(rpc)).toHaveLength(37)
it('has 39 basic rpc', () => {
expect(Object.values(rpc)).toHaveLength(39)
})

it('set node url to http://test.localhost:8114', () => {
Expand Down
206 changes: 206 additions & 0 deletions packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,144 @@ describe('Test with mock', () => {
expect(res).toBeNull()
})

describe('get raw tx pool', () => {
it('verbose = true', async () => {
axiosMock.mockResolvedValue({
data: {
id,
jsonrpc: '2.0',
result: {
proposed: {
'0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0': {
ancestors_count: '0x1',
ancestors_cycles: '0x1a00e0',
ancestors_size: '0x1d0',
cycles: '0x1a00e0',
fee: '0x989680',
size: '0x1d0',
},
},
pending: {
'0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0': {
ancestors_count: '0x1',
ancestors_cycles: '0x1a00e0',
ancestors_size: '0x1d0',
cycles: '0x1a00e0',
fee: '0x989680',
size: '0x1d0',
},
},
},
},
})

const res = await rpc.getRawTxPool(true)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_raw_tx_pool',
params: [true],
})
expect(res).toEqual({
proposed: {
'0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0': {
ancestorsCount: '0x1',
ancestorsCycles: '0x1a00e0',
ancestorsSize: '0x1d0',
cycles: '0x1a00e0',
fee: '0x989680',
size: '0x1d0',
},
},
pending: {
'0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0': {
ancestorsCount: '0x1',
ancestorsCycles: '0x1a00e0',
ancestorsSize: '0x1d0',
cycles: '0x1a00e0',
fee: '0x989680',
size: '0x1d0',
},
},
})
})

it('verbose = false', async () => {
axiosMock.mockResolvedValue({
data: {
id,
jsonrpc: '2.0',
result: {
pending: ['0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0'],
proposed: [],
},
},
})

const res = await rpc.getRawTxPool(false)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_raw_tx_pool',
params: [false],
})
expect(res).toEqual({
pending: ['0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0'],
proposed: [],
})
})

it('verbose = null', async () => {
axiosMock.mockResolvedValue({
data: {
id,
jsonrpc: '2.0',
result: {
pending: ['0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0'],
proposed: [],
},
},
})

const res = await rpc.getRawTxPool(null)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_raw_tx_pool',
params: [null],
})
expect(res).toEqual({
pending: ['0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0'],
proposed: [],
})
})

it('verbose = undefined', async () => {
axiosMock.mockResolvedValue({
data: {
id,
jsonrpc: '2.0',
result: {
pending: ['0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0'],
proposed: [],
},
},
})

const res = await rpc.getRawTxPool()
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_raw_tx_pool',
params: [],
})
expect(res).toEqual({
pending: ['0x272881d99bfa40ded47f408e1783ee15990b479ec462f11668cdd3445cc132b0'],
proposed: [],
})
})
})

it('get current epoch', async () => {
axiosMock.mockResolvedValue({
data: {
Expand Down Expand Up @@ -492,6 +630,74 @@ describe('Test with mock', () => {
})
expect(res).toEqual(['0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3'])
})

it('get consensus', async () => {
axiosMock.mockResolvedValue({
data: {
id,
jsonrpc: '2.0',
result: {
block_version: '0x0',
cellbase_maturity: '0x10000000000',
dao_type_hash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
epoch_duration_target: '0x3840',
genesis_hash: '0xeaa2c979898f80a12404578a9e1332d45c8ff2bf665457b10f9934203f230780',
id: 'ckb_dev',
initial_primary_epoch_reward: '0xae6c73c3e070',
max_block_bytes: '0x91c08',
max_block_cycles: '0x2540be400',
max_block_proposals_limit: '0x5dc',
max_uncles_num: '0x2',
median_time_block_count: '0x25',
orphan_rate_target: { denom: '0x28', numer: '0x1' },
permanent_difficulty_in_dummy: true,
primary_epoch_reward_halving_interval: '0x2238',
proposer_reward_ratio: { denom: '0xa', numer: '0x4' },
secondary_epoch_reward: '0x37d0c8e28542',
secp256k1_blake160_multisig_all_type_hash:
'0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
secp256k1_blake160_sighash_all_type_hash:
'0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
tx_proposal_window: { closest: '0x2', farthest: '0xa' },
tx_version: '0x0',
type_id_code_hash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
},
},
})

const res = await rpc.getConsensus()
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_consensus',
params: [],
})
expect(res).toEqual({
blockVersion: '0x0',
cellbaseMaturity: '0x10000000000',
daoTypeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
epochDurationTarget: '0x3840',
genesisHash: '0xeaa2c979898f80a12404578a9e1332d45c8ff2bf665457b10f9934203f230780',
id: 'ckb_dev',
initialPrimaryEpochReward: '0xae6c73c3e070',
maxBlockBytes: '0x91c08',
maxBlockCycles: '0x2540be400',
maxBlockProposalsLimit: '0x5dc',
maxUnclesNum: '0x2',
medianTimeBlockCount: '0x25',
orphanRateTarget: { denom: '0x28', numer: '0x1' },
permanentDifficultyInDummy: true,
primaryEpochRewardHalvingInterval: '0x2238',
proposerRewardRatio: { denom: '0xa', numer: '0x4' },
secondaryEpochReward: '0x37d0c8e28542',
secp256k1Blake160MultisigAllTypeHash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
secp256k1Blake160SighashAllTypeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
txProposalWindow: { closest: '0x2', farthest: '0xa' },
txVersion: '0x0',
typeIdCodeHash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
})
})

it('get blockchain info', async () => {
axiosMock.mockResolvedValue({
data: {
Expand Down
Loading

0 comments on commit 1792227

Please sign in to comment.