Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging dev code to test #27

Merged
merged 6 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@

### 1.0.7 (2023-07-05)

- cleaned package structure
- cleaned package structure

### 1.0.8 (2023-11-30)

- Updated gasFee() method for type 1 transactions and added its test.
- Changed license to MIT.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -28,7 +28,7 @@
"keyring"
],
"author": "",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/getsafle/vault-arbitrum-controller/issues"
},
Expand Down
20 changes: 16 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,22 @@ class KeyringController extends EventEmitter {
}

async getFees(arbitrumTx, web3) {
const { from, to, value, data, gasLimit } = arbitrumTx
const estimate = gasLimit ? gasLimit : await web3.eth.estimateGas({ to, from, value, data })
const gasPrice = await web3.eth.getGasPrice();
return { transactionFees: estimate * gasPrice }
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 = {
"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}
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading