-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
3 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
import { evmBasedWeb3 } from '@tatumio/shared-blockchain-evm-based' | ||
import Web3 from 'web3' | ||
import { EvmBasedBlockchain, httpHelper } from '@tatumio/shared-core' | ||
import { hexToNumber } from 'web3-utils' | ||
import { EvmBasedBlockchain } from '@tatumio/shared-core' | ||
|
||
export const xdcWeb3 = (args: { blockchain: EvmBasedBlockchain; client?: Web3 }) => { | ||
const evmBasedWeb3Result = evmBasedWeb3(args) | ||
|
||
return { | ||
...evmBasedWeb3Result, | ||
async getGasPriceInWei(): Promise<string> { | ||
const gasStationUrl = 'https://rpc.xinfin.network/' | ||
|
||
try { | ||
const { data } = await httpHelper.post(`${gasStationUrl}gasPrice`, { | ||
jsonrpc: '2.0', | ||
method: 'eth_gasPrice', | ||
params: [], | ||
id: 1, | ||
}) | ||
const asNumber = hexToNumber(data.result) | ||
return (data ? Web3.utils.toWei(`${asNumber}`, 'wei') : Web3.utils.toWei('0.25', 'gwei')).toString() | ||
} catch (e) { | ||
return Web3.utils.toWei('0.25', 'gwei') | ||
} | ||
}, | ||
} | ||
return evmBasedWeb3(args) | ||
} |