-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1059 from mars-protocol/develop
v2.6.1
- Loading branch information
Showing
7 changed files
with
77 additions
and
128 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,25 +1,27 @@ | ||
import { ChainInfoID } from 'types/enums'; | ||
import { ChainInfoID } from 'types/enums' | ||
|
||
export default async function getGasPrice(chainConfig: ChainConfig) { | ||
const { id, endpoints, gasPrice, defaultCurrency } = chainConfig; | ||
|
||
if (!endpoints.gasPrices) return gasPrice; | ||
const { id, endpoints, gasPrice, defaultCurrency } = chainConfig | ||
|
||
const uri = id === ChainInfoID.Osmosis1 | ||
? new URL(endpoints.gasPrices) | ||
: new URL(endpoints.gasPrices, endpoints.rest); | ||
if (!endpoints.gasPrices) return gasPrice | ||
|
||
const uri = | ||
id === ChainInfoID.Osmosis1 | ||
? new URL(endpoints.gasPrices) | ||
: new URL(endpoints.gasPrices, endpoints.rest) | ||
|
||
try { | ||
const response = await fetch(uri.toString()); | ||
const data = await response.json(); | ||
const response = await fetch(uri.toString()) | ||
const data = await response.json() | ||
|
||
const price = id === ChainInfoID.Osmosis1 | ||
? (data as { base_fee: string }).base_fee | ||
: (data as { price: Coin }).price.amount; | ||
const price = | ||
id === ChainInfoID.Osmosis1 | ||
? (data as { base_fee: string }).base_fee | ||
: (data as { price: Coin }).price.amount | ||
|
||
return `${price}${defaultCurrency.coinMinimalDenom}`; | ||
return `${price}${defaultCurrency.coinMinimalDenom}` | ||
} catch (e) { | ||
console.error('Failed to fetch gas price:', e); | ||
return gasPrice; | ||
console.error('Failed to fetch gas price:', e) | ||
return gasPrice | ||
} | ||
} |
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
Oops, something went wrong.