Skip to content

Commit

Permalink
added sign() to get v,r,s
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsaurabhx0 committed Dec 12, 2023
1 parent 17958c3 commit b9d2391
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ObservableStore = require('obs-store')
const encryptor = require('browser-passworder')
const { normalize: normalizeAddress } = require('eth-sig-util')

const { Common, Hardfork } =require('@ethereumjs/common')
const { Common, Hardfork } = require('@ethereumjs/common')
const { FeeMarketEIP1559Transaction } = require('@ethereumjs/tx');
const { bufferToHex } = require('ethereumjs-util')

Expand Down Expand Up @@ -283,6 +283,25 @@ class KeyringController extends EventEmitter {
return signedTx
}

/**
* Sign Transaction or Message to get v,r,s
*
* Signs a transaction object.
*
* @param {Object} rawTx - The transaction or message to sign.
* @param {Object} privateKey - The private key of the account.
* @param {Object} web3 - web3 object.
* @returns {Object} The signed transaction object.
*/
async sign(rawTx, privateKey, web3) {
let signedTx;
if (typeof rawTx === 'string')
signedTx = await web3.eth.accounts.sign(rawTx, privateKey);
else
signedTx = await web3.eth.accounts.signTransaction({ ...rawTx, gas: await web3.eth.estimateGas(rawTx) }, privateKey)
return signedTx
}


/**
* Sign Message
Expand Down Expand Up @@ -548,7 +567,7 @@ class KeyringController extends EventEmitter {
fees: fees
}
}
a
a
}

const getBalance = async (address, web3) => {
Expand Down

0 comments on commit b9d2391

Please sign in to comment.