From 40cdbaab937cc69eb837caa4100a0575e9a3a881 Mon Sep 17 00:00:00 2001 From: Keith <keithwhisper@gmail.com> Date: Fri, 23 Aug 2019 13:32:55 +0800 Subject: [PATCH] feat(utils): rename the method of lockScriptToHash to scriptToHash BREAKING CHANGE: rename the method of lockScriptToHash to scriptToHash --- packages/ckb-sdk-utils/__tests__/ckb-utils.test.js | 4 ++-- packages/ckb-sdk-utils/src/index.ts | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/ckb-sdk-utils/__tests__/ckb-utils.test.js b/packages/ckb-sdk-utils/__tests__/ckb-utils.test.js index f9ddfb8b..ebfe75b0 100644 --- a/packages/ckb-sdk-utils/__tests__/ckb-utils.test.js +++ b/packages/ckb-sdk-utils/__tests__/ckb-utils.test.js @@ -13,7 +13,7 @@ const { bytesToHex, utf8ToHex, hexToUtf8, - lockScriptToHash, + scriptToHash, PERSONAL, } = ckbUtils @@ -161,7 +161,7 @@ describe('scriptToHash', () => { } test.each(Object.keys(fixtures))('%s', fixtureName => { const fixture = fixtures[fixtureName] - const lockHash = lockScriptToHash(fixture.script) + const lockHash = scriptToHash(fixture.script) expect(lockHash).toBe(fixture.lockHash) }) }) diff --git a/packages/ckb-sdk-utils/src/index.ts b/packages/ckb-sdk-utils/src/index.ts index 23658d00..b00d950e 100644 --- a/packages/ckb-sdk-utils/src/index.ts +++ b/packages/ckb-sdk-utils/src/index.ts @@ -47,11 +47,7 @@ export enum ScriptHashType { Type = 'Type', } -export const lockScriptToHash = ({ - codeHash = '', - args = [], - hashType = ScriptHashType.Data, -}: CKBComponents.Script) => { +export const scriptToHash = ({ codeHash = '', args = [], hashType = ScriptHashType.Data }: CKBComponents.Script) => { const s = blake2b(32, null, null, PERSONAL) if (codeHash) { s.update(hexToBytes(codeHash.replace(/^0x/, '')))