Skip to content

Commit

Permalink
Merge pull request #264 from cryptape/release/v1.0.0
Browse files Browse the repository at this point in the history
Release/v1.0.0
  • Loading branch information
dont-see-big-shark authored Nov 6, 2019
2 parents 62b4763 + 6b7d1cb commit 95e86ce
Show file tree
Hide file tree
Showing 17 changed files with 24,698 additions and 12,735 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: true
node_js:
- '9.4.0'
- '10.16'
cache:
directories:
- /*/**/node_modules
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# [v1.0.0](https://github.com/cryptape/cita-sdk-js/releases/tag/@cryptape/[email protected])


### Bug Fixes

* fix bug of pass private key without 0x to nervos.appchain.accounts.privateKeyToAccount ([2d5d545](https://github.com/cryptape/cita-sdk-js/commit/2d5d545df12aa229e04b4a6daf75b8a3eb903e90))
* fix chain manage contract address ([12b4558](https://github.com/cryptape/cita-sdk-js/commit/12b4558dbc6ead33f59f777cf1312ca50a8df43d))
* fix hex to bytes ([2c0fb1b](https://github.com/cryptape/cita-sdk-js/commit/2c0fb1b9f546f2f26055d7b1856c0a99f45f96f3))
* fix neuron web address error text ([c1cb96d](https://github.com/cryptape/cita-sdk-js/commit/c1cb96dc181b0b5a53c282b4e39cc6c8b79d75d0))
* fix quota in test ([e328ef8](https://github.com/cryptape/cita-sdk-js/commit/e328ef8c669552c029dc814bcde59e303a0785b6))
* fix setProvider ([f093aa9](https://github.com/cryptape/cita-sdk-js/commit/f093aa999b2fbda1d2045978feee27a3ebaab8c5))
* fix sign flow ([9405148](https://github.com/cryptape/cita-sdk-js/commit/9405148462331cf8efb21de7f7f6c3c3202e6724))
* fix test for 0.17 fix ([097b823](https://github.com/cryptape/cita-sdk-js/commit/097b82368f71de2fab08427ad7c191877927f4f7))
* fix travis cache ([75b3068](https://github.com/cryptape/cita-sdk-js/commit/75b3068fc9257fad557dd39a63b16e3203f3ee03))
* **contract:** update contract subscription methods ([a9d5939](https://github.com/cryptape/cita-sdk-js/commit/a9d59390c3f2ca430c86b268325091411c489ffc))
* **signer:** padding result of bytes2hex with 0 ([d58286b](https://github.com/cryptape/cita-sdk-js/commit/d58286b2f10417089bf5b2a806a2ee64354c0034))
* ignore event signature in getLogs method ([e0eef49](https://github.com/cryptape/cita-sdk-js/commit/e0eef499bb7b73032f9616b4d830f1667c44ce08))
* update test cases ([0e28e78](https://github.com/cryptape/cita-sdk-js/commit/0e28e786ee96aa53ab366fdc9a56c3f4211cd3b4))


### Features

* support SM2 signature and SM3 hash ([a94cd999](https://github.com/cryptape/cita-sdk-js/pull/222))
* add log on debugger ready ([a82ec1d](https://github.com/cryptape/cita-sdk-js/commit/a82ec1d4ffab37a47bde361b2b8f21fea2477d3a))
* update web3 deps ([b4f6460](https://github.com/cryptape/cita-sdk-js/commit/b4f6460ad9b1d527ea5f420c551ada0414039341))
* **rpc:** add two rpc methods ([0aa093e](https://github.com/cryptape/cita-sdk-js/commit/0aa093e2228a88b84524bc62d131228a67cd3dbe))
* **signer:** support cita v2 ([1dfae4d](https://github.com/cryptape/cita-sdk-js/commit/1dfae4d6929508966ced54fcb2d5762ac75b63dd))
* **signer:** update cita-proto ([5ac68dc](https://github.com/cryptape/cita-sdk-js/commit/5ac68dc3f5c4b6842894aea0e54ff7b3750e75ae))


### Performance Improvements

* update neuron-web start time ([8b42137](https://github.com/cryptape/cita-sdk-js/commit/8b421373ef2afe5bd0bb44d52881fbfde27cd04d))



# [v0.25.0](https://github.com/cryptape/cita-sdk-js/releases/tag/@cryptape/[email protected]) ([compare](https://github.com/cryptape/cita-sdk-js/compare/@cryptape/[email protected]...@cryptape/[email protected]))

### Changed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cross-env": "^5.2.0",
"cz-conventional-changelog": "2.1.0",
"dotenv": "^8.0.0",
"eslint": "^4.19.1",
"eslint": "^6.6.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.12.0",
Expand All @@ -47,7 +47,7 @@
"prettier": "^1.13.3",
"protoc": "^1.0.3",
"ts-node": "^8.2.0",
"ts-protoc-gen": "^0.10.0",
"ts-protoc-gen": "^0.12.0",
"typedoc": "^0.15.0",
"types-bn": "^0.0.1",
"typescript": "^3.1.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/cita-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cita-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cryptape/cita-sdk",
"version": "0.25.1",
"version": "1.0.0",
"main": "lib/index.js",
"repository": "https://github.com/cryptape/cita-sdk-js/tree/master/packages/cita-sdk",
"author": "Keith <[email protected]>",
Expand Down Expand Up @@ -35,7 +35,7 @@
"typedoc": "^0.15.0"
},
"dependencies": {
"@cryptape/cita-signer": "^2.5.2",
"@cryptape/cita-signer": "^2.6.0",
"fstream": "1.0.12",
"web3": "1.0.0-beta.37"
},
Expand Down
10 changes: 9 additions & 1 deletion packages/cita-sdk/src/utils/patchPrivateKeyToAccount.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { CryptoTx } from '@cryptape/cita-signer/lib/enum'

import { accountSignedBySm2 } from './sm2Utils'
export default (web3: any) => {
web3.eth.accounts.privateKeyToAccount = new Proxy(
web3.eth.accounts.privateKeyToAccount,
{
apply: (target: Function, _thisArg: any, argumentsList: string[]) => {
apply: (target: Function, _thisArg: any, argumentsList: any[]) => {
let privateKey = argumentsList[0]
if (privateKey && privateKey.length === 64) {
privateKey = '0x' + privateKey
}
if (argumentsList[1] === CryptoTx.SM2) {
return accountSignedBySm2(target.call(_thisArg, privateKey));
}

return target.call(_thisArg, privateKey)
}
}
)
}

18 changes: 18 additions & 0 deletions packages/cita-sdk/src/utils/sm2Utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { bytes2hex, hex2bytes, sm2, sm3 } from '@cryptape/cita-signer/lib'
import { Account } from 'web3/eth/accounts'

export const privateKeyToPublicKeyBySM2 = (privateKey: string): string => {
const key = privateKey.replace(/^0x/, '')
return sm2.SM2KeyPair(null, key).pubToString()
}

export const publicKeyToAddressSM2 = (publicKey: string): string => {
return `0x${bytes2hex(sm3().sum(hex2bytes(publicKey.slice(2))))
.slice(-40)
.toLowerCase()}`
}
export function accountSignedBySm2(account: Account) {
const pubKey = privateKeyToPublicKeyBySM2(account.privateKey)
account.address = publicKeyToAddressSM2(pubKey)
return account
}
29 changes: 21 additions & 8 deletions packages/cita-signer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/cita-signer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cryptape/cita-signer",
"version": "2.5.2",
"version": "2.6.0",
"main": "lib/index.js",
"private": false,
"repository": "https://github.com/cryptape/cita-sdk-js/tree/master/packages/cita-signer",
Expand All @@ -19,10 +19,11 @@
"elliptic": "^6.4.0",
"fstream": "1.0.12",
"google-protobuf": "^3.5.0",
"sm-series-crypto": "^0.2.1",
"web3": "1.0.0-beta.37"
},
"devDependencies": {
"ts-protoc-gen": "^0.10.0"
"ts-protoc-gen": "^0.12.0"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 3 additions & 0 deletions packages/cita-signer/src/enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum CryptoTx {
SECP256K1, SM2
}
Loading

0 comments on commit 95e86ce

Please sign in to comment.