|
1 | | -import { Asset, Chain } from '@chain-registry/types'; |
2 | | -import { ChainInfo, Currency } from '@keplr-wallet/types'; |
3 | 1 | import { fromBech32 } from '@cosmjs/encoding'; |
4 | 2 |
|
5 | | -export const makeKeplrChainInfo = (chain: Chain, asset: Asset): ChainInfo => { |
6 | | - const currency: Currency = { |
7 | | - coinDenom: asset.symbol, |
8 | | - coinMinimalDenom: asset.base, |
9 | | - coinDecimals: |
10 | | - asset.denom_units.find(({ denom }) => denom === asset.display) |
11 | | - ?.exponent ?? 6, |
12 | | - coinGeckoId: asset.coingecko_id, |
13 | | - coinImageUrl: |
14 | | - asset.logo_URIs?.svg || |
15 | | - asset.logo_URIs?.png || |
16 | | - asset.logo_URIs?.jpeg || |
17 | | - '', |
18 | | - }; |
19 | | - |
20 | | - return { |
21 | | - rpc: chain.apis?.rpc?.[0].address ?? '', |
22 | | - rest: chain.apis?.rest?.[0].address ?? '', |
23 | | - chainId: chain.chain_id, |
24 | | - chainName: chain.chain_name, |
25 | | - bip44: { |
26 | | - coinType: 118, |
27 | | - }, |
28 | | - bech32Config: { |
29 | | - bech32PrefixAccAddr: chain.bech32_prefix, |
30 | | - bech32PrefixAccPub: chain.bech32_prefix + 'pub', |
31 | | - bech32PrefixValAddr: chain.bech32_prefix + 'valoper', |
32 | | - bech32PrefixValPub: chain.bech32_prefix + 'valoperpub', |
33 | | - bech32PrefixConsAddr: chain.bech32_prefix + 'valcons', |
34 | | - bech32PrefixConsPub: chain.bech32_prefix + 'valconspub', |
35 | | - }, |
36 | | - currencies: [currency], |
37 | | - feeCurrencies: [ |
38 | | - { |
39 | | - ...currency, |
40 | | - gasPriceStep: { |
41 | | - low: chain.fees?.fee_tokens[0].low_gas_price ?? 0.0025, |
42 | | - average: chain.fees?.fee_tokens[0].average_gas_price ?? 0.025, |
43 | | - high: chain.fees?.fee_tokens[0].high_gas_price ?? 0.04, |
44 | | - }, |
45 | | - }, |
46 | | - ], |
47 | | - stakeCurrency: currency, |
48 | | - }; |
49 | | -}; |
50 | | - |
51 | 3 | export const creditFromFaucet = async ( |
52 | 4 | address: string, |
53 | 5 | denom: string, |
|
0 commit comments