Skip to content

Commit

Permalink
Merge pull request #351 from nervosnetwork/rc/v0.21.0
Browse files Browse the repository at this point in the history
[ᚬmaster] Rc/v0.21.0
  • Loading branch information
Keith-CY authored Sep 21, 2019
2 parents 71040c0 + 7ef0c9a commit 30e8b6a
Show file tree
Hide file tree
Showing 62 changed files with 3,137 additions and 2,529 deletions.
13 changes: 1 addition & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,7 @@ module.exports = {
}],
"max-len": [2, 120],
"object-curly-newline": ["error", {
"ObjectExpression": {
"minProperties": 1,
"multiline": true
},
"ObjectPattern": {
"consistent": true
},
"ImportDeclaration": "never",
"ExportDeclaration": {
"multiline": true,
"minProperties": 3
}
"consistent": true
}]
},
"globals": {
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.21.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.20.0...v0.21.0) (2019-09-21)


### Code Refactoring

* **address** rename public key identifier to publicKeyHash ([b33c096](https://github.com/nervosnetwork/ckb-sdk-js/commit/b33c096))


### Features

* **rpc:** format the outputs of the params formatter ([740b403](https://github.com/nervosnetwork/ckb-sdk-js/commit/740b403))
* **rpc:** update the interface of getLiveCell ([0280d7f](https://github.com/nervosnetwork/ckb-sdk-js/commit/0280d7f))
* **utils:** format the outputs of the utils module ([a30071c](https://github.com/nervosnetwork/ckb-sdk-js/commit/a30071c))


### BREAKING CHANGES

* **rpc:** update the interface of getLiveCell
* **address** rename public key identifier to publicKeyHash
* **rpc:** hexilize the outputs of the params formatter
* **utils:** hexilize the outputs of the utils module





# [0.20.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.1...v0.20.0) (2019-09-07)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"packages": [
"packages/*"
],
"version": "0.20.0"
"version": "0.21.0"
}
8 changes: 8 additions & 0 deletions packages/ckb-cli/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.21.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.20.0...v0.21.0) (2019-09-21)

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





# [0.20.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.1...v0.20.0) (2019-09-07)

**Note:** Version bump only for package @nervosnetwork/ckb-cli
Expand Down
8 changes: 4 additions & 4 deletions packages/ckb-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-cli",
"version": "0.20.0",
"version": "0.21.0",
"description": "Command line package based on @nervosnetwork/ckb-sdk-core",
"author": "Nervos <[email protected]>",
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme",
Expand Down Expand Up @@ -34,15 +34,15 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-core": "0.20.0",
"@nervosnetwork/ckb-sdk-core": "0.21.0",
"blessed": "0.1.81",
"blessed-contrib": "4.8.16",
"commander": "2.20.0",
"inquirer": "6.2.1"
"inquirer": "6.5.2"
},
"devDependencies": {
"@types/blessed": "0.1.12",
"@types/inquirer": "6.5.0"
},
"gitHead": "478433630dd40501f1f67dc259bf9d252c56fcd3"
"gitHead": "5a1aaff6006c91e45e8ba39ceb6ef7c2f870e6cd"
}
16 changes: 16 additions & 0 deletions packages/ckb-sdk-address/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.21.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.20.0...v0.21.0) (2019-09-21)


### Code Refactoring

* **address** rename public key identifier to publicKeyHash ([b33c096](https://github.com/nervosnetwork/ckb-sdk-js/commit/b33c096))


### BREAKING CHANGES

* **address** rename public key identifier to publicKeyHash





# [0.20.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.1...v0.20.0) (2019-09-07)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-address
Expand Down
59 changes: 0 additions & 59 deletions packages/ckb-sdk-address/__tests__/ckb-sdk-address.test.js

This file was deleted.

76 changes: 76 additions & 0 deletions packages/ckb-sdk-address/__tests__/fixtures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"generateAddress": {
"with default configuration": {
"privateKey": "0xe79f3207ea4980b7fed79956d5934249ceac4751a4fae01a0f7c4a96884bc4e3",
"expected": {
"publicKeyHash": "0x36c329ed630d6ce750712a477543672adab57f4c",
"address": "ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83"
}
},
"with specified prefix": {
"privateKey": "0xe79f3207ea4980b7fed79956d5934249ceac4751a4fae01a0f7c4a96884bc4e3",
"prefix": "ckt",
"expected": {
"publicKeyHash": "0x36c329ed630d6ce750712a477543672adab57f4c",
"address": "ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83"
}
},
"with specified type of 0x01": {
"privateKey": "0xe79f3207ea4980b7fed79956d5934249ceac4751a4fae01a0f7c4a96884bc4e3",
"type": "0x01",
"expected": {
"publicKeyHash": "0x36c329ed630d6ce750712a477543672adab57f4c",
"address": "ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83"
}
},
"with specified type of 0x01 and code hash of 0x00": {
"privateKey": "0xe79f3207ea4980b7fed79956d5934249ceac4751a4fae01a0f7c4a96884bc4e3",
"type": "0x01",
"codeHashIndex": "0x00",
"expected": {
"publicKeyHash": "0x36c329ed630d6ce750712a477543672adab57f4c",
"address": "ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83"
}
},
"with private key in bytes format": {
"privateKey": [
231,
159,
50,
7,
234,
73,
128,
183,
254,
215,
153,
86,
213,
147,
66,
73,
206,
172,
71,
81,
164,
250,
224,
26,
15,
124,
74,
150,
136,
75,
196,
227
],
"expected": {
"publicKeyHash": "0x36c329ed630d6ce750712a477543672adab57f4c",
"address": "ckt1qyqrdsefa43s6m882pcj53m4gdnj4k440axqswmu83"
}
}
}
}
22 changes: 22 additions & 0 deletions packages/ckb-sdk-address/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { default: Address } = require('../lib')
const { generateAddress: generateAddressFixtures } = require('./fixtures.json')

describe('ckb-sdk-address', () => {
describe('generate address', () => {
const fixtureTable = Object.entries(generateAddressFixtures).map(
([title, { privateKey, expected, exception, ...config }]) => [title, privateKey, config, expected, exception]
)

test.each(fixtureTable)('%s', (_title, privateKey, config, expected, exception) => {
const option = Object.keys(config).length ? config : undefined
if (undefined !== expected) {
const address = new Address(privateKey, option)
expect(address.publicKeyHash).toBe(expected.publicKeyHash)
expect(address.value).toBe(expected.address)
}
if (undefined !== exception) {
expect(() => new Address(privateKey, option)).toThrow(new Error(exception))
}
})
})
})
10 changes: 5 additions & 5 deletions packages/ckb-sdk-address/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/ckb-sdk-address",
"version": "0.20.0",
"version": "0.21.0",
"description": "Address module of @nervosnetwork/ckb-sdk-core",
"keywords": [
"CKB",
Expand All @@ -27,14 +27,14 @@
},
"scripts": {
"tsc": "tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
"test": "../../node_modules/.bin/jest"
},
"bugs": {
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.20.0",
"@nervosnetwork/ckb-types": "0.20.0"
"@nervosnetwork/ckb-sdk-utils": "0.21.0",
"@nervosnetwork/ckb-types": "0.21.0"
},
"gitHead": "478433630dd40501f1f67dc259bf9d252c56fcd3"
"gitHead": "5a1aaff6006c91e45e8ba39ceb6ef7c2f870e6cd"
}
8 changes: 4 additions & 4 deletions packages/ckb-sdk-address/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import ECPair from '@nervosnetwork/ckb-sdk-utils/lib/ecpair'
import * as utils from '@nervosnetwork/ckb-sdk-utils'
import { AddressOptions } from '@nervosnetwork/ckb-sdk-utils/lib/address'

const { hexToBytes, pubkeyToAddress, blake160, AddressPrefix, AddressType } = utils
const { pubkeyToAddress, blake160, AddressPrefix, AddressType } = utils

class Address extends ECPair {
public value = ''

public identifier = ''
public publicKeyHash = ''

public constructor(
sk: Uint8Array | string,
Expand All @@ -27,13 +27,13 @@ class Address extends ECPair {
codeHashIndex: '0x00',
}
) {
super(typeof sk === 'string' ? hexToBytes(sk) : sk)
super(sk)
this.value = addressAlgorithm(this.publicKey, {
prefix,
type,
codeHashIndex,
})
this.identifier = blake160(this.publicKey as string, 'hex')
this.publicKeyHash = `0x${blake160(this.publicKey as string, 'hex')}`
}
}

Expand Down
16 changes: 16 additions & 0 deletions packages/ckb-sdk-core/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.21.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.20.0...v0.21.0) (2019-09-21)


### Code Refactoring

* **address** rename public key identifier to publicKeyHash ([b33c096](https://github.com/nervosnetwork/ckb-sdk-js/commit/b33c096))


### BREAKING CHANGES

* **address** rename public key identifier to publicKeyHash





# [0.20.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.19.1...v0.20.0) (2019-09-07)

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

0 comments on commit 30e8b6a

Please sign in to comment.