Skip to content

Commit

Permalink
Merge pull request #609 from ckb-js/rc/v0.107.0
Browse files Browse the repository at this point in the history
Release v0.107.0
  • Loading branch information
Keith-CY authored Apr 3, 2023
2 parents 7f3c4dc + 4b91f36 commit 7aaa356
Show file tree
Hide file tree
Showing 41 changed files with 1,376 additions and 3,053 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v2-beta
with:
node-version: 14
node-version: 16

- name: Restore
uses: actions/cache@v2
Expand All @@ -25,12 +25,9 @@ jobs:
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install Lerna
run: npm install -g lerna

- name: Install Deps
run: lerna bootstrap --mutex file:/tmp/.yarn-mutex --concurrency=1;
run: npx lerna bootstrap --mutex file:/tmp/.yarn-mutex --concurrency=1;

- name: Compile
run: |
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,45 @@ jobs:
default:
strategy:
matrix:
node: [12, 14, 16]
node: [16, 18]
os: [macos-latest, ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- name: Skip when run node.js@18 on ubuntu for compatibility reason
id: is_skip
if: matrix.os == 'ubuntu-18.04' && matrix.node == '18'
run: echo 'IS_SKIP=true' >> $GITHUB_OUTPUT

- uses: actions/checkout@v2
if: ${{ steps.is_skip.outputs.IS_SKIP != 'true' }}

- name: Setup Node
if: ${{ steps.is_skip.outputs.IS_SKIP != 'true' }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node }}

- name: Restore
if: ${{ steps.is_skip.outputs.IS_SKIP != 'true' }}
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install Lerna
run: npm install -g lerna

- name: Install Deps
run: lerna bootstrap --mutex file:/tmp/.yarn-mutex --concurrency=1;
if: ${{ steps.is_skip.outputs.IS_SKIP != 'true' }}
run: npx lerna bootstrap --mutex file:/tmp/.yarn-mutex --concurrency=1;

- name: Compile
run: lerna run tsc
if: ${{ steps.is_skip.outputs.IS_SKIP != 'true' }}
run: npx lerna run tsc

- name: Test
if: ${{ steps.is_skip.outputs.IS_SKIP != 'true' }}
run: yarn run test

- name: Upload codecov
if: matrix.os == 'macos-latest' && matrix.node == '14'
uses: codecov/codecov-action@v1
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.107.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.103.1...v0.107.0) (2023-04-03)


### Features

