|
1 | 1 | import { Chain, Chains } from './types'
|
2 | 2 | import { chains } from './chains'
|
3 |
| -import { ChainId } from './enums' |
4 | 3 | export { NativeCurrency, Explorer, Parent } from './types'
|
5 | 4 | export { ChainName, ChainId } from './enums'
|
6 |
| -export { chains, Chain, Chains } |
| 5 | +export { Chain, Chains } |
7 | 6 |
|
8 | 7 | /**
|
9 | 8 | * Get a chain by its `id`.
|
10 | 9 | * @param id - The `id` of the chain
|
11 | 10 | * @returns The `Chain` object associated with the chain `id`
|
12 | 11 | */
|
13 |
| -const getById = (id: number): Chain | undefined => chains[id] |
| 12 | +export const getChainById = (id: number): Chain | undefined => chains[id] |
14 | 13 |
|
15 | 14 | /**
|
16 | 15 | * Get a chain by its `name`.
|
17 | 16 | * @param name - The `name` of the chain
|
18 | 17 | * @returns The `Chain` object associated with the chain `name`
|
19 | 18 | */
|
20 |
| -const getByName = (name: string): Chain | undefined => |
| 19 | +export const getChainByName = (name: string): Chain | undefined => |
21 | 20 | Object.values(chains).find(chain => chain.name === name) || {}
|
22 | 21 |
|
23 | 22 | /**
|
24 | 23 | * Get a chain by its `id` or by its `name`.
|
25 | 24 | * @param idOrName - The name or id of the chain
|
26 | 25 | * @returns The `Chain` object associated with the `id` or `name`
|
27 | 26 | */
|
28 |
| -const get = (idOrName: string | number): Chain | undefined => |
29 |
| - typeof idOrName === 'number' ? getById(idOrName) : getByName(idOrName) |
| 27 | +export const getChain = (idOrName: string | number): Chain | undefined => |
| 28 | + typeof idOrName === 'number' ? getChainById(idOrName) : getChainByName(idOrName) |
30 | 29 |
|
31 | 30 | /**
|
32 | 31 | * Gets the entire `chains` object
|
33 | 32 | * @returns An object containing all chains
|
34 | 33 | */
|
35 |
| -const all = (): Chains => chains |
| 34 | +export const allChains = (): Chains => chains |
36 | 35 |
|
37 |
| -export default { getById, getByName, get, all } |
0 commit comments