Skip to content

Commit

Permalink
Merge pull request #247 from nervosnetwork/rc/v0.14.0
Browse files Browse the repository at this point in the history
[ᚬmaster] Release v0.14.0
  • Loading branch information
Keith-CY authored Jun 15, 2019
2 parents fe22f3a + e983da2 commit 8372c9f
Show file tree
Hide file tree
Showing 29 changed files with 849 additions and 406 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.14.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.13.0...v0.14.0) (2019-06-15)


### Features

* **types:** remove the args field in cell input type ([d07f253](https://github.com/nervosnetwork/ckb-sdk-js/commit/d07f253))
* **core:** add signWitnesses and signTransaction methods in the core module ([c20d36c](https://github.com/nervosnetwork/ckb-sdk-js/commit/c20d36c))


### BREAKING CHANGES

* **types:** the type of cell input changes, its args field is removed.





# [0.13.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.12.0...v0.13.0) (2019-06-01)


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.13.0"
"version": "0.14.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.14.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.13.0...v0.14.0) (2019-06-15)

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





# [0.13.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.12.0...v0.13.0) (2019-06-01)

**Note:** Version bump only for package @nervosnetwork/ckb-cli
Expand Down
6 changes: 3 additions & 3 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.13.0",
"version": "0.14.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,13 +34,13 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-core": "0.13.0",
"@nervosnetwork/ckb-sdk-core": "0.14.0",
"commander": "2.20.0",
"inquirer": "6.2.1"
},
"devDependencies": {
"@types/crypto-js": "3.1.43",
"@types/inquirer": "6.0.0"
},
"gitHead": "fed4580b376c2826d9b565afebaa56c402b56216"
"gitHead": "4fcb80e6068f9219076005435445a41333c00ea9"
}
8 changes: 8 additions & 0 deletions packages/ckb-sdk-address/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.14.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.13.0...v0.14.0) (2019-06-15)

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





# [0.13.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.12.0...v0.13.0) (2019-06-01)


Expand Down
8 changes: 4 additions & 4 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.13.0",
"version": "0.14.0",
"description": "Address module of @nervosnetwork/ckb-sdk-core",
"keywords": [
"CKB",
Expand Down Expand Up @@ -33,8 +33,8 @@
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.13.0",
"@nervosnetwork/ckb-types": "0.13.0"
"@nervosnetwork/ckb-sdk-utils": "0.14.0",
"@nervosnetwork/ckb-types": "0.14.0"
},
"gitHead": "fed4580b376c2826d9b565afebaa56c402b56216"
"gitHead": "4fcb80e6068f9219076005435445a41333c00ea9"
}
2 changes: 1 addition & 1 deletion packages/ckb-sdk-address/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Address extends ECPair {
type,
binIdx,
})
this.idenfitier = blake160(this.publicKey as string, 'hex') as string
this.idenfitier = blake160(this.publicKey as string, 'hex')
}
}

Expand Down
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.14.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.13.0...v0.14.0) (2019-06-15)

