From 2cb008f1e5102d252ffa7fdcce7dae0162c80ddd Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 18 Feb 2022 13:00:31 +0800 Subject: [PATCH 1/5] docs: update docs link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac50df43..e3b6d367 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![License](https://img.shields.io/npm/l/@nervosnetwork/ckb-sdk-core.svg)](./LICENSE) [![Telegram Group](https://cdn.rawgit.com/Patrolavia/telegram-badge/8fe3382b/chat.svg)](https://t.me/nervos_ckb_dev) [![SNYK](https://github.com/nervosnetwork/ckb-sdk-js/workflows/SNYK/badge.svg)](https://github.com/nervosnetwork/ckb-sdk-js/actions?query=workflow%3ASNYK) -[![Deploy Docs](https://github.com/nervosnetwork/ckb-sdk-js/workflows/Deploy%20Docs/badge.svg)](https://nervosnetwork.github.io/ckb-sdk-js/classes/ckb.html) +[![Deploy Docs](https://github.com/nervosnetwork/ckb-sdk-js/workflows/Deploy%20Docs/badge.svg)](https://nervosnetwork.github.io/ckb-sdk-js/classes/_nervosnetwork_ckb_sdk_core.default.html) JavaScript SDK for Nervos [CKB](https://github.com/nervosnetwork/ckb). From 674dfa575571a835911410b1d6a12f8cf5999170 Mon Sep 17 00:00:00 2001 From: yanguoyu <841185308@qq.com> Date: Wed, 2 Mar 2022 14:24:15 +0800 Subject: [PATCH 2/5] implement rpc calculate_dao_maximum_withdraw in sdk (#578) --- packages/ckb-sdk-core/__tests__/index.test.js | 127 ++++++++++++++++++ packages/ckb-sdk-core/src/index.ts | 31 +++++ .../__tests__/convertors/index.test.js | 6 +- .../__tests__/utils/index.test.js | 33 ++++- .../__tests__/utils/occupiedCapacity.test.js | 51 +++++++ .../ckb-sdk-utils/src/convertors/index.ts | 16 ++- packages/ckb-sdk-utils/src/index.ts | 48 ++++++- .../ckb-sdk-utils/src/occupiedCapacity.ts | 10 ++ 8 files changed, 316 insertions(+), 6 deletions(-) create mode 100644 packages/ckb-sdk-utils/__tests__/utils/occupiedCapacity.test.js create mode 100644 packages/ckb-sdk-utils/src/occupiedCapacity.ts diff --git a/packages/ckb-sdk-core/__tests__/index.test.js b/packages/ckb-sdk-core/__tests__/index.test.js index 64534542..f2b8bfd2 100644 --- a/packages/ckb-sdk-core/__tests__/index.test.js +++ b/packages/ckb-sdk-core/__tests__/index.test.js @@ -176,4 +176,131 @@ describe('ckb', () => { expect(tx).toEqual(expected) }) }) + + describe('calculate dao maximum withdraw', () => { + it('normal withdraw hash', async () => { + ckb.rpc = { + getTransaction: jest.fn().mockResolvedValueOnce({ + txStatus: { status: 'committed' }, + transaction: { + outputs: [ + { + "capacity":"0xe8d4a51000", + "lock":{ + "args":"0xf601cac75568afec3b9c9af1e1ff730062007685", + "codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + "hashType":"type" + }, + "type":{ + "args":"0x", + "codeHash":"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e", + "hashType":"type" + } + } + ], + outputsData: ["0x0000000000000000","0x"] + } + }), + getHeader: jest.fn() + .mockResolvedValueOnce({ dao: '0x1aaf2ca6847c223c3ef9e8c069c9250020212a6311e2d30200609349396eb407' }) + .mockResolvedValueOnce({ dao: '0x9bafffa73e432e3c94c6f9db34cb25009f9e4efe4b5fd60200ea63c6d4ffb407' }) + } + const res = await ckb.calculateDaoMaximumWithdraw({ tx: '', index: '0x0' }, '') + expect(res).toBe('0xe8df95141e') + ckb.rpc = rpc + }) + it('another normal withdraw hash', async () => { + ckb.rpc = { + getTransaction: jest.fn().mockResolvedValueOnce({ + "transaction":{ + "outputs":[ + { + "capacity":"0x6fc23ac00", + "lock":{ + "args":"0x4cc2e6526204ae6a2e8fcf12f7ad472f41a1606d5b9624beebd215d780809f6aa10000001000000030000000990000009cdfb2824302e0cd0ee1fb4ac9849c8c2348ab84f2e7d2c6e12e8b6f5f5f378d69000000100000003000000031000000deec13a7b8e100579541384ccaf4b5223733e4a5483c3aec95ddc4c1d5ea5b2201340000004cc2e6526204ae6a2e8fcf12f7ad472f41a1606d5b9624beebd215d780809f6a153ab336340f7985b8b9e412b7968fedabd69a9cb0040000000000c0", + "codeHash":"0x5a2506bb68d81a11dcadad4cb7eae62a17c43c619fe47ac8037bc8ce2dd90360", + "hashType":"type" + }, + "type":null + }, + { + "capacity":"0x83e607de09", + "lock":{ + "args":"0x2718f00d61e6fb37eed98cfdf6b30bde38cad8f6", + "codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + "hashType":"type" + }, + "type":null + } + ], + "outputsData":[ + "0x", + "0x" + ], + }, + "txStatus":{ + "blockHash":"0x8c14f374c5934613dbb0f9cbebb0edaabe259291a08e2dd3afbb291b1b8be359", + "reason":null, + "status":"committed" + } + }), + getHeader: jest.fn() + .mockResolvedValueOnce({ dao: '0x7e9a4d29f532433cb8dbe56b64ce2500b4c9c67a3fccda020098a1f224a4b707' }) + .mockResolvedValueOnce({ dao: '0xd87090655733433c2395d67a64ce2500d73e963e54ccda0200f244c504a4b707' }) + } + const res = await ckb.calculateDaoMaximumWithdraw({index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691') + expect(res).toBe('0x6fc23ac9b') + ckb.rpc = rpc + }) + it('normal withdraw outputpoint', async () => { + ckb.rpc = { + getTransaction: jest.fn().mockResolvedValue({ + "transaction":{ + "outputs":[ + { + "capacity":"0x6fc23ac00", + "lock":{ + "args":"0x4cc2e6526204ae6a2e8fcf12f7ad472f41a1606d5b9624beebd215d780809f6aa10000001000000030000000990000009cdfb2824302e0cd0ee1fb4ac9849c8c2348ab84f2e7d2c6e12e8b6f5f5f378d69000000100000003000000031000000deec13a7b8e100579541384ccaf4b5223733e4a5483c3aec95ddc4c1d5ea5b2201340000004cc2e6526204ae6a2e8fcf12f7ad472f41a1606d5b9624beebd215d780809f6a153ab336340f7985b8b9e412b7968fedabd69a9cb0040000000000c0", + "codeHash":"0x5a2506bb68d81a11dcadad4cb7eae62a17c43c619fe47ac8037bc8ce2dd90360", + "hashType":"type" + }, + "type":null + }, + { + "capacity":"0x83e607de09", + "lock":{ + "args":"0x2718f00d61e6fb37eed98cfdf6b30bde38cad8f6", + "codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + "hashType":"type" + }, + "type":null + } + ], + "outputsData":[ + "0x", + "0x" + ], + }, + "txStatus":{ + "blockHash":"0x8c14f374c5934613dbb0f9cbebb0edaabe259291a08e2dd3afbb291b1b8be359", + "reason":null, + "status":"committed" + } + }), + getHeader: jest.fn() + .mockResolvedValueOnce({ dao: '0x7e9a4d29f532433cb8dbe56b64ce2500b4c9c67a3fccda020098a1f224a4b707' }) + .mockResolvedValueOnce({ dao: '0xd87090655733433c2395d67a64ce2500d73e963e54ccda0200f244c504a4b707' }) + } + const res = await ckb.calculateDaoMaximumWithdraw({index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691') + expect(res).toBe('0x6fc23ac9b') + ckb.rpc = rpc + }) + it('exception', async () => { + ckb.rpc = { + getTransaction: jest.fn().mockResolvedValueOnce({ txStatus: {}}) + } + await expect(ckb.calculateDaoMaximumWithdraw({ tx: '', index: '0x0' }, '')).rejects.toThrow('Transaction is not committed yet') + ckb.rpc = rpc + }) + }) }) diff --git a/packages/ckb-sdk-core/src/index.ts b/packages/ckb-sdk-core/src/index.ts index 96662a38..fe42a28a 100644 --- a/packages/ckb-sdk-core/src/index.ts +++ b/packages/ckb-sdk-core/src/index.ts @@ -420,6 +420,37 @@ class CKB { } } + public calculateDaoMaximumWithdraw = async ( + depositOutPoint: CKBComponents.OutPoint, + withdraw: CKBComponents.Hash | CKBComponents.OutPoint + ): Promise => { + let tx = await this.rpc.getTransaction(depositOutPoint.txHash) + if (tx.txStatus.status !== 'committed') throw new Error('Transaction is not committed yet') + const depositBlockHash = tx.txStatus.blockHash + let celloutput = tx.transaction.outputs[+depositOutPoint.index] + let celloutputData = tx.transaction.outputsData[+depositOutPoint.index] + let withdrawBlockHash: CKBComponents.Hash + if (typeof withdraw === 'string') { + withdrawBlockHash = withdraw + } else { + tx = await this.rpc.getTransaction(withdraw.txHash) + if (tx.txStatus.status !== 'committed') throw new Error('Transaction is not committed yet') + withdrawBlockHash = tx.txStatus.blockHash + celloutput = tx.transaction.outputs[+withdraw.index] + celloutputData = tx.transaction.outputsData[+withdraw.index] + } + const [depositHeader, withDrawHeader] = await Promise.all([ + this.rpc.getHeader(depositBlockHash), + this.rpc.getHeader(withdrawBlockHash) + ]) + return utils.calculateMaximumWithdraw( + celloutput, + celloutputData, + depositHeader.dao, + withDrawHeader.dao + ) + } + #secp256k1DepsShouldBeReady = () => { if (!this.config.secp256k1Dep) { throw new ParameterRequiredException('Secp256k1 dep') diff --git a/packages/ckb-sdk-utils/__tests__/convertors/index.test.js b/packages/ckb-sdk-utils/__tests__/convertors/index.test.js index 7b5ec2b0..34a3407a 100644 --- a/packages/ckb-sdk-utils/__tests__/convertors/index.test.js +++ b/packages/ckb-sdk-utils/__tests__/convertors/index.test.js @@ -1,4 +1,4 @@ -const { toUint16Le, toUint32Le, toUint64Le, hexToBytes, bytesToHex } = require('../../lib/convertors') +const { toUint16Le, toUint32Le, toUint64Le, hexToBytes, bytesToHex, toBigEndian } = require('../../lib/convertors') const { HexStringWithout0xException } = require('../../lib/exceptions') const { @@ -68,3 +68,7 @@ describe('bytes to hex', () => { expect(bytesToHex(bytes)).toEqual(expected) }) }) + +describe('to big endian', () => { + expect(toBigEndian('0x3ef9e8c069c92500')).toBe('0x0025c969c0e8f93e') +}) \ No newline at end of file diff --git a/packages/ckb-sdk-utils/__tests__/utils/index.test.js b/packages/ckb-sdk-utils/__tests__/utils/index.test.js index c236a4b2..c818e614 100644 --- a/packages/ckb-sdk-utils/__tests__/utils/index.test.js +++ b/packages/ckb-sdk-utils/__tests__/utils/index.test.js @@ -1,4 +1,4 @@ -const { privateKeyToPublicKey, privateKeyToAddress, scriptToHash, rawTransactionToHash } = require('../..') +const { privateKeyToPublicKey, privateKeyToAddress, scriptToHash, rawTransactionToHash, calculateMaximumWithdraw, extractDAOData } = require('../..') const exceptions = require('../../lib/exceptions') const rawTransactionToHashFixtures = require('./rawTransactionToHash.fixtures.json') @@ -82,3 +82,34 @@ describe('privateKeyToAddress', () => { }), ).toBe(fixture.testnetAddress) }) + +describe('calculate-maximum-withdraw', () => { + const outputCell = { + "capacity":"0xe8d4a51000", + "lock":{ + "args":"0xf601cac75568afec3b9c9af1e1ff730062007685", + "codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", + "hashType":"type" + }, + "type":{ + "args":"0x", + "codeHash":"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e", + "hashType":"type" + } + } + expect( + calculateMaximumWithdraw( + outputCell, + '0x0000000000000000', + '0x1aaf2ca6847c223c3ef9e8c069c9250020212a6311e2d30200609349396eb407', + '0x9bafffa73e432e3c94c6f9db34cb25009f9e4efe4b5fd60200ea63c6d4ffb407' + )).toBe('0xe8df95141e') +}) + +describe('extract header dao', () => { + const DAOData = extractDAOData('0x1aaf2ca6847c223c3ef9e8c069c9250020212a6311e2d30200609349396eb407') + expect(DAOData.c).toBe('0x3c227c84a62caf1a') + expect(DAOData.ar).toBe('0x0025c969c0e8f93e') + expect(DAOData.s).toBe('0x02d3e211632a2120') + expect(DAOData.u).toBe('0x07b46e3949936000') +}) \ No newline at end of file diff --git a/packages/ckb-sdk-utils/__tests__/utils/occupiedCapacity.test.js b/packages/ckb-sdk-utils/__tests__/utils/occupiedCapacity.test.js new file mode 100644 index 00000000..7741fb25 --- /dev/null +++ b/packages/ckb-sdk-utils/__tests__/utils/occupiedCapacity.test.js @@ -0,0 +1,51 @@ +const { scriptOccupied, cellOccupied } = require('../..') + +describe('script occupied', () => { + it('no args', () => { + const occupied = scriptOccupied({ + args: '0x', + codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', + hashType: 'type' + }) + expect(occupied).toBe(33) + }) + it('with args', () => { + const occupied = scriptOccupied({ + args: '0x00ffee', + codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', + hashType: 'type' + }) + expect(occupied).toBe(36) + }) +}) + + +describe('cell occupied', () => { + it('no type', () => { + const occupied = cellOccupied({ + capacity: '0xe8d4a51000', + lock: { + args: '0x', + codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', + hashType: 'type' + }, + }) + expect(occupied).toBe(41) + }) + it('with type', () => { + const occupied = cellOccupied({ + capacity: '0xe8d4a51000', + lock: { + args: '0x', + codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', + hashType: 'type' + }, + type: { + args: '0x00ff', + codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', + hashType: 'type' + } + }) + expect(occupied).toBe(76) + }) +}) \ No newline at end of file diff --git a/packages/ckb-sdk-utils/src/convertors/index.ts b/packages/ckb-sdk-utils/src/convertors/index.ts index bb3e9eaa..b80c850a 100644 --- a/packages/ckb-sdk-utils/src/convertors/index.ts +++ b/packages/ckb-sdk-utils/src/convertors/index.ts @@ -1,4 +1,4 @@ -import { assertToBeHexStringOrBigint } from '../validators' +import { assertToBeHexStringOrBigint, assertToBeHexString } from '../validators' import { HexStringWithout0xException } from '../exceptions' /** @@ -61,6 +61,19 @@ export const hexToBytes = (rawhex: string | number | bigint) => { return new Uint8Array(bytes) } +/** + * Converts a hex string in little endian into big endian + * + * @memberof convertors + * @param {string} le16 The hex string to convert + * @returns {string} Returns a big endian + */ + export const toBigEndian = (leHex: string) => { + assertToBeHexString(leHex) + const bytes = hexToBytes(leHex); + return `0x${bytes.reduceRight((pre, cur) => pre + cur.toString(16).padStart(2, '0'), '')}` +} + export const bytesToHex = (bytes: Uint8Array): string => `0x${[...bytes].map(b => b.toString(16).padStart(2, '0')).join('')}` @@ -70,4 +83,5 @@ export default { toUint64Le, hexToBytes, bytesToHex, + toBigEndian } diff --git a/packages/ckb-sdk-utils/src/index.ts b/packages/ckb-sdk-utils/src/index.ts index c8843628..3326cacb 100644 --- a/packages/ckb-sdk-utils/src/index.ts +++ b/packages/ckb-sdk-utils/src/index.ts @@ -1,10 +1,11 @@ import JSBI from 'jsbi' import ECPair from './ecpair' -import { hexToBytes } from './convertors' +import { hexToBytes, toBigEndian } from './convertors' import { pubkeyToAddress, AddressOptions } from './address' -import { ParameterRequiredException } from './exceptions' +import { ParameterRequiredException, HexStringWithout0xException } from './exceptions' import crypto from './crypto' -import { serializeScript } from './serialization/script' +import { serializeScript } from './serialization' +import { cellOccupied } from './occupiedCapacity' import { serializeRawTransaction, serializeTransaction, serializeWitnessArgs } from './serialization/transaction' import { PERSONAL } from './const' @@ -13,6 +14,7 @@ export * from './serialization' export * from './convertors' export * from './epochs' export * from './sizes' +export * from './occupiedCapacity' export * as systemScripts from './systemScripts' export * as reconcilers from './reconcilers' @@ -44,3 +46,43 @@ export const privateKeyToPublicKey = (privateKey: string) => { export const privateKeyToAddress = (privateKey: string, options: AddressOptions) => pubkeyToAddress(privateKeyToPublicKey(privateKey), options) + + +export const extractDAOData = (dao: CKBComponents.DAO) => { + if (!dao.startsWith('0x')) { + throw new HexStringWithout0xException(dao) + } + const value = dao.replace('0x', '') + return { + c: toBigEndian(`0x${value.slice(0, 16)}`), + ar: toBigEndian(`0x${value.slice(16, 32)}`), + s: toBigEndian(`0x${value.slice(32, 48)}`), + u: toBigEndian(`0x${value.slice(48, 64)}`) + } +} + +export const calculateMaximumWithdraw = ( + outputCell: CKBComponents.CellOutput, + outputDataCapacity: CKBComponents.Bytes, + depositDAO: CKBComponents.DAO, + withdrawDAO: CKBComponents.DAO +) => { + const depositCellSerialized = cellOccupied(outputCell) + outputDataCapacity.slice(2).length / 2 + const occupiedCapacity = JSBI.asUintN( + 128, + JSBI.multiply(JSBI.BigInt(100000000), JSBI.BigInt(depositCellSerialized)) + ) + return `0x${JSBI.add( + JSBI.divide( + JSBI.multiply( + JSBI.subtract( + JSBI.asUintN(128, JSBI.BigInt(outputCell.capacity)), + occupiedCapacity + ), + JSBI.asUintN(128, JSBI.BigInt(extractDAOData(withdrawDAO).ar)) + ), + JSBI.asUintN(128, JSBI.BigInt(extractDAOData(depositDAO).ar)) + ), + occupiedCapacity + ).toString(16)}` +} diff --git a/packages/ckb-sdk-utils/src/occupiedCapacity.ts b/packages/ckb-sdk-utils/src/occupiedCapacity.ts new file mode 100644 index 00000000..45729d92 --- /dev/null +++ b/packages/ckb-sdk-utils/src/occupiedCapacity.ts @@ -0,0 +1,10 @@ +const codeHashOccupied = 32 +const hashTypeOccupied = 1 + +export const scriptOccupied = (script: CKBComponents.Script) => { + return script.args.slice(2).length / 2 + codeHashOccupied + hashTypeOccupied +} + +export const cellOccupied = (cell: CKBComponents.CellOutput) => { + return 8 + scriptOccupied(cell.lock) + (cell.type ? scriptOccupied(cell.type) : 0) +} \ No newline at end of file From 8aa5bcc1f38cc6ee63b583c1bc6cd76ea75ee695 Mon Sep 17 00:00:00 2001 From: yanguoyu <841185308@qq.com> Date: Wed, 2 Mar 2022 14:41:15 +0800 Subject: [PATCH 3/5] test: add test for calculateDaoMaximumWithdraw with withdraw outputpoint --- packages/ckb-sdk-core/__tests__/index.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/ckb-sdk-core/__tests__/index.test.js b/packages/ckb-sdk-core/__tests__/index.test.js index f2b8bfd2..35705e34 100644 --- a/packages/ckb-sdk-core/__tests__/index.test.js +++ b/packages/ckb-sdk-core/__tests__/index.test.js @@ -291,7 +291,10 @@ describe('ckb', () => { .mockResolvedValueOnce({ dao: '0x7e9a4d29f532433cb8dbe56b64ce2500b4c9c67a3fccda020098a1f224a4b707' }) .mockResolvedValueOnce({ dao: '0xd87090655733433c2395d67a64ce2500d73e963e54ccda0200f244c504a4b707' }) } - const res = await ckb.calculateDaoMaximumWithdraw({index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691') + const res = await ckb.calculateDaoMaximumWithdraw( + {index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, + {index: '0x0', txHash: '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691' } + ) expect(res).toBe('0x6fc23ac9b') ckb.rpc = rpc }) From 6a6de605956caed395ea9fedd776516b852c8aea Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 2 Mar 2022 14:30:52 +0800 Subject: [PATCH 4/5] chore: update package versions and changelogs --- CHANGELOG.md | 10 ++++++++++ lerna.json | 2 +- packages/ckb-sdk-core/CHANGELOG.md | 10 ++++++++++ packages/ckb-sdk-core/package.json | 8 ++++---- packages/ckb-sdk-rpc/CHANGELOG.md | 8 ++++++++ packages/ckb-sdk-rpc/package.json | 6 +++--- packages/ckb-sdk-utils/CHANGELOG.md | 11 +++++++++++ packages/ckb-sdk-utils/package.json | 4 ++-- packages/ckb-types/CHANGELOG.md | 8 ++++++++ packages/ckb-types/package.json | 2 +- 10 files changed, 58 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 564c013c..3d6de3be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.102.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.2) (2022-03-02) + +* **core:** add `calculateDaoMaximumWithdraw` to calculate maximum withdraw capacity based on withdrawing block hash or withdrawing cell outpoint([#578](https://github.com/nervosnetwork/ckb-sdk-js/pull/578)) +* **utils:** add `extractDAOData` to deserialize DAO field in block header ([#578](https://github.com/nervosnetwork/ckb-sdk-js/pull/578)) +* **utils:** add `calculateMaximumWithdraw` to calculate maximum withdraw capacity offline ([#578](https://github.com/nervosnetwork/ckb-sdk-js/pull/578)) + + + + + ## [0.102.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.1) (2022-02-17) **Note:** Version bump only for package ckb-sdk-js diff --git a/lerna.json b/lerna.json index 44293f30..26d7b281 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "0.102.1" + "version": "0.102.2" } diff --git a/packages/ckb-sdk-core/CHANGELOG.md b/packages/ckb-sdk-core/CHANGELOG.md index a05d753d..a6a0bdff 100644 --- a/packages/ckb-sdk-core/CHANGELOG.md +++ b/packages/ckb-sdk-core/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.102.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.2) (2022-03-02) + +### Features + +* add `calculateDaoMaximumWithdraw` to calculate maximum withdraw capacity based on withdrawing block hash or withdrawing cell outpoint([#578](https://github.com/nervosnetwork/ckb-sdk-js/pull/578)) + + + + + ## [0.102.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.1) (2022-02-17) **Note:** Version bump only for package @nervosnetwork/ckb-sdk-core diff --git a/packages/ckb-sdk-core/package.json b/packages/ckb-sdk-core/package.json index 485bd77a..3257e326 100644 --- a/packages/ckb-sdk-core/package.json +++ b/packages/ckb-sdk-core/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-core", - "version": "0.102.1", + "version": "0.102.2", "description": "JavaScript SDK for Nervos Network CKB Project", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", @@ -33,9 +33,9 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-sdk-rpc": "0.102.1", - "@nervosnetwork/ckb-sdk-utils": "0.102.1", - "@nervosnetwork/ckb-types": "0.102.1", + "@nervosnetwork/ckb-sdk-rpc": "0.102.2", + "@nervosnetwork/ckb-sdk-utils": "0.102.2", + "@nervosnetwork/ckb-types": "0.102.2", "tslib": "2.3.1" }, "gitHead": "78ef8aea8ca68f25528c8eb3aed4506ea4a37241" diff --git a/packages/ckb-sdk-rpc/CHANGELOG.md b/packages/ckb-sdk-rpc/CHANGELOG.md index 0a92b086..aeb93d40 100644 --- a/packages/ckb-sdk-rpc/CHANGELOG.md +++ b/packages/ckb-sdk-rpc/CHANGELOG.md @@ -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.102.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.2) (2022-03-02) + +**Note:** Version bump only for package @nervosnetwork/ckb-sdk-rpc + + + + + ## [0.102.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.1) (2022-02-17) **Note:** Version bump only for package @nervosnetwork/ckb-sdk-rpc diff --git a/packages/ckb-sdk-rpc/package.json b/packages/ckb-sdk-rpc/package.json index 674f53f7..530dc910 100644 --- a/packages/ckb-sdk-rpc/package.json +++ b/packages/ckb-sdk-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-rpc", - "version": "0.102.1", + "version": "0.102.2", "description": "RPC module of @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js/packages/ckb-rpc#readme", @@ -33,12 +33,12 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-sdk-utils": "0.102.1", + "@nervosnetwork/ckb-sdk-utils": "0.102.2", "axios": "0.21.4", "tslib": "2.3.1" }, "devDependencies": { - "@nervosnetwork/ckb-types": "0.102.1" + "@nervosnetwork/ckb-types": "0.102.2" }, "gitHead": "78ef8aea8ca68f25528c8eb3aed4506ea4a37241" } diff --git a/packages/ckb-sdk-utils/CHANGELOG.md b/packages/ckb-sdk-utils/CHANGELOG.md index e7e7f120..4e6a8675 100644 --- a/packages/ckb-sdk-utils/CHANGELOG.md +++ b/packages/ckb-sdk-utils/CHANGELOG.md @@ -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.102.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.2) (2022-03-02) + +### Features + +* add `extractDAOData` to deserialize DAO field in block header ([#578](https://github.com/nervosnetwork/ckb-sdk-js/pull/578)) +* add `calculateMaximumWithdraw` to calculate maximum withdraw capacity offline ([#578](https://github.com/nervosnetwork/ckb-sdk-js/pull/578)) + + + + + ## [0.102.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.1) (2022-02-17) **Note:** Version bump only for package @nervosnetwork/ckb-sdk-utils diff --git a/packages/ckb-sdk-utils/package.json b/packages/ckb-sdk-utils/package.json index 14852c2e..1a2a36e0 100644 --- a/packages/ckb-sdk-utils/package.json +++ b/packages/ckb-sdk-utils/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-sdk-utils", - "version": "0.102.1", + "version": "0.102.2", "description": "Utils module of @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", @@ -31,7 +31,7 @@ "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, "dependencies": { - "@nervosnetwork/ckb-types": "0.102.1", + "@nervosnetwork/ckb-types": "0.102.2", "bech32": "2.0.0", "elliptic": "6.5.4", "jsbi": "3.1.3", diff --git a/packages/ckb-types/CHANGELOG.md b/packages/ckb-types/CHANGELOG.md index 86a5ea6e..35008992 100644 --- a/packages/ckb-types/CHANGELOG.md +++ b/packages/ckb-types/CHANGELOG.md @@ -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.102.2](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.2) (2022-03-02) + +**Note:** Version bump only for package @nervosnetwork/ckb-types + + + + + ## [0.102.1](https://github.com/nervosnetwork/ckb-sdk-js/compare/v0.101.0...v0.102.1) (2022-02-17) **Note:** Version bump only for package @nervosnetwork/ckb-types diff --git a/packages/ckb-types/package.json b/packages/ckb-types/package.json index cceb383d..c168c01c 100644 --- a/packages/ckb-types/package.json +++ b/packages/ckb-types/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/ckb-types", - "version": "0.102.1", + "version": "0.102.2", "description": "Type module of @nervosnetwork/ckb-sdk-core", "author": "Nervos ", "homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", From 087b9c3fd5c32c6c16361eb2c2c709842b00ea11 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 2 Mar 2022 15:18:15 +0800 Subject: [PATCH 5/5] chore: update lerna hashes --- packages/ckb-sdk-core/package.json | 2 +- packages/ckb-sdk-rpc/package.json | 2 +- packages/ckb-sdk-utils/package.json | 2 +- packages/ckb-types/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ckb-sdk-core/package.json b/packages/ckb-sdk-core/package.json index 3257e326..aa1f76b4 100644 --- a/packages/ckb-sdk-core/package.json +++ b/packages/ckb-sdk-core/package.json @@ -38,5 +38,5 @@ "@nervosnetwork/ckb-types": "0.102.2", "tslib": "2.3.1" }, - "gitHead": "78ef8aea8ca68f25528c8eb3aed4506ea4a37241" + "gitHead": "6a6de605956caed395ea9fedd776516b852c8aea" } diff --git a/packages/ckb-sdk-rpc/package.json b/packages/ckb-sdk-rpc/package.json index 530dc910..58560cbe 100644 --- a/packages/ckb-sdk-rpc/package.json +++ b/packages/ckb-sdk-rpc/package.json @@ -40,5 +40,5 @@ "devDependencies": { "@nervosnetwork/ckb-types": "0.102.2" }, - "gitHead": "78ef8aea8ca68f25528c8eb3aed4506ea4a37241" + "gitHead": "6a6de605956caed395ea9fedd776516b852c8aea" } diff --git a/packages/ckb-sdk-utils/package.json b/packages/ckb-sdk-utils/package.json index 1a2a36e0..02ea242b 100644 --- a/packages/ckb-sdk-utils/package.json +++ b/packages/ckb-sdk-utils/package.json @@ -41,5 +41,5 @@ "@types/bitcoinjs-lib": "5.0.0", "@types/elliptic": "6.4.12" }, - "gitHead": "78ef8aea8ca68f25528c8eb3aed4506ea4a37241" + "gitHead": "6a6de605956caed395ea9fedd776516b852c8aea" } diff --git a/packages/ckb-types/package.json b/packages/ckb-types/package.json index c168c01c..084bd30d 100644 --- a/packages/ckb-types/package.json +++ b/packages/ckb-types/package.json @@ -20,5 +20,5 @@ "bugs": { "url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" }, - "gitHead": "78ef8aea8ca68f25528c8eb3aed4506ea4a37241" + "gitHead": "6a6de605956caed395ea9fedd776516b852c8aea" }