Skip to content

Commit

Permalink
Merge pull request #164 from diekuche/new-chains
Browse files Browse the repository at this point in the history
added new chains, added select for token type
  • Loading branch information
Spaider15 authored Aug 15, 2023
2 parents f8f7508 + d33e819 commit 2e95057
Show file tree
Hide file tree
Showing 16 changed files with 334 additions and 31 deletions.
31 changes: 31 additions & 0 deletions src/components/CreatePage/CreatePage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,35 @@
font-size: 95px;
color: rgba(115, 237, 201, 0.07);
transform: rotate(-90deg);
}

.tokenTypeSelect {
display: flex;
color: white;
gap: 20px;
margin-bottom: 15px;
}
.tokenTypeSelect label span {
font-weight: 400;
font-size: 14px;
line-height: 18px;
color: rgba(246, 248, 254, 0.8);
}
.tokenTypeSelect label {
display: flex;
gap: 7px;
}
.tokenTypeSelect input {
margin: 0;
padding: 0;
padding-top: 3px;
}

.tabBox {
background: #12262d;
border: solid 1px rgba(115, 237, 201, 0.1);
border-radius: 0px 16px 16px;
backdrop-filter: blur(10px);
width: 100%;
padding: 35px 45px 35px 45px;
}
57 changes: 44 additions & 13 deletions src/components/CreatePage/CreatePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
import { useRef, useState } from "react";
import { useMemo, useRef, useState } from "react";
import { Tabs, Tab } from "ui/CreatePage/Tabs";
import NTT from "ui/CreatePage/NTT";
import NFT from "ui/CreatePage/NFT";
Expand All @@ -23,6 +23,7 @@ const CreatePage = () => {
const chain = useChain();
const [creating, setCreating] = useState(false);
const { account, connect, isConnected } = useAccount();
const [tokenType, setTokenType] = useState("cw20");

const {
addCw20Token,
Expand Down Expand Up @@ -196,22 +197,31 @@ const CreatePage = () => {
}
form.current?.reset();
} catch (error) {
toast.error(error as string, {
toast(`${error}`, {
type: "error",
});
console.error("error when create token", error);
console.error("error when create token");
console.log(error);
} finally {
setCreating(false);
}
};

const onCreateToken = (values: CreateFormValues) => {
if (chain.config.features?.includes("tokenfactory")) {
return onCreateFactoryToken(values);
if (tokenType === "cw20") {
return onCreateCw20Token(values);
}
return onCreateCw20Token(values);
return onCreateFactoryToken(values);
};

const tokenTypes = useMemo(() => [{
key: "cw20",
label: "CW20",
}].concat(chain.config.features?.includes("tokenfactory") ? [{
key: "tokenfactory",
label: "Tokenfactory",
}] : []), [chain]);

return (
<div className={styles.mainpage}>
<div className={styles.group}>
Expand All @@ -224,13 +234,34 @@ const CreatePage = () => {
<div className={styles.tabPageContent}>
{selectedTabId === "token"
&& (
<TokenForm
isConnected={isConnected}
connect={connect}
creating={creating}
onCreate={onCreateToken}
ref={form}
/>
<div className={styles.tabBox}>
{tokenTypes.length > 1 && (
<div className={styles.tokenTypeSelect}>
{tokenTypes.map((tt) => (
<label>
<span>
{tt.label}
</span>
<input
name="token-type"
type="radio"
value={tt.key}
onChange={(e) => setTokenType(e.target.value)}
checked={tokenType === tt.key}
/>
</label>
))}
</div>
)}
<TokenForm
isLogoEnabled={tokenType === "cw20"}
isConnected={isConnected}
connect={connect}
creating={creating}
onCreate={onCreateToken}
ref={form}
/>
</div>
)}
{selectedTabId === "nft" && <NFT />}
{selectedTabId === "ntt" && <NTT />}
Expand Down
14 changes: 11 additions & 3 deletions src/components/PoolWindow/Deposit/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const Deposit = ({
// No allowance for this account
console.log("Error when deposit to pool", pool);
console.log(e);
toast.error("Unknown error");
toast.error(`${e}`);
}).finally(() => setProcessing(false));
};
return (
Expand Down Expand Up @@ -119,7 +119,11 @@ const Deposit = ({
</div>
</div>
<div className={styles.secondStirngTwoField}>
<div className={styles.cash}>$0.00</div>
<div className={styles.cash}>
{tokenAmountToFloat(reserve1, token1.decimals)}
{" "}
{token1.symbol}
</div>
<div className={styles.balance}>
Balance:
{" "}
Expand Down Expand Up @@ -153,7 +157,11 @@ const Deposit = ({
</div>
</div>
<div className={styles.secondStirngTwoField}>
<div className={styles.cash}>$0.00</div>
<div className={styles.cash}>
{tokenAmountToFloat(reserve2, token2.decimals)}
{" "}
{token2.symbol}
</div>
<div className={styles.balance}>
Balance:
{" "}
Expand Down
1 change: 1 addition & 0 deletions src/components/PoolWindow/PoolWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const fetch = async (chain: Chain, account: Account, pool: PoolDetails) => {
chain.query(USER_TOKEN_DETAILS(pool.token1, account.address)),
chain.query(USER_TOKEN_DETAILS(pool.token2, account.address)),
]);
console.log("poolInfo", poolInfo);
return {
poolInfo,
tokens,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Pools/AllPools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const AllPools = ({
const [filter, setFilter] = useState("");
const [page, setPage] = useState(1);
const [poolForDeposit, setPoolForDeposit] = useState<PoolDetails | null>(null);

const [modal, setModal] = useState(false);
const pools = (
filter
Expand All @@ -36,6 +37,7 @@ const AllPools = ({
)
: nonFilteredPools
);

const pagesCount = Math.ceil(pools.length / PAGE_SIZE);

const toggleModal = () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/Pools/Pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const fetchData = async (
const token2Denom = (poolInfo.token2_denom as unknown as PoolDenom);
const token1 = await chain.query(POOL_TOKEN_DETAILS(token1Denom));
const token2 = await chain.query(POOL_TOKEN_DETAILS(token2Denom));
console.log("token1", token1, "token2", token2);
return {
address: poolAddress,
index,
Expand Down
17 changes: 15 additions & 2 deletions src/config/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { juno } from "./chains/juno";
import osmoTest from "./chains/osmo-test";
import JunoTest from "./chains/juno-test";
import Bostrom from "./chains/bostrom";
import { DesmosMainnet } from "./chains/desmos";
import { NeutronMainnet } from "./chains/neutron";
import { ArchwayMainnet } from "./chains/archway";

export type ChainId = "juno-1" | "uni-6" | "bostrom" | "osmo-test-5";
export type ChainId = "juno-1" | "uni-6" | "bostrom" | "osmo-test-5" | "desmos-mainnet" | "neutron-1" | "archway-1";

export type ChainConfig = Omit<ChainInfo, "chainId"> & {
chainId: ChainId;
Expand All @@ -18,7 +21,7 @@ export const Chains: Record<ChainId, ChainConfig> = {
isTestNet: true,
} as ChainConfig,
"juno-1": { ...juno, features: ["tokenfactory"] } as ChainConfig,
// "archway-1": { ...mainnetChains.archway } as ChainConfig,
"archway-1": { ...ArchwayMainnet } as ChainConfig,
"uni-6": {
...JunoTest,
chainId: "uni-6",
Expand All @@ -28,4 +31,14 @@ export const Chains: Record<ChainId, ChainConfig> = {
...Bostrom,
chainId: "bostrom",
},
"desmos-mainnet": {
...DesmosMainnet,
chainId: "desmos-mainnet",
features: ["cosmwasm"],
},
"neutron-1": {
...NeutronMainnet,
chainId: "neutron-1",
features: [],
},
};
55 changes: 55 additions & 0 deletions src/config/chains/archway.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export const ArchwayMainnet = {
bech32Config: {
bech32PrefixAccAddr: "archway",
bech32PrefixAccPub: "archwaypub",
bech32PrefixConsAddr: "archwayvalcons",
bech32PrefixConsPub: "archwayvalconspub",
bech32PrefixValAddr: "archwayvaloper",
bech32PrefixValPub: "archwayvaloperpub",
},
bip44: {
coinType: 118,
},
chainId: "archway-1",
chainName: "Archway",
chainSymbolImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/archway/chain.png",
currencies: [
{
coinDecimals: 18,
coinDenom: "ARCH",
coinGeckoId: "archway",
coinMinimalDenom: "aarch",
coinImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/archway/aarch.png",
},
],
features: ["cosmwasm"],
feeCurrencies: [
{
coinDecimals: 18,
coinDenom: "ARCH",
coinGeckoId: "archway",
coinMinimalDenom: "aarch",
gasPriceStep: {
low: 1000000000000,
average: 1500000000000,
high: 2000000000000,
},
coinImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/archway/aarch.png",
},
],
rest: "https://api.mainnet.archway.io",
rpc: "https://rpc.mainnet.archway.io",
stakeCurrency: {
coinDecimals: 18,
coinDenom: "ARCH",
coinGeckoId: "archway",
coinMinimalDenom: "aarch",
coinImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/archway/aarch.png",
},
nodeProvider: {
name: "Phi Labs",
email: "[email protected]",
website: "https://philabs.xyz",
},
walletUrlForStaking: "https://wallet.keplr.app/chains/archway",
};
53 changes: 53 additions & 0 deletions src/config/chains/desmos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ChainInfo } from "@keplr-wallet/types";
import { chains } from "chain-registry";

const chain = chains.find(({ chain_name }) => chain_name === "desmos");
if (!chain) {
throw new Error(`Not found chain ${"desmos-mainnet"} in registry`);
}
export const DesmosMainnet: ChainInfo = {
chainId: "desmos-mainnet",
chainName: "Desmos",
chainSymbolImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/desmos-mainnet/chain.png",
rpc: "https://rpc.mainnet.desmos.network",
rest: "https://api.mainnet.desmos.network",
bip44: {
coinType: 852,
},
bech32Config: {
bech32PrefixAccAddr: "desmos",
bech32PrefixAccPub: "desmospub",
bech32PrefixValAddr: "desmosvaloper",
bech32PrefixValPub: "desmosvaloperpub",
bech32PrefixConsAddr: "desmosvalcons",
bech32PrefixConsPub: "desmosvalconspub",
},
currencies: [
{
coinDenom: "DSM",
coinMinimalDenom: "udsm",
coinDecimals: 6,
coinGeckoId: "desmos",
},
],
feeCurrencies: [
{
coinDenom: "DSM",
coinMinimalDenom: "udsm",
coinDecimals: 6,
coinGeckoId: "desmos",
gasPriceStep: {
low: 0.01,
average: 0.03,
high: 0.05,
},
},
],
stakeCurrency: {
coinDenom: "DSM",
coinMinimalDenom: "udsm",
coinDecimals: 6,
coinGeckoId: "desmos",
},
features: [],
};
Loading

0 comments on commit 2e95057

Please sign in to comment.