Skip to content

Commit

Permalink
fix(types): remove the hash_type field from the type of cell_out_point
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the type of cell out point changes
  • Loading branch information
Keith-CY committed Jul 29, 2019
1 parent 2757b82 commit 58c019f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 56 deletions.
14 changes: 8 additions & 6 deletions packages/ckb-sdk-core/__tests__/successFixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
}
},
"target": {
"codeHash": "f1951123466e4479842387a66fabfd6b65fc87fd84ae8e6cd3053edb27fff2fd",
"codeHash": "54811ce986d5c3e57eaafab22cdd080e32209e39590e204a99b32935f835a13c",
"outPoint": {
"blockHash": "c3b42742ea8658c93de23f16a10c43212bd8b24a6bde5a93b8446dba3fb2a728",
"blockHash": "0efcf4221871200e064e5c48969909ccfb04686395db5f733b0da15361c5ac04",
"cell": {
"txHash": "6950a2491d7c0ccac11fcb985cbb3f6b5a70eaf6fff952c08a20d1b99c01fb98",
"txHash": "d0608a90cc3fd5bec9807263d3c7c93fad48a1afa0e44b38a664fbe79d4a1400",
"index": "1"
}
}
Expand Down Expand Up @@ -71,7 +71,8 @@
"data": "0x",
"lock": {
"args": [],
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001"
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hashType": "Data"
},
"type": null
}
Expand Down Expand Up @@ -107,7 +108,8 @@
"data": "0x",
"lock": {
"args": [],
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001"
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hashType": "Data"
},
"type": null
}
Expand All @@ -116,7 +118,7 @@
"witnesses": [
{
"data": [
"0xaa659c1d2920d144b76e4d03eb4d0c56b22e66501c68bb330bc58b5af1ba411c3728e526386d4186955049405a669a9ce63ec0e3b233ca7696f9a5d95651a25600"
"0x54370f05bcdc65adec5b8a082001439a752822f6a8b784b13cd6911f2c6bea3166daf6f22eb24eb36d183874f4e3dff1a4d43b4cfdfa8c7df34537fe7ec6409600"
]
}
]
Expand Down
12 changes: 4 additions & 8 deletions packages/ckb-sdk-rpc/__tests__/formatters/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@
{
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
},
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Expand All @@ -100,8 +99,7 @@
"previousOutput": {
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
},
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand All @@ -127,8 +125,7 @@
{
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
},
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Expand All @@ -138,8 +135,7 @@
"previous_output": {
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
},
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down
48 changes: 16 additions & 32 deletions packages/ckb-sdk-rpc/__tests__/formatters/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,11 @@
{
"source": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
},
"target": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
}
}
],
Expand All @@ -124,16 +122,14 @@
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
}
},
"target": {
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
}
}
},
Expand All @@ -150,16 +146,14 @@
"source": {
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
}
},
"target": {
"blockHash": null,
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
}
}
},
Expand All @@ -181,8 +175,7 @@
"previous_output": {
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
},
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down Expand Up @@ -212,8 +205,7 @@
"previousOutput": {
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
},
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down Expand Up @@ -329,8 +321,7 @@
"previous_output": {
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
},
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down Expand Up @@ -384,8 +375,7 @@
"previousOutput": {
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
},
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down Expand Up @@ -696,8 +686,7 @@
"block_hash": null,
"cell": {
"index": "0",
"tx_hash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f",
"hash_type": "Data"
"tx_hash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f"
}
}
},
Expand All @@ -713,8 +702,7 @@
"blockHash": null,
"cell": {
"index": "0",
"txHash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f",
"hashType": "Data"
"txHash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f"
}
}
}
Expand Down Expand Up @@ -763,8 +751,7 @@
"block_hash": null,
"cell": {
"index": "0",
"tx_hash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f",
"hash_type": "Data"
"tx_hash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f"
}
}
}
Expand All @@ -782,8 +769,7 @@
"blockHash": null,
"cell": {
"index": "0",
"txHash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f",
"hashType": "Data"
"txHash": "0xecd3917b7d9833a34d30da39b943b1811163f30771aae3165f60529955afb37f"
}
}
}
Expand Down Expand Up @@ -841,8 +827,7 @@
"previous_output": {
"cell": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hash_type": "Data"
"index": "4294967295"
},
"block_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down Expand Up @@ -878,8 +863,7 @@
"previousOutput": {
"cell": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295",
"hashType": "Data"
"index": "4294967295"
},
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
Expand Down
7 changes: 1 addition & 6 deletions packages/ckb-sdk-rpc/src/paramsFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ const formatter = {
...rest,
}),
toHash: (hash: string): CKB_RPC.Hash256 => (hash.startsWith('0x') ? hash : `0x${hash}`),
toCellOutPoint: ({
txHash: tx_hash,
hashType: hash_type,
...rest
}: CKBComponents.CellOutPoint): CKB_RPC.CellOutPoint => ({
toCellOutPoint: ({ txHash: tx_hash, ...rest }: CKBComponents.CellOutPoint): CKB_RPC.CellOutPoint => ({
tx_hash,
hash_type,
...rest,
}),
toOutPoint: ({ cell = null, blockHash: block_hash = null, ...rest }: CKBComponents.OutPoint): CKB_RPC.OutPoint => ({
Expand Down
3 changes: 1 addition & 2 deletions packages/ckb-sdk-rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ const formatter = {
},
toCellOutPoint: (cellOutPoint: CKB_RPC.CellOutPoint): CKBComponents.CellOutPoint => {
if (!cellOutPoint) return cellOutPoint
const { tx_hash: txHash, hash_type: hashType, ...rest } = cellOutPoint
const { tx_hash: txHash, ...rest } = cellOutPoint
return {
txHash,
hashType,
...rest,
}
},
Expand Down
1 change: 0 additions & 1 deletion packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ declare module CKB_RPC {
export interface CellOutPoint {
tx_hash: Hash256
index: Index
hash_type: ScriptHashType
}

export interface OutPoint {
Expand Down
1 change: 0 additions & 1 deletion packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ declare namespace CKBComponents {
export interface CellOutPoint {
txHash: Hash256
index: Index
hashType: ScriptHashType
}

export interface OutPoint {
Expand Down

0 comments on commit 58c019f

Please sign in to comment.