diff --git a/components/AssetInput/AssetInput.tsx b/components/AssetInput/AssetInput.tsx index 621fe903..231efabd 100644 --- a/components/AssetInput/AssetInput.tsx +++ b/components/AssetInput/AssetInput.tsx @@ -24,12 +24,11 @@ interface AssetInputProps { balance?: number whalePrice?: number disabled?: boolean - minMax?: boolean + hideHalfMax?: boolean isSingleInput?: boolean hideToken?: string edgeTokenList?: string[] ignoreSlack?: boolean - hideMax?: boolean hideDollarValue?: boolean showBalanceSlider?: boolean isBonding?: boolean @@ -45,7 +44,7 @@ const AssetInput = forwardRef((props: AssetInputProps, _) => { token, onChange, ignoreSlack, - hideMax, + hideHalfMax, hideDollarValue, mobile, } = props @@ -104,7 +103,7 @@ const AssetInput = forwardRef((props: AssetInputProps, _) => { numberOfTokens={numberOfTokens} dollarValue={dollarValue} maxDisabled={maxDisabled} - hideMax={hideMax} + hideHalfMax={hideHalfMax} onMaxClick={onMaxClick} onHalfClick={onHalfClick} mobile={mobile} diff --git a/components/AssetInput/AssetList.tsx b/components/AssetInput/AssetList.tsx index 341703e8..853d392b 100644 --- a/components/AssetInput/AssetList.tsx +++ b/components/AssetInput/AssetList.tsx @@ -42,7 +42,7 @@ const AssetList: FC = ({ : tokenList?.tokens const [tokenBalance = []] = - unbondingBalances !== null + unbondingBalances ? [ tokens?.map(({ symbol }) => unbondingBalances.find((b) => b.tokenSymbol === symbol)?.amount), ] diff --git a/components/AssetInput/BalanceWithMax.tsx b/components/AssetInput/BalanceWithMax.tsx index 25caa4e0..1a8d3ed5 100644 --- a/components/AssetInput/BalanceWithMax.tsx +++ b/components/AssetInput/BalanceWithMax.tsx @@ -55,7 +55,7 @@ const MaxButton = ({ } return ( diff --git a/components/Pages/Flashloan/Vaults/hooks/useTransaction.tsx b/components/Pages/Flashloan/Vaults/hooks/useTransaction.tsx index 2802d44b..c4788030 100644 --- a/components/Pages/Flashloan/Vaults/hooks/useTransaction.tsx +++ b/components/Pages/Flashloan/Vaults/hooks/useTransaction.tsx @@ -62,7 +62,7 @@ export const useTransaction = ({ return signingClient.getTx(txHash) }, { - enabled: txHash !== null, + enabled: Boolean(txHash), retry: true, }, ) @@ -72,8 +72,11 @@ export const useTransaction = ({ async () => { setError(null) setTxStep(TxStep.Estimating) + if (!signingClient) { + return + } try { - const response = await signingClient.simulate( + const response = await signingClient?.simulate( senderAddress, debouncedMsgs, '', @@ -112,9 +115,9 @@ export const useTransaction = ({ }, { enabled: - debouncedMsgs !== null && + Boolean(debouncedMsgs) && txStep === TxStep.Idle && - error === null && + !error && Boolean(signingClient) && enabled, refetchOnWindowFocus: false, @@ -215,13 +218,13 @@ export const useTransaction = ({ } const submit = useCallback(() => { - if (!(fee === null || msgs === null || msgs.length < 1)) { + if (!(!fee || !msgs || msgs.length < 1)) { mutate() } }, [msgs, fee, mutate]) useEffect(() => { - if (txInfo !== null && txHash !== null) { + if (txInfo && txHash) { if (txInfo?.code) { setTxStep(TxStep.Failed) onError?.(txHash, txInfo) diff --git a/components/Pages/Flashloan/hooks/useTransaction.tsx b/components/Pages/Flashloan/hooks/useTransaction.tsx index e0b90db1..bfb55399 100644 --- a/components/Pages/Flashloan/hooks/useTransaction.tsx +++ b/components/Pages/Flashloan/hooks/useTransaction.tsx @@ -45,8 +45,11 @@ export const useTransaction = ({ ['fee', msgs, error], async () => { setTxStep(TxStep.Estimating) + if (!signingClient) { + return + } try { - const response = await signingClient.simulate( + const response = await signingClient?.simulate( senderAddress, debouncedMsgs, '', @@ -84,9 +87,9 @@ export const useTransaction = ({ }, { enabled: - debouncedMsgs !== null && + Boolean(debouncedMsgs) && txStep === TxStep.Idle && - error === null && + !error && Boolean(signingClient) && enabled, refetchOnWindowFocus: false, @@ -179,7 +182,7 @@ export const useTransaction = ({ ) const submit = useCallback(() => { - if (msgs === null || msgs.length < 1) { + if (!msgs || msgs.length < 1) { return } mutate() diff --git a/components/Pages/Trade/Liquidity/BondingDaysSlider.tsx b/components/Pages/Trade/Liquidity/BondingDaysSlider.tsx index 617c2580..a6260c86 100644 --- a/components/Pages/Trade/Liquidity/BondingDaysSlider.tsx +++ b/components/Pages/Trade/Liquidity/BondingDaysSlider.tsx @@ -56,10 +56,10 @@ export const BondingDaysSlider = ({ { - { - if (!isWalletConnected) { + if (isWalletConnected && allSnapshotsTaken && rewards.length !== 0) { + claim.submit() + } else if (!isWalletConnected) { openView() } else { - if (allSnapshotsTaken) { - claim.submit() - } else { - forceSnapshots.submit() - } + forceSnapshots.submit() } } } + /> ) diff --git a/components/Pages/Trade/Liquidity/DepositForm.tsx b/components/Pages/Trade/Liquidity/DepositForm.tsx index d503b2b4..7a2d415c 100644 --- a/components/Pages/Trade/Liquidity/DepositForm.tsx +++ b/components/Pages/Trade/Liquidity/DepositForm.tsx @@ -28,6 +28,7 @@ type Props = { chainId: string mobile?: boolean poolId: string + openView: any } const DepositForm = ({ @@ -45,6 +46,7 @@ const DepositForm = ({ chainId, mobile, poolId, + openView, }: Props) => { const { control, handleSubmit, setValue, getValues } = useForm({ mode: 'onChange', @@ -148,7 +150,7 @@ const DepositForm = ({ paddingX={2} width="full" as="form" - onSubmit={handleSubmit(tx?.submit)} + onSubmit={isWalletConnected ? handleSubmit(tx?.submit) : handleSubmit(openView)} > diff --git a/components/Pages/Trade/Liquidity/ManageLiquidity.tsx b/components/Pages/Trade/Liquidity/ManageLiquidity.tsx index 6ebd1b29..284dd6de 100644 --- a/components/Pages/Trade/Liquidity/ManageLiquidity.tsx +++ b/components/Pages/Trade/Liquidity/ManageLiquidity.tsx @@ -45,7 +45,7 @@ const ManageLiquidity = ({ poolIdFromUrl }) => { const router = useRouter() const chains: Array = useChainInfos() const { chainId, walletChainName } = useRecoilValue(chainState) - const { isWalletConnected, address } = useChain(walletChainName) + const { isWalletConnected, address, openView } = useChain(walletChainName) const [reverse, setReverse] = useState(false) const [isTokenSet, setIsToken] = useState(false) const { data: poolData } = usePoolsListQuery() @@ -276,6 +276,7 @@ const ManageLiquidity = ({ poolIdFromUrl }) => { chainId={chainId} poolId={poolIdFromUrl} mobile={isMobile} + openView={openView} /> )} @@ -285,10 +286,11 @@ const ManageLiquidity = ({ poolIdFromUrl }) => { clearForm={clearForm} poolId={poolIdFromUrl} mobile={isMobile} + openView={openView} /> - + {dailyEmissionData.length > 0 ? ( diff --git a/components/Pages/Trade/Liquidity/Overview.tsx b/components/Pages/Trade/Liquidity/Overview.tsx index 8eda29da..750a4f15 100644 --- a/components/Pages/Trade/Liquidity/Overview.tsx +++ b/components/Pages/Trade/Liquidity/Overview.tsx @@ -21,6 +21,7 @@ const Overview = ({ poolId, dailyEmissions }: Props) => { })), [positionData]) + return ( void } -const WithdrawForm = ({ poolId, isWalletConnected, clearForm, mobile }: Props) => { +const WithdrawForm = ({ poolId, isWalletConnected, clearForm, mobile, openView }: Props) => { const [ { swap_address: swapAddress = null, @@ -29,7 +30,6 @@ const WithdrawForm = ({ poolId, isWalletConnected, clearForm, mobile }: Props) = ] = useQueryPoolLiquidity({ poolId }) const claimableLP = useClaimableLP({ poolId }) - const [reverse, setReverse] = useState(false) const [assetA, assetB] = poolId?.split('-') || [] const lpBalance = liquidity?.available?.provided?.tokenAmount || 0 @@ -61,7 +61,6 @@ const WithdrawForm = ({ poolId, isWalletConnected, clearForm, mobile }: Props) = const tokenA = watch('token1') const tokenB = watch('token2') - const { lp, simulated } = useSimulateWithdraw({ lp: liquidity?.available?.provided?.tokenAmount, tokenA: liquidity?.reserves?.myNotLocked?.[0], @@ -152,7 +151,7 @@ const WithdrawForm = ({ poolId, isWalletConnected, clearForm, mobile }: Props) = paddingX={2} width="full" as="form" - onSubmit={handleSubmit(tx?.submit)} + onSubmit={isWalletConnected ? handleSubmit(tx?.submit) : handleSubmit(openView)} > { if (reverse) { setReverse(false) @@ -171,6 +171,7 @@ const WithdrawForm = ({ poolId, isWalletConnected, clearForm, mobile }: Props) = /> { setError(null) setTxStep(TxStep.Estimating) + if (!signingClient) { + return + } try { - const response = await signingClient.simulate( + const response = await signingClient?.simulate( senderAddress, debouncedMsgs, '', @@ -85,7 +88,6 @@ export const useTransaction = ({ setError('Try increasing slippage') throw new Error('Try increasing slippage') } else { - console.error({ error }) setTxStep(TxStep.Idle) setError(error?.message) throw Error(error?.message) @@ -99,9 +101,9 @@ export const useTransaction = ({ }, { enabled: - debouncedMsgs !== null && + Boolean(debouncedMsgs) && txStep === TxStep.Idle && - error === null && + !error && Boolean(signingClient) && Boolean(senderAddress) && enabled && @@ -129,7 +131,7 @@ export const useTransaction = ({ return signingClient.getTx(txHash) }, { - enabled: txHash !== null, + enabled: Boolean(txHash), retry: true, }, ) @@ -228,7 +230,7 @@ export const useTransaction = ({ } const submit = useCallback(() => { - if (!(fee === null || msgs === null || msgs.length < 1)) { + if (!(!fee || !msgs || msgs.length < 1)) { mutate() } }, [msgs, fee, mutate]) diff --git a/components/Pages/Trade/Liquidity/hooks/useProvideLP.ts b/components/Pages/Trade/Liquidity/hooks/useProvideLP.ts index 67c3de06..247ec46d 100644 --- a/components/Pages/Trade/Liquidity/hooks/useProvideLP.ts +++ b/components/Pages/Trade/Liquidity/hooks/useProvideLP.ts @@ -111,11 +111,11 @@ const useProvideLP = ({ reverse = false, bondingDays }) => { const { msgs, encodedMsgs } = useMemo(() => { if ( - simulated === null || + !simulated || !tokenAAmount || !tokenBAmount || - swapAddress === null || - minUnbondingDuration === null + !swapAddress || + !minUnbondingDuration ) { return {} } @@ -200,7 +200,7 @@ const useProvideLP = ({ reverse = false, bondingDays }) => { onError: () => {}, }) const noMatchingPool = - swapAddress === null && !isLoading + !swapAddress && !isLoading ? { buttonLabel: 'No Matching Pool', } diff --git a/components/Pages/Trade/Liquidity/hooks/useRewards.ts b/components/Pages/Trade/Liquidity/hooks/useRewards.ts index 607fdf11..f991e1b9 100644 --- a/components/Pages/Trade/Liquidity/hooks/useRewards.ts +++ b/components/Pages/Trade/Liquidity/hooks/useRewards.ts @@ -43,10 +43,9 @@ const aggregateRewards = (rewards: RewardData[]): RewardInfo[] => { return acc } const { amount } = reward - acc[denom] = (acc[denom] || 0) + amount + acc[denom] = (acc[denom] || 0) + Number(amount) return acc }, {}) - // Use Object.entries and map to transform aggregates into an array of rewards return Object.entries(aggregates).map(([id, amount]) => { // Determine whether id is a contract_addr or a denom diff --git a/components/Pages/Trade/Liquidity/hooks/useWithdraw.ts b/components/Pages/Trade/Liquidity/hooks/useWithdraw.ts index 66b5ad5e..49e426f3 100644 --- a/components/Pages/Trade/Liquidity/hooks/useWithdraw.ts +++ b/components/Pages/Trade/Liquidity/hooks/useWithdraw.ts @@ -33,7 +33,7 @@ const useWithdraw = ({ const { signingClient } = useClients(walletChainName) const { msgs, encodedMsgs } = useMemo(() => { - if (parseFloat(amount) === 0 || contract === null || !signingClient) { + if (parseFloat(amount) === 0 || !contract || !signingClient) { return {} } diff --git a/components/Pages/Trade/Liquidity/hooks/useWithdrawTransaction.tsx b/components/Pages/Trade/Liquidity/hooks/useWithdrawTransaction.tsx index d87535ce..6a014eeb 100644 --- a/components/Pages/Trade/Liquidity/hooks/useWithdrawTransaction.tsx +++ b/components/Pages/Trade/Liquidity/hooks/useWithdrawTransaction.tsx @@ -53,8 +53,11 @@ export const useWithdrawTransaction = ({ async () => { setError(null) setTxStep(TxStep.Estimating) + if (!signingClient) { + return + } try { - const response = await signingClient.simulate( + const response = await signingClient?.simulate( senderAddress, debouncedMsgs, '', @@ -84,9 +87,9 @@ export const useWithdrawTransaction = ({ }, { enabled: - debouncedMsgs !== null && + Boolean(debouncedMsgs) && txStep === TxStep.Idle && - error === null && + !error && Boolean(signingClient) && Number(amount) > 0 && enabled, @@ -208,7 +211,7 @@ export const useWithdrawTransaction = ({ return await signingClient.getTx(txHash) }, { - enabled: txHash !== null && Boolean(signingClient), + enabled: Boolean(txHash) && Boolean(signingClient), retry: true, }, ) @@ -220,13 +223,13 @@ export const useWithdrawTransaction = ({ } const submit = useCallback(() => { - if (!(fee === null || msgs === null || msgs.length < 1)) { + if (!(!fee || !msgs || msgs.length < 1)) { mutate() } }, [msgs, fee, mutate]) useEffect(() => { - if (txInfo !== null && txHash !== null) { + if (txInfo && txHash) { if (txInfo?.code) { setTxStep(TxStep.Failed) onError?.(txHash, txInfo) diff --git a/components/Pages/Trade/Swap/SwapForm.tsx b/components/Pages/Trade/Swap/SwapForm.tsx index 9b51a57c..6759ba15 100644 --- a/components/Pages/Trade/Swap/SwapForm.tsx +++ b/components/Pages/Trade/Swap/SwapForm.tsx @@ -248,11 +248,12 @@ const SwapForm: FC = ({ rules={{ required: true }} render={({ field }) => ( { @@ -291,11 +292,11 @@ const SwapForm: FC = ({ rules={{ required: true }} render={({ field }) => ( = ({ state?.isLoading } disabled={ - tx?.txStep !== TxStep.Ready || simulated === null || !isWalletConnected + tx?.txStep !== TxStep.Ready || !simulated || !isWalletConnected } > {buttonLabel} diff --git a/components/Pages/Trade/Swap/hooks/useSimulate.ts b/components/Pages/Trade/Swap/hooks/useSimulate.ts index 1e0492d3..14a18b6c 100644 --- a/components/Pages/Trade/Swap/hooks/useSimulate.ts +++ b/components/Pages/Trade/Swap/hooks/useSimulate.ts @@ -18,7 +18,7 @@ const useSimulate = ({ cosmWasmClient, msg, routerAddress }) => { const { data, isLoading, error } = useQuery( ['simulation', debounseMsg], async () => { - if (msg === null) { + if (!msg) { return null } return simulate({ cosmWasmClient, diff --git a/components/Pages/Trade/Swap/hooks/useTransaction.tsx b/components/Pages/Trade/Swap/hooks/useTransaction.tsx index a24da71a..1b0a19f3 100644 --- a/components/Pages/Trade/Swap/hooks/useTransaction.tsx +++ b/components/Pages/Trade/Swap/hooks/useTransaction.tsx @@ -53,8 +53,11 @@ export const useTransaction = ({ async () => { setError(null) setTxStep(TxStep.Estimating) + if (!signingClient) { + return + } try { - const response = await signingClient.simulate( + const response = await signingClient?.simulate( senderAddress, debouncedMsgs, '', @@ -99,9 +102,9 @@ export const useTransaction = ({ }, { enabled: - debouncedMsgs !== null && + Boolean(debouncedMsgs) && txStep === TxStep.Idle && - error === null && + !error && enabled, refetchOnWindowFocus: false, retry: false, @@ -201,7 +204,7 @@ export const useTransaction = ({ } const submit = useCallback(() => { - if (!(fee === null || msgs === null || !msgs || msgs.length < 1)) { + if (!(!fee || !msgs || msgs.length < 1)) { mutate() } }, [msgs, fee, mutate]) diff --git a/components/Wallet/Modal/WalletConnectButton.tsx b/components/Wallet/Modal/WalletConnectButton.tsx index 85208f50..0ef0c95b 100644 --- a/components/Wallet/Modal/WalletConnectButton.tsx +++ b/components/Wallet/Modal/WalletConnectButton.tsx @@ -43,10 +43,10 @@ export const WalletConnectButton = ({ onCloseModal, connect, walletType }: Props const setWallet = useCallback(async () => { let err = false if (walletType === WalletType.keplrExtension && window.keplr) { - const connected = (await window.keplr.getChainInfosWithoutEndpoints()).map((elem) => elem.chainId) + const connected = (await window.keplr?.getChainInfosWithoutEndpoints()).map((elem) => elem.chainId) const keplrChains: any[] = await getKeplrChains(Object.values(ACTIVE_NETWORKS[network])) for (const chain of keplrChains) { - if (!connected.includes(chain.chainId)) { + if (!connected?.includes(chain.chainId)) { // eslint-disable-next-line no-await-in-loop await window.keplr.experimentalSuggestChain(chain) } diff --git a/hooks/useTransaction.tsx b/hooks/useTransaction.tsx index bd0c89ed..9f79c0d4 100644 --- a/hooks/useTransaction.tsx +++ b/hooks/useTransaction.tsx @@ -53,8 +53,11 @@ export const useTransaction = ({ async () => { setError(null) setTxStep(TxStep.Estimating) + if (!signingClient || !debouncedMsgs) { + return + } try { - const response = await signingClient.simulate( + const response = await signingClient?.simulate( senderAddress, debouncedMsgs, '', ) if (buttonLabel) { @@ -96,9 +99,9 @@ export const useTransaction = ({ }, { enabled: - debouncedMsgs !== null && + Boolean(debouncedMsgs) && txStep === TxStep.Idle && - error === null && + !error && enabled, refetchOnWindowFocus: false, retry: false, @@ -190,7 +193,7 @@ export const useTransaction = ({ return signingClient.getTx(txHash) }, { - enabled: txHash !== null, + enabled: Boolean(txHash), retry: true, }, ) @@ -202,13 +205,13 @@ export const useTransaction = ({ } const submit = useCallback(() => { - if (!(fee === null || msgs === null || msgs.length < 1)) { + if (!(!fee || !msgs || msgs.length < 1)) { mutate() } }, [msgs, fee, mutate]) useEffect(() => { - if (txInfo !== null && txHash !== null) { + if (txInfo && txHash) { if (txInfo?.txResponse?.code) { setTxStep(TxStep.Failed) onError?.(txHash, txInfo) diff --git a/hooks/useTxInfo.ts b/hooks/useTxInfo.ts index a697508f..5411dde8 100644 --- a/hooks/useTxInfo.ts +++ b/hooks/useTxInfo.ts @@ -11,10 +11,9 @@ const useTxInfo = ({ txHash, signingClient }: TxInfo) => { const { data: txInfo } = useQuery( ['txInfo', txHash], () => { - if (txHash == null) { + if (!txHash) { return } - return signingClient.getTx(txHash) }, { diff --git a/hooks/useTxStatus.tsx b/hooks/useTxStatus.tsx index e0edbf85..6df4d3a2 100644 --- a/hooks/useTxStatus.tsx +++ b/hooks/useTxStatus.tsx @@ -22,7 +22,7 @@ const useTxStatus = ({ signingClient, transactionType }: Props) => { const queryClient = useQueryClient() useEffect(() => { - if (txInfo !== null && txState.txHash !== null) { + if (txInfo && txState.txHash) { if (txInfo?.code) { setTxState({ ...txState, diff --git a/next.config.js b/next.config.js index 9c0d7769..422ba90c 100644 --- a/next.config.js +++ b/next.config.js @@ -36,22 +36,22 @@ const config = { }, { source: '/dashboard', - destination: '/terra/dashboard', + destination: '/migaloo/dashboard', permanent: false, }, { source: '/pools', - destination: '/terra/pools', + destination: '/migaloo/pools', permanent: false, }, { source: '/vaults', - destination: '/terra/vaults', + destination: '/migaloo/vaults', permanent: false, }, { source: '/flashloan', - destination: '/terra/flashloan', + destination: '/migaloo/flashloan', permanent: false, }, ] @@ -92,9 +92,7 @@ const config = { // !! WARN !! ignoreBuildErrors: true, }, - experimental: { - outputStandalone: true, - }, + output: "standalone", eslint: { // Warning: This allows production builds to successfully complete even if // your project has ESLint errors.