Skip to content

Commit

Permalink
updated signTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainLEVI-XXX committed Dec 20, 2023
1 parent 89e0ca0 commit bf278fc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@
### 1.2.5 (2023-12-14)

- Replaced deprecated ethereumjs-tx lib to @ethereumjs/tx and @ethereumjs/common for transaction signing.
- Changed license to MIT.
- Changed license to MIT.
- Removed 'signTransaction' dependency from 'getFees' method.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const keyringTypes = [
SimpleKeyring,
HdKeyring,
]
let chainId;


class KeyringController extends EventEmitter {

Expand Down Expand Up @@ -269,6 +269,8 @@ class KeyringController extends EventEmitter {
async signTransaction(bscTx, privateKey) {

const pkey = Buffer.from(privateKey, 'hex');

const chainId = bscTx.chainId;

const common = Common.custom({ chainId: chainId }, { hardfork: Hardfork.Istanbul })

Expand All @@ -284,6 +286,7 @@ class KeyringController extends EventEmitter {

/**
* Sign Transaction or Message to get v,r,s
*
* Signs a transaction object.
*
* @param {Object} rawTx - The transaction or message to sign.
Expand Down Expand Up @@ -531,7 +534,6 @@ class KeyringController extends EventEmitter {
async getFees(bscTx, web3) {
const { from, to, value, data } = bscTx
const gasLimit = await web3.eth.estimateGas({ to, from, value, data })
chainId = await web3.eth.getChainId();
const gasPrice = parseInt(await web3.eth.getGasPrice());
const fees = {
"slow":{
Expand Down
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('Initialize wallet ', () => {
gasPrice: getFeeEstimate.fees.slow.gasPrice,
nonce: defaultNonce,
data: '0x',
chainId: TESTNET.CHAIN_ID
};

const privateKey = await bscKeyring.exportAccount(accounts[0])
Expand Down

0 comments on commit bf278fc

Please sign in to comment.