* Sign support multisig. ([#593](https://github.com/nervosnetwork/ckb-sdk-js/issues/593)) ([3ad7abd](https://github.com/nervosnetwork/ckb-sdk-js/commit/3ad7abde0b29e65898b4a93976002b1275caac60))
* add rpc of "get_fee_rate_statics" ([#608](https://github.com/ckb-js/ckb-sdk-js/pull/608))





## [0.103.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.102.3...v0.103.1) (2022-05-31)


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.103.1"
"version": "0.107.0"
}
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"packages/*"
],
"scripts": {
"bootstrap": "lerna bootstrap",
"tsc": "lerna run tsc",
"bootstrap": "npx lerna bootstrap",
"tsc": "npx lerna run tsc",
"cm": "git-cz",
"build:lib": "lerna run tsc",
"build:lib": "npx lerna run tsc",
"build:umd": "./scripts/bundle-umd.sh",
"clean:lib": "rimraf **/packages/*/lib",
"docs": "typedoc --out docs --entryPointStrategy packages 'packages/*' --name CKB-SDK.js --excludeExternals --theme default --readme README.md",
"publish": "lerna run tsc && lerna publish --from-package",
"publish": "npx lerna run tsc && npx lerna publish --from-package",
"test": "jest --coverage"
},
"husky": {
Expand Down Expand Up @@ -41,7 +41,6 @@
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.2",
"jest": "27.2.4",
"lerna": "4.0.0",
"lint-staged": "11.1.2",
"prettier": "2.4.1",
"rimraf": "3.0.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/ckb-sdk-core/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.107.0](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.103.1...v0.107.0) (2023-04-03)


### Features

* Sign support multisig. ([#593](https://github.com/nervosnetwork/ckb-sdk-js/issues/593)) ([3ad7abd](https://github.com/nervosnetwork/ckb-sdk-js/commit/3ad7abde0b29e65898b4a93976002b1275caac60))





## [0.103.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.102.3...v0.103.1) (2022-05-31)

**Note:** Version bump only for package @nervosnetwork/ckb-sdk-core
Expand Down
149 changes: 149 additions & 0 deletions packages/ckb-sdk-core/__tests__/multisig/fixtures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"serializeMultisigConfig": {
"exception with config is less than 0": {
"config": {
"r": -1,
"m": 2,
"n": 3,
"blake160s": []
},
"exception": "For multisig sign, signer should between 0 and 255"
},
"exception with config is grater than 255": {
"config": {
"r": 256,
"m": 2,
"n": 3,
"blake160s": []
},
"exception": "For multisig sign, signer should between 0 and 255"
},
"exception with r shouldn't be greater than n": {
"config": {
"r": 3,
"m": 2,
"n": 3,
"blake160s": []
},
"exception": "For m of n multisig sign, r shouldn't be greater than m"
},
"exception with m is greater than n": {
"config": {
"r": 1,
"m": 4,
"n": 3,
"blake160s": []
},
"exception": "For m of n multisig sign, m shouldn't be greater than n"
},
"exception blake160s length not equal with n": {
"config": {
"r": 1,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1"]
},
"exception": "For m of n multisig sign, signer's length should equal with n"
},
"test serializeMultisigConfig": {
"config": {
"r": 1,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xb7672fcde903607f6bb150a730085c2a43c422fa", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1"]
},
"expected": "0x000102037c021957a27000e794f25828270f187c791443e3b7672fcde903607f6bb150a730085c2a43c422fad93b3564ef1b2dcf7bca781f968b3c7d2db85fd1"
}
},
"hashMultisig": {
"normal": {
"config": {
"r": 0,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"]
},
"expected": "0xe7db180742a9b5c4f2d9319d74982503fbc88a37"
}
},
"getMultisigStatus": {
"Unsigned": {
"config": {
"r": 0,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"]
},
"signatures": [],
"expected": "Unsigned"
},
"PartiallySigned": {
"config": {
"r": 0,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"]
},
"signatures": ["0x7c021957a27000e794f25828270f187c791443e3"],
"expected": "PartiallySigned"
},
"Signed": {
"config": {
"r": 0,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"]
},
"signatures": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1"],
"expected": "Signed"
},
"exception with More signature for multisig, all signatures overflow": {
"config": {
"r": 1,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"]
},
"signatures": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"],
"exception": "More signature for multisig"
},
"exception with More signature for multisig, m signatures overflow": {
"config": {
"r": 1,
"m": 1,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3", "0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1", "0xb7672fcde903607f6bb150a730085c2a43c422fa"]
},
"signatures": ["0xd93b3564ef1b2dcf7bca781f968b3c7d2db85fd1"],
"exception": "More signature for multisig"
}
},
"isMultisigConfig": {
"false with loss field": {
"config": {
"m": "2",
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3"]
},
"expected": false
},
"false with unmatch field type": {
"config": {
"r": "a",
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3"]
},
"expected": false
},
"success": {
"config": {
"r": 0,
"m": 2,
"n": 3,
"blake160s": ["0x7c021957a27000e794f25828270f187c791443e3"]
},
"expected": true
}
}
}
85 changes: 85 additions & 0 deletions packages/ckb-sdk-core/__tests__/multisig/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const { serializeMultisigConfig, hashMultisig, getMultisigStatus, isMultisigConfig } = require('../../lib/multisig')
const fixtures = require('./fixtures.json')

describe('test serializeMultisigConfig', () => {
const serializeMultisigConfigTable = Object.entries(fixtures.serializeMultisigConfig).map(
([title, { config, expected, exception }]) => [
title,
config,
exception,
expected
],
)
test.each(serializeMultisigConfigTable)(
'%s',
(_title, config, exception, expected) => {
if (exception !== undefined) {
expect(() =>serializeMultisigConfig(config)).toThrowError(exception)
} else {
const result = serializeMultisigConfig(config)
expect(result).toEqual(expected)
}
},
)
})
describe('test hashMultisig', () => {
const hashMultisigTable = Object.entries(fixtures.hashMultisig).map(
([title, { config, expected, exception }]) => [
title,
config,
exception,
expected
],
)

test.each(hashMultisigTable)(
'%s',
(_title, config, exception, expected) => {
if (exception !== undefined) {
expect(() => hashMultisig(config)).toThrowError(exception)
} else {
const result = hashMultisig(config)
expect(result).toEqual(expected)
}
},
)
})
describe('test getMultisigStatus', () => {
const table = Object.entries(fixtures.getMultisigStatus).map(
([title, { config, signatures, expected, exception }]) => [
title,
config,
signatures,
exception,
expected
],
)

test.each(table)(
'%s',
(_title, config, signatures, exception, expected) => {
if (exception !== undefined) {
expect(() =>getMultisigStatus(config, signatures)).toThrowError(exception)
} else {
const result = getMultisigStatus(config, signatures)
expect(result).toEqual(expected)
}
},
)
})
describe('test isMultisigConfig', () => {
const table = Object.entries(fixtures.isMultisigConfig).map(
([title, { config, expected }]) => [
title,
config,
expected
],
)

test.each(table)(
'%s',
(_title, config, expected) => {
expect(isMultisigConfig(config)).toEqual(expected)
},
)
})
Loading

0 comments on commit 7aaa356

Please sign in to comment.