Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Merged
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
Prev Previous commit
Next Next commit
Merge conflicts
  • Loading branch information
GregTheGreek authored and spacesailor24 committed Aug 26, 2021
commit f8b1f4b25cfd079182dd2ffdf9bb2c5a0d8a1434
6 changes: 5 additions & 1 deletion packages/web3-core-helpers/src/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ var _txInputFormatter = function (options) {
if (options.gas || options.gasLimit) {
options.gas = options.gas || options.gasLimit;
}

if (options.maxPriorityFeePerGas || options.maxFeePerGas) {
delete options.gasPrice;
}

['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
['gasPrice', 'gas', 'value', 'maxPriorityFeePerGas', 'maxFeePerGas', 'nonce'].filter(function (key) {
return options[key] !== undefined;
}).forEach(function (key) {
options[key] = utils.numberToHex(options[key]);
Expand Down
47 changes: 47 additions & 0 deletions test/eth.accounts.signTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var Web3 = require('../packages/web3');
var Accounts = require("./../packages/web3-eth-accounts");
var chai = require('chai');
var assert = chai.assert;
var bn = require('bn.js');

var common = {
baseChain: 'mainnet',
Expand Down Expand Up @@ -649,6 +650,52 @@ var tests = [
transactionHash: "0xbc2c9edab3d4e3a795fa402b52d6149e874de15f0cc6c0858eb34e1fe1ef31fe",
messageHash: "0xa3a2cdc45e9cefb9a614ead90ce65f68bcf8a90dbe0ccbd84c1b62403bd05346"
},
{
// test #28
address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23',
iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV',
privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318',
transaction: {
chainId: 1,
nonce: 0,
maxPriorityFeePerGas: new bn('0x3B9ACA00'),
maxFeePerGas: new bn('0xB2D05E00'),
gasLimit: '0x6A40',
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test
value: "1000000000",
data: "",
common: commonLondon
},
// signature from eth_signTransaction
rawTransaction: "0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3",
oldSignature: "0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3",
transactionHash: "0xd5b7290a477b9c421d39e61d0f566ec33276fb49b9ff85cfd6152a18f1c92dab",
messageHash: "0x17e20e530a889ce52057de228b5b97edcad6002468d723346cd0b6b7a9943457"
},
{
// test #29
address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23',
iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV',
privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318',
transaction: {
chainId: 1,
nonce: 0,
maxPriorityFeePerGas: '1000000000',
maxFeePerGas: '3000000000',
gasLimit: '0x6A40',
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test
value: "1000000000",
data: "",
common: commonLondon
},
// signature from eth_signTransaction
rawTransaction: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36",
oldSignature: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36",
transactionHash: "0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e",
messageHash: "0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b"
},
];

describe("eth", function () {
Expand Down
53 changes: 53 additions & 0 deletions test/formatters.inputTransactionFormatter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var bn = require('bn.js');
var chai = require('chai');
var assert = chai.assert;

var formatters = require('../packages/web3-core-helpers/src/formatters.js');

var tests = [{
Expand Down Expand Up @@ -98,6 +100,57 @@ var tests = [{
gas: '0x3e8',
gasPrice: '0x3e8'
}
}, {
input: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
gas: '0x3e8',
maxPriorityFeePerGas: '1000',
maxFeePerGas: '1000'
},
result: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
gas: '0x3e8',
maxPriorityFeePerGas: '0x3e8',
maxFeePerGas: '0x3e8'
}
}, {
input: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
gas: '0x3e8',
maxPriorityFeePerGas: 1000,
maxFeePerGas: 1000
},
result: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
gas: '0x3e8',
maxPriorityFeePerGas: '0x3e8',
maxFeePerGas: '0x3e8'
}
}, {
input: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
gas: '0x3e8',
maxPriorityFeePerGas: new bn(1000),
maxFeePerGas: new bn(1000)
},
result: {
data: '0x34234bf23bf4234',
value: '0x64',
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
gas: '0x3e8',
maxPriorityFeePerGas: '0x3e8',
maxFeePerGas: '0x3e8'
}
}];

describe('formatters', function () {
Expand Down