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

Fix/avoid errors terra station #398

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const useTransaction = () => {
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}
return signingClient?.getTx(txHash)
Expand Down
2 changes: 1 addition & 1 deletion components/Pages/Flashloan/Vaults/hooks/useTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const useTransaction = ({
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}

Expand Down
4 changes: 2 additions & 2 deletions components/Pages/Flashloan/hooks/useTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ export const useTransaction = ({
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}

return signingClient.getTx(txHash)
},
{
enabled: txHash != null,
enabled: txHash !== null,
retry: true,
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const useTransaction = ({
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}
return signingClient.getTx(txHash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const useWithdrawTransaction = ({
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}

Expand Down
2 changes: 1 addition & 1 deletion components/Pages/Trade/Swap/hooks/useTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const useTransaction = ({
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}
return signingClient.getTx(txHash)
Expand Down
19 changes: 18 additions & 1 deletion components/Wallet/Modal/MobileNotSupportedModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react'

import {
HStack,
Image,
Link,
Modal,
ModalContent,
ModalHeader,
ModalOverlay,
Text,
VStack,
} from '@chakra-ui/react'

function MobileNotSupportedModal() {
Expand All @@ -14,7 +18,20 @@ function MobileNotSupportedModal() {
<ModalOverlay />
<ModalContent border="1px" borderColor="gray.200" padding="1" margin="4">
<ModalHeader>
<Text>Mobile not yet supported</Text>
<VStack>
<Text>Currently, only Leaps in-app browser is supported on mobile.</Text>
<Link href="https://www.leapwallet.io/" isExternal>
<Image flex={'1'} maxBlockSize={'12'} src="https://assets-global.website-files.com/63af9e8fb337a641e2075c4f/63afa06f10dd572ce7252901_logo.svg" alt="Leap Logo" />
</Link>
<HStack>
<Link href="https://play.google.com/store/apps/details?id=io.leapwallet.cosmos&utm_source=website&utm_medium=permanent-website&utm_campaign=permanent" isExternal>
<Image flex={'1'} maxBlockSize={'12'} src="https://assets-global.website-files.com/63af9e8fb337a641e2075c4f/63f7ac8b92f9f9c3bea96e10_Google_Play_Store_badge_EN.svg" alt="Google Play Store Badge" />
</Link>
<Link href="https://apps.apple.com/in/app/leap-cosmos/id1642465549/?utm_source=website&utm_medium=permanent-website&utm_campaign=permanent" isExternal>
<Image flex={'1'} maxBlockSize={'12'} src="https://assets-global.website-files.com/63af9e8fb337a641e2075c4f/63f7acd2acfc21f24c483fd9_appstroe.svg" alt="AppStore Badge" />
</Link>
</HStack>
</VStack>
</ModalHeader>
</ModalContent>
</Modal>
Expand Down
7 changes: 3 additions & 4 deletions components/Wallet/Modal/WalletConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,21 @@ export const WalletConnectButton = ({ onCloseModal, connect, walletType }: Props
}
}
}
if ((walletType === WalletType.terraExtension || walletType === WalletType.keplrExtension) && (chainId === ChainId.injective || chainId === ChainId.terrac)) {
const windowConnection = walletType === WalletType.terraExtension ? window.station.keplr : window.keplr
if ((walletType === WalletType.terraExtension || walletType === WalletType.keplrExtension)) {
const windowConnection = walletType === WalletType.terraExtension ? (window.station?.keplr) : (window?.keplr);
try {
await (windowConnection.getKey(chainId))
} catch (e) {
err = true
console.error(`${chainId} not activated`)
console.error(e);
handleChainActivationError(chainName, toast);
}
}
if (!err) {
connect()
}
onCloseModal()
}, [onCloseModal, connect])
}, [onCloseModal, connect, walletType])

const renderContent = () => {
switch (walletType) {
Expand Down
6 changes: 3 additions & 3 deletions components/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const Wallet = () => {
setWalletChains(snapChainIds);
setCurrentConnectedChainIds(snapChainIds);
} else if (walletType === WalletType.terraExtension || walletType === WalletType.keplrExtension) {
const walletWindowConnection =
walletType === WalletType.terraExtension ? window.station.keplr : window.keplr;
const walletWindowConnection = walletType === WalletType.terraExtension ? (window.station?.keplr) : (window?.keplr);


const getAddedStationChainsIds = async () => {
const chainInfos = await walletWindowConnection.getChainInfosWithoutEndpoints();
Expand Down Expand Up @@ -191,7 +191,7 @@ const Wallet = () => {
setTokenSwapState(newState)
if (isWalletConnected) {
const newChain = allChains[WALLET_CHAIN_NAMES_BY_CHAIN_ID[chain.chainId]]
if (!(window.localStorage.getItem(COSMOS_KIT_WALLET_KEY) === WalletType.leapSnap)) {
if (window.localStorage.getItem(COSMOS_KIT_WALLET_KEY) !== WalletType.leapSnap && window.localStorage.getItem(COSMOS_KIT_WALLET_KEY) !== WalletType.terraExtension) {
await newChain.connect()
} else {
resetWallet()
Expand Down
2 changes: 1 addition & 1 deletion hooks/useTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export const useTransaction = ({
const { data: txInfo } = useQuery(
['txInfo', txHash],
() => {
if (txHash === null) {
if (!txHash) {
return null
}

Expand Down
Loading