Skip to content

Commit

Permalink
Add Galaxy Station wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
echel0n-HX committed May 8, 2024
1 parent c92f3f5 commit d180b9c
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 56 deletions.
72 changes: 36 additions & 36 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

if [ $exitCode = 127 ]; then
echo "husky - command not found in PATH=$PATH"
fi

exit $exitCode
fi
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

if [ $exitCode = 127 ]; then
echo "husky - command not found in PATH=$PATH"
fi

exit $exitCode
fi
8 changes: 8 additions & 0 deletions components/Icons/GalaxyStationExtensionIcon.tsx

Large diffs are not rendered by default.

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
8 changes: 5 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,9 @@ export const fetchCurrentEpoch = async (client: CosmWasmClient,

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

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
6 changes: 4 additions & 2 deletions components/Pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export const Dashboard: FC = () => {
const circulatingWhaleSupply = dashboardData.supply?.circulating / (10 ** 6) || 0
const marketCap = circulatingWhaleSupply * (prices?.WHALE || 0) || 0
const mappedDashboardData = dashboardData.dashboardData?.map((data) => {
const apr = dashboardData.bondingInfos[data.chainName]?.bondingAPR
const buyback = dashboardData.bondingInfos[data.chainName]?.buyback

const apr = (dashboardData?.bondingInfos?.[data.chainName]?.bondingAPR) || 0;
const buyback = (dashboardData?.bondingInfos?.[data.chainName]?.buyback) || 0;

return ({
logoUrl: getChainLogoUrlByName(data.chainName),
chainName: data.chainName,
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'

import { useChain } from '@cosmos-kit/react-lite'
import CosmostationWalletIcon from 'components/Icons/CosmostationWalletIcon'
import GalaxyStationExtensionIcon from 'components/Icons/GalaxyStationExtensionIcon';
import KeplrWalletIcon from 'components/Icons/KeplrWalletIcon'
import LeapSnapIcon from 'components/Icons/LeapSnapIcon'
import LeapWalletIcon from 'components/Icons/LeapWalletIcon'
Expand Down Expand Up @@ -30,6 +31,8 @@ export const ConnectedWalletIcon = () => {
return <NinjiWalletIcon />
case WalletType.okxwallet:
return <OKXWalletIcon />
case WalletType.galaxyStationExtension:
return <GalaxyStationExtensionIcon />
default:
return <></>
}
Expand Down
9 changes: 7 additions & 2 deletions components/Wallet/Modal/WalletConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback } from 'react'

import { Button, HStack, Text, useToast } from '@chakra-ui/react'
import CosmostationWalletIcon from 'components/Icons/CosmostationWalletIcon'
import GalaxyStationExtensionIcon from 'components/Icons/GalaxyStationExtensionIcon';
import KeplrWalletIcon from 'components/Icons/KeplrWalletIcon'
import LeapSnapIcon from 'components/Icons/LeapSnapIcon'
import LeapWalletIcon from 'components/Icons/LeapWalletIcon'
Expand Down Expand Up @@ -54,8 +55,8 @@ export const WalletConnectButton = ({ onCloseModal, connect, walletType }: Props
}
}
}
if ((walletType === WalletType.terraExtension || walletType === WalletType.keplrExtension)) {
const windowConnection = walletType === WalletType.terraExtension ? (window.station?.keplr) : (window?.keplr)
if ((walletType === WalletType.terraExtension || walletType === WalletType.galaxyStationExtension || walletType === WalletType.keplrExtension)) {
const windowConnection = walletType === WalletType.terraExtension ? (window.station?.keplr) : walletType === WalletType.galaxyStationExtension ? (window.galaxyStation?.keplr) : (window?.keplr)
try {
await (windowConnection.getKey(chainId))
} catch (e) {
Expand Down Expand Up @@ -94,6 +95,8 @@ export const WalletConnectButton = ({ onCloseModal, connect, walletType }: Props
return 'Ninji Wallet'
case WalletType.okxwallet:
return 'OKX Wallet'
case WalletType.galaxyStationExtension:
return 'Galaxy Station'
default:
return null
}
Expand Down Expand Up @@ -123,6 +126,8 @@ export const WalletConnectButton = ({ onCloseModal, connect, walletType }: Props
return <NinjiWalletIcon />
case WalletType.okxwallet:
return <OKXWalletIcon />
case WalletType.galaxyStationExtension:
return <GalaxyStationExtensionIcon />
default:
return null
}
Expand Down
2 changes: 2 additions & 0 deletions components/Wallet/Modal/WalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum WalletType {
cosmoStationMobile = 'cosmostation-mobile',
ninjiExtension = 'ninji-extension',
okxwallet = 'okxwallet-extension',
galaxyStationExtension = 'galaxy-station-extension',
}

export const WalletModal = ({ isOpen, setOpen, walletRepo }) => {
Expand All @@ -50,6 +51,7 @@ export const WalletModal = ({ isOpen, setOpen, walletRepo }) => {
WalletType.leapExtension,
WalletType.ninjiExtension,
WalletType.okxwallet,
WalletType.galaxyStationExtension,
].includes(walletName);
if (walletName === WalletType.okxwallet && !okxchains.includes(chainId)) {
return false
Expand Down
4 changes: 2 additions & 2 deletions components/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,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)
} else if (walletType === WalletType.terraExtension || walletType === WalletType.keplrExtension || walletType === WalletType.galaxyStationExtension) {
const walletWindowConnection = walletType === WalletType.terraExtension ? (window.station?.keplr) : walletType === WalletType.galaxyStationExtension ? (window.galaxyStation?.keplr) : (window?.keplr)
const getAddedStationChainsIds = async () => {
const chainInfos = await walletWindowConnection?.getChainInfosWithoutEndpoints()
if (!chainInfos) {
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@cosmos-kit/react-lite": "^2.6.9",
"@cosmos-kit/shell": "^2.6.9",
"@cosmos-kit/station": "^2.5.9",
"@cosmos-kit/galaxy-station": "^2.6.2",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@injectivelabs/sdk-ts": "^1.14.6",
Expand Down
5 changes: 5 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { QueryClientProvider } from 'react-query'

import { CSSReset, ChakraProvider } from '@chakra-ui/react'
import { wallets as cosmoStationWallets } from '@cosmos-kit/cosmostation'
import { wallets as galaxyStationWallets } from '@cosmos-kit/galaxy-station'
import { wallets as keplrWallets } from '@cosmos-kit/keplr'
import { wallets as leapWallets } from '@cosmos-kit/leap'
import { wallets as ninjiWallets } from '@cosmos-kit/ninji'
Expand Down Expand Up @@ -63,6 +64,10 @@ const MyApp: FC<AppProps> = ({
name: 'okxwallet',
wallet: okxwallet,
},
{
name: 'galaxystation',
wallet: galaxyStationWallets,
},
];

const reorderWallets = useMemo(() => {
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 d180b9c

Please sign in to comment.