Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hu-ke committed Nov 22, 2024
1 parent 29b5434 commit 04cba0f
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 27 deletions.
2 changes: 2 additions & 0 deletions examples/asset-list/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
return (
<ThemeProvider>
<ChainProvider
// @ts-ignore
chains={chains}
// @ts-ignore
assetLists={assets}
wallets={wallets}
walletConnectOptions={{
Expand Down
6 changes: 3 additions & 3 deletions examples/asset-list/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AssetDenomUnit } from '@chain-registry/types';
import { DenomUnit } from '@chain-registry/types';
import { Duration } from 'osmo-query/dist/codegen/google/protobuf/duration';
import { Gauge } from 'osmo-query/dist/codegen/osmosis/incentives/gauge';
import { SuperfluidAsset } from 'osmo-query/dist/codegen/osmosis/superfluid/superfluid';
import { Coin } from 'osmo-query/dist/codegen/cosmos/base/v1beta1/coin';
import { Pool } from 'osmo-query/dist/codegen/osmosis/gamm/pool-models/balancer/balancerPool';

export type CoinDenom = AssetDenomUnit['denom'];
export type CoinDenom = DenomUnit['denom'];

export type Exponent = AssetDenomUnit['exponent'];
export type Exponent = DenomUnit['exponent'];

export type CoinSymbol = string;

Expand Down
10 changes: 5 additions & 5 deletions examples/authz/utils/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { getChainAssets } from './chain';

export function getChainLogo(chain: Chain) {
return chain.logo_URIs?.svg || chain.logo_URIs?.png || chain.logo_URIs?.jpeg;
return chain.logo_URIs?.svg || chain.logo_URIs?.png;
}

export function formatDate(date?: Date) {
Expand All @@ -29,10 +29,10 @@ export function paginate(limit: bigint, reverse: boolean = false) {
export function percent(num: number | string = 0, total: number, decimals = 2) {
return total
? new BigNumber(num)
.dividedBy(total)
.multipliedBy(100)
.decimalPlaces(decimals)
.toNumber()
.dividedBy(total)
.multipliedBy(100)
.decimalPlaces(decimals)
.toNumber()
: 0;
}

Expand Down
2 changes: 2 additions & 0 deletions examples/ibc-transfer/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
return (
<ThemeProvider>
<ChainProvider
// @ts-ignore
chains={chains}
// @ts-ignore
assetLists={assets}
wallets={wallets}
walletConnectOptions={{
Expand Down
6 changes: 3 additions & 3 deletions examples/ibc-transfer/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AssetDenomUnit } from '@chain-registry/types';
import { DenomUnit } from '@chain-registry/types';
import { Duration } from 'osmo-query/dist/codegen/google/protobuf/duration';
import { Gauge } from 'osmo-query/dist/codegen/osmosis/incentives/gauge';
import { SuperfluidAsset } from 'osmo-query/dist/codegen/osmosis/superfluid/superfluid';
import { Coin } from 'osmo-query/dist/codegen/cosmos/base/v1beta1/coin';
import { Pool } from 'osmo-query/dist/codegen/osmosis/gamm/pool-models/balancer/balancerPool';

export type CoinDenom = AssetDenomUnit['denom'];
export type CoinDenom = DenomUnit['denom'];

export type Exponent = AssetDenomUnit['exponent'];
export type Exponent = DenomUnit['exponent'];

export type CoinSymbol = string;

Expand Down
2 changes: 2 additions & 0 deletions examples/nft/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
return (
<ThemeProvider>
<ChainProvider
// @ts-ignore
chains={chains}
// @ts-ignore
assetLists={assets}
wallets={wallets}
walletConnectOptions={{
Expand Down
14 changes: 7 additions & 7 deletions examples/rollkit/components/wallet/Chain.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from "react";
import { Chains } from "@chain-registry/types";
import { Chain } from "@chain-registry/types";
import { matchSorter } from "match-sorter";
import {
Avatar,
Expand All @@ -13,15 +13,15 @@ import {
} from "@interchain-ui/react";

export type ChainSelectProps = {
chains: Chains;
chains: Chain[];
chainName?: string;
onChange?: (chainName?: string) => void;
};

export function ChainSelect({
chainName,
chains = [],
onChange = () => {},
onChange = () => { },
}: ChainSelectProps) {
const { themeClass } = useTheme();
const [value, setValue] = useState<string>();
Expand All @@ -31,7 +31,7 @@ export function ChainSelect({
() =>
chains.reduce(
(cache, chain) => (cache[chain.chain_name] = chain, cache),
{} as Record<string, Chains[number]>,
{} as Record<string, Chain[][number]>,
),
[chains],
);
Expand All @@ -56,8 +56,8 @@ export function ChainSelect({
const chain = cache[chainName];

if (chain) {
setValue(chain.chain_name);
setInput(chain.pretty_name);
setValue(chain.chain_name || '');
setInput(chain.pretty_name || '');
}
}
}, [chains, chainName]);
Expand Down Expand Up @@ -122,7 +122,7 @@ export function ChainSelect({
<Combobox.Item key={option.value} textValue={option.label}>
<ChainOption
logo={option.logo ?? ""}
label={option.label}
label={option.label || ''}
/>
</Combobox.Item>
))}
Expand Down
1 change: 0 additions & 1 deletion examples/stake-tokens/components/staking/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const Overview = ({
imgSrc={
coin.logo_URIs?.png ||
coin.logo_URIs?.svg ||
coin.logo_URIs?.jpeg ||
''
}
symbol={coin.symbol}
Expand Down
3 changes: 2 additions & 1 deletion examples/stake-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"locks": "npm run locks:remove && npm run locks:create"
},
"dependencies": {
"@chain-registry/types": "^0.50.18",
"@cosmjs/cosmwasm-stargate": "0.31.3",
"@cosmjs/stargate": "0.32.3",
"@cosmos-kit/react": "2.17.0",
Expand Down Expand Up @@ -40,4 +41,4 @@
"typescript": "^5.5.4"
},
"packageManager": "[email protected]"
}
}
2 changes: 2 additions & 0 deletions examples/stake-tokens/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
return (
<ThemeProvider>
<ChainProvider
// @ts-ignore
chains={chains}
// @ts-ignore
assetLists={assets}
wallets={wallets}
walletConnectOptions={{
Expand Down
8 changes: 8 additions & 0 deletions examples/stake-tokens/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ __metadata:
languageName: node
linkType: hard

"@chain-registry/types@npm:^0.50.18":
version: 0.50.18
resolution: "@chain-registry/types@npm:0.50.18"
checksum: 10c0/a7b5ca5b42fbf80a98e802372fe64602c1ac3cef8b3cb20ba8e444cd2613a07ab3b26d5049eb00fbcb578836050a859c78f722c8a414ae1525043860fa0709e0
languageName: node
linkType: hard

"@chain-registry/utils@npm:^1.46.1, @chain-registry/utils@npm:^1.46.4":
version: 1.46.4
resolution: "@chain-registry/utils@npm:1.46.4"
Expand Down Expand Up @@ -632,6 +639,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@cosmology/stake-tokens@workspace:."
dependencies:
"@chain-registry/types": "npm:^0.50.18"
"@cosmjs/cosmwasm-stargate": "npm:0.31.3"
"@cosmjs/stargate": "npm:0.32.3"
"@cosmos-kit/react": "npm:2.17.0"
Expand Down
12 changes: 6 additions & 6 deletions examples/vote-proposal/components/wallet/Chain.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from "react";
import { Chains } from "@chain-registry/types";
import { Chain } from "@chain-registry/types";
import { matchSorter } from "match-sorter";
import {
Avatar,
Expand All @@ -13,15 +13,15 @@ import {
} from "@interchain-ui/react";

export type ChainSelectProps = {
chains: Chains;
chains: Chain[];
chainName?: string;
onChange?: (chainName?: string) => void;
};

export function ChainSelect({
chainName,
chains = [],
onChange = () => {},
onChange = () => { },
}: ChainSelectProps) {
const { themeClass } = useTheme();
const [value, setValue] = useState<string>();
Expand All @@ -31,7 +31,7 @@ export function ChainSelect({
() =>
chains.reduce(
(cache, chain) => (cache[chain.chain_name] = chain, cache),
{} as Record<string, Chains[number]>,
{} as Record<string, Chain[][number]>,
),
[chains],
);
Expand All @@ -57,7 +57,7 @@ export function ChainSelect({

if (chain) {
setValue(chain.chain_name);
setInput(chain.pretty_name);
setInput(chain.pretty_name || '');
}
}
}, [chains, chainName]);
Expand Down Expand Up @@ -122,7 +122,7 @@ export function ChainSelect({
<Combobox.Item key={option.value} textValue={option.label}>
<ChainOption
logo={option.logo ?? ""}
label={option.label}
label={option.label ?? ""}
/>
</Combobox.Item>
))}
Expand Down
2 changes: 2 additions & 0 deletions examples/vote-proposal/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
return (
<ThemeProvider>
<ChainProvider
// @ts-ignore
chains={chains}
// @ts-ignore
assetLists={assets}
wallets={wallets}
walletConnectOptions={{
Expand Down
2 changes: 1 addition & 1 deletion examples/vote-proposal/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assets } from 'chain-registry';
import { AssetList, Asset } from '@chain-registry/types';

export function getChainLogo(chain: Chain) {
return chain.logo_URIs?.svg || chain.logo_URIs?.png || chain.logo_URIs?.jpeg;
return chain.logo_URIs?.svg || chain.logo_URIs?.png;
}

export function formatDate(date?: Date) {
Expand Down

0 comments on commit 04cba0f

Please sign in to comment.