22 lines
693 B
TypeScript
22 lines
693 B
TypeScript
import { cacheFn, vaultConfigsCache } from 'api/cache'
|
|
import { getParamsQueryClient } from 'api/cosmwasm-client'
|
|
import { VaultConfigBaseForAddr } from 'types/generated/mars-params/MarsParams.types'
|
|
import iterateContractQuery from 'utils/iterateContractQuery'
|
|
|
|
export const getVaultConfigs = async (
|
|
chainConfig: ChainConfig,
|
|
): Promise<VaultConfigBaseForAddr[]> => {
|
|
try {
|
|
const paramsQueryClient = await getParamsQueryClient(chainConfig)
|
|
return await cacheFn(
|
|
() => iterateContractQuery(paramsQueryClient.allVaultConfigs, 'addr'),
|
|
vaultConfigsCache,
|
|
`${chainConfig.id}/vaultConfigs`,
|
|
600,
|
|
)
|
|
} catch (ex) {
|
|
console.error(ex)
|
|
throw ex
|
|
}
|
|
}
|