-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from atomex-protocol/feat/atm-326-calculation-…
…of-estimated-fees-ethereum Implement fees calculation for ethereum operations
- Loading branch information
Showing
5 changed files
with
67 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as web3Helper from './web3Helper'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import BigNumber from 'bignumber.js'; | ||
import type Web3 from 'web3'; | ||
import type { Unit } from 'web3-utils'; | ||
|
||
export const getGasPriceInWei = async (toolkit: Web3): Promise<BigNumber> => { | ||
const gasPrice = await toolkit.eth.getGasPrice(); | ||
|
||
return new BigNumber(gasPrice); | ||
}; | ||
|
||
export const convertFromWei = (toolkit: Web3, value: BigNumber | string, unit: Unit): BigNumber => { | ||
const stringValue = typeof value === 'string' ? value : value.toString(10); | ||
const result = toolkit.utils.fromWei(stringValue, unit); | ||
|
||
return new BigNumber(result); | ||
}; |