From 33db16f727719892f82be4c6cce466ff70977905 Mon Sep 17 00:00:00 2001 From: saurabh Date: Thu, 30 Nov 2023 16:44:23 +0530 Subject: [PATCH 1/2] updated getFees() and added its test --- CHANGELOG.md | 6 +++++- package-lock.json | 6 +++--- package.json | 2 +- src/index.js | 9 ++++++--- test/index.js | 13 +++++++++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bab9e68..2485efd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,4 +37,8 @@ ### 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. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9ca18ef..14dc2b4 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..8b30a3d 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" 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() From 21ace46865d57409c788c5072b15cf3af99da9d5 Mon Sep 17 00:00:00 2001 From: saurabh Date: Thu, 30 Nov 2023 16:50:38 +0530 Subject: [PATCH 2/2] changed license --- CHANGELOG.md | 3 ++- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2485efd..b5ab106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,4 +41,5 @@ ### 1.0.8 (2023-11-30) -- Updated the getFees() method for gas estimation and added its test. \ No newline at end of file +- 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 14dc2b4..d350b7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "": { "name": "@getsafle/vault-optimism-controller", "version": "1.0.8", - "license": "MIT", + "license": "MIT" , "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", diff --git a/package.json b/package.json index 8b30a3d..d4c0532 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "keyring" ], "author": "", - "license": "ISC", + "license": "MIT", "bugs": { "url": "https://github.com/getsafle/vault-optimism-controller/issues" },