From d180b9cecba64e0bb71bfffdac64cf19c75277d5 Mon Sep 17 00:00:00 2001 From: echel0n-HX Date: Wed, 8 May 2024 01:27:37 -0700 Subject: [PATCH 1/3] Add Galaxy Station wallet --- .husky/_/husky.sh | 72 +++++++++---------- .../Icons/GalaxyStationExtensionIcon.tsx | 8 +++ .../Pages/Bonding/hooks/getBondingConfig.ts | 7 +- .../Pages/Bonding/hooks/getCurrentEpoch.ts | 8 ++- .../Bonding/hooks/getFeeDistributorConfig.ts | 4 +- components/Pages/Dashboard/Dashboard.tsx | 6 +- .../Pages/Trade/Incentivize/hooks/useEpoch.ts | 15 ++-- .../ConnectedWallet/ConnectedWalletIcon.tsx | 3 + .../Wallet/Modal/WalletConnectButton.tsx | 9 ++- components/Wallet/Modal/WalletModal.tsx | 2 + components/Wallet/Wallet.tsx | 4 +- constants/endpoints.json | 2 +- package.json | 1 + pages/_app.tsx | 5 ++ public/mainnet/comdex-1/config.json | 3 + 15 files changed, 93 insertions(+), 56 deletions(-) create mode 100644 components/Icons/GalaxyStationExtensionIcon.tsx create mode 100644 public/mainnet/comdex-1/config.json diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh index cec959a6..00bf2b41 100644 --- a/.husky/_/husky.sh +++ b/.husky/_/husky.sh @@ -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 diff --git a/components/Icons/GalaxyStationExtensionIcon.tsx b/components/Icons/GalaxyStationExtensionIcon.tsx new file mode 100644 index 00000000..8f55e671 --- /dev/null +++ b/components/Icons/GalaxyStationExtensionIcon.tsx @@ -0,0 +1,8 @@ +import * as React from 'react' + +export default function GalaxyStationExtensionIcon() { + return ( + + ) +} diff --git a/components/Pages/Bonding/hooks/getBondingConfig.ts b/components/Pages/Bonding/hooks/getBondingConfig.ts index e1e62ba5..b4406b56 100644 --- a/components/Pages/Bonding/hooks/getBondingConfig.ts +++ b/components/Pages/Bonding/hooks/getBondingConfig.ts @@ -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) @@ -29,7 +29,10 @@ export const getBondingConfig = async (client: CosmWasmClient | null, export const fetchConfig = async (client: CosmWasmClient, config: Config): Promise => { // 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: {}, }) diff --git a/components/Pages/Bonding/hooks/getCurrentEpoch.ts b/components/Pages/Bonding/hooks/getCurrentEpoch.ts index 6e8acceb..83765055 100644 --- a/components/Pages/Bonding/hooks/getCurrentEpoch.ts +++ b/components/Pages/Bonding/hooks/getCurrentEpoch.ts @@ -37,7 +37,10 @@ export interface Epoch { export const fetchCurrentEpoch = async (client: CosmWasmClient, config: Config): Promise => { - 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: {}, }) @@ -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 } diff --git a/components/Pages/Bonding/hooks/getFeeDistributorConfig.ts b/components/Pages/Bonding/hooks/getFeeDistributorConfig.ts index c522476d..eda1df73 100644 --- a/components/Pages/Bonding/hooks/getFeeDistributorConfig.ts +++ b/components/Pages/Bonding/hooks/getFeeDistributorConfig.ts @@ -22,7 +22,7 @@ const fetchConfig = async (client: CosmWasmClient, config: Config): Promise => { // TODO: API - const result: JsonObject = await client.queryContractSmart(config.fee_distributor, + const result: JsonObject = await client.queryContractSmart(config?.fee_distributor, { config: {}, }) @@ -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) diff --git a/components/Pages/Dashboard/Dashboard.tsx b/components/Pages/Dashboard/Dashboard.tsx index 2b419ff0..71cbad17 100644 --- a/components/Pages/Dashboard/Dashboard.tsx +++ b/components/Pages/Dashboard/Dashboard.tsx @@ -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, diff --git a/components/Pages/Trade/Incentivize/hooks/useEpoch.ts b/components/Pages/Trade/Incentivize/hooks/useEpoch.ts index f7a01bf3..b739d156 100644 --- a/components/Pages/Trade/Incentivize/hooks/useEpoch.ts +++ b/components/Pages/Trade/Incentivize/hooks/useEpoch.ts @@ -86,12 +86,15 @@ const useEpoch = () => { const { cosmWasmClient } = useClients(walletChainName) const { data: config } = useQuery({ 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({ @@ -99,7 +102,7 @@ const useEpoch = () => { 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) { diff --git a/components/Wallet/ConnectedWalletWithDisconnect/ConnectedWallet/ConnectedWalletIcon.tsx b/components/Wallet/ConnectedWalletWithDisconnect/ConnectedWallet/ConnectedWalletIcon.tsx index b78a77b3..b1195d19 100644 --- a/components/Wallet/ConnectedWalletWithDisconnect/ConnectedWallet/ConnectedWalletIcon.tsx +++ b/components/Wallet/ConnectedWalletWithDisconnect/ConnectedWallet/ConnectedWalletIcon.tsx @@ -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' @@ -30,6 +31,8 @@ export const ConnectedWalletIcon = () => { return case WalletType.okxwallet: return + case WalletType.galaxyStationExtension: + return default: return <> } diff --git a/components/Wallet/Modal/WalletConnectButton.tsx b/components/Wallet/Modal/WalletConnectButton.tsx index 25c07e53..c2ccec00 100644 --- a/components/Wallet/Modal/WalletConnectButton.tsx +++ b/components/Wallet/Modal/WalletConnectButton.tsx @@ -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' @@ -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) { @@ -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 } @@ -123,6 +126,8 @@ export const WalletConnectButton = ({ onCloseModal, connect, walletType }: Props return case WalletType.okxwallet: return + case WalletType.galaxyStationExtension: + return default: return null } diff --git a/components/Wallet/Modal/WalletModal.tsx b/components/Wallet/Modal/WalletModal.tsx index 2cdb1034..216d7337 100644 --- a/components/Wallet/Modal/WalletModal.tsx +++ b/components/Wallet/Modal/WalletModal.tsx @@ -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 }) => { @@ -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 diff --git a/components/Wallet/Wallet.tsx b/components/Wallet/Wallet.tsx index ceb3cc98..6869f85f 100644 --- a/components/Wallet/Wallet.tsx +++ b/components/Wallet/Wallet.tsx @@ -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) { diff --git a/constants/endpoints.json b/constants/endpoints.json index 319d18ce..77ebd3cf 100644 --- a/constants/endpoints.json +++ b/constants/endpoints.json @@ -36,7 +36,7 @@ "https://rpc.comdex.one" ], "rest": [ - "https://ww-comdex-rest.polkachu.com" + "https://rest.comdex.one" ] }, "injective": { diff --git a/package.json b/package.json index 63f1fed0..9a019712 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pages/_app.tsx b/pages/_app.tsx index 6c1e454f..fdbe4616 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -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' @@ -63,6 +64,10 @@ const MyApp: FC = ({ name: 'okxwallet', wallet: okxwallet, }, + { + name: 'galaxystation', + wallet: galaxyStationWallets, + }, ]; const reorderWallets = useMemo(() => { diff --git a/public/mainnet/comdex-1/config.json b/public/mainnet/comdex-1/config.json new file mode 100644 index 00000000..bfd870e4 --- /dev/null +++ b/public/mainnet/comdex-1/config.json @@ -0,0 +1,3 @@ +{ +} + From 8d608a37834ec7ce2aa23adcf2e175874eba0094 Mon Sep 17 00:00:00 2001 From: nick134 <76399455+nick134-bit@users.noreply.github.com> Date: Fri, 10 May 2024 17:36:08 +0200 Subject: [PATCH 2/3] chore: avoid error message --- hooks/useClients.ts | 9 ++++---- package.json | 50 ++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/hooks/useClients.ts b/hooks/useClients.ts index a7749b91..fc4098fd 100644 --- a/hooks/useClients.ts +++ b/hooks/useClients.ts @@ -18,7 +18,8 @@ export const useClients = (walletChainName: string) => { isWalletConnected, setDefaultSignOptions, wallet, getOfflineSigner } = useChain(walletChainName) - if (isWalletConnected && wallet?.name !== 'station-extension') { + + if (isWalletConnected && !wallet?.name.includes('station')) { try { setDefaultSignOptions({ preferNoSetFee: true, @@ -56,9 +57,9 @@ export const useClients = (walletChainName: string) => { const client = await InjectiveStargate.InjectiveSigningStargateClient.connectWithSigner( 'https://sentry.tm.injective.network:443', offlineSigner, { - registry, - aminoTypes, - }, + registry, + aminoTypes, + }, ) return client } catch { diff --git a/package.json b/package.json index 9a019712..d1ad631e 100644 --- a/package.json +++ b/package.json @@ -23,56 +23,56 @@ "@cosmjs/encoding": "0.32.2", "@cosmjs/launchpad": "0.27.1", "@cosmjs/proto-signing": "0.32.2", - "@cosmos-kit/cosmostation": "^2.6.10", - "@cosmos-kit/keplr": "^2.6.9", - "@cosmos-kit/leap": "^2.6.11", - "@cosmos-kit/ninji": "^2.6.9", - "@cosmos-kit/okxwallet": "^2.4.9", - "@cosmos-kit/react-lite": "^2.6.9", - "@cosmos-kit/shell": "^2.6.9", - "@cosmos-kit/station": "^2.5.9", + "@cosmos-kit/cosmostation": "^2.8.0", + "@cosmos-kit/keplr": "^2.8.0", "@cosmos-kit/galaxy-station": "^2.6.2", + "@cosmos-kit/leap": "^2.8.0", + "@cosmos-kit/ninji": "^2.8.0", + "@cosmos-kit/okxwallet": "^2.6.0", + "@cosmos-kit/react-lite": "^2.8.0", + "@cosmos-kit/shell": "^2.8.0", + "@cosmos-kit/station": "^2.7.0", "@emotion/react": "^11", "@emotion/styled": "^11", - "@injectivelabs/sdk-ts": "^1.14.6", - "@next/bundle-analyzer": "^14.1.0", - "@nick134-bit/nicks-injectivejs": "^0.0.2", - "@tanstack/react-table": "^8.12.0", + "@injectivelabs/sdk-ts": "^1.14.7", + "@next/bundle-analyzer": "^14.2.3", + "@nick134-bit/nicks-injectivejs": "^0.0.3", + "@tanstack/react-table": "^8.16.0", "@terra-money/feather.js": "^2.0.4", "@typescript-eslint/eslint-plugin": "^6.19.0", "@typescript-eslint/parser": "^6.19.0", "bignumber.js": "^9.1.2", - "chain-registry": "^1.28.6", - "dayjs": "^1.11.10", + "chain-registry": "^1.47.2", + "dayjs": "^1.11.11", "eslint-plugin-import-helpers": "^1.3.1", "intercept-stdout": "^0.1.2", "isomorphic-unfetch": "^4.0.2", - "jsoneditor": "^10.0.1", + "jsoneditor": "^10.0.3", "junoblocks": "^0.2.93", "lodash": "^4.17.21", - "next": "13.4.0", + "next": "14.2.3", "numeral": "^2.0.6", - "react": "^18.2.0", + "react": "^18.3.1", "react-device-detect": "^2.2.3", - "react-dom": "^18.2.0", - "react-hook-form": "^7.51.0", + "react-dom": "^18.3.1", + "react-hook-form": "^7.51.4", "react-hot-toast": "^2.4.1", - "react-icons": "^5.0.1", + "react-icons": "^5.2.1", "react-query": "^3.39.3", - "recharts": "^2.12.2", + "recharts": "^2.12.7", "recoil": "^0.7.7" }, "devDependencies": { - "@keplr-wallet/types": "^0.12.70", + "@keplr-wallet/types": "^0.12.88", "@types/react": "18.2.57", - "autoprefixer": "^10.4.18", + "autoprefixer": "^10.4.19", "eslint": "^8.56.0", "eslint-config-next": "^14.1.0", "husky": "^9.0.11", "lint-staged": "^15.2.2", - "postcss": "^8.4.35", + "postcss": "^8.4.38", "prettier": "^3.2.5", - "typescript": "^5.3.3" + "typescript": "^5.4.5" }, "lint-staged": { "**/*.{ts,md,tsx}": "prettier --write" From d22eb0e44977e2885af76907e2ada38a43c5b7dd Mon Sep 17 00:00:00 2001 From: nick134 <76399455+nick134-bit@users.noreply.github.com> Date: Mon, 13 May 2024 09:48:27 +0200 Subject: [PATCH 3/3] chore: bump node version --- .node-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.node-version b/.node-version index 3876fd49..ee5c2446 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -18.16.1 +22.1.0