Skip to content

Commit

Permalink
Merge pull request #25 from getsafle/feature-update-returnObject-getFee
Browse files Browse the repository at this point in the history
updated returned object of getFee
  • Loading branch information
sshubhamagg authored Dec 1, 2023
2 parents 6576ef4 + e946f87 commit 3281ec5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 14 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,22 @@ class KeyringController extends EventEmitter {
async getFees(optimismTx, web3) {
const { from, to, value, data } = optimismTx
const gasLimit = await web3.eth.estimateGas({ from, to, value, data });
const gasPrice = await web3.eth.getGasPrice();
return {
gasLimit: gasLimit,
gasPrice: parseInt(gasPrice)
const gasPrice = parseInt(await web3.eth.getGasPrice());
const fees = {
"slow":{
"gasPrice": parseInt(gasPrice)
},
"standard":{
"gasPrice": gasPrice + parseInt(gasPrice * 0.05)
},
"fast":{
"gasPrice": gasPrice + parseInt(gasPrice * 0.1)
},
baseFee: 0
}
return { gasLimit: gasLimit, fees: fees}
}

}

const getBalance = async (address, web3) => {
Expand Down
3 changes: 0 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ describe('Initialize wallet ', () => {
console.log(" with manual gasLimit ", fees)

const privateKey = await optimismKeyring.exportAccount(accounts[0])
//console.log('privateKey=',privateKey)
const tx3 = await optimismKeyring.sign(TESTING_MESSAGE_1, privateKey, web3)
console.log("tx3 ", tx3)
})
Expand Down Expand Up @@ -149,8 +148,6 @@ describe('Initialize wallet ', () => {
const signedTX = await optimismKeyring.signTransaction(rawTx, privateKey)
console.log("signedTX ", signedTX)

// const sentTX = await optimismKeyring.sendTransaction(signedTX, web3)
//console.log("sentTX ", sentTX)
})

})

0 comments on commit 3281ec5

Please sign in to comment.