Skip to content

Commit

Permalink
fix: comdex (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick134-bit authored May 2, 2024
1 parent c92f3f5 commit fa9533f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
7 changes: 5 additions & 2 deletions components/Pages/Bonding/hooks/getBondingConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface BondingContractConfig {

export const getBondingConfig = async (client: CosmWasmClient | null,
config: Config) => {
if (!client && !config) {
if (!client || !config?.whale_lair) {
return null
}
const bondingConfig = await fetchConfig(client, config)
Expand All @@ -29,7 +29,10 @@ export const getBondingConfig = async (client: CosmWasmClient | null,
export const fetchConfig = async (client: CosmWasmClient,
config: Config): Promise<BondingContractConfig> => {
// TODO: API
const result: JsonObject = await client.queryContractSmart(config.whale_lair,
if (!client || !config?.whale_lair) {
return null
}
const result: JsonObject = await client.queryContractSmart(config?.whale_lair,
{
config: {},
})
Expand Down
9 changes: 6 additions & 3 deletions components/Pages/Bonding/hooks/getCurrentEpoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export interface Epoch {

export const fetchCurrentEpoch = async (client: CosmWasmClient,
config: Config): Promise<Epoch> => {
const result: JsonObject = await client?.queryContractSmart(config.fee_distributor,
if (!client || !config?.fee_distributor) {
return null
}
const result: JsonObject = await client?.queryContractSmart(config?.fee_distributor,
{
current_epoch: {},
})
Expand All @@ -47,10 +50,10 @@ export const fetchCurrentEpoch = async (client: CosmWasmClient,

export const getCurrentEpoch = async (client: CosmWasmClient,
config: Config) => {
if (!client) {
if (!client || !config?.fee_distributor) {
return null
}

console.log(config, client)
const currentEpoch = await fetchCurrentEpoch(client, config)

return { currentEpoch }
Expand Down
4 changes: 2 additions & 2 deletions components/Pages/Bonding/hooks/getFeeDistributorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const fetchConfig = async (client: CosmWasmClient,
config: Config): Promise<FeeDistributionConfig> => {
// TODO: API

const result: JsonObject = await client.queryContractSmart(config.fee_distributor,
const result: JsonObject = await client.queryContractSmart(config?.fee_distributor,
{
config: {},
})
Expand All @@ -31,7 +31,7 @@ const fetchConfig = async (client: CosmWasmClient,
}
export const getFeeDistributorConfig = async (client: CosmWasmClient,
config: Config) => {
if (!client) {
if (!client || !config?.fee_distributor) {
return null
}
const feeDistributionConfig = await fetchConfig(client, config)
Expand Down
15 changes: 9 additions & 6 deletions components/Pages/Trade/Incentivize/hooks/useEpoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,23 @@ const useEpoch = () => {
const { cosmWasmClient } = useClients(walletChainName)
const { data: config } = useQuery<EpochConfigData>({
queryKey: ['incentive', 'config', contracts?.fee_distributor],
queryFn: async () =>
// TODO: API
await cosmWasmClient?.queryContractSmart(contracts?.fee_distributor, {
queryFn: async () => {
if (!contracts?.fee_distributor) {
return null
}
return await cosmWasmClient?.queryContractSmart(contracts?.fee_distributor, {
config: {},
}),
enabled: Boolean(contracts) && Boolean(cosmWasmClient),
})
},
enabled: Boolean(contracts?.fee_distributor) && Boolean(cosmWasmClient),
})

const { data } = useQuery<EpochData>({
queryKey: ['incentive', 'epoch', contracts?.fee_distributor],
queryFn: async () => await cosmWasmClient?.queryContractSmart(contracts?.fee_distributor, {
current_epoch: {},
}),
enabled: Boolean(contracts) && Boolean(cosmWasmClient),
enabled: Boolean(contracts?.fee_distributor) && Boolean(cosmWasmClient),
})
const dateToEpoch = (givenDate) => {
if (!data?.epoch?.id || !config?.epoch_config?.duration || !givenDate) {
Expand Down
2 changes: 1 addition & 1 deletion constants/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"https://rpc.comdex.one"
],
"rest": [
"https://ww-comdex-rest.polkachu.com"
"https://rest.comdex.one"
]
},
"injective": {
Expand Down
3 changes: 3 additions & 0 deletions public/mainnet/comdex-1/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
}

0 comments on commit fa9533f

Please sign in to comment.