diff --git a/CHANGELOG.md b/CHANGELOG.md index bab9e68..b5ab106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,4 +37,9 @@ ### 1.0.7 (2023-07-05) -- cleaned package structure \ No newline at end of file +- cleaned package structure + +### 1.0.8 (2023-11-30) + +- Updated the getFees() method for gas estimation and added its test. +- Changed the License to MIT. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9ca18ef..d350b7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "@getsafle/vault-optimism-controller", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@getsafle/vault-optimism-controller", - "version": "1.0.7", - "license": "ISC", + "version": "1.0.8", + "license": "MIT" , "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", diff --git a/package.json b/package.json index 24ea5a6..d4c0532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/vault-optimism-controller", - "version": "1.0.7", + "version": "1.0.8", "description": "optimism controller for safle vault", "engines": { "node": ">= 10" @@ -28,7 +28,7 @@ "keyring" ], "author": "", - "license": "ISC", + "license": "MIT", "bugs": { "url": "https://github.com/getsafle/vault-optimism-controller/issues" }, diff --git a/src/index.js b/src/index.js index 71e53ac..1178c94 100644 --- a/src/index.js +++ b/src/index.js @@ -522,10 +522,13 @@ class KeyringController extends EventEmitter { } async getFees(optimismTx, web3) { - const { from, to, value, data, gasLimit } = optimismTx - const estimate = gasLimit ? gasLimit : await web3.eth.estimateGas({ to, from, value, data }) + const { from, to, value, data } = optimismTx + const gasLimit = await web3.eth.estimateGas({ from, to, value, data }); const gasPrice = await web3.eth.getGasPrice(); - return { transactionFees: estimate * gasPrice } + return { + gasLimit: gasLimit, + gasPrice: parseInt(gasPrice) + } } } diff --git a/test/index.js b/test/index.js index 6162050..9ae97d3 100644 --- a/test/index.js +++ b/test/index.js @@ -109,6 +109,19 @@ describe('Initialize wallet ', () => { console.log(" get balance ", balance, accounts) }) + it("Get fees for a optimism tx", async () => { + const accounts = await optimismKeyring.getAccounts() + const web3 = new Web3(TESTNET.URL); + const tx = { + from:accounts[0], + to:'0x641BB2596D8c0b32471260712566BF933a2f1a8e', + value:0, + data:"0x00" + } + const getEstimate = await optimismKeyring.getFees(tx, web3) + console.log(" get gas estimate ", getEstimate) + + }) it("sign Transaction ", async () => { const accounts = await optimismKeyring.getAccounts()