Skip to content

Commit

Permalink
Merge pull request #552 from nervosnetwork/rename-uncles_hash-to-extr…
Browse files Browse the repository at this point in the history
…a_hash-in-header

feat(rpc): rename 'uncles_hash' to 'extra_hash' in block header
  • Loading branch information
Keith-CY authored Aug 30, 2021
2 parents 5b00f47 + 58c055c commit 45bfbc4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/ckb-sdk-core/__mocks__/data/genesisBlock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot": "0x0d31bf4fe7d0274d8331c76b320dbb0c9557a21fdf599e9f56d8c369529f8961",
"proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"dao": "0x0469b82c6c1ea12e0000c16ff286230066cbed490e00000000b2b49f02fbfe06",
"epoch": "0x0",
"hash": "0x184ac4658ed0c04a126551257990db132366cac22ab6270bbbc1f8c3220f302d",
Expand Down
24 changes: 12 additions & 12 deletions packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Test with mock', () => {
proposals_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x5cd2b117',
transactions_root: '0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c',
uncles_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
proposals: [],
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('Test with mock', () => {
proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x5cd2b117',
transactionsRoot: '0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c',
unclesHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extraHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
proposals: [],
Expand Down Expand Up @@ -829,7 +829,7 @@ describe('Test with mock', () => {
proposals_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x172a8804ad1',
transactions_root: '0xcde937f363e195a97467061a45a6b5b318da02fc3fec5e76ab298e41ace0b7a1',
uncles_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
proposals: [],
Expand Down Expand Up @@ -890,7 +890,7 @@ describe('Test with mock', () => {
proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x172a8804ad1',
transactionsRoot: '0xcde937f363e195a97467061a45a6b5b318da02fc3fec5e76ab298e41ace0b7a1',
unclesHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extraHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
proposals: [],
Expand Down Expand Up @@ -945,7 +945,7 @@ describe('Test with mock', () => {
proposals_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x172a8804ad1',
transactions_root: '0xcde937f363e195a97467061a45a6b5b318da02fc3fec5e76ab298e41ace0b7a1',
uncles_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
id,
Expand All @@ -969,7 +969,7 @@ describe('Test with mock', () => {
proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x172a8804ad1',
transactionsRoot: '0xcde937f363e195a97467061a45a6b5b318da02fc3fec5e76ab298e41ace0b7a1',
unclesHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extraHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
})
})
Expand Down Expand Up @@ -1307,7 +1307,7 @@ describe('Test with mock', () => {
proposals_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x172a8804ad1',
transactions_root: '0xcde937f363e195a97467061a45a6b5b318da02fc3fec5e76ab298e41ace0b7a1',
uncles_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
id,
Expand All @@ -1331,7 +1331,7 @@ describe('Test with mock', () => {
proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x172a8804ad1',
transactionsRoot: '0xcde937f363e195a97467061a45a6b5b318da02fc3fec5e76ab298e41ace0b7a1',
unclesHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extraHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
})
})
Expand All @@ -1352,7 +1352,7 @@ describe('Test with mock', () => {
proposals_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x1725940cb91',
transactions_root: '0xcd95e31e21734fb796de0070407c1d4f91ec00d699f840e5ad9aa293443744e6',
uncles_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
id,
Expand All @@ -1376,7 +1376,7 @@ describe('Test with mock', () => {
proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x1725940cb91',
transactionsRoot: '0xcd95e31e21734fb796de0070407c1d4f91ec00d699f840e5ad9aa293443744e6',
unclesHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extraHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
})
})
Expand Down Expand Up @@ -1539,7 +1539,7 @@ describe('Test with mock', () => {
proposals_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x1725940cb91',
transactions_root: '0xcd95e31e21734fb796de0070407c1d4f91ec00d699f840e5ad9aa293443744e6',
uncles_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
proposals: [],
Expand Down Expand Up @@ -1617,7 +1617,7 @@ describe('Test with mock', () => {
proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
timestamp: '0x1725940cb91',
transactionsRoot: '0xcd95e31e21734fb796de0070407c1d4f91ec00d699f840e5ad9aa293443744e6',
unclesHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
extraHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
version: '0x0',
},
proposals: [],
Expand Down
16 changes: 8 additions & 8 deletions packages/ckb-sdk-rpc/__tests__/formatters/result.fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
"nonce": "0",
"timestamp": "1557311767",
"transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": []
Expand All @@ -298,7 +298,7 @@
"nonce": "0",
"timestamp": "1557311767",
"transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": []
Expand All @@ -323,7 +323,7 @@
"nonce": "0",
"timestamp": "1557311767",
"transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
Expand Down Expand Up @@ -372,7 +372,7 @@
"nonce": "0",
"timestamp": "1557311767",
"transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
Expand Down Expand Up @@ -423,7 +423,7 @@
"nonce": "0",
"timestamp": "1557311767",
"transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": []
Expand All @@ -440,7 +440,7 @@
"nonce": "0",
"timestamp": "1557311767",
"transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
Expand Down Expand Up @@ -960,7 +960,7 @@
"proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x5cd2b117",
"transactions_root": "0x7fe9a50693f3e0a7418c7a99e9a298f8d0806b149bed700bb09c1f35a63100ce",
"uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0x0"
},
"expected": {
Expand All @@ -974,7 +974,7 @@
"proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x5cd2b117",
"transactionsRoot": "0x7fe9a50693f3e0a7418c7a99e9a298f8d0806b149bed700bb09c1f35a63100ce",
"unclesHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0x0"
}
}
Expand Down
19 changes: 13 additions & 6 deletions packages/ckb-sdk-rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ const formatter = {
toHash: (hash: RPC.Hash256): CKBComponents.Hash256 => hash,
toHeader: (header: RPC.Header): CKBComponents.BlockHeader => {
if (!header) return header
const { compact_target, transactions_root, proposals_hash, uncles_hash, parent_hash, ...rest } = header
const {
compact_target: compactTarget,
transactions_root: transactionsRoot,
proposals_hash: proposalsHash,
extra_hash: extraHash,
parent_hash: parentHash,
...rest
} = header
return {
compactTarget: compact_target,
parentHash: parent_hash,
transactionsRoot: transactions_root,
proposalsHash: proposals_hash,
unclesHash: uncles_hash,
compactTarget,
parentHash,
transactionsRoot,
proposalsHash,
extraHash,
...rest,
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb-sdk-rpc/types/rpc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ declare module RPC {
nonce: CKBComponents.Nonce
timestamp: Timestamp
transactions_root: Hash256
uncles_hash: Hash256
extra_hash: Hash256
version: Version
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ declare namespace CKBComponents {
* @property nonce
* @property timestamp
* @property transactionsRoot
* @property unclesHash
* @property extraHash
* @property version
*/
export interface BlockHeader {
Expand All @@ -213,7 +213,7 @@ declare namespace CKBComponents {
nonce: Nonce
timestamp: Timestamp
transactionsRoot: Hash256
unclesHash: Hash256
extraHash: Hash256
version: Version
}

Expand Down

0 comments on commit 45bfbc4

Please sign in to comment.