Skip to content

Commit

Permalink
Merge pull request #530 from nervosnetwork/rc/v0.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Mar 8, 2021
2 parents 1792227 + 11a7930 commit c265757
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 348 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.40.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.39.0...v0.40.0) (2021-03-08)


### Features

* **rpc:** remove indexer from RPC module ([b3ba942](https://github.com/nervosnetwork/ckb-sdk-js/commit/b3ba942f55af750559714194a9d91289469ea4c2))


### BREAKING CHANGES

* **rpc:** Remove the entire indexer from the RPC module





# [0.39.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.2...v0.39.0) (2021-01-13)


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.39.0"
"version": "0.40.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.40.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.39.0...v0.40.0) (2021-03-08)

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





# [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
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.39.0",
"version": "0.40.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.39.0",
"@nervosnetwork/ckb-sdk-utils": "0.39.0",
"@nervosnetwork/ckb-types": "0.39.0",
"@nervosnetwork/ckb-sdk-rpc": "0.40.0",
"@nervosnetwork/ckb-sdk-utils": "0.40.0",
"@nervosnetwork/ckb-types": "0.40.0",
"tslib": "2.0.1"
},
"gitHead": "94af87551108a40f79c1cead0db5d3cc5c679302"
"gitHead": "91badc4ec74bbcb4365b632348f1bbc7a5377adf"
}
16 changes: 16 additions & 0 deletions packages/ckb-sdk-rpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.40.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.39.0...v0.40.0) (2021-03-08)


### Features

* **rpc:** remove indexer from RPC module ([b3ba942](https://github.com/nervosnetwork/ckb-sdk-js/commit/b3ba942f55af750559714194a9d91289469ea4c2))


### BREAKING CHANGES

* **rpc:** Remove the entire indexer from the RPC module





# [0.39.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.38.2...v0.39.0) (2021-01-13)


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 39 basic rpc', () => {
expect(Object.values(rpc)).toHaveLength(39)
it('has 33 basic rpc', () => {
expect(Object.values(rpc)).toHaveLength(33)
})

it('set node url to http://test.localhost:8114', () => {
Expand Down
217 changes: 8 additions & 209 deletions packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,32 +451,6 @@ describe('Test with mock', () => {
})
expect(res).toBe('0x4a8b4e8a4')
})
it('get capacity by lock hash', async () => {
const LOCK_HASH = '0x4ceaa32f692948413e213ce6f3a83337145bde6e11fd8cb94377ce2637dcc412'
axiosMock.mockResolvedValue({
data: {
id,
jsonrpc: '2.0',
result: {
block_number: '0x400',
capacity: '0xb00fb84df292',
cells_count: '0x3f5',
},
},
})
const res = await rpc.getCapacityByLockHash(LOCK_HASH)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_capacity_by_lock_hash',
params: [LOCK_HASH],
})
expect(res).toEqual({
blockNumber: '0x400',
capacity: '0xb00fb84df292',
cellsCount: '0x3f5',
})
})
it('get block economic state', async () => {
const BLOCK_HASH = '0x02530b25ad0ff677acc365cb73de3e8cc09c7ddd58272e879252e199d08df83b'

Expand Down Expand Up @@ -1151,184 +1125,6 @@ describe('Test with mock', () => {
})
})

it('index lock hash', async () => {
const PARAMS = ['0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674', '0x0']
axiosMock.mockResolvedValue({
data: {
jsonrpc: '2.0',
result: {
block_hash: '0x8b5de4cad43e62fdc391d897b94a97d1af369bbe2b7cbe1de20d432da5a23f4c',
block_number: '0x18',
lock_hash: '0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674',
},
id,
},
})
const res = await rpc.indexLockHash(...PARAMS)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'index_lock_hash',
params: PARAMS,
})
expect(res).toEqual({
blockHash: '0x8b5de4cad43e62fdc391d897b94a97d1af369bbe2b7cbe1de20d432da5a23f4c',
blockNumber: '0x18',
lockHash: '0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674',
})
})

it('deindex lock hash', async () => {
const LOCK_HASH = '0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674'
axiosMock.mockResolvedValue({
data: {
jsonrpc: '2.0',
result: null,
id,
},
})
const res = await rpc.deindexLockHash(LOCK_HASH)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'deindex_lock_hash',
params: [LOCK_HASH],
})
expect(res).toBeNull()
})

