Skip to content

Commit

Permalink
feat(core): remove experimental rpc
Browse files Browse the repository at this point in the history
1. remove computeTransactionHash RPC;
2. remove computeScriptHash RPC;

BREAKING CHANGE: computeTransactionHash and computeScriptHash are removed from the rpc list
  • Loading branch information
Keith-CY committed Jul 15, 2020
1 parent 7be2b9c commit 32c7a0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 58 deletions.
10 changes: 0 additions & 10 deletions packages/ckb-sdk-core/__tests__/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,6 @@
"exception": "Witnesses is required"
}
},
"computeScriptHash": {
"baisc": {
"script": {
"codeHash": "0xb35557e7e9854206f7bc13e3c3a7fa4cf8892c84a09237fb0aab40aab3771eee",
"hashType": "data",
"args": "0x"
},
"expected": "0x9e9e450fa32ef75e7063023574f1fd3647e8eb35ff5ce9e3c04fb3056c8e37d6"
}
},
"generateRawTransaction": {
"testnet": {
"params": {
Expand Down
18 changes: 0 additions & 18 deletions packages/ckb-sdk-core/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,6 @@ describe('ckb', () => {
})
})

describe('compute script hash', () => {
const fixtureTable = Object.entries(fixtures.computeScriptHash).map(([title, { script, expected, exception }]) => [
title,
script,
expected,
exception,
])
test.each(fixtureTable)('%s', async (_title, script, expected, exception) => {
if (undefined !== exception) {
const computedHash = await ckb.rpc.computeScriptHash(script)
expect(computedHash).toBe(expected)
}
if (undefined !== exception) {
expect(ckb.rpc.computeScriptHash(script)).reject.toThrowError(exception)
}
})
})

describe('sign transaction', () => {
const fixtureTable = Object.entries(fixtures.signTransaction).map(([title, { params, expected, exception }]) => [
title,
Expand Down
34 changes: 4 additions & 30 deletions packages/ckb-sdk-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,6 @@ class CKB {
url: nodeUrl,
}
this.rpc = new RPC(nodeUrl)

const computeTransactionHashMethod = {
name: 'computeTransactionHash',
method: '_compute_transaction_hash',
paramsFormatters: [this.rpc.paramsFormatter.toRawTransaction],
}

/**
* @method computeTransactionHash
* @description this RPC is used to calculate the hash of a raw transaction
* @deprecated this RPC method has been marked as deprecated in Nervos CKB Project
*/
this.rpc.addMethod(computeTransactionHashMethod)

const computeScriptHashMethod = {
name: 'computeScriptHash',
method: '_compute_script_hash',
paramsFormatters: [this.rpc.paramsFormatter.toScript],
}

/**
* @method computeScriptHash
* @description this RPC is used to calculate the hash of lock/type script
* @deprecated this RPC method has been marked as deprecated in Nervos CKB Project
*/
this.rpc.addMethod(computeScriptHashMethod)
}

public setNode(node: URL | CKBComponents.Node): CKBComponents.Node {
Expand All @@ -96,15 +70,15 @@ class CKB {

public generateLockHash = (
publicKeyHash: PublicKeyHash,
deps: Omit<DepCellInfo, 'outPoint'> | undefined = this.config.secp256k1Dep,
dep: Omit<DepCellInfo, 'outPoint'> | undefined = this.config.secp256k1Dep,
) => {
if (!deps) {
if (!dep) {
throw new ParameterRequiredException('deps')
}

return this.utils.scriptToHash({
hashType: deps.hashType,
codeHash: deps.codeHash,
hashType: dep.hashType,
codeHash: dep.codeHash,
args: publicKeyHash,
})
}
Expand Down

0 comments on commit 32c7a0c

Please sign in to comment.