Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/disable not connected chains improvements #394

Merged
merged 12 commits into from
Oct 9, 2023
26 changes: 13 additions & 13 deletions components/Finder.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { ReactNode } from 'react'

import { Link } from '@chakra-ui/react'

import { truncate } from '../libs/text'
import { ChainId } from 'constants/index'
import { truncate } from 'libs/text'

type Props = {
chainId: string
txHash: string
children?: ReactNode
}

const getUrl = (chainId, txHash) => {
const getUrl = (chainId: string, txHash: string) => {
switch (chainId) {
case 'uni-6':
return `https://testnet.mintscan.io/juno-testnet/txs/${txHash}`
case 'migaloo-1':
case ChainId.migaloo:
return `https://explorer.silknodes.io/migaloo/tx/${txHash}`
case 'narwhal-1':
case ChainId.narwhal:
return `https://testnet.migaloo.explorers.guru/transaction/${txHash}`
case 'pisco-1':
case ChainId.pisco:
return `https://finder.terra.money/testnet/tx/${txHash}`
case 'juno-1':
case ChainId.juno:
return `https://mintscan.io/juno/txs/${txHash}`
case 'phoenix-1':
case ChainId.terra:
return `https://finder.terra.money/mainnet/tx/${txHash}`
case 'chihuahua-1':
case ChainId.chihuahua:
return `https://www.mintscan.io/chihuahua/txs/${txHash}`
case 'injective-888':
return `https://testnet.explorer.injective.network/transaction/${txHash}`
case 'injective-1':
case ChainId.injective:
return `https://explorer.injective.network/transaction/${txHash}`
case 'comdex-1':
case ChainId.comdex:
return `https://mintscan.io/comdex/txs/${txHash}`
case 'pacific-1':
case ChainId.sei:
return `https://ping.pub/sei/tx/${txHash}`
case 'columbus-5':
case ChainId.terrac:
return `https://ping.pub/terra-luna/tx/${txHash}`
default:
return null
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions components/Icons/ShellWalletIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ShellWalletIcon = () => (<img src="/logos/shell-icon.png" width={'27px'} />)
1 change: 1 addition & 0 deletions components/Icons/TerraStationWalletIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TerraStationWalletIcon = () => (<img src="/logos/station-icon.png" width={'27px'} />)
11 changes: 11 additions & 0 deletions components/Icons/WalletConnectIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Image } from '@chakra-ui/react'

export const WalletConnectIcon = () => (
<Image
src={'/logos/wallet-connect-icon.png'}
width="auto"
maxW="1.5rem"
maxH="1.5rem"
alt="token1-img"
/>
)
File renamed without changes.
6 changes: 3 additions & 3 deletions components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
VStack,
useDisclosure,
} from '@chakra-ui/react'
import BurgerIcon from 'components/icons/BurgerIcon'
import { ACTIVE_BONDING_NETWORKS } from 'constants/index'
import BurgerIcon from 'components/Icons/BurgerIcon'
import { ACTIVE_BONDING_NETWORKS, ChainId } from 'constants/index'
import { useRecoilValue } from 'recoil'
import { chainState } from 'state/chainState'

Expand Down Expand Up @@ -80,7 +80,7 @@ const Navbar = () => {
<Logo />
</Box>
<Card paddingX={10} gap={6}>
{(chainId === 'columbus-5' ? luncMenuLinks : ACTIVE_BONDING_NETWORKS.includes(chainId)
{(chainId === ChainId.terrac ? luncMenuLinks : ACTIVE_BONDING_NETWORKS.includes(chainId)
? menuLinks
: bondingDisabledMenuLinks
).map((menu) => (
Expand Down
7 changes: 3 additions & 4 deletions components/Pages/Dashboard/BondingActions/hooks/bondTokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate/build/signingcosmwasmclient'
import { coin } from '@cosmjs/stargate'
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { ChainId } from 'constants/index'
import { TerraTreasuryService } from 'services/treasuryService'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'

Expand All @@ -27,18 +28,16 @@ export const bondTokens = async (
contractAddress: config.whale_lair,
message: handleMsg,
funds: [coin(amount, denom)] })
let fee = 'auto'
if (await signingClient.getChainId() === 'columbus-5') {
let fee: any = 'auto'
if (await signingClient.getChainId() === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, [execMsg], '',
) * 1.3)
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(
amount, denom, gas,
)
}

return await signingClient.signAndBroadcast(
// @ts-ignore
address, [execMsg], fee, '',
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate/build/signingcosmwasmclient'
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { ChainId } from 'constants/index'
import { TerraTreasuryService } from 'services/treasuryService'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'

Expand All @@ -16,8 +17,8 @@ export const claimRewards = async (
contractAddress: config.fee_distributor,
message: handleMsg,
funds: [] })
let fee = 'auto'
if (await signingClient.getChainId() === 'columbus-5') {
let fee: any = 'auto'
if (await signingClient.getChainId() === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, [execMsg], '',
) * 1.3)
Expand All @@ -26,7 +27,6 @@ export const claimRewards = async (
)
}
return await signingClient.signAndBroadcast(
// @ts-ignore
address, [execMsg], fee, '',
)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate/build/signingcosmwasmclient'
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { ChainId } from 'constants/index'
import { TerraTreasuryService } from 'services/treasuryService'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'

import { TerraTreasuryService } from '../../../../../services/treasuryService'

export const createNewEpoch = async (
signingClient: SigningCosmWasmClient,
config: Config,
Expand All @@ -17,8 +17,8 @@ export const createNewEpoch = async (
contractAddress: config.fee_distributor,
message: handleMsg,
funds: [] })
let fee = 'auto'
if (await signingClient.getChainId() === 'columbus-5') {
let fee: any = 'auto'
if (await signingClient.getChainId() === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, [execMsg], '',
) * 1.3)
Expand All @@ -27,7 +27,6 @@ export const createNewEpoch = async (
)
}
return await signingClient.signAndBroadcast(
// @ts-ignore
address, [execMsg], fee, '',
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate/build/signingcosmwasmclient'
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { ChainId } from 'constants/index'
import { TerraTreasuryService } from 'services/treasuryService'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'

Expand Down Expand Up @@ -27,8 +28,8 @@ export const unbondTokens = async (
contractAddress: config.whale_lair,
message: handleMsg,
funds: [] })
let fee = 'auto'
if (await signingClient.getChainId() === 'columbus-5') {
let fee: any = 'auto'
if (await signingClient.getChainId() === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, [execMsg], '',
) * 1.3)
Expand All @@ -37,7 +38,6 @@ export const unbondTokens = async (
)
}
return await signingClient.signAndBroadcast(
// @ts-ignore
address, [execMsg], fee, '',
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate/build/signingcosmwasmclient'
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { ChainId } from 'constants/index'
import { TerraTreasuryService } from 'services/treasuryService'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'

Expand All @@ -19,8 +20,8 @@ export const withdrawTokens = async (
contractAddress: config.whale_lair,
message: handleMsg,
funds: [] })
let fee = 'auto'
if (await signingClient.getChainId() === 'columbus-5') {
let fee: any = 'auto'
if (await signingClient.getChainId() === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, [execMsg], '',
) * 1.3)
Expand All @@ -29,7 +30,6 @@ export const withdrawTokens = async (
)
}
return await signingClient.signAndBroadcast(
// @ts-ignore
address, [execMsg], fee, '',
)
}
2 changes: 1 addition & 1 deletion components/Pages/Dashboard/RewardsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const ProgressBar = ({ progress, currentEpochStartTimeInNano }) => {
borderRadius="10px"
position="relative"
animation={
isImminent ? `${pulseAnimation} 1.8s ease-in-out infinite` : undefined
isImminent ? `${pulseAnimation} 1.8s ease-in-out infinite` : null
}
/>
</Box>
Expand Down
11 changes: 7 additions & 4 deletions components/Pages/Dashboard/RewardsTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const RewardsTooltip = ({
isWalletConnected,
daysSinceLastClaim,
}: Props) => {
const [isLabelOpen, setIsLabelOpen] = useState(false)
const lastClaimed = () => {
if (daysSinceLastClaim >= 21) {
return '21+ days ago'
Expand Down Expand Up @@ -46,12 +47,12 @@ export const RewardsTooltip = ({
label={
isWalletConnected ? (
<VStack
minW="250px"
minW="180px"
minH="fit-content"
borderRadius="10px"
bg="blackAlpha.900"
px="4"
py="4"
px="2"
py="2"
position="relative"
border="none"
justifyContent="center"
Expand All @@ -69,7 +70,9 @@ export const RewardsTooltip = ({
} // Displaying nothing when wallet disconnected
bg="transparent"
>
<VStack alignItems="flex-start" minW={50}>
<VStack alignItems="flex-start" minW={50} onMouseEnter={() => setIsLabelOpen(true)}
onMouseLeave={() => setIsLabelOpen(false)}
onClick={() => setIsLabelOpen(!isLabelOpen)}>
<Text ref={textRef} mb="-0.3rem" color="white">
{dollarValue}
</Text>
Expand Down
8 changes: 4 additions & 4 deletions components/Pages/Trade/Incentivize/hooks/useClosePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { useMemo } from 'react'
import { useMutation } from 'react-query'

import { useChain } from '@cosmos-kit/react-lite'
import { ChainId } from 'constants/index'
import { useClients } from 'hooks/useClients'
import useTxStatus from 'hooks/useTxStatus'
import { usePoolFromListQueryById } from 'queries/usePoolsListQuery'
import { useRecoilValue } from 'recoil'
import { TerraTreasuryService } from 'services/treasuryService'
import { chainState } from 'state/chainState'
import { createExecuteMessage, validateTransactionSuccess } from 'util/messages/index'

import { TerraTreasuryService } from '../../../../../services/treasuryService'

type OpenPosition = {
poolId: string
}
Expand Down Expand Up @@ -64,8 +64,8 @@ export const useClosePosition = ({ poolId }: OpenPosition) => {
console.log({ msg,
flowId,
poolId })
let fee:any = 'auto'
if (await signingClient.getChainId() === 'columbus-5') {
let fee: any = 'auto'
if (await signingClient.getChainId() === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, msg, '',
) * 1.3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { fetchTotalPoolSupply } from 'components/Pages/Trade/Pools/hooks/fetchTo
import {
AMP_WHALE_TOKEN_SYMBOL,
B_WHALE_TOKEN_SYMBOL,
ChainId,
WHALE_TOKEN_SYMBOL,
} from 'constants/index'
import usePrices from 'hooks/usePrices'
Expand Down Expand Up @@ -181,9 +182,9 @@ export const useIncentivePoolInfo = (

useEffect(() => {
const fetchPoolData = async () => {
currentChainPrefix = chainId === 'columbus-5' ? 'terra-classic' : currentChainPrefix
currentChainPrefix = chainId === ChainId.terrac ? 'terra-classic' : currentChainPrefix
const poolData =
currentChainPrefix === 'terra' && chainId !== 'columbus-5'
currentChainPrefix === 'terra' && chainId !== ChainId.terrac
? await getPairAprAndDailyVolumeTerra(pools)
: await getPairAprAndDailyVolume(pools, currentChainPrefix)
setPoolsWithAprAnd24HrVolume(poolData)
Expand Down
5 changes: 3 additions & 2 deletions components/Pages/Trade/Incentivize/hooks/useOpenFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from 'components/Pages/Dashboard/hooks/useDashboardData'
import useEpoch from 'components/Pages/Trade/Incentivize/hooks/useEpoch'
import useFactoryConfig from 'components/Pages/Trade/Incentivize/hooks/useFactoryConfig'
import { ChainId } from 'constants/index'
import { useClients } from 'hooks/useClients'
import useSimulate from 'hooks/useSimulate'
import { useTokenInfo } from 'hooks/useTokenInfo'
Expand Down Expand Up @@ -120,8 +121,8 @@ export const useOpenFlow = ({ poolId, token, startDate, endDate }: Props) => {

const { mutate: submit, ...tx } = useMutation({
mutationFn: async () => {
let fee:any = 'auto'
if (chainId === 'columbus-5') {
let fee: any = 'auto'
if (chainId === ChainId.terrac) {
const gas = Math.ceil(await signingClient.simulate(
address, msgs, '',
) * 1.3)
Expand Down
24 changes: 16 additions & 8 deletions components/Pages/Trade/Liquidity/BondingDaysSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ type Props = {
show: boolean
}

const setBondingdays = (input: string, setBondingDays: any) => {
if (Number(input) <= 365 && Number(input) >= 1) {
const setBondingdays = (
input: string, setBondingDays: any, bondingDays:number,
) => {
if (Number(input).valueOf() === 0 && Number(bondingDays).valueOf() === 0) {
setBondingDays(Number(bondingDays).valueOf())
}
if (Number(input) <= 365 && Number(input) >= 0) {
setBondingDays(input)
}
if (Number(input) > 365) {
Expand Down Expand Up @@ -51,10 +56,10 @@ export const BondingDaysSlider = ({
<Box width="full">
<Slider
focusThumbOnChange={false}
defaultValue={0}
defaultValue={1}
value={bondingDays}
step={1}
min={0}
min={1}
max={365}
borderRadius={100}
height={1.5}
Expand All @@ -75,14 +80,17 @@ export const BondingDaysSlider = ({
maxWidth={''}
>
<NumberInput
defaultValue={0}
min={0}
defaultValue={1}
min={1}
max={365}
textColor={'white'}
size={'xs'}
value={bondingDays}
value={bondingDays.valueOf()}
inputMode={'numeric'}
onChange={(elem: string) => {
setBondingdays(elem, setBondingDays)
setBondingdays(
elem, setBondingDays, bondingDays,
)
}}
>
<NumberInputField border={'hidden'} maxWidth={'70'} />
Expand Down
Loading