Skip to content

Eason/bugfix #34

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
da5ee34
fix: prevent runtime error by using optional chaining for walletInfo.…
sdqede Jun 23, 2025
6f16e0b
chain-registry 2.0
sdqede Jun 23, 2025
59b6207
modify packageManager from yarn 4.1 to 4.3
sdqede Jun 23, 2025
47e6f77
upgrade chain-registry to 2.0
sdqede Jun 23, 2025
6282a84
fix bugs of building failure
sdqede Jun 23, 2025
3f6e72d
fix Type error: 'Component' cannot be used as a JSX component
sdqede Jun 23, 2025
63d8db3
replaced @chain-registry/v2 with chain-registry v2.0
sdqede Jun 26, 2025
e5e42a0
upgraded interchain-kit
sdqede Jun 26, 2025
34f16a8
fix interchain-kit issue in chain-admin
sdqede Jun 26, 2025
a29efb7
upgraded interchain-kit for hyperweb ui
sdqede Jun 26, 2025
f7d17a0
regenerate lock file
sdqede Jun 26, 2025
e6ff975
solved building issue of chain-admin
sdqede Jun 26, 2025
ad0fc7b
add lock file for templates
sdqede Jun 26, 2025
01ff89f
interchain-kit addChain async
sdqede Jun 30, 2025
c53b8a4
renew prettier config
sdqede Jun 30, 2025
ecfe06a
apply prettier to all modified files
sdqede Jun 30, 2025
5953ba3
fixed some bugs about reading attributes from undefined
sdqede Jun 30, 2025
639ca5c
use the same version of @interchainjs/cosmos and @interchainjs/react
sdqede Jun 30, 2025
bee56c3
removed as any inside createInstantiateContract
sdqede Jun 30, 2025
c65aa78
install packages and regenerate lock file
sdqede Jul 2, 2025
a02c2e8
upgrade interchainjs
sdqede Jul 2, 2025
c548008
fixed some path issue of new interchianjs in the chain-admin
sdqede Jul 2, 2025
2650084
fixed some issue related to building
sdqede Jul 2, 2025
e0843c8
keep using @chain-registry/v2 because @interchainjs/utils peer deppen…
sdqede Jul 2, 2025
a19dbee
fixed issue that asset list show no assets
sdqede Jul 2, 2025
8ec71c6
show icon of hyper token
sdqede Jul 2, 2025
063d99c
Add special handling for Hyperweb chain's native token throughout ass…
sdqede Jul 2, 2025
1b2a0dd
fixed some issue of building
sdqede Jul 2, 2025
5cabe45
fixed signer issue on contract deploying
sdqede Jul 3, 2025
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
17 changes: 14 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.formatOnSave": false
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.formatOnSave": false
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
"type": "git",
"url": "https://github.com/hyperweb-io/create-hyperweb-app"
},
"packageManager": "yarn@4.1.0"
"packageManager": "yarn@4.3.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export const AssetListSection = ({ chainName }: AssetListSectionProps) => {
<AssetsOverview
isLoading={isLoading || !data}
assets={data?.assets ?? []}
prices={data?.prices ?? {}}
prices={Object.fromEntries(
Object.entries(data?.prices ?? {}).filter(
([, value]) => value != null
)
)}
selectedChainName={chainName}
refetch={refetch}
/>
Expand Down
12 changes: 10 additions & 2 deletions templates/chain-admin/components/asset-list/AssetsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ const AssetsOverview = ({

{data && dropdownTransferInfo && (
<DropdownTransferModal
prices={data?.prices ?? {}}
prices={Object.fromEntries(
Object.entries(data?.prices ?? {}).filter(
([, value]) => value != null
)
)}
assets={ibcAssets}
transferInfoState={{
transferInfo: dropdownTransferInfo,
Expand All @@ -176,7 +180,11 @@ const AssetsOverview = ({

{rowTransferInfo && (
<RowTransferModal
prices={data?.prices ?? {}}
prices={Object.fromEntries(
Object.entries(data?.prices ?? {}).filter(
([, value]) => value != null
)
)}
transferInfo={rowTransferInfo}
updateData={refetch}
modalControl={rowModalControl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const OverviewTransferWrapper = (
const toastHandlers = useToastHandlers();
const { data: signingClient } = useSigningClient(sourceChainName);
const { mutate: transfer, isLoading } = useTransfer({
clientResolver: signingClient,
clientResolver: signingClient as any,
options: {
context: defaultContext,
...toastHandlers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const TransferModalBody = (
const toastHandlers = useToastHandlers();
const { data: signingClient } = useSigningClient(sourceChainName);
const { mutate: transfer, isLoading } = useTransfer({
clientResolver: signingClient,
clientResolver: signingClient as any,
options: {
context: defaultContext,
...toastHandlers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ConnectButton = () => {
const walletLogo =
typeof walletInfo?.logo === 'string'
? walletInfo.logo
: walletInfo.logo.major || walletInfo.logo.minor;
: walletInfo?.logo?.major || walletInfo?.logo?.minor;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useMemo, useState } from 'react';
import { Box } from '@interchain-ui/react';
import { Asset } from '@chain-registry/v2-types';
import { Asset } from '@chain-registry/types';
import BigNumber from 'bignumber.js';
import { TbCurrencyDollarOff } from 'react-icons/tb';
import { LuListPlus } from 'react-icons/lu';
import { VscJson } from 'react-icons/vsc';
import { Coin } from '@interchainjs/react/types';
import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin';

import { JsonInput } from './JsonInput';
import { SelectAssetContent } from './SelectAssetContent';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dispatch, SetStateAction, useMemo } from 'react';
import { assetLists } from '@chain-registry/v2';
import { assetLists } from 'chain-registry';
import { LuPlus } from 'react-icons/lu';

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction, useState } from 'react';
import { HiOutlineTrash } from 'react-icons/hi';
import { Asset } from '@chain-registry/v2-types';
import { Asset } from '@chain-registry/types';
import {
Avatar,
Box,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const DeployJsContract = ({
code: await readFileContent(jsFile),
onTxSucceed: (txInfo) => {
setIsLoading(false);
setTxResult(txInfo);
setTxResult(txInfo as DeliverTxResponse);
updateMyContracts();
onSuccess?.();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
} from '@interchain-ui/react';
import { IoChevronDown } from 'react-icons/io5';
import { useChain } from '@interchain-kit/react';
import { Coin, DeliverTxResponse } from '@interchainjs/react/types';
import { DeliverTxResponse } from '@interchainjs/react/types';
import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin';

import { CodeIdField } from './CodeIdField';
import {
Expand Down Expand Up @@ -123,7 +124,6 @@ export const InstantiateContract = ({
txResult.events.find((e) => e.type === 'instantiate')?.attributes[0]
.value ?? '';

// @ts-expect-error
const transactionHash = txResult?.hash || txResult?.transactionHash || '';

const infoItems: TxInfoItem[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo, useState } from 'react';
import { Box, Text } from '@interchain-ui/react';
import { useChain } from '@interchain-kit/react';
import { Coin } from '@interchainjs/react/types';
import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin';

import {
JsonInput,
Expand Down
2 changes: 1 addition & 1 deletion templates/chain-admin/components/staking/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const DelegateModal = ({
const toastHandlers = useToastHandlers();
const { data: signingClient } = useSigningClient(chainName);
const { mutate: delegate, isLoading: isDelegating } = useDelegate({
clientResolver: signingClient,
clientResolver: signingClient as any,
options: {
context: defaultContext,
...toastHandlers,
Expand Down
2 changes: 1 addition & 1 deletion templates/chain-admin/components/staking/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Overview = ({
const { data: signingClient } = useSigningClient(chainName);
const { mutate: withdrawDelegatorReward, isLoading: isClaiming } =
useWithdrawDelegatorReward({
clientResolver: signingClient,
clientResolver: signingClient as any,
options: {
context: defaultContext,
...toastHandlers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const RedelegateModal = ({
const { data: signingClient } = useSigningClient(chainName);
const { mutate: beginRedelegate, isLoading: isRedelegating } =
useBeginRedelegate({
clientResolver: signingClient,
clientResolver: signingClient as any,
options: {
context: defaultContext,
...toastHandlers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const UndelegateModal = ({
const toastHandlers = useToastHandlers();
const { data: signingClient } = useSigningClient(chainName);
const { mutate: undelegate, isLoading: isUndelegating } = useUndelegate({
clientResolver: signingClient,
clientResolver: signingClient as any,
options: {
context: defaultContext,
...toastHandlers,
Expand Down
2 changes: 1 addition & 1 deletion templates/chain-admin/components/voting/Voting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function Voting({ chainName }: VotingProps) {
const { modal, open: openModal, close: closeModal, setTitle } = useModal('');
const [tallies, setTallies] = useState<{ [key: string]: TallyResult }>({});

const chain = chains.find((c) => c.chain_name === chainName);
const chain = chains.find((c) => c.chainName === chainName);

useEffect(() => {
if (!data.proposals || data.proposals.length === 0) return;
Expand Down
11 changes: 8 additions & 3 deletions templates/chain-admin/hooks/asset-list/useAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useChain } from '@interchain-kit/react';
import { defaultContext } from '@tanstack/react-query';
import BigNumber from 'bignumber.js';
import { useGetAllBalances } from '@interchainjs/react/cosmos/bank/v1beta1/query.rpc.react';
import { Coin } from '@interchainjs/react/types';
import { Coin } from '@interchainjs/react/cosmos/base/v1beta1/coin';

import { PrettyAsset } from '@/components';
import { useChainUtils } from './useChainUtils';
Expand Down Expand Up @@ -73,7 +73,12 @@ export const useAssets = (chainName: string) => {
Object.entries(dataQueries).map(([key, query]) => [key, query.data])
) as QueriesData;

const { allBalances, prices } = queriesData;
const { allBalances, prices: rawPrices } = queriesData;

// Filter out undefined values to ensure proper indexing
const prices = Object.fromEntries(
Object.entries(rawPrices ?? {}).filter(([, value]) => value != null)
);

const nativeAndIbcBalances: Coin[] = allBalances?.filter(
({ denom }) => !denom.startsWith('gamm') && prices[denom]
Expand All @@ -100,7 +105,7 @@ export const useAssets = (chainName: string) => {
const dollarValue = calcCoinDollarValue(prices, { amount, denom });
return {
symbol,
logoUrl: asset.logo_URIs?.png || asset.logo_URIs?.svg,
logoUrl: asset?.logoURIs?.png || asset?.logoURIs?.svg,
prettyChainName: getPrettyChainName(denom),
displayAmount: convRawToDispAmount(denom, amount),
dollarValue,
Expand Down
33 changes: 24 additions & 9 deletions templates/chain-admin/hooks/asset-list/useChainAssetsPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ type CoinGeckoUSD = { usd: number };
type CoinGeckoUSDResponse = Record<CoinGeckoId, CoinGeckoUSD>;

const getAssetsWithGeckoIds = (assets: Asset[]) => {
return assets.filter((asset) => !!asset?.coingecko_id);
return assets.filter((asset) => !!asset?.coingeckoId);
};

const getGeckoIds = (assets: Asset[]) => {
return assets.map((asset) => asset.coingecko_id) as string[];
return assets.map((asset) => asset.coingeckoId) as string[];
};

const formatPrices = (
prices: CoinGeckoUSDResponse,
assets: Asset[]
): Record<string, number> => {
return Object.entries(prices).reduce((priceHash, cur) => {
const denom = assets.find((asset) => asset.coingecko_id === cur[0])!.base;
const denom = assets.find((asset) => asset.coingeckoId === cur[0])!.base;
return { ...priceHash, [denom]: cur[1].usd };
}, {});
};
Expand Down Expand Up @@ -48,12 +48,27 @@ export const useChainAssetsPrices = (chainName: string) => {
return useQuery({
queryKey: ['useChainAssetsPrices', chainName],
queryFn: () => fetchPrices(geckoIds),
select: (data) => ({
...formatPrices(data, assetsWithGeckoIds),
...(isStarshipChain
? { [allAssets[0].base]: DEFAULT_HYPERWEB_TOKEN_PRICE }
: {}),
}),
select: (data) => {
const formattedPrices = formatPrices(data, assetsWithGeckoIds);

// Always add hyperweb price for hyperweb chain
const hyperwebPrice =
chainName === 'hyperweb'
? { uhyper: DEFAULT_HYPERWEB_TOKEN_PRICE }
: {};

// Also add for starship chains if detected
const starshipPrice =
isStarshipChain && allAssets.length > 0
? { [allAssets[0].base]: DEFAULT_HYPERWEB_TOKEN_PRICE }
: {};

return {
...formattedPrices,
...hyperwebPrice,
...starshipPrice,
};
},
staleTime: Infinity,
});
};
Loading
Loading