* **core:** add signWitnesses and signTransaction methods in the core module ([c20d36c](https://github.com/nervosnetwork/ckb-sdk-js/commit/c20d36c))





# [0.13.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.12.0...v0.13.0) (2019-06-01)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-core
Expand Down
4 changes: 2 additions & 2 deletions packages/ckb-sdk-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

`@nervosnetwork/ckb-sdk-core` is the JavaScript SDK for Nervos Network [CKB Project](https://github.com/nervosnetwork/ckb)

# More Information
## More Information

[README.md](../../README.md)
[README.md](https://github.com/nervosnetwork/ckb-sdk-js/blob/develop/README.md)
105 changes: 78 additions & 27 deletions packages/ckb-sdk-core/__tests__/ckb-core.test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,86 @@
const successFixtures = require('./successFixtures.json')
const exceptionFixtures = require('./exceptionFixtures.json')

const Core = require('../lib').default

const url = 'http://localhost:8114'
const core = new Core(url)

describe('ckb-core', () => {
const fixture = {
empty: {
codeHash: '',
outPoint: {
blockHash: '',
cell: {
txHash: '',
index: '0',
},
},
},
target: {
codeHash: '9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08',
outPoint: {
blockHash: 'aad9b82caa07f5989dfb8caa44927f0bab515a96ccaaceba82c7bea609fec205',
cell: {
txHash: 'bffab7ee0a050e2cb882de066d3dbf3afdd8932d6a26eda44f06e4b23f0f4b5a',
index: '1',
},
},
},
}
it('load the system cell', async () => {
expect(core.config.systemCellInfo).toEqual(fixture.empty)

const systemCellInfo = await core.loadSystemCell()
expect(systemCellInfo).toEqual(fixture.target)
describe('success', () => {
it('load the system cell', async () => {
const fixture = successFixtures.loadSystemCell
expect(core.config.systemCellInfo).toEqual(fixture.emptyInfo)

const systemCellInfo = await core.loadSystemCell()
expect(systemCellInfo).toEqual(fixture.target)
})

it('sign witnesses', () => {
const fixture = successFixtures.signWitnesses
const signedWitnessesByPrivateKey = core.signWitnesses(fixture.privateKey)(fixture.message)
expect(signedWitnessesByPrivateKey).toEqual(fixture.target)

const signedWitnessesByAddressObject = core.signWitnesses(core.generateAddress(fixture.privateKey))(
fixture.message
)
expect(signedWitnessesByAddressObject).toEqual(fixture.target)
})

it('sign transaction', async () => {
const fixture = successFixtures.signTransaction
const signedTransactionWithPrivateKey = await core.signTransaction(fixture.privateKey)(fixture.transaction)
const signedTransactionWithAddressObj = await core.signTransaction(core.generateAddress(fixture.privateKey))(
fixture.transaction
)
expect(signedTransactionWithPrivateKey).toEqual(fixture.target)
expect(signedTransactionWithAddressObj).toEqual(fixture.target)
})
})

describe('exceptions', () => {
describe('sign witneses', () => {
it('throw an error when key is missing', () => {
const fixture = exceptionFixtures.signWitnessesWithoutKey
expect(() => core.signWitnesses(fixture.privateKey)(fixture.message)).toThrowError(fixture.exception)
})

it('throw an error when transaction hash is missing', () => {
const fixture = exceptionFixtures.signWitnessesWithoutTransactionHash
expect(() => core.signWitnesses(fixture.privateKey)(fixture.message)).toThrowError(fixture.exception)
})
})

describe('sign transaction', () => {
it('throw an error when key is missing', () => {
const fixture = exceptionFixtures.signTransactionWithoutKey
expect(core.signTransaction(fixture.privateKey)(fixture.transaction)).rejects.toEqual(
new Error(fixture.exception)
)
})

it('throw an error when trasnaction is missing', () => {
const fixture = exceptionFixtures.signTransactionWithoutTransaction
expect(core.signTransaction(fixture.privateKey)(fixture.transaction)).rejects.toEqual(
new Error(fixture.exception)
)
})

it('throw an error when witnesses is missing', () => {
const fixture = exceptionFixtures.signTransactionWithoutWitnesses
console.log(!fixture.transaction.witnesses)
expect(core.signTransaction(fixture.privateKey)(fixture.transaction)).rejects.toEqual(
new Error(fixture.exception)
)
})

it('throw an error with invalid cound of witnesses', () => {
const fixture = exceptionFixtures.signTransactionWithInvalidCountOfWitnesses
console.log(!fixture.transaction.witnesses)
expect(core.signTransaction(fixture.privateKey)(fixture.transaction)).rejects.toEqual(
new Error(fixture.exception)
)
})
})
})
})
Loading

0 comments on commit 8372c9f

Please sign in to comment.