From 9bc52527f9999357b1702fb8f246e1e3c07a78a0 Mon Sep 17 00:00:00 2001 From: saurabh Date: Thu, 30 Nov 2023 18:39:29 +0530 Subject: [PATCH 1/4] updated gasfee() method for gas estimation --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/index.js | 11 +++++++---- test/index.js | 13 +++++++++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee1965c..58d8b56 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 gasFee() method for type 1 transactions and added its test. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 91f8a28..8e072fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/vault-arbitrum-controller", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/vault-arbitrum-controller", - "version": "1.0.7", + "version": "1.0.8", "license": "ISC", "dependencies": { "bip39": "^3.0.4", diff --git a/package.json b/package.json index 571de0c..6b8e58e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/vault-arbitrum-controller", - "version": "1.0.7", + "version": "1.0.8", "description": "arbitrum controller for safle vault", "engines": { "node": ">= 10" diff --git a/src/index.js b/src/index.js index df72608..d2e9ed1 100644 --- a/src/index.js +++ b/src/index.js @@ -505,11 +505,14 @@ class KeyringController extends EventEmitter { return { transactionDetails: receipt.transactionHash } } - async getFees(arbitrumTx, web3) { - const { from, to, value, data, gasLimit } = arbitrumTx - const estimate = gasLimit ? gasLimit : await web3.eth.estimateGas({ to, from, value, data }) + async getFees(velasTx, web3) { + const { from, to, value, data, manualLimit } = velasTx + const gasLimit = manualLimit ? manualLimit : await web3.eth.estimateGas({ to, from, 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 eb155cd..90b93c5 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 arbitrum tx", async () => { + const accounts = await arbitrumKeyring.getAccounts() + const web3 = new Web3(TESTNET.URL); + const tx = { + from: accounts[0], + to: '0x641BB2596D8c0b32471260712566BF933a2f1a8e', + value: 0, + data: "0x00" + } + const getEstimate = await arbitrumKeyring.getFees(tx, web3) + console.log(" get gas estimate ", getEstimate) + }) + it("sign Transaction ", async () => { const accounts = await arbitrumKeyring.getAccounts() From 982ad4d35ee0154caaf78e1e54e4568a654cb6e3 Mon Sep 17 00:00:00 2001 From: saurabh Date: Thu, 30 Nov 2023 18:40:55 +0530 Subject: [PATCH 2/4] 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 58d8b56..cec5f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,4 +41,5 @@ ### 1.0.8 (2023-11-30) -- Updated gasFee() method for type 1 transactions and added its test. \ No newline at end of file +- Updated gasFee() method for type 1 transactions and added its test. +- Changed license to MIT. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8e072fd..7a89d27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "": { "name": "@getsafle/vault-arbitrum-controller", "version": "1.0.8", - "license": "ISC", + "license": "MIT", "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", diff --git a/package.json b/package.json index 6b8e58e..368a204 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "keyring" ], "author": "", - "license": "ISC", + "license": "MIT", "bugs": { "url": "https://github.com/getsafle/vault-arbitrum-controller/issues" }, From 7b5553bb94be8c00521381e7f53967bcb5510f56 Mon Sep 17 00:00:00 2001 From: saurabh Date: Fri, 1 Dec 2023 18:46:21 +0530 Subject: [PATCH 3/4] updated return object of getFee --- src/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index d2e9ed1..676f0dc 100644 --- a/src/index.js +++ b/src/index.js @@ -508,11 +508,20 @@ class KeyringController extends EventEmitter { async getFees(velasTx, web3) { const { from, to, value, data, manualLimit } = velasTx const gasLimit = manualLimit ? manualLimit : await web3.eth.estimateGas({ to, from, 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} } } From d52056e775d007610c667246fc08ab58c9b6734e Mon Sep 17 00:00:00 2001 From: saurabh Date: Fri, 1 Dec 2023 18:59:23 +0530 Subject: [PATCH 4/4] changed param name --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 676f0dc..ce5b032 100644 --- a/src/index.js +++ b/src/index.js @@ -505,8 +505,8 @@ class KeyringController extends EventEmitter { return { transactionDetails: receipt.transactionHash } } - async getFees(velasTx, web3) { - const { from, to, value, data, manualLimit } = velasTx + async getFees(arbitrumTx, web3) { + const { from, to, value, data, manualLimit } = arbitrumTx const gasLimit = manualLimit ? manualLimit : await web3.eth.estimateGas({ to, from, value, data }) const gasPrice = parseInt(await web3.eth.getGasPrice()); const fees = {