Skip to content

Commit

Permalink
fixed bostrom config
Browse files Browse the repository at this point in the history
  • Loading branch information
“arvitaly” committed Jul 24, 2023
1 parent dea51e0 commit 7110b08
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/config/chains/bostrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Bostrom = {
{
coinDenom: "boot",
coinMinimalDenom: "boot",
coinDecimals: 6,
coinDecimals: 0,
coinGeckoId: "bostrom",
coinImageUrl: "https://raw.githubusercontent.com/cosmos/chain-registry/master/bostrom/images/boot.png",
},
Expand Down
4 changes: 2 additions & 2 deletions src/queries/cw20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const CW20_TOKEN_LOGO = (tokenAddr: string) => ({
});

export const CW20_TOKEN_DETAILS = (tokenAddr: string) => ({
queryKey: `/v0.1/cw20/${tokenAddr}/details`,
queryKey: `/v0.01/cw20/${tokenAddr}/details`,
queryFn: async (context: {
chain: Chain
}): Promise<Cw20TokenDetails> => {
Expand Down Expand Up @@ -89,7 +89,7 @@ export const CW20_USER_TOKEN_DETAILS = (
tokenAddress: string,
userAddress: string,
) => ({
queryKey: `/v0.1/user/${userAddress}/cw20/${tokenAddress}/details`,
queryKey: `/v0.01/user/${userAddress}/cw20/${tokenAddress}/details`,
queryFn: async (context: {
chain: Chain
}): Promise<UserCw20TokenDetails> => {
Expand Down
22 changes: 14 additions & 8 deletions src/queries/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,39 @@ import { Chain } from "classes/Chain";
import { NativeTokenDetails } from "types/tokens";

export const NATIVE_TOKEN_DETAILS = (denom: string) => ({
queryKey: `v0.1/native/${denom}/details`,
queryKey: `v0.01/native/${denom}/details`,
queryFn: async ({ chain }: {
chain: Chain
}): Promise<NativeTokenDetails> => {
const isFactoryToken = denom.toLowerCase().startsWith("factory/");
const bank = await chain.bank();
const meta = await bank.denomMetadata(denom).catch(() => null);
const minMetaDenom = meta ? meta.denomUnits.find((u) => u.exponent === 0) : null;

if (isFactoryToken) {
const bank = await chain.bank();
const meta = await bank.denomMetadata(denom);
if (!meta) {
throw new Error(`Not found factory token metadata for ${denom}`);
}
return {
type: "native",
denom,
decimals: meta.denomUnits[0].exponent,
decimals: minMetaDenom?.exponent || 0,
symbol: meta.symbol,
};
}

const native = chain.config.currencies.find(
(currency) => currency.coinMinimalDenom === denom,
);

if (native) {
return {
type: "native",
logo: native.coinImageUrl,
denom: native.coinDenom,
minimalDenom: native.coinMinimalDenom,
decimals: native.coinDecimals,
symbol: native.coinDenom,
denom: meta ? meta.base : native.coinDenom,
minimalDenom: minMetaDenom?.denom || native.coinMinimalDenom,
decimals: minMetaDenom?.exponent || native.coinDecimals,
symbol: meta?.symbol || native.coinDenom,
};
}
return {
Expand Down
4 changes: 2 additions & 2 deletions src/queries/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const SWAP_POOL_INFO = (poolAddress: string) => ({
});

export const SWAP_POOL_LIST = (factoryAddr: string) => ({
queryKey: `/v0.1/factory/${factoryAddr}/pools`,
queryKey: `/v0.01/factory/${factoryAddr}/pools`,
queryFn: async ({ chain }: { chain: Chain }) => {
try {
const factory = new SwapPoolFactoryQueryClient(await chain.getCosmWasmClient(), factoryAddr);
Expand Down Expand Up @@ -45,7 +45,7 @@ export const POOL_TOKEN_DETAILS = (denom: PoolDenom): {
return NATIVE_TOKEN_DETAILS(denom.native);
}
return {
queryKey: `/v0.1/cw20/${denom.cw20}/details`,
queryKey: `/v0.01/cw20/${denom.cw20}/details`,
queryFn: (context: {
chain: Chain
}) => CW20_TOKEN_DETAILS(
Expand Down
4 changes: 2 additions & 2 deletions src/queries/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { NATIVE_TOKEN_DETAILS } from "./native";
export const USER_TOKEN_DETAILS = (token: TokenDetails, userAddress: string) => {
if (token.type === "native") {
return {
queryKey: `/v0.1/user/${userAddress}/native/${token.denom}/details`,
queryKey: `/v0.01/user/${userAddress}/native/${token.denom}/details`,
queryFn: async ({
chain,
}: {
Expand All @@ -27,7 +27,7 @@ export const USER_TOKEN_DETAILS = (token: TokenDetails, userAddress: string) =>
};
}
return {
queryKey: `/v0.1/user/${userAddress}/cw20/${token.address}/details`,
queryKey: `/v0.01/user/${userAddress}/cw20/${token.address}/details`,
queryFn: (
context: {
chain: Chain
Expand Down
66 changes: 0 additions & 66 deletions src/stories/CreatePage/FactoryTokenForm.tsx

This file was deleted.

10 changes: 4 additions & 6 deletions src/stories/CreatePage/TokenForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RefObject, useState } from "react";
import { ForwardedRef, forwardRef, useState } from "react";
import { v4 as uuidv4 } from "uuid";
import Button from "ui/Button";
import Input, { InputProps } from "ui/CreatePage/Input";
Expand Down Expand Up @@ -28,16 +28,14 @@ export type TokenFormProps = {
connect: () => void;
creating: boolean;
onCreate: (values: CreateFormValues) => void;
ref: RefObject<HTMLFormElement> | undefined;
};

const CW20TokenForm = ({
const TokenForm = ({
creating,
isConnected,
connect,
onCreate,
ref,
}: TokenFormProps) => {
}: TokenFormProps, ref: ForwardedRef<HTMLFormElement>) => {
const [balances, setBalances] = useState<Balance[]>([
defaultBalance,
]);
Expand Down Expand Up @@ -221,4 +219,4 @@ const CW20TokenForm = ({
);
};

export default CW20TokenForm;
export default forwardRef<HTMLFormElement, TokenFormProps>(TokenForm);

0 comments on commit 7110b08

Please sign in to comment.