import axios from 'axios';
import { LCD_URL } from 'src/constants/config';
const getParamStaking = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/staking/v1beta1/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamSlashing = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/slashing/v1beta1/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamDistribution = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/distribution/v1beta1/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamBandwidth = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cyber/bandwidth/v1beta1/bandwidth/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamGov = async () => {
try {
const responseGovDeposit = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/gov/v1beta1/params/deposit`,
});
const responseGovTallying = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/gov/v1beta1/params/tallying`,
});
const responseGovVoting = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/gov/v1beta1/params/voting`,
});
const response = {
deposit: responseGovDeposit.data.deposit_params,
tally: responseGovTallying.data.tally_params,
voting: responseGovVoting.data.voting_params,
};
return response;
} catch (e) {
console.log(e);
return null;
}
};
const getParamRank = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cyber/rank/v1beta1/rank/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamInlfation = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/mint/v1beta1/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamResources = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cyber/resources/v1beta1/resources/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamLiquidity = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cosmos/liquidity/v1beta1/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamGrid = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cyber/grid/v1beta1/grid/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamDmn = async () => {
try {
const response = await axios({
method: 'get',
url: `${LCD_URL}/cyber/dmn/v1beta1/dmn/params`,
});
return response.data.params;
} catch (e) {
console.log(e);
return null;
}
};
const getParamNetwork = async (_address, _node) => {
try {
let staking = null;
let slashing = null;
let distribution = null;
let bandwidth = null;
let gov = null;
let rank = null;
let mint = null;
let resources = null;
let liquidity = null;
let grid = null;
let dmn = null;
const dataStaking = await getParamStaking();
if (dataStaking !== null) {
staking = dataStaking;
}
const dataSlashing = await getParamSlashing();
if (dataSlashing !== null) {
slashing = dataSlashing;
}
const dataDistribution = await getParamDistribution();
if (dataDistribution !== null) {
distribution = dataDistribution;
}
const dataGov = await getParamGov();
if (dataGov !== null) {
gov = dataGov;
}
const dataBandwidth = await getParamBandwidth();
if (dataBandwidth !== null) {
bandwidth = dataBandwidth;
}
const dataRank = await getParamRank();
if (dataRank !== null) {
rank = dataRank;
}
const dataInlfation = await getParamInlfation();
if (dataInlfation !== null) {
mint = dataInlfation;
}
const dataResources = await getParamResources();
if (dataResources !== null) {
resources = dataResources;
}
const dataLiquidity = await getParamLiquidity();
if (dataLiquidity !== null) {
liquidity = dataLiquidity;
}
const dataGrid = await getParamGrid();
if (dataGrid !== null) {
grid = dataGrid;
}
const dataDmn = await getParamDmn();
if (dataDmn !== null) {
dmn = dataDmn;
}
const response = {
staking,
slashing,
distribution,
bandwidth,
gov,
rank,
mint,
resources,
liquidity,
grid,
dmn,
};
return response;
} catch (e) {
console.log(e);
return null;
}
};
export default getParamNetwork;