Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: BSC - get transaction with gasLimit over 53 bits #3948

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/web3-core-helpers/src/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ var outputTransactionFormatter = function (tx) {
if (tx.transactionIndex !== null)
tx.transactionIndex = utils.hexToNumber(tx.transactionIndex);
tx.nonce = utils.hexToNumber(tx.nonce);
tx.gas = utils.hexToNumber(tx.gas);
tx.gas = outputBigNumberFormatter(tx.gas);
tx.gasPrice = outputBigNumberFormatter(tx.gasPrice);
tx.value = outputBigNumberFormatter(tx.value);

Expand Down Expand Up @@ -345,9 +345,9 @@ var inputLogFormatter = function (options) {
return utils.fromUtf8(value);
};

if (options === undefined) options = {}
if (options === undefined) options = {};
// If options !== undefined, don't blow out existing data
if (options.fromBlock === undefined) options = {...options, fromBlock: 'latest'}
if (options.fromBlock === undefined) options = {...options, fromBlock: 'latest'};
if (options.fromBlock || options.fromBlock === 0)
options.fromBlock = inputBlockNumberFormatter(options.fromBlock);

Expand Down
54 changes: 27 additions & 27 deletions test/eth.getBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ var blockResult = {
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"difficulty": "0x027f07",
"totalDifficulty": "0x027f07",
"size": "0x027f07",
"totalDifficulty": "0x027f07",
"size": "0x027f07",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x9f759",
"gasUsed": "0x9f759",
"timestamp": "0x54e34e8e",
"transactions": ['0x460cfb8472af2c5fd05b5a2','0x460cfb8472af2c5fd05b5a2'],
"transactions": ['0x460cfb8472af2c5fd05b5a2', '0x460cfb8472af2c5fd05b5a2'],
"uncles": ["0x460cfb8472af2c5fd05b5a2", "0xd5460cfb8472af2c5fd05b5a2"]
};
var formattedBlockResult = {
Expand All @@ -34,12 +34,12 @@ var formattedBlockResult = {
"miner": "0x4E65FDa2159562a496F9f3522f89122A3088497a",
"difficulty": '163591',
"totalDifficulty": '163591',
"size": 163591,
"size": 163591,
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": 653145,
"gasUsed": 653145,
"timestamp": 1424182926,
"transactions": ['0x460cfb8472af2c5fd05b5a2','0x460cfb8472af2c5fd05b5a2'],
"transactions": ['0x460cfb8472af2c5fd05b5a2', '0x460cfb8472af2c5fd05b5a2'],
"uncles": ["0x460cfb8472af2c5fd05b5a2", "0xd5460cfb8472af2c5fd05b5a2"]
};
var blockResultWithTx = {
Expand All @@ -53,25 +53,25 @@ var blockResultWithTx = {
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"difficulty": "0x027f07",
"totalDifficulty": "0x027f07",
"size": "0x027f07",
"totalDifficulty": "0x027f07",
"size": "0x027f07",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x9f759",
"gasUsed": "0x9f759",
"timestamp": "0x54e34e8e",
"transactions": [{
"status": "mined",
"hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"nonce":"0x2",
"hash": "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"nonce": "0x2",
"blockHash": "0x6fd9e2a26ab",
"blockNumber": "0x15df",
"transactionIndex": "0x1",
"from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"to":"0x85f43d8a49eeb85d32cf465507dd71d507100c1d",
"value":"0x7f110",
"transactionIndex": "0x1",
"from": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"to": "0x85f43d8a49eeb85d32cf465507dd71d507100c1d",
"value": "0x7f110",
"gas": "0x7f110",
"gasPrice":"0x09184e72a000",
"input":"0x603880600c6000396000f30060",
"gasPrice": "0x09184e72a000",
"input": "0x603880600c6000396000f30060",
}],
"uncles": ["0x460cfb8472af2c5fd05b5a2", "0xd5460cfb8472af2c5fd05b5a2"]
};
Expand All @@ -87,24 +87,24 @@ var formattedBlockResultWithTx = {
"miner": "0x4E65FDa2159562a496F9f3522f89122A3088497a",
"difficulty": '163591',
"totalDifficulty": '163591',
"size": 163591,
"size": 163591,
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": 653145,
"gasUsed": 653145,
"timestamp": 1424182926,
"transactions": [{
"status": "mined",
"hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"hash": "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"nonce": 2,
"blockHash": "0x6fd9e2a26ab",
"blockNumber": 5599,
"transactionIndex": 1,
"from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1",
"to":"0x85F43D8a49eeB85d32Cf465507DD71d507100C1d",
"transactionIndex": 1,
"from": "0x407D73d8a49eeb85D32Cf465507dd71d507100c1",
"to": "0x85F43D8a49eeB85d32Cf465507DD71d507100C1d",
"value": '520464',
"gas": 520464,
"gas": '520464',
"gasPrice": '10000000000000',
"input":"0x603880600c6000396000f30060",
"input": "0x603880600c6000396000f30060",
}],
"uncles": ["0x460cfb8472af2c5fd05b5a2", "0xd5460cfb8472af2c5fd05b5a2"]
};
Expand All @@ -114,19 +114,19 @@ var tests = [{
formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', false],
result: blockResult,
formattedResult: formattedBlockResult,
call: 'eth_'+ method + 'ByHash'
},{
call: 'eth_' + method + 'ByHash'
}, {
args: [436],
formattedArgs: ['0x1b4', false],
result: blockResult,
formattedResult: formattedBlockResult,
call: 'eth_'+ method + 'ByNumber'
},{
call: 'eth_' + method + 'ByNumber'
}, {
args: [436, true],
formattedArgs: ['0x1b4', true],
result: blockResultWithTx,
formattedResult: formattedBlockResultWithTx,
call: 'eth_'+ method + 'ByNumber'
call: 'eth_' + method + 'ByNumber'
}];

testMethod.runTests('eth', method, tests);
Expand Down
2 changes: 1 addition & 1 deletion test/eth.getTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var formattedTxResult = {
"from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address
"to":"0x85F43D8a49eeB85d32Cf465507DD71d507100C1d", // checksum address
"value": '520464',
"gas": 520464,
"gas": '520464',
"gasPrice": '10000000000000',
"input":"0x603880600c6000396000f30060"
};
Expand Down
2 changes: 1 addition & 1 deletion test/eth.getTransactionFromBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var formattedTxResult = {
"from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address
"to":"0x85F43D8a49eeB85d32Cf465507DD71d507100C1d", // checksum address
"value": '520464',
"gas": 520464,
"gas": '520464',
"gasPrice": '10000000000000',
"input":"0x603880600c6000396000f30060"
};
Expand Down