it('get live cells by lock hash', async () => {
const PARAMS = ['0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674', '0x0', '0x10', false]
axiosMock.mockResolvedValue({
data: {
jsonrpc: '2.0',
result: [
{
cell_output: {
capacity: '0x12479d77059e',
lock: {
args: '0xe2fa82e70b062c8644b80ad7ecf6e015e5f352f6',
code_hash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
hash_type: 'type',
},
type: null,
},
cellbase: true,
created_by: {
block_number: '0x12',
index: '0x0',
tx_hash: '0xdda2f516ebfaf1d3ff5eecd65c78a22254127606339fec4a5328099ea0ddb7db',
},
output_data_len: '0x0',
},
],
id,
},
})
const res = await rpc.getLiveCellsByLockHash(...PARAMS)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_live_cells_by_lock_hash',
params: PARAMS,
})
expect(res).toEqual([
{
cellOutput: {
capacity: '0x12479d77059e',
lock: {
args: '0xe2fa82e70b062c8644b80ad7ecf6e015e5f352f6',
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
hashType: 'type',
},
type: null,
},
cellbase: true,
createdBy: {
blockNumber: '0x12',
index: '0x0',
txHash: '0xdda2f516ebfaf1d3ff5eecd65c78a22254127606339fec4a5328099ea0ddb7db',
},
outputDataLen: '0x0',
},
])
})

it('get lock hash index states', async () => {
axiosMock.mockResolvedValue({
data: {
jsonrpc: '2.0',
result: [
{
block_hash: '0x7c7f64c875b22807451620c9d1e9af460e851ffe82d85a90e1bccb1117e2e3a4',
block_number: '0x8dd',
lock_hash: '0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674',
},
],
id,
},
})
const res = await rpc.getLockHashIndexStates()
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_lock_hash_index_states',
params: [],
})
expect(res).toEqual([
{
blockHash: '0x7c7f64c875b22807451620c9d1e9af460e851ffe82d85a90e1bccb1117e2e3a4',
blockNumber: '0x8dd',
lockHash: '0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674',
},
])
})

it('get tranactions by lock hash', async () => {
const PARAMS = ['0x0da2fe99fe549e082d4ed483c2e968a89ea8d11aabf5d79e5cbf06522de6e674', '0x0', '0x10', false]
axiosMock.mockResolvedValue({
data: {
jsonrpc: '2.0',
result: [
{
consumed_by: {
block_number: '0x67c',
index: '0x0',
tx_hash: '0xfd9170c6a55095b7f878bfbddaa726446fa91414ec6fd61e8d5275451b91d854',
},
created_by: {
block_number: '0xc',
index: '0x0',
tx_hash: '0x5b8184b27bad1238809300cb116ad85bdd2cc1ce0736d619c1468774cf27d4ce',
},
},
],
id,
},
})
const res = await rpc.getTransactionsByLockHash(...PARAMS)
expect(axiosMock.mock.calls[0][0].data).toEqual({
id,
jsonrpc: '2.0',
method: 'get_transactions_by_lock_hash',
params: PARAMS,
})
expect(res).toEqual([
{
consumedBy: {
blockNumber: '0x67c',
index: '0x0',
txHash: '0xfd9170c6a55095b7f878bfbddaa726446fa91414ec6fd61e8d5275451b91d854',
},
createdBy: {
blockNumber: '0xc',
index: '0x0',
txHash: '0x5b8184b27bad1238809300cb116ad85bdd2cc1ce0736d619c1468774cf27d4ce',
},
},
])
})

it('get banned addresses', async () => {
axiosMock.mockResolvedValue({
data: {
Expand Down Expand Up @@ -1713,13 +1509,16 @@ describe('Test with mock', () => {
})

it('should accept params in list', () => {
const multiParamBatch = rpc.createBatchRequest([['getLiveCellsByLockHash', '0x0', '0x1', '0x2'], ['getPeers']])
expect(multiParamBatch).toEqual([['getLiveCellsByLockHash', '0x0', '0x1', '0x2'], ['getPeers']])
multiParamBatch.add('getLiveCellsByLockHash', '0x0', '0x1', '0x2')
const multiParamBatch = rpc.createBatchRequest([
['setBan', 'address', 'insert', null, true, 'mock request'],
['getPeers'],
])
expect(multiParamBatch).toEqual([['setBan', 'address', 'insert', null, true, 'mock request'], ['getPeers']])
multiParamBatch.add('setBan', 'address', 'delete')
expect(multiParamBatch).toEqual([
['getLiveCellsByLockHash', '0x0', '0x1', '0x2'],
['setBan', 'address', 'insert', null, true, 'mock request'],
['getPeers'],
['getLiveCellsByLockHash', '0x0', '0x1', '0x2'],
['setBan', 'address', 'delete'],
])
})

Expand Down
8 changes: 4 additions & 4 deletions packages/ckb-sdk-rpc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-sdk-rpc",
"version": "0.39.0",
"version": "0.40.0",
"description": "RPC module of @nervosnetwork/ckb-sdk-core",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js/packages/ckb-rpc#readme",
Expand Down Expand Up @@ -33,12 +33,12 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.39.0",
"@nervosnetwork/ckb-sdk-utils": "0.40.0",
"axios": "0.21.1",
"tslib": "2.0.1"
},
"devDependencies": {
"@nervosnetwork/ckb-types": "0.39.0"
"@nervosnetwork/ckb-types": "0.40.0"
},
"gitHead": "94af87551108a40f79c1cead0db5d3cc5c679302"
"gitHead": "91badc4ec74bbcb4365b632348f1bbc7a5377adf"
}
Loading

0 comments on commit c265757

Please sign in to comment.