-
Notifications
You must be signed in to change notification settings - Fork 33
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
1 parent
e485eb8
commit b922c9d
Showing
3 changed files
with
153 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
import { Chain } from '@chain-registry/types'; | ||
import { customFind } from './assets'; | ||
|
||
export const getGasPriceStep = (chain: Chain) => { | ||
export const getGasPriceRangesFromChain = (chain: Chain) => { | ||
const feeToken = chain.fees?.fee_tokens?.[0]; | ||
return { | ||
low: chain.fees?.fee_tokens?.[0]?.low_gas_price ?? 0.01, | ||
average: chain.fees?.fee_tokens?.[0]?.average_gas_price ?? 0.025, | ||
high: chain.fees?.fee_tokens?.[0]?.high_gas_price ?? 0.04 | ||
low: feeToken?.low_gas_price ?? 0.01, | ||
average: feeToken?.average_gas_price ?? 0.025, | ||
high: feeToken?.high_gas_price ?? 0.04 | ||
}; | ||
}; | ||
|
||
export const getChainByChainName = (chains: Chain[], chainName: string) => { | ||
return customFind(chains, (chain) => chain.chain_name === chainName); | ||
}; | ||
|
||
export const getChainByChainId = (chains: Chain[], chainId: string) => { | ||
return customFind(chains, (chain) => chain.chain_id === chainId); | ||
}; | ||
|
||
export const getChainNameByChainId = (chains: Chain[], chainId: string) => { | ||
return getChainByChainId(chains, chainId)?.chain_name; | ||
}; | ||
|
||
export const getChainIdByChainName = (chains: Chain[], chainName: string) => { | ||
return getChainByChainName(chains, chainName)?.chain_id; | ||
}; | ||
|
||
export const getChainGasPriceRanges = (chains: Chain[], chainName: string) => { | ||
const chain = getChainByChainName(chains, chainName); | ||
return chain ? getGasPriceRangesFromChain(chain) : undefined; | ||
}; | ||
|
||
export const getChainPrettyName = (chains: Chain[], chainName: string) => { | ||
return getChainByChainName(chains, chainName)?.pretty_name; | ||
}; | ||
|
||
export const getChainBech32Prefix = (chains: Chain[], chainName: string) => { | ||
return getChainByChainName(chains, chainName)?.bech32_prefix; | ||
}; |