diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..b52a92b1 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "semi": false, + "printWidth": 100 +} diff --git a/components/Button.tsx b/components/Button.tsx index e17d3e43..9b15b694 100644 --- a/components/Button.tsx +++ b/components/Button.tsx @@ -1,22 +1,26 @@ -import React from "react"; +import React from 'react' type Props = { - children: string; - className?: string; - onClick: () => void; -}; + children: string + className?: string + onClick: () => void + disabled?: boolean +} const Button = React.forwardRef( - ({ children, className = "", onClick }, ref) => ( + ({ children, className = '', onClick, disabled }, ref) => ( ) -); +) -Button.displayName = "Button"; -export default Button; +Button.displayName = 'Button' +export default Button diff --git a/components/ConnectModal.tsx b/components/ConnectModal.tsx index 07c2b2ef..8f895091 100644 --- a/components/ConnectModal.tsx +++ b/components/ConnectModal.tsx @@ -1,81 +1,85 @@ -import React, { Fragment, useState } from "react"; -import Image from "next/image"; -import { Dialog, Transition } from "@headlessui/react"; -import { toast } from "react-toastify"; +import React, { Fragment, useState } from 'react' +import Image from 'next/image' +import { Dialog, Transition } from '@headlessui/react' +import { toast } from 'react-toastify' +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { Coin } from '@cosmjs/stargate' -import { getInjectiveAddress } from "utils/address"; -import { getExperimentalChainConfigBasedOnChainId } from "utils/experimental-chains"; -import { ChainId } from "types"; -import useWalletStore from "stores/useWalletStore"; +import { getInjectiveAddress } from 'utils/address' +import { getExperimentalChainConfigBasedOnChainId } from 'utils/experimental-chains' +import { ChainId } from 'types' +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' type Props = { - isOpen: boolean; - onClose: () => void; -}; + isOpen: boolean + onClose: () => void +} const ConnectModal = ({ isOpen, onClose }: Props) => { - const [isLoading, setIsLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false) - const actions = useWalletStore((state) => state.actions); - const metamaskInstalled = useWalletStore((state) => state.metamaskInstalled); - const isKeplrInstalled = typeof window !== "undefined" && window.keplr; + const actions = useWalletStore((state) => state.actions) + const metamaskInstalled = useWalletStore((state) => state.metamaskInstalled) + const isKeplrInstalled = typeof window !== 'undefined' && window.keplr const handleConnectSuccess = () => { - onClose(); + onClose() // defering update on loading state to avoid updating before close animation is finished setTimeout(() => { - setIsLoading(false); - }, 500); - }; + setIsLoading(false) + }, 500) + } const handleConnectKeplr = async () => { if (!window.keplr) { - toast.error("You need Keplr extension installed"); - return; + toast.error('You need Keplr extension installed') + return } - setIsLoading(true); + setIsLoading(true) try { - const chainData = getExperimentalChainConfigBasedOnChainId( - ChainId.Mainnet - ); - await window.keplr.experimentalSuggestChain(chainData); + const chainData = getExperimentalChainConfigBasedOnChainId(chain.chainId) - const key = await window.keplr.getKey(ChainId.Mainnet); - actions.setAddress(key.bech32Address); + if (chainData) { + await window.keplr.experimentalSuggestChain(chainData) + } - handleConnectSuccess(); + const key = await window.keplr.getKey(chain.chainId) + actions.setAddress(key.bech32Address) + + handleConnectSuccess() } catch (e) { // TODO: handle exception - console.log(e); - setIsLoading(false); + console.log(e) + setIsLoading(false) } - }; + } const handleConnectMetamask = async () => { if (!metamaskInstalled) { - toast.error("You need Metamask extension installed"); - return; + toast.error('You need Metamask extension installed') + return } - setIsLoading(true); + setIsLoading(true) try { // TODO: missing type definitions const addresses = await (window.ethereum as any).request({ - method: "eth_requestAccounts", - }); - const [address] = addresses; - actions.setAddress(getInjectiveAddress(address)); - handleConnectSuccess(); + method: 'eth_requestAccounts', + }) + const [address] = addresses + actions.setAddress(getInjectiveAddress(address)) + handleConnectSuccess() } catch (e) { // TODO: handle exception - console.log(e); - setIsLoading(false); + console.log(e) + setIsLoading(false) } - }; + } return ( @@ -104,10 +108,7 @@ const ConnectModal = ({ isOpen, onClose }: Props) => { leaveTo="opacity-0 scale-95" > - + Connect your wallet {isLoading ? ( @@ -135,12 +136,7 @@ const ConnectModal = ({ isOpen, onClose }: Props) => { className="flex items-center p-4 bg-black/90 rounded-xl hover:bg-black" onClick={handleConnectMetamask} > - metamask + metamask
-

- Connect using Metamask -

+

Connect using Metamask

@@ -199,7 +186,7 @@ const ConnectModal = ({ isOpen, onClose }: Props) => {
- ); -}; + ) +} -export default ConnectModal; +export default ConnectModal diff --git a/components/Container/index.tsx b/components/Container/index.tsx index 3c35c581..b11bf22f 100644 --- a/components/Container/index.tsx +++ b/components/Container/index.tsx @@ -1,13 +1,13 @@ -import React from "react"; -import styles from "./Container.module.css"; +import React from 'react' +import styles from './Container.module.css' type Props = { - children: React.ReactNode; - className?: string; -}; + children: React.ReactNode + className?: string +} -const Container = ({ children, className = "" }: Props) => { - return
{children}
; -}; +const Container = ({ children, className = '' }: Props) => { + return
{children}
+} -export default Container; +export default Container diff --git a/components/CreditManager/CreditManagerContainer.tsx b/components/CreditManager/CreditManagerContainer.tsx new file mode 100644 index 00000000..0e18b1b9 --- /dev/null +++ b/components/CreditManager/CreditManagerContainer.tsx @@ -0,0 +1,14 @@ +import React from 'react' + +// move this component outside and probably adapt generic container component to different UI variants +export const CreditManagerContainer = ({ + children, + className, +}: { + children: React.ReactNode + className?: string +}) => { + return
{children}
+} + +export default CreditManagerContainer diff --git a/components/CreditManager/FundAccount.tsx b/components/CreditManager/FundAccount.tsx new file mode 100644 index 00000000..c5bb4040 --- /dev/null +++ b/components/CreditManager/FundAccount.tsx @@ -0,0 +1,165 @@ +import React, { useEffect, useMemo, useState } from 'react' +import * as Slider from '@radix-ui/react-slider' +import BigNumber from 'bignumber.js' +import { Switch } from '@headlessui/react' + +import Button from '../Button' +import useAllowedCoins from 'hooks/useAllowedCoins' +import useDepositCreditAccount from 'hooks/useDepositCreditAccount' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import useAllBalances from 'hooks/useAllBalances' +import { getTokenDecimals, getTokenSymbol } from 'utils/tokens' +import CreditManagerContainer from './CreditManagerContainer' + +const FundAccount = () => { + const [amount, setAmount] = useState(0) + const [selectedToken, setSelectedToken] = useState('') + const [enabled, setEnabled] = useState(false) + + const selectedAccount = useCreditManagerStore((state) => state.selectedAccount) + + const { data: balancesData } = useAllBalances() + const { data: allowedCoinsData, isLoading: isLoadingAllowedCoins } = useAllowedCoins() + const { mutate } = useDepositCreditAccount( + selectedAccount || '', + selectedToken, + BigNumber(amount) + .times(10 ** getTokenDecimals(selectedToken)) + .toNumber() + ) + + useEffect(() => { + if (allowedCoinsData && allowedCoinsData.length > 0) { + // initialize selected token when allowedCoins fetch data is available + setSelectedToken(allowedCoinsData[0]) + } + }, [allowedCoinsData]) + + const walletAmount = useMemo(() => { + if (!selectedToken) return 0 + + return BigNumber(balancesData?.find((balance) => balance.denom === selectedToken)?.amount ?? 0) + .div(10 ** getTokenDecimals(selectedToken)) + .toNumber() + }, [balancesData, selectedToken]) + + const handleValueChange = (value: number) => { + if (value > walletAmount) { + setAmount(walletAmount) + return + } + + setAmount(value) + } + + const maxValue = walletAmount + const percentageValue = isNaN(amount) ? 0 : (amount * 100) / maxValue + + return ( + <> + +

+ Transfer assets from your injective wallet to your Mars credit account. If you don’t have + any assets in your injective wallet use the injective bridge to transfer funds to your + injective wallet. +

+ {isLoadingAllowedCoins ? ( +

Loading...

+ ) : ( + <> +
+
+
Asset:
+ +
+
+
Amount:
+ handleValueChange(e.target.valueAsNumber)} + /> +
+
+

In wallet: {walletAmount.toLocaleString()}

+ {/* SLIDER - initial implementation to test functionality */} + {/* TODO: will need to be revamped later on */} +
+ { + const decimal = value[0] / 100 + const tokenDecimals = getTokenDecimals(selectedToken) + // limit decimal precision based on token contract decimals + const newAmount = Number((decimal * maxValue).toFixed(tokenDecimals)) + + setAmount(newAmount) + }} + > + + + + +
{percentageValue.toFixed(0)}%
+
+
+ +
+ + )} +
+ +
+

Lending Assets

+
Lend assets from account to earn yield.
+
+ + + + +
+ + + ) +} + +export default FundAccount diff --git a/components/CreditManager/index.tsx b/components/CreditManager/index.tsx new file mode 100644 index 00000000..98c78659 --- /dev/null +++ b/components/CreditManager/index.tsx @@ -0,0 +1,127 @@ +import React, { useState } from 'react' +import BigNumber from 'bignumber.js' + +import Button from '../Button' +import { formatCurrency } from 'utils/formatters' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' +import useCreditAccountBalances from 'hooks/useCreditAccountPositions' +import { getTokenDecimals } from 'utils/tokens' +import FundAccount from './FundAccount' +import CreditManagerContainer from './CreditManagerContainer' + +const CreditManager = () => { + const [isFund, setIsFund] = useState(false) + + const address = useWalletStore((state) => state.address) + const selectedAccount = useCreditManagerStore((state) => state.selectedAccount) + + const { data: positionsData, isLoading: isLoadingPositions } = useCreditAccountBalances( + selectedAccount ?? '' + ) + + const totalPosition = + positionsData?.coins.reduce((acc, coin) => { + return Number(coin.value) + acc + }, 0) ?? 0 + + const totalDebt = + positionsData?.debt.reduce((acc, coin) => { + return Number(coin.value) + acc + }, 0) ?? 0 + + if (!address) { + return ( +
+ You must have a connected wallet +
+ ) + } + + return ( +
+ + {isFund ? ( +
+

Fund Account

+ +
+ ) : ( +
+ + +
+ )} +
+ {isFund ? ( + + ) : ( + <> + +
+
Total Position:
+
{formatCurrency(totalPosition)}
+
+
+
Total Liabilities:
+
{formatCurrency(totalDebt)}
+
+
+ +

Balances

+ {isLoadingPositions ? ( +
Loading...
+ ) : ( + <> +
+
Asset
+
Value
+
Size
+
APY
+
+ {positionsData?.coins.map((coin) => ( +
+
{coin.denom}
+
{formatCurrency(coin.value)}
+
+ {BigNumber(coin.amount) + .div(10 ** getTokenDecimals(coin.denom)) + .toNumber() + .toLocaleString(undefined, { + maximumFractionDigits: 6, + })} +
+
-
+
+ ))} + {positionsData?.debt.map((coin) => ( +
+
{coin.denom}
+
{formatCurrency(coin.value)}
+
+ {BigNumber(coin.amount) + .div(10 ** getTokenDecimals(coin.denom)) + .toNumber() + .toLocaleString(undefined, { + maximumFractionDigits: 6, + })} +
+
-
+
+ ))} + + )} +
+ + )} +
+ ) +} + +export default CreditManager diff --git a/components/Layout/index.tsx b/components/Layout/index.tsx index 63705877..142b2e25 100644 --- a/components/Layout/index.tsx +++ b/components/Layout/index.tsx @@ -1,15 +1,22 @@ -import Navigation from "components/Navigation"; -import React from "react"; +import React from 'react' +import useCreditManagerStore from 'stores/useCreditManagerStore' -import styles from "./Layout.module.css"; +import CreditManager from 'components/CreditManager' +import Navigation from 'components/Navigation' +import styles from './Layout.module.css' const Layout = ({ children }: { children: React.ReactNode }) => { + const isOpen = useCreditManagerStore((s) => s.isOpen) + return (
-
{children}
+
+ {children} + {isOpen && } +
- ); -}; + ) +} -export default Layout; +export default Layout diff --git a/components/Navigation.tsx b/components/Navigation.tsx index fb6f4f44..a6b8bbe4 100644 --- a/components/Navigation.tsx +++ b/components/Navigation.tsx @@ -1,46 +1,60 @@ -import React from "react"; -import Link from "next/link"; -import { useRouter } from "next/router"; -import { Popover } from "@headlessui/react"; -import { ChevronDownIcon } from "@heroicons/react/24/solid"; +import React, { useMemo } from 'react' +import Link from 'next/link' +import { useRouter } from 'next/router' +import { Popover } from '@headlessui/react' +import { ChevronDownIcon } from '@heroicons/react/24/solid' -import SearchInput from "components/SearchInput"; -import ProgressBar from "components/ProgressBar"; -import Wallet from "./Wallet"; -import { formatCurrency } from "utils/formatters"; +import SearchInput from 'components/SearchInput' +import ProgressBar from 'components/ProgressBar' +import Spinner from 'components/Spinner' +import Wallet from 'components/Wallet' +import { formatCurrency } from 'utils/formatters' +import useCreditAccounts from 'hooks/useCreditAccounts' +import useCreateCreditAccount from 'hooks/useCreateCreditAccount' +import useDeleteCreditAccount from 'hooks/useDeleteCreditAccount' +import useCreditManagerStore from 'stores/useCreditManagerStore' -const mockedAccounts = [ - { - label: "Subaccount 1", - }, - { - label: "Subaccount 2", - }, - { - label: "Subaccount 3", - }, - { - label: "Subaccount 4", - }, -]; +// TODO: will require some tweaks depending on how lower viewport mocks pans out +const MAX_VISIBLE_CREDIT_ACCOUNTS = 5 + +const navItems = [ + { href: '/trade', label: 'Trade' }, + { href: '/yield', label: 'Yield' }, + { href: '/borrow', label: 'Borrow' }, + { href: '/portfolio', label: 'Portfolio' }, + { href: '/council', label: 'Council' }, +] const NavLink = ({ href, children }: { href: string; children: string }) => { - const router = useRouter(); + const router = useRouter() return ( - + {children} - ); -}; + ) +} const Navigation = () => { + const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) + const setSelectedAccount = useCreditManagerStore((s) => s.actions.setSelectedAccount) + const toggleCreditManager = useCreditManagerStore((s) => s.actions.toggleCreditManager) + + const { data: creditAccountsList } = useCreditAccounts() + const { mutate: createCreditAccount, isLoading: isLoadingCreate } = useCreateCreditAccount() + const { mutate: deleteCreditAccount, isLoading: isLoadingDelete } = useDeleteCreditAccount( + selectedAccount || '' + ) + + const { firstCreditAccounts, restCreditAccounts } = useMemo(() => { + return { + firstCreditAccounts: creditAccountsList?.slice(0, MAX_VISIBLE_CREDIT_ACCOUNTS) ?? [], + restCreditAccounts: creditAccountsList?.slice(MAX_VISIBLE_CREDIT_ACCOUNTS) ?? [], + } + }, [creditAccountsList]) + return (
{/* Main navigation bar */} @@ -51,11 +65,11 @@ const Navigation = () => {
- Trade - Yield - Borrow - Portfolio - Council + {navItems.map((item, index) => ( + + {item.label} + + ))}
@@ -63,11 +77,42 @@ const Navigation = () => {
- {mockedAccounts.map((account, index) => ( -
- {account.label} + {firstCreditAccounts.map((account) => ( +
setSelectedAccount(account)} + > + Account {account}
))} + {restCreditAccounts.length > 0 && ( + + +
+ More + +
+
+ +
+ {restCreditAccounts.map((account) => ( +
setSelectedAccount(account)} + > + Account {account} +
+ ))} +
+
+
+ )}
@@ -76,46 +121,65 @@ const Navigation = () => {
-
-
alert("TODO")} - > - Create subaccount + {({ close }) => ( +
+
{ + close() + createCreditAccount() + }} + > + Create Account +
+
{ + close() + deleteCreditAccount() + }} + > + Close Account +
+
alert('TODO')} + > + Transfer Balance +
+
alert('TODO')} + > + Rearrange +
-
alert("TODO")} - > - Close subaccount -
-
alert("TODO")} - > - Transfer balance -
-
alert("TODO")}> - Rearrange -
-
+ )}
-

$: ${formatCurrency(2500)}

+

{formatCurrency(2500)}

Lvg
Risk
-
+
+ {(isLoadingCreate || isLoadingDelete) && ( +
+ +
+ )}
- ); -}; + ) +} -export default Navigation; +export default Navigation diff --git a/components/ProgressBar.tsx b/components/ProgressBar.tsx index 93558206..2276c233 100644 --- a/components/ProgressBar.tsx +++ b/components/ProgressBar.tsx @@ -1,22 +1,22 @@ -import React, { useEffect, useState } from "react"; -import { ArrowRightIcon } from "@heroicons/react/24/solid"; +import React, { useEffect, useState } from 'react' +import { ArrowRightIcon } from '@heroicons/react/24/solid' type Props = { - value: number; -}; + value: number +} const ProgressBar = ({ value }: Props) => { - const percentageValue = `${(value * 100).toFixed(0)}%`; - const [newValue, setNewValue] = useState(0.77); + const percentageValue = `${(value * 100).toFixed(0)}%` + const [newValue, setNewValue] = useState(0.77) useEffect(() => { setInterval(() => { // randomizing value between value and 1 - setNewValue(Math.random() * (1 - value) + value); - }, 3000); - }, [value]); + setNewValue(Math.random() * (1 - value) + value) + }, 3000) + }, [value]) - const percentageNewValue = `${(newValue * 100).toFixed(0)}%`; + const percentageNewValue = `${(newValue * 100).toFixed(0)}%` return (
@@ -34,7 +34,7 @@ const ProgressBar = ({ value }: Props) => { {percentageNewValue}
- ); -}; + ) +} -export default ProgressBar; +export default ProgressBar diff --git a/components/SearchInput.tsx b/components/SearchInput.tsx index c3ca8e39..aac97781 100644 --- a/components/SearchInput.tsx +++ b/components/SearchInput.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React from 'react' const SearchInput = () => (
@@ -20,6 +20,6 @@ const SearchInput = () => ( placeholder="Search" />
-); +) -export default SearchInput; +export default SearchInput diff --git a/components/Spinner.tsx b/components/Spinner.tsx new file mode 100644 index 00000000..b3e210dc --- /dev/null +++ b/components/Spinner.tsx @@ -0,0 +1,28 @@ +import React from 'react' + +const Spinner = () => { + return ( + + + + + ) +} + +export default Spinner diff --git a/components/Wallet.tsx b/components/Wallet.tsx index c702a050..d3e3954d 100644 --- a/components/Wallet.tsx +++ b/components/Wallet.tsx @@ -1,19 +1,20 @@ -import React, { useEffect, useState } from "react"; -import { Popover } from "@headlessui/react"; -import { toast } from "react-toastify"; -import Image from "next/image"; +import React, { useEffect, useState } from 'react' +import { Popover } from '@headlessui/react' +import { toast } from 'react-toastify' +import Image from 'next/image' -import Button from "./Button"; -import ConnectModal from "./ConnectModal"; -import useWalletStore from "stores/useWalletStore"; -import useInjectiveBalance from "hooks/useInjectiveBalance"; -import { formatWalletAddress } from "utils/formatters"; +import Button from './Button' +import ConnectModal from './ConnectModal' +import useWalletStore from 'stores/useWalletStore' +import useTokenBalance from 'hooks/useTokenBalance' +import { formatWalletAddress } from 'utils/formatters' +import { chain } from 'utils/chains' const WalletPopover = ({ children }: { children: React.ReactNode }) => { - const address = useWalletStore((state) => state.address); - const actions = useWalletStore((state) => state.actions); + const address = useWalletStore((state) => state.address) + const actions = useWalletStore((state) => state.actions) - const { data } = useInjectiveBalance(); + const { data } = useTokenBalance() return ( @@ -25,17 +26,15 @@ const WalletPopover = ({ children }: { children: React.ReactNode }) => {
- token + token

- INJ{" "} - - {data?.toFixed(2)} - + {chain.stakeCurrency.coinDenom}{' '} + {data?.toFixed(2)}

@@ -45,8 +44,8 @@ const WalletPopover = ({ children }: { children: React.ReactNode }) => { className="flex items-center text-slate-500 hover:text-slate-700 text-sm" onClick={() => { navigator.clipboard.writeText(address).then(() => { - toast.success("Address copied to your clipboard"); - }); + toast.success('Address copied to your clipboard') + }) }} > {
- ); -}; + ) +} const Wallet = () => { - const [showConnectModal, setShowConnectModal] = useState(false); - const [hasHydrated, setHasHydrated] = useState(false); + const [showConnectModal, setShowConnectModal] = useState(false) + const [hasHydrated, setHasHydrated] = useState(false) - const address = useWalletStore((state) => state.address); + const address = useWalletStore((state) => state.address) // avoid server-client hydration mismatch useEffect(() => { - setHasHydrated(true); - }, []); + setHasHydrated(true) + }, []) return ( <> @@ -90,12 +89,9 @@ const Wallet = () => { Connect Wallet )} - setShowConnectModal(false)} - /> + setShowConnectModal(false)} /> - ); -}; + ) +} -export default Wallet; +export default Wallet diff --git a/config/contracts.ts b/config/contracts.ts new file mode 100644 index 00000000..031ae0a9 --- /dev/null +++ b/config/contracts.ts @@ -0,0 +1,9 @@ +// https://github.com/mars-protocol/rover/blob/master/scripts/deploy/addresses/osmo-test-4.json +export const contractAddresses = { + accountNft: 'osmo16v3mvsdnkh4c6ykc885n3x5ay9e36akdzxcl2g93698rqw007xxqesld8w', + mockRedBank: 'osmo1xrnx0q3x7kwzss53fry0dwwsc7pff6aq628l6n0rmvegkalp4y7qzl7j7z', + mockOracle: 'osmo1r9u2tfq8n5xpn2g0fq8ha0rj0cyp2fzr5w9jvcqwt3r8lxdfm6yszmtza5', + mockVault: 'osmo1gg4rpug7vwrnq0ask0k7nmw23z6wl8c8fr7jmup9pdpaal9uc5nqq7lyrm', + swapper: 'osmo1ak4x8k2h7s6pq5dnlncmgsmx2nqcaplpfxlmklx2ln7qn6dtny8q70apjv', + creditManager: 'osmo1963xgmt8agyc6q4k2vhf980kffq6ukkj9mgtwdxxnpj3dak2akdq20z9dw', +} diff --git a/config/tokenInfo.ts b/config/tokenInfo.ts new file mode 100644 index 00000000..1ef9c285 --- /dev/null +++ b/config/tokenInfo.ts @@ -0,0 +1,20 @@ +type Token = { + symbol: string + decimals: number + icon: string +} + +const tokenInfo: { [key in string]: Token } = { + uosmo: { + symbol: 'OSMO', + decimals: 6, + icon: '/tokens/osmo.svg', + }, + 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2': { + symbol: 'ATOM', + icon: '', + decimals: 6, + }, +} + +export default tokenInfo diff --git a/hooks/useAllBalances.tsx b/hooks/useAllBalances.tsx index e9fa743c..e2f777d5 100644 --- a/hooks/useAllBalances.tsx +++ b/hooks/useAllBalances.tsx @@ -1,20 +1,29 @@ -import { useQuery } from "@tanstack/react-query"; +import { useQuery } from '@tanstack/react-query' -import useWalletStore from "stores/useWalletStore"; +import useWalletStore from 'stores/useWalletStore' +import { queryKeys } from 'types/query-keys-factory' +import { chain } from 'utils/chains' + +type Result = { + balances: { amount: string; denom: string }[] +} const useAllBalances = () => { - const address = useWalletStore((state) => state.address); + const address = useWalletStore((state) => state.address) - return useQuery( - ["allBalances"], - () => - fetch( - `https://lcd.injective.network/cosmos/bank/v1beta1/balances/${address}` - ).then((res) => res.json()), + const result = useQuery( + queryKeys.allBalances(address), + () => fetch(`${chain.rest}/cosmos/bank/v1beta1/balances/${address}`).then((res) => res.json()), { enabled: !!address, + staleTime: Infinity, } - ); -}; + ) -export default useAllBalances; + return { + ...result, + data: result?.data?.balances, + } +} + +export default useAllBalances diff --git a/hooks/useAllowedCoins.tsx b/hooks/useAllowedCoins.tsx new file mode 100644 index 00000000..eda87ce8 --- /dev/null +++ b/hooks/useAllowedCoins.tsx @@ -0,0 +1,46 @@ +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { useQuery } from '@tanstack/react-query' +import { useEffect, useState } from 'react' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import { queryKeys } from 'types/query-keys-factory' + +type Result = string[] + +const queryMsg = { + allowed_coins: {}, +} + +const useAllowedCoins = () => { + const [signingClient, setSigningClient] = useState() + const address = useWalletStore((state) => state.address) + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + const result = useQuery( + queryKeys.allowedCoins(), + async () => signingClient?.queryContractSmart(contractAddresses.creditManager, queryMsg), + { + enabled: !!address && !!signingClient, + staleTime: Infinity, + } + ) + + return { + ...result, + data: result?.data, + } +} + +export default useAllowedCoins diff --git a/hooks/useCreateCreditAccount.tsx b/hooks/useCreateCreditAccount.tsx new file mode 100644 index 00000000..81b4449a --- /dev/null +++ b/hooks/useCreateCreditAccount.tsx @@ -0,0 +1,63 @@ +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { useMutation, useQueryClient } from '@tanstack/react-query' +import { useEffect, useState } from 'react' +import { toast } from 'react-toastify' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import { hardcodedFee } from 'utils/contants' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import { queryKeys } from 'types/query-keys-factory' + +// 200000 gas used +const executeMsg = { + create_credit_account: {}, +} + +const useCreateCreditAccount = () => { + const [signingClient, setSigningClient] = useState() + const setSelectedAccount = useCreditManagerStore((state) => state.actions.setSelectedAccount) + const address = useWalletStore((state) => state.address) + + const queryClient = useQueryClient() + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + return useMutation( + async () => + await signingClient?.execute( + address, + contractAddresses.creditManager, + executeMsg, + hardcodedFee + ), + { + onSettled: () => { + queryClient.invalidateQueries(queryKeys.creditAccounts(address)) + }, + onError: (err: Error) => { + toast.error(err.message) + }, + onSuccess: (data) => { + if (!data) return + + // TODO: is there some better way to parse response to extract token id??? + const createdID = data.logs[0].events[2].attributes[6].value + setSelectedAccount(createdID) + toast.success('New account created') + }, + } + ) +} + +export default useCreateCreditAccount diff --git a/hooks/useCreditAccountPositions.tsx b/hooks/useCreditAccountPositions.tsx new file mode 100644 index 00000000..c5c22840 --- /dev/null +++ b/hooks/useCreditAccountPositions.tsx @@ -0,0 +1,79 @@ +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { useQuery } from '@tanstack/react-query' +import { useEffect, useMemo, useState } from 'react' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import { queryKeys } from 'types/query-keys-factory' + +interface CoinValue { + amount: string + denom: string + price: string + value: string +} + +interface DebtSharesValue { + amount: string + denom: string + price: string + shares: string + value: string +} + +export interface VaultPosition { + locked: string + unlocked: string +} + +interface VaultPositionWithAddr { + addr: string + position: VaultPosition +} + +interface Result { + account_id: string + coins: CoinValue[] + debt: DebtSharesValue[] + vault_positions: VaultPositionWithAddr[] +} + +const useCreditAccountPositions = (accountId: string) => { + const [signingClient, setSigningClient] = useState() + const address = useWalletStore((state) => state.address) + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + const result = useQuery( + queryKeys.creditAccountsPositions(accountId), + async () => + signingClient?.queryContractSmart(contractAddresses.creditManager, { + positions: { + account_id: accountId, + }, + }), + { + enabled: !!address && !!signingClient, + staleTime: Infinity, + } + ) + + return { + ...result, + data: useMemo(() => { + return result?.data + }, [result.data]), + } +} + +export default useCreditAccountPositions diff --git a/hooks/useCreditAccounts.tsx b/hooks/useCreditAccounts.tsx new file mode 100644 index 00000000..848d2095 --- /dev/null +++ b/hooks/useCreditAccounts.tsx @@ -0,0 +1,63 @@ +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { useQuery } from '@tanstack/react-query' +import { useEffect, useMemo, useState } from 'react' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import { queryKeys } from 'types/query-keys-factory' + +type Result = { + tokens: string[] +} + +const useCreditAccounts = () => { + const [signingClient, setSigningClient] = useState() + const address = useWalletStore((state) => state.address) + const selectedAccount = useCreditManagerStore((state) => state.selectedAccount) + const creditManagerActions = useCreditManagerStore((state) => state.actions) + + const queryMsg = useMemo(() => { + return { + tokens: { + owner: address, + }, + } + }, [address]) + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + const result = useQuery( + queryKeys.creditAccounts(address), + async () => signingClient?.queryContractSmart(contractAddresses.accountNft, queryMsg), + { + enabled: !!address && !!signingClient, + onSuccess: (data) => { + if (!data.tokens.includes(selectedAccount || '') && data.tokens.length > 0) { + creditManagerActions.setSelectedAccount(data.tokens[0]) + } + }, + } + ) + + return { + ...result, + data: useMemo(() => { + if (!address) return [] + + return result?.data && result.data.tokens + }, [address, result?.data]), + } +} + +export default useCreditAccounts diff --git a/hooks/useDeleteCreditAccount.tsx b/hooks/useDeleteCreditAccount.tsx new file mode 100644 index 00000000..78fc74da --- /dev/null +++ b/hooks/useDeleteCreditAccount.tsx @@ -0,0 +1,55 @@ +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { useMutation, useQueryClient } from '@tanstack/react-query' +import { useEffect, useState } from 'react' +import { toast } from 'react-toastify' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import { hardcodedFee } from 'utils/contants' +import { queryKeys } from 'types/query-keys-factory' + +const useCreateCreditAccount = (accountId: string) => { + const [signingClient, setSigningClient] = useState() + const address = useWalletStore((state) => state.address) + + const queryClient = useQueryClient() + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + return useMutation( + async () => + await signingClient?.execute( + address, + contractAddresses.accountNft, + { + burn: { + token_id: accountId, + }, + }, + hardcodedFee + ), + { + onSettled: () => { + queryClient.invalidateQueries(queryKeys.creditAccounts(address)) + }, + onError: (err: Error) => { + toast.error(err.message) + }, + onSuccess: () => { + toast.success('Credit Account Deleted') + }, + } + ) +} + +export default useCreateCreditAccount diff --git a/hooks/useDepositCreditAccount.tsx b/hooks/useDepositCreditAccount.tsx new file mode 100644 index 00000000..443992cf --- /dev/null +++ b/hooks/useDepositCreditAccount.tsx @@ -0,0 +1,71 @@ +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { useMutation, useQueryClient } from '@tanstack/react-query' +import { useEffect, useState } from 'react' +import { toast } from 'react-toastify' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import { hardcodedFee } from 'utils/contants' +import { queryKeys } from 'types/query-keys-factory' + +const useDepositCreditAccount = (accountId: string, denom: string, amount: number) => { + const [signingClient, setSigningClient] = useState() + const address = useWalletStore((state) => state.address) + + const queryClient = useQueryClient() + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + return useMutation( + async () => + await signingClient?.execute( + address, + contractAddresses.creditManager, + { + update_credit_account: { + account_id: accountId, + actions: [ + { + deposit: { + denom, + amount: String(amount), + }, + }, + ], + }, + }, + hardcodedFee, + undefined, + [ + { + denom, + amount: String(amount), + }, + ] + ), + { + onError: (err: Error) => { + toast.error(err.message) + }, + onSuccess: () => { + queryClient.invalidateQueries(queryKeys.allBalances(address)) + queryClient.invalidateQueries(queryKeys.tokenBalance(address, denom)) + queryClient.invalidateQueries(queryKeys.creditAccountsPositions(accountId)) + + toast.success('Deposited Successfully') + }, + } + ) +} + +export default useDepositCreditAccount diff --git a/hooks/useInjectiveBalance.tsx b/hooks/useInjectiveBalance.tsx deleted file mode 100644 index 36602de9..00000000 --- a/hooks/useInjectiveBalance.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; -import BigNumber from "bignumber.js"; - -import useWalletStore from "stores/useWalletStore"; - -type Result = { - balance: { - amount: number; - denom: string; - }; -}; - -const useAllBalances = () => { - const address = useWalletStore((state) => state.address); - - const result = useQuery( - ["injectiveBalance"], - async () => - fetch( - `https://lcd.injective.network/cosmos/bank/v1beta1/balances/${address}/by_denom?denom=inj` - ).then((res) => res.json()), - { - enabled: !!address, - } - ); - - return { - ...result, - data: - result?.data && - BigNumber(result.data.balance.amount) - .div(10 ** 18) - .toNumber(), - }; -}; - -export default useAllBalances; diff --git a/hooks/useTokenBalance.tsx b/hooks/useTokenBalance.tsx new file mode 100644 index 00000000..d60d18bd --- /dev/null +++ b/hooks/useTokenBalance.tsx @@ -0,0 +1,41 @@ +import { useQuery } from '@tanstack/react-query' +import BigNumber from 'bignumber.js' + +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { queryKeys } from 'types/query-keys-factory' + +type Result = { + balance: { + amount: number + denom: string + } +} + +const useTokenBalance = (denom?: string) => { + const address = useWalletStore((state) => state.address) + + const result = useQuery( + queryKeys.tokenBalance(address, denom || chain.stakeCurrency.coinMinimalDenom), + async () => + fetch( + `${chain.rest}/cosmos/bank/v1beta1/balances/${address}/by_denom?denom=${ + denom || chain.stakeCurrency.coinMinimalDenom + }` + ).then((res) => res.json()), + { + enabled: !!address, + } + ) + + return { + ...result, + data: result?.data + ? BigNumber(result.data.balance.amount) + .div(10 ** chain.stakeCurrency.coinDecimals) + .toNumber() + : 0, + } +} + +export default useTokenBalance diff --git a/next.config.js b/next.config.js index 3438a669..c6b0c019 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,4 @@ -const { withSentryConfig } = require("@sentry/nextjs"); +const { withSentryConfig } = require('@sentry/nextjs') // This file sets a custom webpack configuration to use your Next.js app // with Sentry. @@ -13,7 +13,7 @@ const nextConfig = { // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map hideSourceMaps: true, }, -}; +} const sentryWebpackPluginOptions = { // Additional config options for the Sentry Webpack plugin. Keep in mind that @@ -25,8 +25,8 @@ const sentryWebpackPluginOptions = { silent: true, // Suppresses all logs // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options. -}; +} // Make sure adding Sentry options is the last code to run before exporting, to // ensure that your source maps include changes from all other Webpack plugins -module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions); +module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions) diff --git a/package.json b/package.json index 10221eb4..e3adbddc 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,13 @@ "lint": "next lint" }, "dependencies": { + "@cosmjs/cosmwasm-stargate": "^0.29.0", + "@cosmjs/stargate": "^0.29.0", "@headlessui/react": "^1.7.0", "@heroicons/react": "^2.0.11", "@keplr-wallet/cosmos": "^0.10.24", "@metamask/detect-provider": "^1.2.0", + "@radix-ui/react-slider": "^1.0.0", "@sentry/nextjs": "^7.12.1", "@tanstack/react-query": "^4.3.4", "bech32": "^2.0.0", diff --git a/pages/_app.tsx b/pages/_app.tsx index 79fe0120..f71afda0 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,34 +1,34 @@ -import type { AppProps } from "next/app"; -import Head from "next/head"; -import { ToastContainer, Zoom } from "react-toastify"; -import "react-toastify/dist/ReactToastify.min.css"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import detectEthereumProvider from "@metamask/detect-provider"; +import type { AppProps } from 'next/app' +import Head from 'next/head' +import { ToastContainer, Zoom } from 'react-toastify' +import 'react-toastify/dist/ReactToastify.min.css' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import detectEthereumProvider from '@metamask/detect-provider' -import "../styles/globals.css"; -import Layout from "components/Layout"; -import { useEffect } from "react"; -import useWalletStore from "stores/useWalletStore"; +import '../styles/globals.css' +import Layout from 'components/Layout' +import { useEffect } from 'react' +import useWalletStore from 'stores/useWalletStore' async function isMetamaskInstalled(): Promise { - const provider = await detectEthereumProvider(); + const provider = await detectEthereumProvider() - return !!provider; + return !!provider } -const queryClient = new QueryClient(); +const queryClient = new QueryClient() function MyApp({ Component, pageProps }: AppProps) { - const actions = useWalletStore((state) => state.actions); + const actions = useWalletStore((state) => state.actions) // init store useEffect(() => { const verifyMetamask = async () => { - actions.setMetamaskInstalledStatus(await isMetamaskInstalled()); - }; + actions.setMetamaskInstalledStatus(await isMetamaskInstalled()) + } - verifyMetamask(); - }, [actions]); + verifyMetamask() + }, [actions]) return ( <> @@ -51,7 +51,7 @@ function MyApp({ Component, pageProps }: AppProps) { /> - ); + ) } -export default MyApp; +export default MyApp diff --git a/pages/_error.js b/pages/_error.js index 49f0ea6e..66488b60 100644 --- a/pages/_error.js +++ b/pages/_error.js @@ -16,24 +16,24 @@ * - https://reactjs.org/docs/error-boundaries.html */ -import * as Sentry from '@sentry/nextjs'; -import NextErrorComponent from 'next/error'; +import * as Sentry from '@sentry/nextjs' +import NextErrorComponent from 'next/error' -const CustomErrorComponent = props => { +const CustomErrorComponent = (props) => { // If you're using a Nextjs version prior to 12.2.1, uncomment this to // compensate for https://github.com/vercel/next.js/issues/8592 // Sentry.captureUnderscoreErrorException(props); - return ; -}; + return +} -CustomErrorComponent.getInitialProps = async contextData => { +CustomErrorComponent.getInitialProps = async (contextData) => { // In case this is running in a serverless function, await this in order to give Sentry // time to send the error before the lambda exits - await Sentry.captureUnderscoreErrorException(contextData); + await Sentry.captureUnderscoreErrorException(contextData) // This will contain the status code of the response - return NextErrorComponent.getInitialProps(contextData); -}; + return NextErrorComponent.getInitialProps(contextData) +} -export default CustomErrorComponent; +export default CustomErrorComponent diff --git a/pages/borrow.tsx b/pages/borrow.tsx index 6f667470..0562e116 100644 --- a/pages/borrow.tsx +++ b/pages/borrow.tsx @@ -1,13 +1,71 @@ -import React from "react"; -import Container from "components/Container"; +import React from 'react' +import Image from 'next/image' + +import Container from 'components/Container' + +const AssetRow = () => { + return ( +
+
+ token +
+
DENOM
+
Name
+
+
+
10.00%
+
+
Amount
+
Value
+
+
+
Amount
+
Value
+
+
ACTION
+
+ ) +} const Borrow = () => { return (
- Borrow Module - Placeholder + +
+

Borrowed

+
+
Asset
+
Borrow Rate
+
Borrowed
+
Liquidity Available
+
Manage
+
+
+ {Array.from(Array(3).keys()).map(() => ( + // eslint-disable-next-line react/jsx-key + + ))} +
+
+
+

Not Borrowed Yet

+
+
Asset
+
Borrow Rate
+
Borrowed
+
Liquidity Available
+
Manage
+
+
+ {Array.from(Array(5).keys()).map(() => ( + // eslint-disable-next-line react/jsx-key + + ))} +
+
+
- ); -}; + ) +} -export default Borrow; +export default Borrow diff --git a/pages/council.tsx b/pages/council.tsx index c68478e1..ea62f0aa 100644 --- a/pages/council.tsx +++ b/pages/council.tsx @@ -1,12 +1,12 @@ -import React from "react"; -import Container from "components/Container"; +import React from 'react' +import Container from 'components/Container' const Council = () => { return (
Council Placeholder
- ); -}; + ) +} -export default Council; +export default Council diff --git a/pages/index.tsx b/pages/index.tsx index ee61ce1b..0b1f3cf1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,12 +1,337 @@ -import type { NextPage } from "next"; +import React, { useEffect, useState } from 'react' +import type { NextPage } from 'next' // import Head from "next/head"; // import Image from "next/image"; // import styles from "../styles/Home.module.css"; +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +// import { Coin } from "@cosmjs/stargate"; +import { toast } from 'react-toastify' +import BigNumber from 'bignumber.js' +import { useQueryClient } from '@tanstack/react-query' -// import Container from "components/Container"; +import Container from 'components/Container' +import Button from 'components/Button' +import useWalletStore from 'stores/useWalletStore' +import { chain } from 'utils/chains' +import { contractAddresses } from 'config/contracts' +import { hardcodedFee } from 'utils/contants' +import Spinner from 'components/Spinner' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import { queryKeys } from 'types/query-keys-factory' const Home: NextPage = () => { - return
Home Page
; -}; + const [sendAmount, setSendAmount] = useState('') + const [recipientAddress, setRecipientAddress] = useState('') -export default Home; + const [allTokens, setAllTokens] = useState(null) + const [walletTokens, setWalletTokens] = useState(null) + + const [borrowAmount, setBorrowAmount] = useState(0) + + const [error, setError] = useState(null) + const [isLoading, setIsLoading] = useState(false) + + const address = useWalletStore((state) => state.address) + const selectedAccount = useCreditManagerStore((state) => state.selectedAccount) + const queryClient = useQueryClient() + + const [signingClient, setSigningClient] = useState() + + useEffect(() => { + ;(async () => { + if (!window.keplr) return + + const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) + const clientInstance = await SigningCosmWasmClient.connectWithSigner(chain.rpc, offlineSigner) + + setSigningClient(clientInstance) + })() + }, [address]) + + const handleSendClick = async () => { + setError(null) + setIsLoading(true) + + try { + // console.log(await signingClient.getHeight()); + + // console.log( + // "contract info", + // signingClient.getContract( + // "osmo1zf26ahe5gqjtvnedh7ems7naf2wtw3z4ll6atf3t0hptal8ss4vq2mlx6w" + // ) + // ); + + const res = await signingClient?.sendTokens( + address, + recipientAddress, + [ + { + denom: chain.stakeCurrency.coinMinimalDenom, + amount: BigNumber(sendAmount) + .times(10 ** chain.stakeCurrency.coinDecimals) + .toString(), + }, + ], + hardcodedFee + ) + + console.log('txResponse', res) + toast.success( + , + { autoClose: false } + ) + } catch (e: any) { + console.log(e) + setError(e.message) + } finally { + setIsLoading(false) + } + } + + const handleCreateCreditAccount = async () => { + setError(null) + setIsLoading(true) + + try { + // 200000 gas used + const executeMsg = { + create_credit_account: {}, + } + + const createResult = await signingClient?.execute( + address, + contractAddresses.creditManager, + executeMsg, + hardcodedFee + ) + + console.log('mint result', createResult) + toast.success( + , + { autoClose: false } + ) + + queryClient.invalidateQueries(queryKeys.creditAccounts(address)) + } catch (e: any) { + console.log(e) + setError(e.message) + } finally { + setIsLoading(false) + } + } + + // https://github.com/mars-protocol/rover/blob/master/scripts/types/generated/account-nft/AccountNft.types.ts + const handleGetCreditAccounts = async () => { + setError(null) + setIsLoading(true) + + try { + const allTokensQueryMsg = { + all_tokens: {}, + } + + const allTokensResponse = await signingClient?.queryContractSmart( + contractAddresses.accountNft, + allTokensQueryMsg + ) + + setAllTokens(allTokensResponse.tokens) + + console.log('all tokens', allTokensResponse) + + // Returns de owner of a specific "credit account" + // const ownerOfQueryMsg = { + // owner_of: { + // include_expired: false, + // token_id: "1", + // }, + // }; + + // const ownerResponse = await signingClient.queryContractSmart( + // contractAddresses.accountNft, + // ownerOfQueryMsg + // ); + + // console.log("res owner", ownerResponse); + + const tokensQueryMsg = { + tokens: { + owner: address, + }, + } + + const tokensResponse = await signingClient?.queryContractSmart( + contractAddresses.accountNft, + tokensQueryMsg + ) + + console.log('res tokens', tokensResponse) + setWalletTokens(tokensResponse.tokens) + } catch (e: any) { + console.log(e) + setError(e.message) + } finally { + setIsLoading(false) + } + } + + const handleBorrowClick = async () => { + setError(null) + setIsLoading(true) + + try { + if (!selectedAccount) return + + const executeMsg = { + update_credit_account: { + account_id: selectedAccount, + actions: [ + { + borrow: { + denom: 'uosmo', + amount: BigNumber(borrowAmount) + .times(10 ** 6) + .toString(), + }, + }, + ], + }, + } + + const borrowResult = await signingClient?.execute( + address, + contractAddresses.creditManager, + executeMsg, + hardcodedFee + ) + + console.log('borrow result', borrowResult) + toast.success( + , + { autoClose: false } + ) + + queryClient.invalidateQueries(queryKeys.creditAccounts(address)) + queryClient.invalidateQueries(queryKeys.creditAccountsPositions(selectedAccount)) + queryClient.invalidateQueries(queryKeys.tokenBalance(address, 'uosmo')) + } catch (e: any) { + console.log(e) + setError(e.message) + } finally { + setIsLoading(false) + } + } + + return ( +
+ +

Send Tokens

+
+
+

Address:

+ setRecipientAddress(e.target.value)} + /> +
+
+

Amount:

+ setSendAmount(e.target.value)} + /> +
+
+ +
+ +

Create Credit Account (Mint NFT)

+ +
+ +

Get all Credit Accounts

+ +
+ +

Borrow OSMO

+ setBorrowAmount(e.target.valueAsNumber)} + /> + +
+ +
+ {allTokens && ( +
+
+
All Tokens
+

- {allTokens.length} total

+
+ {allTokens.map((token) => ( +

{token}

+ ))} +
+ )} + {walletTokens && ( + <> +
+
Your Tokens
+

- {walletTokens.length} total

+
+ {walletTokens.map((token) => ( +

{token}

+ ))} + + )} +
+ {error &&
{error}
} + {isLoading && ( +
+ +
+ )} +
+ ) +} + +export default Home diff --git a/pages/portfolio.tsx b/pages/portfolio.tsx index 5fa4988d..1dc073dd 100644 --- a/pages/portfolio.tsx +++ b/pages/portfolio.tsx @@ -1,12 +1,12 @@ -import React from "react"; +import React from 'react' -import Container from "components/Container"; -import { formatCurrency } from "utils/formatters"; +import Container from 'components/Container' +import { formatCurrency } from 'utils/formatters' const mockedAccounts = [ { id: 1, - label: "Subaccount 1", + label: 'Subaccount 1', networth: 100000, totalPositionValue: 150000, debt: 50000, @@ -16,7 +16,7 @@ const mockedAccounts = [ }, { id: 2, - label: "Subaccount 2", + label: 'Subaccount 2', networth: 33000, totalPositionValue: 11000, debt: 20000, @@ -26,7 +26,7 @@ const mockedAccounts = [ }, { id: 3, - label: "Subaccount 3", + label: 'Subaccount 3', networth: 0, totalPositionValue: 12938129, debt: 9999999999, @@ -36,7 +36,7 @@ const mockedAccounts = [ }, { id: 4, - label: "Subaccount 4", + label: 'Subaccount 4', networth: 33653.22, totalPositionValue: 100000, debt: 50001.9, @@ -44,7 +44,7 @@ const mockedAccounts = [ leverage: 3, maxLeverage: 5, }, -]; +] const Portfolio = () => { return ( @@ -68,12 +68,8 @@ const Portfolio = () => {

Debt

-

0 ? "text-green-400" : "text-red-500" - }`} - > - {account.profit > 0 && "+"} +

0 ? 'text-green-400' : 'text-red-500'}`}> + {account.profit > 0 && '+'} {formatCurrency(account.profit)}

P&L

@@ -91,7 +87,7 @@ const Portfolio = () => { ))}
- ); -}; + ) +} -export default Portfolio; +export default Portfolio diff --git a/pages/trade.tsx b/pages/trade.tsx index 2d2429fb..51e0d7ad 100644 --- a/pages/trade.tsx +++ b/pages/trade.tsx @@ -1,5 +1,5 @@ -import React from "react"; -import Container from "components/Container"; +import React from 'react' +import Container from 'components/Container' const Trade = () => { return ( @@ -14,7 +14,7 @@ const Trade = () => { Trader order overview - ); -}; + ) +} -export default Trade; +export default Trade diff --git a/pages/yield.tsx b/pages/yield.tsx index ed70ba78..ad92d210 100644 --- a/pages/yield.tsx +++ b/pages/yield.tsx @@ -1,5 +1,5 @@ -import React from "react"; -import Container from "components/Container"; +import React from 'react' +import Container from 'components/Container' const Yield = () => { return ( @@ -7,7 +7,7 @@ const Yield = () => { Yield Module Placeholder - ); -}; + ) +} -export default Yield; +export default Yield diff --git a/public/injective.svg b/public/tokens/injective.svg similarity index 100% rename from public/injective.svg rename to public/tokens/injective.svg diff --git a/public/tokens/osmo.svg b/public/tokens/osmo.svg new file mode 100644 index 00000000..17bf0f6e --- /dev/null +++ b/public/tokens/osmo.svg @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sentry.client.config.js b/sentry.client.config.js index 33128fab..dc6b933a 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -2,18 +2,18 @@ // The config you add here will be used whenever a page is visited. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import * as Sentry from "@sentry/nextjs"; +import * as Sentry from '@sentry/nextjs' -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; +const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN Sentry.init({ dsn: SENTRY_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENV, // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 0.5, - enabled: process.env.NODE_ENV !== "development", + enabled: process.env.NODE_ENV !== 'development', // ... // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps -}); +}) diff --git a/sentry.server.config.js b/sentry.server.config.js index 9c50c274..9f9ce8ab 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -2,18 +2,18 @@ // The config you add here will be used whenever the server handles a request. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import * as Sentry from "@sentry/nextjs"; +import * as Sentry from '@sentry/nextjs' -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; +const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN Sentry.init({ dsn: SENTRY_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENV, // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 0.5, - enabled: process.env.NODE_ENV !== "development", + enabled: process.env.NODE_ENV !== 'development', // ... // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps -}); +}) diff --git a/stores/useCreditManagerStore.tsx b/stores/useCreditManagerStore.tsx new file mode 100644 index 00000000..668887c7 --- /dev/null +++ b/stores/useCreditManagerStore.tsx @@ -0,0 +1,37 @@ +import create from 'zustand' +import { persist } from 'zustand/middleware' + +interface CreditManagerStore { + isOpen: boolean + selectedAccount: string | null + actions: { + toggleCreditManager: () => void + setSelectedAccount: (id: string) => void + } +} + +const useCreditManagerStore = create()( + persist( + (set, get) => ({ + isOpen: false, + selectedAccount: null, + actions: { + toggleCreditManager: () => set(() => ({ isOpen: !get().isOpen })), + setSelectedAccount: (accountId: string) => { + set(() => ({ + selectedAccount: accountId, + })) + }, + }, + }), + { + name: 'creditManager', + partialize: (state) => + Object.fromEntries( + Object.entries(state).filter(([key]) => ['selectedAccount'].includes(key)) + ), + } + ) +) + +export default useCreditManagerStore diff --git a/stores/useWalletStore.tsx b/stores/useWalletStore.tsx index 0eea46c0..4c196a95 100644 --- a/stores/useWalletStore.tsx +++ b/stores/useWalletStore.tsx @@ -1,52 +1,41 @@ -import create from "zustand"; -import { persist } from "zustand/middleware"; +import create from 'zustand' +import { persist } from 'zustand/middleware' -import { Wallet } from "types"; - -const dummyStorageApi = { - getItem: () => null, - removeItem: () => undefined, - setItem: () => undefined, -}; +import { Wallet } from 'types' interface WalletStore { - address: string; - injectiveAddress: string; - addresses: string[]; - metamaskInstalled: boolean; - wallet: Wallet; + address: string + injectiveAddress: string + addresses: string[] + metamaskInstalled: boolean + wallet: Wallet actions: { - setAddress: (address: string) => void; - setMetamaskInstalledStatus: (value: boolean) => void; - }; + setAddress: (address: string) => void + setMetamaskInstalledStatus: (value: boolean) => void + } } const useWalletStore = create()( persist( (set, get) => ({ - address: "", - injectiveAddress: "", + address: '', + injectiveAddress: '', addresses: [], metamaskInstalled: false, wallet: Wallet.Metamask, actions: { setAddress: (address: string) => set(() => ({ address })), - setMetamaskInstalledStatus: (value: boolean) => - set(() => ({ metamaskInstalled: value })), + setMetamaskInstalledStatus: (value: boolean) => set(() => ({ metamaskInstalled: value })), }, }), { - name: "wallet", + name: 'wallet', partialize: (state) => Object.fromEntries( - Object.entries(state).filter( - ([key]) => !["metamaskInstalled", "actions"].includes(key) - ) + Object.entries(state).filter(([key]) => !['metamaskInstalled', 'actions'].includes(key)) ), - // getStorage: () => - // typeof window !== "undefined" ? localStorage : dummyStorageApi, } ) -); +) -export default useWalletStore; +export default useWalletStore diff --git a/tailwind.config.js b/tailwind.config.js index 48429970..bc6661e0 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,11 +1,12 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: [ - "./pages/**/*.{js,ts,jsx,tsx}", - "./components/**/*.{js,ts,jsx,tsx}", - ], + content: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'], theme: { - extend: {}, + extend: { + colors: { + 'background-2': '#585A74', + }, + }, }, plugins: [], -}; +} diff --git a/types/generated/account-nft/AccountNft.client.ts b/types/generated/account-nft/AccountNft.client.ts new file mode 100644 index 00000000..82c371e9 --- /dev/null +++ b/types/generated/account-nft/AccountNft.client.ts @@ -0,0 +1,635 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { Coin, StdFee } from '@cosmjs/amino' +import { + InstantiateMsg, + ExecuteMsg, + Binary, + Expiration, + Timestamp, + Uint64, + QueryMsg, + AllNftInfoResponseForEmpty, + OwnerOfResponse, + Approval, + NftInfoResponseForEmpty, + Empty, + OperatorsResponse, + TokensResponse, + ApprovalResponse, + ApprovalsResponse, + ContractInfoResponse, + MinterResponse, + NumTokensResponse, + String, +} from './AccountNft.types' +export interface AccountNftReadOnlyInterface { + contractAddress: string + proposedNewOwner: () => Promise + ownerOf: ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean + tokenId: string + }) => Promise + approval: ({ + includeExpired, + spender, + tokenId, + }: { + includeExpired?: boolean + spender: string + tokenId: string + }) => Promise + approvals: ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean + tokenId: string + }) => Promise + allOperators: ({ + includeExpired, + limit, + owner, + startAfter, + }: { + includeExpired?: boolean + limit?: number + owner: string + startAfter?: string + }) => Promise + numTokens: () => Promise + contractInfo: () => Promise + nftInfo: ({ tokenId }: { tokenId: string }) => Promise + allNftInfo: ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean + tokenId: string + }) => Promise + tokens: ({ + limit, + owner, + startAfter, + }: { + limit?: number + owner: string + startAfter?: string + }) => Promise + allTokens: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }) => Promise + minter: () => Promise +} +export class AccountNftQueryClient implements AccountNftReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.proposedNewOwner = this.proposedNewOwner.bind(this) + this.ownerOf = this.ownerOf.bind(this) + this.approval = this.approval.bind(this) + this.approvals = this.approvals.bind(this) + this.allOperators = this.allOperators.bind(this) + this.numTokens = this.numTokens.bind(this) + this.contractInfo = this.contractInfo.bind(this) + this.nftInfo = this.nftInfo.bind(this) + this.allNftInfo = this.allNftInfo.bind(this) + this.tokens = this.tokens.bind(this) + this.allTokens = this.allTokens.bind(this) + this.minter = this.minter.bind(this) + } + + proposedNewOwner = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + proposed_new_owner: {}, + }) + } + ownerOf = async ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean + tokenId: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + owner_of: { + include_expired: includeExpired, + token_id: tokenId, + }, + }) + } + approval = async ({ + includeExpired, + spender, + tokenId, + }: { + includeExpired?: boolean + spender: string + tokenId: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + approval: { + include_expired: includeExpired, + spender, + token_id: tokenId, + }, + }) + } + approvals = async ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean + tokenId: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + approvals: { + include_expired: includeExpired, + token_id: tokenId, + }, + }) + } + allOperators = async ({ + includeExpired, + limit, + owner, + startAfter, + }: { + includeExpired?: boolean + limit?: number + owner: string + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_operators: { + include_expired: includeExpired, + limit, + owner, + start_after: startAfter, + }, + }) + } + numTokens = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + num_tokens: {}, + }) + } + contractInfo = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + contract_info: {}, + }) + } + nftInfo = async ({ tokenId }: { tokenId: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + nft_info: { + token_id: tokenId, + }, + }) + } + allNftInfo = async ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean + tokenId: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_nft_info: { + include_expired: includeExpired, + token_id: tokenId, + }, + }) + } + tokens = async ({ + limit, + owner, + startAfter, + }: { + limit?: number + owner: string + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + tokens: { + limit, + owner, + start_after: startAfter, + }, + }) + } + allTokens = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_tokens: { + limit, + start_after: startAfter, + }, + }) + } + minter = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + minter: {}, + }) + } +} +export interface AccountNftInterface extends AccountNftReadOnlyInterface { + contractAddress: string + sender: string + proposeNewOwner: ( + { + newOwner, + }: { + newOwner: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + acceptOwnership: ( + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + mint: ( + { + user, + }: { + user: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + transferNft: ( + { + recipient, + tokenId, + }: { + recipient: string + tokenId: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + sendNft: ( + { + contract, + msg, + tokenId, + }: { + contract: string + msg: Binary + tokenId: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + approve: ( + { + expires, + spender, + tokenId, + }: { + expires?: Expiration + spender: string + tokenId: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + revoke: ( + { + spender, + tokenId, + }: { + spender: string + tokenId: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + approveAll: ( + { + expires, + operator, + }: { + expires?: Expiration + operator: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + revokeAll: ( + { + operator, + }: { + operator: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + burn: ( + { + tokenId, + }: { + tokenId: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class AccountNftClient extends AccountNftQueryClient implements AccountNftInterface { + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.proposeNewOwner = this.proposeNewOwner.bind(this) + this.acceptOwnership = this.acceptOwnership.bind(this) + this.mint = this.mint.bind(this) + this.transferNft = this.transferNft.bind(this) + this.sendNft = this.sendNft.bind(this) + this.approve = this.approve.bind(this) + this.revoke = this.revoke.bind(this) + this.approveAll = this.approveAll.bind(this) + this.revokeAll = this.revokeAll.bind(this) + this.burn = this.burn.bind(this) + } + + proposeNewOwner = async ( + { + newOwner, + }: { + newOwner: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + propose_new_owner: { + new_owner: newOwner, + }, + }, + fee, + memo, + funds, + ) + } + acceptOwnership = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + accept_ownership: {}, + }, + fee, + memo, + funds, + ) + } + mint = async ( + { + user, + }: { + user: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + mint: { + user, + }, + }, + fee, + memo, + funds, + ) + } + transferNft = async ( + { + recipient, + tokenId, + }: { + recipient: string + tokenId: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + transfer_nft: { + recipient, + token_id: tokenId, + }, + }, + fee, + memo, + funds, + ) + } + sendNft = async ( + { + contract, + msg, + tokenId, + }: { + contract: string + msg: Binary + tokenId: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + send_nft: { + contract, + msg, + token_id: tokenId, + }, + }, + fee, + memo, + funds, + ) + } + approve = async ( + { + expires, + spender, + tokenId, + }: { + expires?: Expiration + spender: string + tokenId: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + approve: { + expires, + spender, + token_id: tokenId, + }, + }, + fee, + memo, + funds, + ) + } + revoke = async ( + { + spender, + tokenId, + }: { + spender: string + tokenId: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + revoke: { + spender, + token_id: tokenId, + }, + }, + fee, + memo, + funds, + ) + } + approveAll = async ( + { + expires, + operator, + }: { + expires?: Expiration + operator: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + approve_all: { + expires, + operator, + }, + }, + fee, + memo, + funds, + ) + } + revokeAll = async ( + { + operator, + }: { + operator: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + revoke_all: { + operator, + }, + }, + fee, + memo, + funds, + ) + } + burn = async ( + { + tokenId, + }: { + tokenId: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + burn: { + token_id: tokenId, + }, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/account-nft/AccountNft.react-query.ts b/types/generated/account-nft/AccountNft.react-query.ts new file mode 100644 index 00000000..67eba018 --- /dev/null +++ b/types/generated/account-nft/AccountNft.react-query.ts @@ -0,0 +1,535 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee, Coin } from '@cosmjs/amino' +import { + InstantiateMsg, + ExecuteMsg, + Binary, + Expiration, + Timestamp, + Uint64, + QueryMsg, + AllNftInfoResponseForEmpty, + OwnerOfResponse, + Approval, + NftInfoResponseForEmpty, + Empty, + OperatorsResponse, + TokensResponse, + ApprovalResponse, + ApprovalsResponse, + ContractInfoResponse, + MinterResponse, + NumTokensResponse, + String, +} from './AccountNft.types' +import { AccountNftQueryClient, AccountNftClient } from './AccountNft.client' +export const accountNftQueryKeys = { + contract: [ + { + contract: 'accountNft', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...accountNftQueryKeys.contract[0], address: contractAddress }] as const, + proposedNewOwner: (contractAddress: string | undefined, args?: Record) => + [ + { ...accountNftQueryKeys.address(contractAddress)[0], method: 'proposed_new_owner', args }, + ] as const, + ownerOf: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'owner_of', args }] as const, + approval: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'approval', args }] as const, + approvals: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'approvals', args }] as const, + allOperators: (contractAddress: string | undefined, args?: Record) => + [ + { ...accountNftQueryKeys.address(contractAddress)[0], method: 'all_operators', args }, + ] as const, + numTokens: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'num_tokens', args }] as const, + contractInfo: (contractAddress: string | undefined, args?: Record) => + [ + { ...accountNftQueryKeys.address(contractAddress)[0], method: 'contract_info', args }, + ] as const, + nftInfo: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'nft_info', args }] as const, + allNftInfo: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'all_nft_info', args }] as const, + tokens: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'tokens', args }] as const, + allTokens: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'all_tokens', args }] as const, + minter: (contractAddress: string | undefined, args?: Record) => + [{ ...accountNftQueryKeys.address(contractAddress)[0], method: 'minter', args }] as const, +} +export interface AccountNftReactQuery { + client: AccountNftQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface AccountNftMinterQuery extends AccountNftReactQuery {} +export function useAccountNftMinterQuery({ + client, + options, +}: AccountNftMinterQuery) { + return useQuery( + accountNftQueryKeys.minter(client?.contractAddress), + () => (client ? client.minter() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftAllTokensQuery + extends AccountNftReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useAccountNftAllTokensQuery({ + client, + args, + options, +}: AccountNftAllTokensQuery) { + return useQuery( + accountNftQueryKeys.allTokens(client?.contractAddress, args), + () => + client + ? client.allTokens({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftTokensQuery extends AccountNftReactQuery { + args: { + limit?: number + owner: string + startAfter?: string + } +} +export function useAccountNftTokensQuery({ + client, + args, + options, +}: AccountNftTokensQuery) { + return useQuery( + accountNftQueryKeys.tokens(client?.contractAddress, args), + () => + client + ? client.tokens({ + limit: args.limit, + owner: args.owner, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftAllNftInfoQuery + extends AccountNftReactQuery { + args: { + includeExpired?: boolean + tokenId: string + } +} +export function useAccountNftAllNftInfoQuery({ + client, + args, + options, +}: AccountNftAllNftInfoQuery) { + return useQuery( + accountNftQueryKeys.allNftInfo(client?.contractAddress, args), + () => + client + ? client.allNftInfo({ + includeExpired: args.includeExpired, + tokenId: args.tokenId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftNftInfoQuery + extends AccountNftReactQuery { + args: { + tokenId: string + } +} +export function useAccountNftNftInfoQuery({ + client, + args, + options, +}: AccountNftNftInfoQuery) { + return useQuery( + accountNftQueryKeys.nftInfo(client?.contractAddress, args), + () => + client + ? client.nftInfo({ + tokenId: args.tokenId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftContractInfoQuery + extends AccountNftReactQuery {} +export function useAccountNftContractInfoQuery({ + client, + options, +}: AccountNftContractInfoQuery) { + return useQuery( + accountNftQueryKeys.contractInfo(client?.contractAddress), + () => (client ? client.contractInfo() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftNumTokensQuery + extends AccountNftReactQuery {} +export function useAccountNftNumTokensQuery({ + client, + options, +}: AccountNftNumTokensQuery) { + return useQuery( + accountNftQueryKeys.numTokens(client?.contractAddress), + () => (client ? client.numTokens() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftAllOperatorsQuery + extends AccountNftReactQuery { + args: { + includeExpired?: boolean + limit?: number + owner: string + startAfter?: string + } +} +export function useAccountNftAllOperatorsQuery({ + client, + args, + options, +}: AccountNftAllOperatorsQuery) { + return useQuery( + accountNftQueryKeys.allOperators(client?.contractAddress, args), + () => + client + ? client.allOperators({ + includeExpired: args.includeExpired, + limit: args.limit, + owner: args.owner, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftApprovalsQuery + extends AccountNftReactQuery { + args: { + includeExpired?: boolean + tokenId: string + } +} +export function useAccountNftApprovalsQuery({ + client, + args, + options, +}: AccountNftApprovalsQuery) { + return useQuery( + accountNftQueryKeys.approvals(client?.contractAddress, args), + () => + client + ? client.approvals({ + includeExpired: args.includeExpired, + tokenId: args.tokenId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftApprovalQuery + extends AccountNftReactQuery { + args: { + includeExpired?: boolean + spender: string + tokenId: string + } +} +export function useAccountNftApprovalQuery({ + client, + args, + options, +}: AccountNftApprovalQuery) { + return useQuery( + accountNftQueryKeys.approval(client?.contractAddress, args), + () => + client + ? client.approval({ + includeExpired: args.includeExpired, + spender: args.spender, + tokenId: args.tokenId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftOwnerOfQuery + extends AccountNftReactQuery { + args: { + includeExpired?: boolean + tokenId: string + } +} +export function useAccountNftOwnerOfQuery({ + client, + args, + options, +}: AccountNftOwnerOfQuery) { + return useQuery( + accountNftQueryKeys.ownerOf(client?.contractAddress, args), + () => + client + ? client.ownerOf({ + includeExpired: args.includeExpired, + tokenId: args.tokenId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftProposedNewOwnerQuery + extends AccountNftReactQuery {} +export function useAccountNftProposedNewOwnerQuery({ + client, + options, +}: AccountNftProposedNewOwnerQuery) { + return useQuery( + accountNftQueryKeys.proposedNewOwner(client?.contractAddress), + () => (client ? client.proposedNewOwner() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface AccountNftBurnMutation { + client: AccountNftClient + msg: { + tokenId: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftBurnMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.burn(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftRevokeAllMutation { + client: AccountNftClient + msg: { + operator: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftRevokeAllMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.revokeAll(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftApproveAllMutation { + client: AccountNftClient + msg: { + expires?: Expiration + operator: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftApproveAllMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.approveAll(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftRevokeMutation { + client: AccountNftClient + msg: { + spender: string + tokenId: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftRevokeMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.revoke(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftApproveMutation { + client: AccountNftClient + msg: { + expires?: Expiration + spender: string + tokenId: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftApproveMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.approve(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftSendNftMutation { + client: AccountNftClient + msg: { + contract: string + msg: Binary + tokenId: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftSendNftMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.sendNft(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftTransferNftMutation { + client: AccountNftClient + msg: { + recipient: string + tokenId: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftTransferNftMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.transferNft(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftMintMutation { + client: AccountNftClient + msg: { + user: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftMintMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.mint(msg, fee, memo, funds), + options, + ) +} +export interface AccountNftAcceptOwnershipMutation { + client: AccountNftClient + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftAcceptOwnershipMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, args: { fee, memo, funds } = {} }) => client.acceptOwnership(fee, memo, funds), + options, + ) +} +export interface AccountNftProposeNewOwnerMutation { + client: AccountNftClient + msg: { + newOwner: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useAccountNftProposeNewOwnerMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.proposeNewOwner(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/account-nft/AccountNft.types.ts b/types/generated/account-nft/AccountNft.types.ts new file mode 100644 index 00000000..84408b14 --- /dev/null +++ b/types/generated/account-nft/AccountNft.types.ts @@ -0,0 +1,187 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export interface InstantiateMsg { + minter: string + name: string + symbol: string +} +export type ExecuteMsg = + | { + propose_new_owner: { + new_owner: string + } + } + | { + accept_ownership: {} + } + | { + mint: { + user: string + } + } + | { + transfer_nft: { + recipient: string + token_id: string + } + } + | { + send_nft: { + contract: string + msg: Binary + token_id: string + } + } + | { + approve: { + expires?: Expiration | null + spender: string + token_id: string + } + } + | { + revoke: { + spender: string + token_id: string + } + } + | { + approve_all: { + expires?: Expiration | null + operator: string + } + } + | { + revoke_all: { + operator: string + } + } + | { + burn: { + token_id: string + } + } +export type Binary = string +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type Timestamp = Uint64 +export type Uint64 = string +export type QueryMsg = + | { + proposed_new_owner: {} + } + | { + owner_of: { + include_expired?: boolean | null + token_id: string + } + } + | { + approval: { + include_expired?: boolean | null + spender: string + token_id: string + } + } + | { + approvals: { + include_expired?: boolean | null + token_id: string + } + } + | { + all_operators: { + include_expired?: boolean | null + limit?: number | null + owner: string + start_after?: string | null + } + } + | { + num_tokens: {} + } + | { + contract_info: {} + } + | { + nft_info: { + token_id: string + } + } + | { + all_nft_info: { + include_expired?: boolean | null + token_id: string + } + } + | { + tokens: { + limit?: number | null + owner: string + start_after?: string | null + } + } + | { + all_tokens: { + limit?: number | null + start_after?: string | null + } + } + | { + minter: {} + } +export interface AllNftInfoResponseForEmpty { + access: OwnerOfResponse + info: NftInfoResponseForEmpty +} +export interface OwnerOfResponse { + approvals: Approval[] + owner: string +} +export interface Approval { + expires: Expiration + spender: string +} +export interface NftInfoResponseForEmpty { + extension: Empty + token_uri?: string | null +} +export interface Empty { + [k: string]: unknown +} +export interface OperatorsResponse { + operators: Approval[] +} +export interface TokensResponse { + tokens: string[] +} +export interface ApprovalResponse { + approval: Approval +} +export interface ApprovalsResponse { + approvals: Approval[] +} +export interface ContractInfoResponse { + name: string + symbol: string +} +export interface MinterResponse { + minter: string +} +export interface NumTokensResponse { + count: number +} +export type String = string diff --git a/types/generated/account-nft/bundle.ts b/types/generated/account-nft/bundle.ts new file mode 100644 index 00000000..de99f813 --- /dev/null +++ b/types/generated/account-nft/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _0 from './AccountNft.types' +import * as _1 from './AccountNft.client' +import * as _2 from './AccountNft.react-query' +export namespace contracts { + export const AccountNft = { ..._0, ..._1, ..._2 } +} diff --git a/types/generated/credit-manager/CreditManager.client.ts b/types/generated/credit-manager/CreditManager.client.ts new file mode 100644 index 00000000..9610248c --- /dev/null +++ b/types/generated/credit-manager/CreditManager.client.ts @@ -0,0 +1,389 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + Decimal, + OracleBaseForString, + RedBankBaseForString, + SwapperBaseForString, + InstantiateMsg, + VaultBaseForString, + ExecuteMsg, + Action, + Uint128, + CallbackMsg, + Addr, + Coin, + ConfigUpdates, + VaultBaseForAddr, + QueryMsg, + ArrayOfCoinBalanceResponseItem, + CoinBalanceResponseItem, + ArrayOfSharesResponseItem, + SharesResponseItem, + ArrayOfDebtShares, + DebtShares, + ArrayOfVaultWithBalance, + VaultWithBalance, + ArrayOfVaultPositionResponseItem, + VaultPositionResponseItem, + VaultPosition, + VaultPositionState, + ArrayOfString, + ArrayOfVaultBaseForString, + ConfigResponse, + HealthResponse, + Positions, + DebtAmount, +} from './CreditManager.types' +export interface CreditManagerReadOnlyInterface { + contractAddress: string + config: () => Promise + allowedVaults: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: VaultBaseForString + }) => Promise + allowedCoins: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }) => Promise + positions: ({ accountId }: { accountId: string }) => Promise + health: ({ accountId }: { accountId: string }) => Promise + allCoinBalances: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }) => Promise + allDebtShares: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }) => Promise + totalDebtShares: () => Promise + allTotalDebtShares: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }) => Promise + allVaultPositions: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }) => Promise + totalVaultCoinBalance: ({ vault }: { vault: VaultBaseForString }) => Promise + allTotalVaultCoinBalances: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: VaultBaseForString + }) => Promise +} +export class CreditManagerQueryClient implements CreditManagerReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.config = this.config.bind(this) + this.allowedVaults = this.allowedVaults.bind(this) + this.allowedCoins = this.allowedCoins.bind(this) + this.positions = this.positions.bind(this) + this.health = this.health.bind(this) + this.allCoinBalances = this.allCoinBalances.bind(this) + this.allDebtShares = this.allDebtShares.bind(this) + this.totalDebtShares = this.totalDebtShares.bind(this) + this.allTotalDebtShares = this.allTotalDebtShares.bind(this) + this.allVaultPositions = this.allVaultPositions.bind(this) + this.totalVaultCoinBalance = this.totalVaultCoinBalance.bind(this) + this.allTotalVaultCoinBalances = this.allTotalVaultCoinBalances.bind(this) + } + + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {}, + }) + } + allowedVaults = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: VaultBaseForString + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + allowed_vaults: { + limit, + start_after: startAfter, + }, + }) + } + allowedCoins = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + allowed_coins: { + limit, + start_after: startAfter, + }, + }) + } + positions = async ({ accountId }: { accountId: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + positions: { + account_id: accountId, + }, + }) + } + health = async ({ accountId }: { accountId: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + health: { + account_id: accountId, + }, + }) + } + allCoinBalances = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_coin_balances: { + limit, + start_after: startAfter, + }, + }) + } + allDebtShares = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_debt_shares: { + limit, + start_after: startAfter, + }, + }) + } + totalDebtShares = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + total_debt_shares: {}, + }) + } + allTotalDebtShares = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_total_debt_shares: { + limit, + start_after: startAfter, + }, + }) + } + allVaultPositions = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_vault_positions: { + limit, + start_after: startAfter, + }, + }) + } + totalVaultCoinBalance = async ({ vault }: { vault: VaultBaseForString }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + total_vault_coin_balance: { + vault, + }, + }) + } + allTotalVaultCoinBalances = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: VaultBaseForString + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_total_vault_coin_balances: { + limit, + start_after: startAfter, + }, + }) + } +} +export interface CreditManagerInterface extends CreditManagerReadOnlyInterface { + contractAddress: string + sender: string + createCreditAccount: ( + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + updateCreditAccount: ( + { + accountId, + actions, + }: { + accountId: string + actions: Action[] + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + updateConfig: ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + callback: ( + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class CreditManagerClient + extends CreditManagerQueryClient + implements CreditManagerInterface +{ + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.createCreditAccount = this.createCreditAccount.bind(this) + this.updateCreditAccount = this.updateCreditAccount.bind(this) + this.updateConfig = this.updateConfig.bind(this) + this.callback = this.callback.bind(this) + } + + createCreditAccount = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + create_credit_account: {}, + }, + fee, + memo, + funds, + ) + } + updateCreditAccount = async ( + { + accountId, + actions, + }: { + accountId: string + actions: Action[] + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_credit_account: { + account_id: accountId, + actions, + }, + }, + fee, + memo, + funds, + ) + } + updateConfig = async ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_config: { + new_config: newConfig, + }, + }, + fee, + memo, + funds, + ) + } + callback = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + callback: {}, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/credit-manager/CreditManager.react-query.ts b/types/generated/credit-manager/CreditManager.react-query.ts new file mode 100644 index 00000000..9d2140d2 --- /dev/null +++ b/types/generated/credit-manager/CreditManager.react-query.ts @@ -0,0 +1,469 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + Decimal, + OracleBaseForString, + RedBankBaseForString, + SwapperBaseForString, + InstantiateMsg, + VaultBaseForString, + ExecuteMsg, + Action, + Uint128, + CallbackMsg, + Addr, + Coin, + ConfigUpdates, + VaultBaseForAddr, + QueryMsg, + ArrayOfCoinBalanceResponseItem, + CoinBalanceResponseItem, + ArrayOfSharesResponseItem, + SharesResponseItem, + ArrayOfDebtShares, + DebtShares, + ArrayOfVaultWithBalance, + VaultWithBalance, + ArrayOfVaultPositionResponseItem, + VaultPositionResponseItem, + VaultPosition, + VaultPositionState, + ArrayOfString, + ArrayOfVaultBaseForString, + ConfigResponse, + HealthResponse, + Positions, + DebtAmount, +} from './CreditManager.types' +import { CreditManagerQueryClient, CreditManagerClient } from './CreditManager.client' +export const creditManagerQueryKeys = { + contract: [ + { + contract: 'creditManager', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...creditManagerQueryKeys.contract[0], address: contractAddress }] as const, + config: (contractAddress: string | undefined, args?: Record) => + [{ ...creditManagerQueryKeys.address(contractAddress)[0], method: 'config', args }] as const, + allowedVaults: (contractAddress: string | undefined, args?: Record) => + [ + { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'allowed_vaults', args }, + ] as const, + allowedCoins: (contractAddress: string | undefined, args?: Record) => + [ + { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'allowed_coins', args }, + ] as const, + positions: (contractAddress: string | undefined, args?: Record) => + [{ ...creditManagerQueryKeys.address(contractAddress)[0], method: 'positions', args }] as const, + health: (contractAddress: string | undefined, args?: Record) => + [{ ...creditManagerQueryKeys.address(contractAddress)[0], method: 'health', args }] as const, + allCoinBalances: (contractAddress: string | undefined, args?: Record) => + [ + { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'all_coin_balances', args }, + ] as const, + allDebtShares: (contractAddress: string | undefined, args?: Record) => + [ + { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'all_debt_shares', args }, + ] as const, + totalDebtShares: (contractAddress: string | undefined, args?: Record) => + [ + { ...creditManagerQueryKeys.address(contractAddress)[0], method: 'total_debt_shares', args }, + ] as const, + allTotalDebtShares: (contractAddress: string | undefined, args?: Record) => + [ + { + ...creditManagerQueryKeys.address(contractAddress)[0], + method: 'all_total_debt_shares', + args, + }, + ] as const, + allVaultPositions: (contractAddress: string | undefined, args?: Record) => + [ + { + ...creditManagerQueryKeys.address(contractAddress)[0], + method: 'all_vault_positions', + args, + }, + ] as const, + totalVaultCoinBalance: (contractAddress: string | undefined, args?: Record) => + [ + { + ...creditManagerQueryKeys.address(contractAddress)[0], + method: 'total_vault_coin_balance', + args, + }, + ] as const, + allTotalVaultCoinBalances: ( + contractAddress: string | undefined, + args?: Record, + ) => + [ + { + ...creditManagerQueryKeys.address(contractAddress)[0], + method: 'all_total_vault_coin_balances', + args, + }, + ] as const, +} +export interface CreditManagerReactQuery { + client: CreditManagerQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface CreditManagerAllTotalVaultCoinBalancesQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: VaultBaseForString + } +} +export function useCreditManagerAllTotalVaultCoinBalancesQuery({ + client, + args, + options, +}: CreditManagerAllTotalVaultCoinBalancesQuery) { + return useQuery( + creditManagerQueryKeys.allTotalVaultCoinBalances(client?.contractAddress, args), + () => + client + ? client.allTotalVaultCoinBalances({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerTotalVaultCoinBalanceQuery + extends CreditManagerReactQuery { + args: { + vault: VaultBaseForString + } +} +export function useCreditManagerTotalVaultCoinBalanceQuery({ + client, + args, + options, +}: CreditManagerTotalVaultCoinBalanceQuery) { + return useQuery( + creditManagerQueryKeys.totalVaultCoinBalance(client?.contractAddress, args), + () => + client + ? client.totalVaultCoinBalance({ + vault: args.vault, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerAllVaultPositionsQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useCreditManagerAllVaultPositionsQuery({ + client, + args, + options, +}: CreditManagerAllVaultPositionsQuery) { + return useQuery( + creditManagerQueryKeys.allVaultPositions(client?.contractAddress, args), + () => + client + ? client.allVaultPositions({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerAllTotalDebtSharesQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useCreditManagerAllTotalDebtSharesQuery({ + client, + args, + options, +}: CreditManagerAllTotalDebtSharesQuery) { + return useQuery( + creditManagerQueryKeys.allTotalDebtShares(client?.contractAddress, args), + () => + client + ? client.allTotalDebtShares({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerTotalDebtSharesQuery + extends CreditManagerReactQuery {} +export function useCreditManagerTotalDebtSharesQuery({ + client, + options, +}: CreditManagerTotalDebtSharesQuery) { + return useQuery( + creditManagerQueryKeys.totalDebtShares(client?.contractAddress), + () => (client ? client.totalDebtShares() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerAllDebtSharesQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useCreditManagerAllDebtSharesQuery({ + client, + args, + options, +}: CreditManagerAllDebtSharesQuery) { + return useQuery( + creditManagerQueryKeys.allDebtShares(client?.contractAddress, args), + () => + client + ? client.allDebtShares({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerAllCoinBalancesQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useCreditManagerAllCoinBalancesQuery({ + client, + args, + options, +}: CreditManagerAllCoinBalancesQuery) { + return useQuery( + creditManagerQueryKeys.allCoinBalances(client?.contractAddress, args), + () => + client + ? client.allCoinBalances({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerHealthQuery + extends CreditManagerReactQuery { + args: { + accountId: string + } +} +export function useCreditManagerHealthQuery({ + client, + args, + options, +}: CreditManagerHealthQuery) { + return useQuery( + creditManagerQueryKeys.health(client?.contractAddress, args), + () => + client + ? client.health({ + accountId: args.accountId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerPositionsQuery + extends CreditManagerReactQuery { + args: { + accountId: string + } +} +export function useCreditManagerPositionsQuery({ + client, + args, + options, +}: CreditManagerPositionsQuery) { + return useQuery( + creditManagerQueryKeys.positions(client?.contractAddress, args), + () => + client + ? client.positions({ + accountId: args.accountId, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerAllowedCoinsQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useCreditManagerAllowedCoinsQuery({ + client, + args, + options, +}: CreditManagerAllowedCoinsQuery) { + return useQuery( + creditManagerQueryKeys.allowedCoins(client?.contractAddress, args), + () => + client + ? client.allowedCoins({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerAllowedVaultsQuery + extends CreditManagerReactQuery { + args: { + limit?: number + startAfter?: VaultBaseForString + } +} +export function useCreditManagerAllowedVaultsQuery({ + client, + args, + options, +}: CreditManagerAllowedVaultsQuery) { + return useQuery( + creditManagerQueryKeys.allowedVaults(client?.contractAddress, args), + () => + client + ? client.allowedVaults({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerConfigQuery + extends CreditManagerReactQuery {} +export function useCreditManagerConfigQuery({ + client, + options, +}: CreditManagerConfigQuery) { + return useQuery( + creditManagerQueryKeys.config(client?.contractAddress), + () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface CreditManagerCallbackMutation { + client: CreditManagerClient + msg: CallbackMsg + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useCreditManagerCallbackMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.callback(msg, fee, memo, funds), + options, + ) +} +export interface CreditManagerUpdateConfigMutation { + client: CreditManagerClient + msg: { + newConfig: ConfigUpdates + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useCreditManagerUpdateConfigMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateConfig(msg, fee, memo, funds), + options, + ) +} +export interface CreditManagerUpdateCreditAccountMutation { + client: CreditManagerClient + msg: { + accountId: string + actions: Action[] + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useCreditManagerUpdateCreditAccountMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateCreditAccount(msg, fee, memo, funds), + options, + ) +} +export interface CreditManagerCreateCreditAccountMutation { + client: CreditManagerClient + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useCreditManagerCreateCreditAccountMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, args: { fee, memo, funds } = {} }) => client.createCreditAccount(fee, memo, funds), + options, + ) +} diff --git a/types/generated/credit-manager/CreditManager.types.ts b/types/generated/credit-manager/CreditManager.types.ts new file mode 100644 index 00000000..9268d76e --- /dev/null +++ b/types/generated/credit-manager/CreditManager.types.ts @@ -0,0 +1,314 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type Decimal = string +export type OracleBaseForString = string +export type RedBankBaseForString = string +export type SwapperBaseForString = string +export interface InstantiateMsg { + allowed_coins: string[] + allowed_vaults: VaultBaseForString[] + max_close_factor: Decimal + max_liquidation_bonus: Decimal + oracle: OracleBaseForString + owner: string + red_bank: RedBankBaseForString + swapper: SwapperBaseForString +} +export interface VaultBaseForString { + address: string +} +export type ExecuteMsg = + | { + create_credit_account: {} + } + | { + update_credit_account: { + account_id: string + actions: Action[] + } + } + | { + update_config: { + new_config: ConfigUpdates + } + } + | { + callback: CallbackMsg + } +export type Action = + | { + deposit: Coin + } + | { + withdraw: Coin + } + | { + borrow: Coin + } + | { + repay: Coin + } + | { + vault_deposit: { + coins: Coin[] + vault: VaultBaseForString + } + } + | { + vault_withdraw: { + amount: Uint128 + vault: VaultBaseForString + } + } + | { + liquidate_coin: { + debt_coin: Coin + liquidatee_account_id: string + request_coin_denom: string + } + } + | { + swap_exact_in: { + coin_in: Coin + denom_out: string + slippage: Decimal + } + } +export type Uint128 = string +export type CallbackMsg = + | { + withdraw: { + account_id: string + coin: Coin + recipient: Addr + } + } + | { + borrow: { + account_id: string + coin: Coin + } + } + | { + repay: { + account_id: string + coin: Coin + } + } + | { + assert_below_max_l_t_v: { + account_id: string + } + } + | { + vault_deposit: { + account_id: string + coins: Coin[] + vault: VaultBaseForAddr + } + } + | { + update_vault_coin_balance: { + account_id: string + previous_total_balance: Uint128 + vault: VaultBaseForAddr + } + } + | { + vault_withdraw: { + account_id: string + amount: Uint128 + vault: VaultBaseForAddr + } + } + | { + vault_force_withdraw: { + account_id: string + amount: Uint128 + vault: VaultBaseForAddr + } + } + | { + liquidate_coin: { + debt_coin: Coin + liquidatee_account_id: string + liquidator_account_id: string + request_coin_denom: string + } + } + | { + assert_health_factor_improved: { + account_id: string + previous_health_factor: Decimal + } + } + | { + swap_exact_in: { + account_id: string + coin_in: Coin + denom_out: string + slippage: Decimal + } + } + | { + update_coin_balances: { + account_id: string + previous_balances: Coin[] + } + } +export type Addr = string +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown +} +export interface ConfigUpdates { + account_nft?: string | null + allowed_coins?: string[] | null + allowed_vaults?: VaultBaseForString[] | null + max_close_factor?: Decimal | null + max_liquidation_bonus?: Decimal | null + oracle?: OracleBaseForString | null + owner?: string | null + red_bank?: RedBankBaseForString | null + swapper?: SwapperBaseForString | null +} +export interface VaultBaseForAddr { + address: Addr +} +export type QueryMsg = + | { + config: {} + } + | { + allowed_vaults: { + limit?: number | null + start_after?: VaultBaseForString | null + } + } + | { + allowed_coins: { + limit?: number | null + start_after?: string | null + } + } + | { + positions: { + account_id: string + } + } + | { + health: { + account_id: string + } + } + | { + all_coin_balances: { + limit?: number | null + start_after?: [string, string] | null + } + } + | { + all_debt_shares: { + limit?: number | null + start_after?: [string, string] | null + } + } + | { + total_debt_shares: string + } + | { + all_total_debt_shares: { + limit?: number | null + start_after?: string | null + } + } + | { + all_vault_positions: { + limit?: number | null + start_after?: [string, string] | null + } + } + | { + total_vault_coin_balance: { + vault: VaultBaseForString + } + } + | { + all_total_vault_coin_balances: { + limit?: number | null + start_after?: VaultBaseForString | null + } + } +export type ArrayOfCoinBalanceResponseItem = CoinBalanceResponseItem[] +export interface CoinBalanceResponseItem { + account_id: string + amount: Uint128 + denom: string +} +export type ArrayOfSharesResponseItem = SharesResponseItem[] +export interface SharesResponseItem { + account_id: string + denom: string + shares: Uint128 +} +export type ArrayOfDebtShares = DebtShares[] +export interface DebtShares { + denom: string + shares: Uint128 +} +export type ArrayOfVaultWithBalance = VaultWithBalance[] +export interface VaultWithBalance { + balance: Uint128 + vault: VaultBaseForAddr +} +export type ArrayOfVaultPositionResponseItem = VaultPositionResponseItem[] +export interface VaultPositionResponseItem { + account_id: string + position: VaultPosition +} +export interface VaultPosition { + state: VaultPositionState + vault: VaultBaseForAddr +} +export interface VaultPositionState { + locked: Uint128 + unlocked: Uint128 +} +export type ArrayOfString = string[] +export type ArrayOfVaultBaseForString = VaultBaseForString[] +export interface ConfigResponse { + account_nft?: string | null + max_close_factor: Decimal + max_liquidation_bonus: Decimal + oracle: string + owner: string + red_bank: string + swapper: string +} +export interface HealthResponse { + above_max_ltv: boolean + liquidatable: boolean + liquidation_health_factor?: Decimal | null + liquidation_threshold_adjusted_collateral: Decimal + max_ltv_adjusted_collateral: Decimal + max_ltv_health_factor?: Decimal | null + total_collateral_value: Decimal + total_debt_value: Decimal +} +export interface Positions { + account_id: string + coins: Coin[] + debts: DebtAmount[] + vaults: VaultPosition[] +} +export interface DebtAmount { + amount: Uint128 + denom: string + shares: Uint128 +} diff --git a/types/generated/credit-manager/bundle.ts b/types/generated/credit-manager/bundle.ts new file mode 100644 index 00000000..5b6328c6 --- /dev/null +++ b/types/generated/credit-manager/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _3 from './CreditManager.types' +import * as _4 from './CreditManager.client' +import * as _5 from './CreditManager.react-query' +export namespace contracts { + export const CreditManager = { ..._3, ..._4, ..._5 } +} diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts new file mode 100644 index 00000000..40e562bf --- /dev/null +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts @@ -0,0 +1,138 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { Coin, StdFee } from '@cosmjs/amino' +import { + OracleBaseForString, + Addr, + PricingMethod, + InstantiateMsg, + VaultPricingInfo, + ExecuteMsg, + ConfigUpdates, + QueryMsg, + ArrayOfVaultPricingInfo, + OracleBaseForAddr, + ConfigResponse, + Decimal, + PriceResponse, +} from './MarsOracleAdapter.types' +export interface MarsOracleAdapterReadOnlyInterface { + contractAddress: string + price: ({ denom }: { denom: string }) => Promise + config: () => Promise + pricingInfo: ({ denom }: { denom: string }) => Promise + allPricingInfo: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }) => Promise +} +export class MarsOracleAdapterQueryClient implements MarsOracleAdapterReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.price = this.price.bind(this) + this.config = this.config.bind(this) + this.pricingInfo = this.pricingInfo.bind(this) + this.allPricingInfo = this.allPricingInfo.bind(this) + } + + price = async ({ denom }: { denom: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + price: { + denom, + }, + }) + } + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {}, + }) + } + pricingInfo = async ({ denom }: { denom: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pricing_info: { + denom, + }, + }) + } + allPricingInfo = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_pricing_info: { + limit, + start_after: startAfter, + }, + }) + } +} +export interface MarsOracleAdapterInterface extends MarsOracleAdapterReadOnlyInterface { + contractAddress: string + sender: string + updateConfig: ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class MarsOracleAdapterClient + extends MarsOracleAdapterQueryClient + implements MarsOracleAdapterInterface +{ + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.updateConfig = this.updateConfig.bind(this) + } + + updateConfig = async ( + { + newConfig, + }: { + newConfig: ConfigUpdates + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_config: { + new_config: newConfig, + }, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts new file mode 100644 index 00000000..8ecf8c9b --- /dev/null +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts @@ -0,0 +1,165 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee, Coin } from '@cosmjs/amino' +import { + OracleBaseForString, + Addr, + PricingMethod, + InstantiateMsg, + VaultPricingInfo, + ExecuteMsg, + ConfigUpdates, + QueryMsg, + ArrayOfVaultPricingInfo, + OracleBaseForAddr, + ConfigResponse, + Decimal, + PriceResponse, +} from './MarsOracleAdapter.types' +import { MarsOracleAdapterQueryClient, MarsOracleAdapterClient } from './MarsOracleAdapter.client' +export const marsOracleAdapterQueryKeys = { + contract: [ + { + contract: 'marsOracleAdapter', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...marsOracleAdapterQueryKeys.contract[0], address: contractAddress }] as const, + price: (contractAddress: string | undefined, args?: Record) => + [{ ...marsOracleAdapterQueryKeys.address(contractAddress)[0], method: 'price', args }] as const, + config: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsOracleAdapterQueryKeys.address(contractAddress)[0], method: 'config', args }, + ] as const, + pricingInfo: (contractAddress: string | undefined, args?: Record) => + [ + { ...marsOracleAdapterQueryKeys.address(contractAddress)[0], method: 'pricing_info', args }, + ] as const, + allPricingInfo: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsOracleAdapterQueryKeys.address(contractAddress)[0], + method: 'all_pricing_info', + args, + }, + ] as const, +} +export interface MarsOracleAdapterReactQuery { + client: MarsOracleAdapterQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MarsOracleAdapterAllPricingInfoQuery + extends MarsOracleAdapterReactQuery { + args: { + limit?: number + startAfter?: string + } +} +export function useMarsOracleAdapterAllPricingInfoQuery({ + client, + args, + options, +}: MarsOracleAdapterAllPricingInfoQuery) { + return useQuery( + marsOracleAdapterQueryKeys.allPricingInfo(client?.contractAddress, args), + () => + client + ? client.allPricingInfo({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsOracleAdapterPricingInfoQuery + extends MarsOracleAdapterReactQuery { + args: { + denom: string + } +} +export function useMarsOracleAdapterPricingInfoQuery({ + client, + args, + options, +}: MarsOracleAdapterPricingInfoQuery) { + return useQuery( + marsOracleAdapterQueryKeys.pricingInfo(client?.contractAddress, args), + () => + client + ? client.pricingInfo({ + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsOracleAdapterConfigQuery + extends MarsOracleAdapterReactQuery {} +export function useMarsOracleAdapterConfigQuery({ + client, + options, +}: MarsOracleAdapterConfigQuery) { + return useQuery( + marsOracleAdapterQueryKeys.config(client?.contractAddress), + () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsOracleAdapterPriceQuery + extends MarsOracleAdapterReactQuery { + args: { + denom: string + } +} +export function useMarsOracleAdapterPriceQuery({ + client, + args, + options, +}: MarsOracleAdapterPriceQuery) { + return useQuery( + marsOracleAdapterQueryKeys.price(client?.contractAddress, args), + () => + client + ? client.price({ + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsOracleAdapterUpdateConfigMutation { + client: MarsOracleAdapterClient + msg: { + newConfig: ConfigUpdates + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsOracleAdapterUpdateConfigMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateConfig(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts new file mode 100644 index 00000000..4dca1c4f --- /dev/null +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.types.ts @@ -0,0 +1,62 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type OracleBaseForString = string +export type Addr = string +export type PricingMethod = 'preview_redeem' +export interface InstantiateMsg { + oracle: OracleBaseForString + owner: string + vault_pricing: VaultPricingInfo[] +} +export interface VaultPricingInfo { + addr: Addr + denom: string + method: PricingMethod +} +export type ExecuteMsg = { + update_config: { + new_config: ConfigUpdates + } +} +export interface ConfigUpdates { + oracle?: OracleBaseForString | null + owner?: string | null + vault_pricing?: VaultPricingInfo[] | null +} +export type QueryMsg = + | { + price: { + denom: string + } + } + | { + config: {} + } + | { + pricing_info: { + denom: string + } + } + | { + all_pricing_info: { + limit?: number | null + start_after?: string | null + } + } +export type ArrayOfVaultPricingInfo = VaultPricingInfo[] +export type OracleBaseForAddr = string +export interface ConfigResponse { + oracle: OracleBaseForAddr + owner: Addr +} +export type Decimal = string +export interface PriceResponse { + denom: string + price: Decimal + [k: string]: unknown +} diff --git a/types/generated/mars-oracle-adapter/bundle.ts b/types/generated/mars-oracle-adapter/bundle.ts new file mode 100644 index 00000000..02375a2b --- /dev/null +++ b/types/generated/mars-oracle-adapter/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _6 from './MarsOracleAdapter.types' +import * as _7 from './MarsOracleAdapter.client' +import * as _8 from './MarsOracleAdapter.react-query' +export namespace contracts { + export const MarsOracleAdapter = { ..._6, ..._7, ..._8 } +} diff --git a/types/generated/mock-oracle/MockOracle.client.ts b/types/generated/mock-oracle/MockOracle.client.ts new file mode 100644 index 00000000..f22720f3 --- /dev/null +++ b/types/generated/mock-oracle/MockOracle.client.ts @@ -0,0 +1,95 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { Coin, StdFee } from '@cosmjs/amino' +import { + Decimal, + InstantiateMsg, + CoinPrice, + ExecuteMsg, + QueryMsg, + PriceResponse, +} from './MockOracle.types' +export interface MockOracleReadOnlyInterface { + contractAddress: string + price: ({ denom }: { denom: string }) => Promise +} +export class MockOracleQueryClient implements MockOracleReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.price = this.price.bind(this) + } + + price = async ({ denom }: { denom: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + price: { + denom, + }, + }) + } +} +export interface MockOracleInterface extends MockOracleReadOnlyInterface { + contractAddress: string + sender: string + changePrice: ( + { + denom, + price, + }: { + denom: string + price: Decimal + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class MockOracleClient extends MockOracleQueryClient implements MockOracleInterface { + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.changePrice = this.changePrice.bind(this) + } + + changePrice = async ( + { + denom, + price, + }: { + denom: string + price: Decimal + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + change_price: { + denom, + price, + }, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/mock-oracle/MockOracle.react-query.ts b/types/generated/mock-oracle/MockOracle.react-query.ts new file mode 100644 index 00000000..aca388f4 --- /dev/null +++ b/types/generated/mock-oracle/MockOracle.react-query.ts @@ -0,0 +1,80 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee, Coin } from '@cosmjs/amino' +import { + Decimal, + InstantiateMsg, + CoinPrice, + ExecuteMsg, + QueryMsg, + PriceResponse, +} from './MockOracle.types' +import { MockOracleQueryClient, MockOracleClient } from './MockOracle.client' +export const mockOracleQueryKeys = { + contract: [ + { + contract: 'mockOracle', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...mockOracleQueryKeys.contract[0], address: contractAddress }] as const, + price: (contractAddress: string | undefined, args?: Record) => + [{ ...mockOracleQueryKeys.address(contractAddress)[0], method: 'price', args }] as const, +} +export interface MockOracleReactQuery { + client: MockOracleQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MockOraclePriceQuery extends MockOracleReactQuery { + args: { + denom: string + } +} +export function useMockOraclePriceQuery({ + client, + args, + options, +}: MockOraclePriceQuery) { + return useQuery( + mockOracleQueryKeys.price(client?.contractAddress, args), + () => + client + ? client.price({ + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MockOracleChangePriceMutation { + client: MockOracleClient + msg: CoinPrice + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMockOracleChangePriceMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.changePrice(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/mock-oracle/MockOracle.types.ts b/types/generated/mock-oracle/MockOracle.types.ts new file mode 100644 index 00000000..833e13cb --- /dev/null +++ b/types/generated/mock-oracle/MockOracle.types.ts @@ -0,0 +1,28 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type Decimal = string +export interface InstantiateMsg { + coins: CoinPrice[] +} +export interface CoinPrice { + denom: string + price: Decimal +} +export type ExecuteMsg = { + change_price: CoinPrice +} +export type QueryMsg = { + price: { + denom: string + } +} +export interface PriceResponse { + denom: string + price: Decimal + [k: string]: unknown +} diff --git a/types/generated/mock-oracle/bundle.ts b/types/generated/mock-oracle/bundle.ts new file mode 100644 index 00000000..5a59629e --- /dev/null +++ b/types/generated/mock-oracle/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _9 from './MockOracle.types' +import * as _10 from './MockOracle.client' +import * as _11 from './MockOracle.react-query' +export namespace contracts { + export const MockOracle = { ..._9, ..._10, ..._11 } +} diff --git a/types/generated/mock-red-bank/MockRedBank.client.ts b/types/generated/mock-red-bank/MockRedBank.client.ts new file mode 100644 index 00000000..2950d9db --- /dev/null +++ b/types/generated/mock-red-bank/MockRedBank.client.ts @@ -0,0 +1,160 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + Decimal, + InstantiateMsg, + CoinMarketInfo, + ExecuteMsg, + Uint128, + Coin, + QueryMsg, + Market, + InterestRateModel, + UserAssetDebtResponse, +} from './MockRedBank.types' +export interface MockRedBankReadOnlyInterface { + contractAddress: string + userAssetDebt: ({ + denom, + userAddress, + }: { + denom: string + userAddress: string + }) => Promise + market: ({ denom }: { denom: string }) => Promise +} +export class MockRedBankQueryClient implements MockRedBankReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.userAssetDebt = this.userAssetDebt.bind(this) + this.market = this.market.bind(this) + } + + userAssetDebt = async ({ + denom, + userAddress, + }: { + denom: string + userAddress: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + user_asset_debt: { + denom, + user_address: userAddress, + }, + }) + } + market = async ({ denom }: { denom: string }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + market: { + denom, + }, + }) + } +} +export interface MockRedBankInterface extends MockRedBankReadOnlyInterface { + contractAddress: string + sender: string + borrow: ( + { + coin, + recipient, + }: { + coin: Coin + recipient?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + repay: ( + { + denom, + onBehalfOf, + }: { + denom: string + onBehalfOf?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class MockRedBankClient extends MockRedBankQueryClient implements MockRedBankInterface { + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.borrow = this.borrow.bind(this) + this.repay = this.repay.bind(this) + } + + borrow = async ( + { + coin, + recipient, + }: { + coin: Coin + recipient?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + borrow: { + coin, + recipient, + }, + }, + fee, + memo, + funds, + ) + } + repay = async ( + { + denom, + onBehalfOf, + }: { + denom: string + onBehalfOf?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + repay: { + denom, + on_behalf_of: onBehalfOf, + }, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/mock-red-bank/MockRedBank.react-query.ts b/types/generated/mock-red-bank/MockRedBank.react-query.ts new file mode 100644 index 00000000..e059eabb --- /dev/null +++ b/types/generated/mock-red-bank/MockRedBank.react-query.ts @@ -0,0 +1,132 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + Decimal, + InstantiateMsg, + CoinMarketInfo, + ExecuteMsg, + Uint128, + Coin, + QueryMsg, + Market, + InterestRateModel, + UserAssetDebtResponse, +} from './MockRedBank.types' +import { MockRedBankQueryClient, MockRedBankClient } from './MockRedBank.client' +export const mockRedBankQueryKeys = { + contract: [ + { + contract: 'mockRedBank', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...mockRedBankQueryKeys.contract[0], address: contractAddress }] as const, + userAssetDebt: (contractAddress: string | undefined, args?: Record) => + [ + { ...mockRedBankQueryKeys.address(contractAddress)[0], method: 'user_asset_debt', args }, + ] as const, + market: (contractAddress: string | undefined, args?: Record) => + [{ ...mockRedBankQueryKeys.address(contractAddress)[0], method: 'market', args }] as const, +} +export interface MockRedBankReactQuery { + client: MockRedBankQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MockRedBankMarketQuery extends MockRedBankReactQuery { + args: { + denom: string + } +} +export function useMockRedBankMarketQuery({ + client, + args, + options, +}: MockRedBankMarketQuery) { + return useQuery( + mockRedBankQueryKeys.market(client?.contractAddress, args), + () => + client + ? client.market({ + denom: args.denom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MockRedBankUserAssetDebtQuery + extends MockRedBankReactQuery { + args: { + denom: string + userAddress: string + } +} +export function useMockRedBankUserAssetDebtQuery({ + client, + args, + options, +}: MockRedBankUserAssetDebtQuery) { + return useQuery( + mockRedBankQueryKeys.userAssetDebt(client?.contractAddress, args), + () => + client + ? client.userAssetDebt({ + denom: args.denom, + userAddress: args.userAddress, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MockRedBankRepayMutation { + client: MockRedBankClient + msg: { + denom: string + onBehalfOf?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMockRedBankRepayMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.repay(msg, fee, memo, funds), + options, + ) +} +export interface MockRedBankBorrowMutation { + client: MockRedBankClient + msg: { + coin: Coin + recipient?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMockRedBankBorrowMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.borrow(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/mock-red-bank/MockRedBank.types.ts b/types/generated/mock-red-bank/MockRedBank.types.ts new file mode 100644 index 00000000..ee4ae957 --- /dev/null +++ b/types/generated/mock-red-bank/MockRedBank.types.ts @@ -0,0 +1,77 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type Decimal = string +export interface InstantiateMsg { + coins: CoinMarketInfo[] +} +export interface CoinMarketInfo { + denom: string + liquidation_threshold: Decimal + max_ltv: Decimal +} +export type ExecuteMsg = + | { + borrow: { + coin: Coin + recipient?: string | null + } + } + | { + repay: { + denom: string + on_behalf_of?: string | null + } + } +export type Uint128 = string +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown +} +export type QueryMsg = + | { + user_asset_debt: { + denom: string + user_address: string + } + } + | { + market: { + denom: string + } + } +export interface Market { + borrow_enabled: boolean + borrow_index: Decimal + borrow_rate: Decimal + collateral_total_scaled: Uint128 + debt_total_scaled: Uint128 + denom: string + deposit_cap: Uint128 + deposit_enabled: boolean + indexes_last_updated: number + interest_rate_model: InterestRateModel + liquidation_bonus: Decimal + liquidation_threshold: Decimal + liquidity_index: Decimal + liquidity_rate: Decimal + max_loan_to_value: Decimal + reserve_factor: Decimal + [k: string]: unknown +} +export interface InterestRateModel { + base: Decimal + optimal_utilization_rate: Decimal + slope_1: Decimal + slope_2: Decimal + [k: string]: unknown +} +export interface UserAssetDebtResponse { + amount: Uint128 + denom: string +} diff --git a/types/generated/mock-red-bank/bundle.ts b/types/generated/mock-red-bank/bundle.ts new file mode 100644 index 00000000..7b5a5df8 --- /dev/null +++ b/types/generated/mock-red-bank/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _12 from './MockRedBank.types' +import * as _13 from './MockRedBank.client' +import * as _14 from './MockRedBank.react-query' +export namespace contracts { + export const MockRedBank = { ..._12, ..._13, ..._14 } +} diff --git a/types/generated/mock-vault/MockVault.client.ts b/types/generated/mock-vault/MockVault.client.ts new file mode 100644 index 00000000..3c40db79 --- /dev/null +++ b/types/generated/mock-vault/MockVault.client.ts @@ -0,0 +1,134 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + OracleBaseForString, + InstantiateMsg, + ExecuteMsg, + QueryMsg, + Uint128, + VaultInfo, + Coin, + ArrayOfCoin, +} from './MockVault.types' +export interface MockVaultReadOnlyInterface { + contractAddress: string + info: () => Promise + previewRedeem: ({ amount }: { amount: Uint128 }) => Promise + totalVaultCoinsIssued: () => Promise +} +export class MockVaultQueryClient implements MockVaultReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.info = this.info.bind(this) + this.previewRedeem = this.previewRedeem.bind(this) + this.totalVaultCoinsIssued = this.totalVaultCoinsIssued.bind(this) + } + + info = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + info: {}, + }) + } + previewRedeem = async ({ amount }: { amount: Uint128 }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + preview_redeem: { + amount, + }, + }) + } + totalVaultCoinsIssued = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + total_vault_coins_issued: {}, + }) + } +} +export interface MockVaultInterface extends MockVaultReadOnlyInterface { + contractAddress: string + sender: string + deposit: (fee?: number | StdFee | 'auto', memo?: string, funds?: Coin[]) => Promise + withdraw: ( + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + forceWithdraw: ( + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class MockVaultClient extends MockVaultQueryClient implements MockVaultInterface { + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.deposit = this.deposit.bind(this) + this.withdraw = this.withdraw.bind(this) + this.forceWithdraw = this.forceWithdraw.bind(this) + } + + deposit = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + deposit: {}, + }, + fee, + memo, + funds, + ) + } + withdraw = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + withdraw: {}, + }, + fee, + memo, + funds, + ) + } + forceWithdraw = async ( + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + force_withdraw: {}, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/mock-vault/MockVault.react-query.ts b/types/generated/mock-vault/MockVault.react-query.ts new file mode 100644 index 00000000..c4ca251d --- /dev/null +++ b/types/generated/mock-vault/MockVault.react-query.ts @@ -0,0 +1,149 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + OracleBaseForString, + InstantiateMsg, + ExecuteMsg, + QueryMsg, + Uint128, + VaultInfo, + Coin, + ArrayOfCoin, +} from './MockVault.types' +import { MockVaultQueryClient, MockVaultClient } from './MockVault.client' +export const mockVaultQueryKeys = { + contract: [ + { + contract: 'mockVault', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...mockVaultQueryKeys.contract[0], address: contractAddress }] as const, + info: (contractAddress: string | undefined, args?: Record) => + [{ ...mockVaultQueryKeys.address(contractAddress)[0], method: 'info', args }] as const, + previewRedeem: (contractAddress: string | undefined, args?: Record) => + [ + { ...mockVaultQueryKeys.address(contractAddress)[0], method: 'preview_redeem', args }, + ] as const, + totalVaultCoinsIssued: (contractAddress: string | undefined, args?: Record) => + [ + { + ...mockVaultQueryKeys.address(contractAddress)[0], + method: 'total_vault_coins_issued', + args, + }, + ] as const, +} +export interface MockVaultReactQuery { + client: MockVaultQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface MockVaultTotalVaultCoinsIssuedQuery + extends MockVaultReactQuery {} +export function useMockVaultTotalVaultCoinsIssuedQuery({ + client, + options, +}: MockVaultTotalVaultCoinsIssuedQuery) { + return useQuery( + mockVaultQueryKeys.totalVaultCoinsIssued(client?.contractAddress), + () => (client ? client.totalVaultCoinsIssued() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MockVaultPreviewRedeemQuery + extends MockVaultReactQuery { + args: { + amount: Uint128 + } +} +export function useMockVaultPreviewRedeemQuery({ + client, + args, + options, +}: MockVaultPreviewRedeemQuery) { + return useQuery( + mockVaultQueryKeys.previewRedeem(client?.contractAddress, args), + () => + client + ? client.previewRedeem({ + amount: args.amount, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MockVaultInfoQuery extends MockVaultReactQuery {} +export function useMockVaultInfoQuery({ + client, + options, +}: MockVaultInfoQuery) { + return useQuery( + mockVaultQueryKeys.info(client?.contractAddress), + () => (client ? client.info() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MockVaultForceWithdrawMutation { + client: MockVaultClient + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMockVaultForceWithdrawMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, args: { fee, memo, funds } = {} }) => client.forceWithdraw(fee, memo, funds), + options, + ) +} +export interface MockVaultWithdrawMutation { + client: MockVaultClient + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMockVaultWithdrawMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, args: { fee, memo, funds } = {} }) => client.withdraw(fee, memo, funds), + options, + ) +} +export interface MockVaultDepositMutation { + client: MockVaultClient + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMockVaultDepositMutation( + options?: Omit, 'mutationFn'>, +) { + return useMutation( + ({ client, args: { fee, memo, funds } = {} }) => client.deposit(fee, memo, funds), + options, + ) +} diff --git a/types/generated/mock-vault/MockVault.types.ts b/types/generated/mock-vault/MockVault.types.ts new file mode 100644 index 00000000..8114114a --- /dev/null +++ b/types/generated/mock-vault/MockVault.types.ts @@ -0,0 +1,48 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export type OracleBaseForString = string +export interface InstantiateMsg { + asset_denoms: string[] + lockup?: number | null + lp_token_denom: string + oracle: OracleBaseForString +} +export type ExecuteMsg = + | { + deposit: {} + } + | { + withdraw: {} + } + | { + force_withdraw: {} + } +export type QueryMsg = + | { + info: {} + } + | { + preview_redeem: { + amount: Uint128 + } + } + | { + total_vault_coins_issued: {} + } +export type Uint128 = string +export interface VaultInfo { + coins: Coin[] + lockup?: number | null + token_denom: string +} +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown +} +export type ArrayOfCoin = Coin[] diff --git a/types/generated/mock-vault/bundle.ts b/types/generated/mock-vault/bundle.ts new file mode 100644 index 00000000..82599902 --- /dev/null +++ b/types/generated/mock-vault/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _15 from './MockVault.types' +import * as _16 from './MockVault.client' +import * as _17 from './MockVault.react-query' +export namespace contracts { + export const MockVault = { ..._15, ..._16, ..._17 } +} diff --git a/types/generated/swapper-base/SwapperBase.client.ts b/types/generated/swapper-base/SwapperBase.client.ts new file mode 100644 index 00000000..02a924c0 --- /dev/null +++ b/types/generated/swapper-base/SwapperBase.client.ts @@ -0,0 +1,292 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + InstantiateMsg, + ExecuteMsg, + Uint128, + Decimal, + Addr, + Empty, + Coin, + QueryMsg, + ConfigForString, + EstimateExactInSwapResponse, + RouteResponseForEmpty, + ArrayOfRouteResponseForEmpty, +} from './SwapperBase.types' +export interface SwapperBaseReadOnlyInterface { + contractAddress: string + config: () => Promise + route: ({ + denomIn, + denomOut, + }: { + denomIn: string + denomOut: string + }) => Promise + routes: ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }) => Promise + estimateExactInSwap: ({ + coinIn, + denomOut, + }: { + coinIn: Coin + denomOut: string + }) => Promise +} +export class SwapperBaseQueryClient implements SwapperBaseReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.config = this.config.bind(this) + this.route = this.route.bind(this) + this.routes = this.routes.bind(this) + this.estimateExactInSwap = this.estimateExactInSwap.bind(this) + } + + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {}, + }) + } + route = async ({ + denomIn, + denomOut, + }: { + denomIn: string + denomOut: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + route: { + denom_in: denomIn, + denom_out: denomOut, + }, + }) + } + routes = async ({ + limit, + startAfter, + }: { + limit?: number + startAfter?: string[][] + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + routes: { + limit, + start_after: startAfter, + }, + }) + } + estimateExactInSwap = async ({ + coinIn, + denomOut, + }: { + coinIn: Coin + denomOut: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + estimate_exact_in_swap: { + coin_in: coinIn, + denom_out: denomOut, + }, + }) + } +} +export interface SwapperBaseInterface extends SwapperBaseReadOnlyInterface { + contractAddress: string + sender: string + updateConfig: ( + { + owner, + }: { + owner?: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + setRoute: ( + { + denomIn, + denomOut, + route, + }: { + denomIn: string + denomOut: string + route: Empty + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + swapExactIn: ( + { + coinIn, + denomOut, + slippage, + }: { + coinIn: Coin + denomOut: string + slippage: Decimal + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise + transferResult: ( + { + denomIn, + denomOut, + recipient, + }: { + denomIn: string + denomOut: string + recipient: Addr + }, + fee?: number | StdFee | 'auto', + memo?: string, + funds?: Coin[], + ) => Promise +} +export class SwapperBaseClient extends SwapperBaseQueryClient implements SwapperBaseInterface { + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.updateConfig = this.updateConfig.bind(this) + this.setRoute = this.setRoute.bind(this) + this.swapExactIn = this.swapExactIn.bind(this) + this.transferResult = this.transferResult.bind(this) + } + + updateConfig = async ( + { + owner, + }: { + owner?: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_config: { + owner, + }, + }, + fee, + memo, + funds, + ) + } + setRoute = async ( + { + denomIn, + denomOut, + route, + }: { + denomIn: string + denomOut: string + route: Empty + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + set_route: { + denom_in: denomIn, + denom_out: denomOut, + route, + }, + }, + fee, + memo, + funds, + ) + } + swapExactIn = async ( + { + coinIn, + denomOut, + slippage, + }: { + coinIn: Coin + denomOut: string + slippage: Decimal + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + swap_exact_in: { + coin_in: coinIn, + denom_out: denomOut, + slippage, + }, + }, + fee, + memo, + funds, + ) + } + transferResult = async ( + { + denomIn, + denomOut, + recipient, + }: { + denomIn: string + denomOut: string + recipient: Addr + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + transfer_result: { + denom_in: denomIn, + denom_out: denomOut, + recipient, + }, + }, + fee, + memo, + funds, + ) + } +} diff --git a/types/generated/swapper-base/SwapperBase.react-query.ts b/types/generated/swapper-base/SwapperBase.react-query.ts new file mode 100644 index 00000000..a47fdc9e --- /dev/null +++ b/types/generated/swapper-base/SwapperBase.react-query.ts @@ -0,0 +1,237 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { StdFee } from '@cosmjs/amino' +import { + InstantiateMsg, + ExecuteMsg, + Uint128, + Decimal, + Addr, + Empty, + Coin, + QueryMsg, + ConfigForString, + EstimateExactInSwapResponse, + RouteResponseForEmpty, + ArrayOfRouteResponseForEmpty, +} from './SwapperBase.types' +import { SwapperBaseQueryClient, SwapperBaseClient } from './SwapperBase.client' +export const swapperBaseQueryKeys = { + contract: [ + { + contract: 'swapperBase', + }, + ] as const, + address: (contractAddress: string | undefined) => + [{ ...swapperBaseQueryKeys.contract[0], address: contractAddress }] as const, + config: (contractAddress: string | undefined, args?: Record) => + [{ ...swapperBaseQueryKeys.address(contractAddress)[0], method: 'config', args }] as const, + route: (contractAddress: string | undefined, args?: Record) => + [{ ...swapperBaseQueryKeys.address(contractAddress)[0], method: 'route', args }] as const, + routes: (contractAddress: string | undefined, args?: Record) => + [{ ...swapperBaseQueryKeys.address(contractAddress)[0], method: 'routes', args }] as const, + estimateExactInSwap: (contractAddress: string | undefined, args?: Record) => + [ + { + ...swapperBaseQueryKeys.address(contractAddress)[0], + method: 'estimate_exact_in_swap', + args, + }, + ] as const, +} +export interface SwapperBaseReactQuery { + client: SwapperBaseQueryClient | undefined + options?: Omit< + UseQueryOptions, + "'queryKey' | 'queryFn' | 'initialData'" + > & { + initialData?: undefined + } +} +export interface SwapperBaseEstimateExactInSwapQuery + extends SwapperBaseReactQuery { + args: { + coinIn: Coin + denomOut: string + } +} +export function useSwapperBaseEstimateExactInSwapQuery({ + client, + args, + options, +}: SwapperBaseEstimateExactInSwapQuery) { + return useQuery( + swapperBaseQueryKeys.estimateExactInSwap(client?.contractAddress, args), + () => + client + ? client.estimateExactInSwap({ + coinIn: args.coinIn, + denomOut: args.denomOut, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface SwapperBaseRoutesQuery + extends SwapperBaseReactQuery { + args: { + limit?: number + startAfter?: string[][] + } +} +export function useSwapperBaseRoutesQuery({ + client, + args, + options, +}: SwapperBaseRoutesQuery) { + return useQuery( + swapperBaseQueryKeys.routes(client?.contractAddress, args), + () => + client + ? client.routes({ + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface SwapperBaseRouteQuery + extends SwapperBaseReactQuery { + args: { + denomIn: string + denomOut: string + } +} +export function useSwapperBaseRouteQuery({ + client, + args, + options, +}: SwapperBaseRouteQuery) { + return useQuery( + swapperBaseQueryKeys.route(client?.contractAddress, args), + () => + client + ? client.route({ + denomIn: args.denomIn, + denomOut: args.denomOut, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface SwapperBaseConfigQuery + extends SwapperBaseReactQuery {} +export function useSwapperBaseConfigQuery({ + client, + options, +}: SwapperBaseConfigQuery) { + return useQuery( + swapperBaseQueryKeys.config(client?.contractAddress), + () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface SwapperBaseTransferResultMutation { + client: SwapperBaseClient + msg: { + denomIn: string + denomOut: string + recipient: Addr + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useSwapperBaseTransferResultMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.transferResult(msg, fee, memo, funds), + options, + ) +} +export interface SwapperBaseSwapExactInMutation { + client: SwapperBaseClient + msg: { + coinIn: Coin + denomOut: string + slippage: Decimal + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useSwapperBaseSwapExactInMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.swapExactIn(msg, fee, memo, funds), + options, + ) +} +export interface SwapperBaseSetRouteMutation { + client: SwapperBaseClient + msg: { + denomIn: string + denomOut: string + route: Empty + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useSwapperBaseSetRouteMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => client.setRoute(msg, fee, memo, funds), + options, + ) +} +export interface SwapperBaseUpdateConfigMutation { + client: SwapperBaseClient + msg: { + owner?: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useSwapperBaseUpdateConfigMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.updateConfig(msg, fee, memo, funds), + options, + ) +} diff --git a/types/generated/swapper-base/SwapperBase.types.ts b/types/generated/swapper-base/SwapperBase.types.ts new file mode 100644 index 00000000..b6863f76 --- /dev/null +++ b/types/generated/swapper-base/SwapperBase.types.ts @@ -0,0 +1,82 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export interface InstantiateMsg { + owner: string +} +export type ExecuteMsg = + | { + update_config: { + owner?: string | null + } + } + | { + set_route: { + denom_in: string + denom_out: string + route: Empty + } + } + | { + swap_exact_in: { + coin_in: Coin + denom_out: string + slippage: Decimal + } + } + | { + transfer_result: { + denom_in: string + denom_out: string + recipient: Addr + } + } +export type Uint128 = string +export type Decimal = string +export type Addr = string +export interface Empty { + [k: string]: unknown +} +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown +} +export type QueryMsg = + | { + config: {} + } + | { + route: { + denom_in: string + denom_out: string + } + } + | { + routes: { + limit?: number | null + start_after?: [string, string] | null + } + } + | { + estimate_exact_in_swap: { + coin_in: Coin + denom_out: string + } + } +export interface ConfigForString { + owner: string +} +export interface EstimateExactInSwapResponse { + amount: Uint128 +} +export interface RouteResponseForEmpty { + denom_in: string + denom_out: string + route: Empty +} +export type ArrayOfRouteResponseForEmpty = RouteResponseForEmpty[] diff --git a/types/generated/swapper-base/bundle.ts b/types/generated/swapper-base/bundle.ts new file mode 100644 index 00000000..efff3078 --- /dev/null +++ b/types/generated/swapper-base/bundle.ts @@ -0,0 +1,13 @@ +// @ts-nocheck +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.16.5. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import * as _18 from './SwapperBase.types' +import * as _19 from './SwapperBase.client' +import * as _20 from './SwapperBase.react-query' +export namespace contracts { + export const SwapperBase = { ..._18, ..._19, ..._20 } +} diff --git a/types/index.ts b/types/index.ts index 1bd90684..7b49567e 100644 --- a/types/index.ts +++ b/types/index.ts @@ -11,43 +11,43 @@ export enum EthereumChainId { } export enum ChainId { - Mainnet = "injective-1", - Testnet = "injective-888", - Devnet = "injective-777", + Mainnet = 'injective-1', + Testnet = 'injective-888', + Devnet = 'injective-777', } export enum Wallet { - Metamask = "metamask", - Ledger = "ledger", - LedgerLegacy = "ledger-legacy", - Trezor = "trezor", - Keplr = "keplr", - Torus = "torus", - WalletConnect = "wallet-connect", + Metamask = 'metamask', + Ledger = 'ledger', + LedgerLegacy = 'ledger-legacy', + Trezor = 'trezor', + Keplr = 'keplr', + Torus = 'torus', + WalletConnect = 'wallet-connect', } // COSMOS export enum CosmosChainId { - Injective = "injective-1", - Cosmoshub = "cosmoshub-4", - Juno = "juno-1", - Osmosis = "osmosis-1", - Terra = "columbus-5", - TerraUST = "columbus-5", - Chihuahua = "chihuahua-1", - Axelar = "axelar-dojo-1", - Evmos = "evmos_9001-2", - Persistence = "core-1", - Secret = "secret-4", - Stride = "stride-1", + Injective = 'injective-1', + Cosmoshub = 'cosmoshub-4', + Juno = 'juno-1', + Osmosis = 'osmosis-1', + Terra = 'columbus-5', + TerraUST = 'columbus-5', + Chihuahua = 'chihuahua-1', + Axelar = 'axelar-dojo-1', + Evmos = 'evmos_9001-2', + Persistence = 'core-1', + Secret = 'secret-4', + Stride = 'stride-1', } export enum TestnetCosmosChainId { - Injective = "injective-888", - Cosmoshub = "cosmoshub-testnet", + Injective = 'injective-888', + Cosmoshub = 'cosmoshub-testnet', } export enum DevnetCosmosChainId { - Injective = "injective-777", - Injective1 = "injective-777", + Injective = 'injective-777', + Injective1 = 'injective-777', } diff --git a/types/keplr.d.ts b/types/keplr.d.ts index 559e977a..58a9bd33 100644 --- a/types/keplr.d.ts +++ b/types/keplr.d.ts @@ -1,4 +1,4 @@ -import type { Window as KeplrWindow } from "@keplr-wallet/types"; +import type { Window as KeplrWindow } from '@keplr-wallet/types' declare global { interface Window extends KeplrWindow {} diff --git a/types/query-keys-factory.ts b/types/query-keys-factory.ts new file mode 100644 index 00000000..9494ab23 --- /dev/null +++ b/types/query-keys-factory.ts @@ -0,0 +1,7 @@ +export const queryKeys = { + allBalances: (address: string) => ['allBalances', address], + allowedCoins: () => ['allowedCoins'], + creditAccounts: (address: string) => ['creditAccounts', address], + creditAccountsPositions: (accountId: string) => ['creditAccountPositions', accountId], + tokenBalance: (address: string, denom: string) => ['tokenBalance', address, denom], +} diff --git a/utils/address.ts b/utils/address.ts index f09959ac..7771598c 100644 --- a/utils/address.ts +++ b/utils/address.ts @@ -1,18 +1,16 @@ -import { bech32 } from "bech32"; -import { Address } from "ethereumjs-util"; +import { bech32 } from 'bech32' +import { Address } from 'ethereumjs-util' export const getInjectiveAddress = (address: string): string => { - const addressBuffer = Address.fromString(address.toString()).toBuffer(); + const addressBuffer = Address.fromString(address.toString()).toBuffer() - return bech32.encode("inj", bech32.toWords(addressBuffer)); -}; + return bech32.encode('inj', bech32.toWords(addressBuffer)) +} export const getAddressFromInjectiveAddress = (address: string): string => { - if (address.startsWith("0x")) { - return address; + if (address.startsWith('0x')) { + return address } - return `0x${Buffer.from( - bech32.fromWords(bech32.decode(address).words) - ).toString("hex")}`; -}; + return `0x${Buffer.from(bech32.fromWords(bech32.decode(address).words)).toString('hex')}` +} diff --git a/utils/chains.ts b/utils/chains.ts new file mode 100644 index 00000000..634bf408 --- /dev/null +++ b/utils/chains.ts @@ -0,0 +1,55 @@ +export const chainsInfo = { + Injective: { + chainId: 'injective-1', + rpc: 'https://tm.injective.network', + rest: 'https://lcd.injective.network', + stakeCurrency: { + coinDenom: 'INJ', + coinMinimalDenom: 'inj', + coinDecimals: 18, + coinGeckoId: 'injective-protocol', + coinImageUrl: '/tokens/injective.svg', + }, + // works + // rest: "https://lcd.injective.network", + }, + InjectiveTestnet: { + chainId: 'injective-888', + // need to check + rpc: 'https://testnet.tm.injective.dev', + rest: 'https://testnet.lcd.injective.dev', + stakeCurrency: { + coinDenom: 'INJ', + coinMinimalDenom: 'inj', + coinDecimals: 18, + coinGeckoId: 'injective-protocol', + coinImageUrl: '/tokens/injective.svg', + }, + }, + Osmosis: { + chainId: 'osmosis-1', + rpc: 'https://rpc.osmosis.zone', + rest: 'https://lcd.osmosis.zone', + stakeCurrency: { + coinDenom: 'OSMO', + coinMinimalDenom: 'uosmo', + coinDecimals: 6, + coinGeckoId: 'osmosis', + coinImageUrl: '/tokens/osmo.svg', + }, + }, + OsmosisTestnet: { + chainId: 'osmo-test-4', + rpc: 'https://rpc-test.osmosis.zone', + rest: 'https://lcd-test.osmosis.zone', + stakeCurrency: { + coinDenom: 'OSMO', + coinMinimalDenom: 'uosmo', + coinDecimals: 6, + coinGeckoId: 'osmosis', + coinImageUrl: '/tokens/osmo.svg', + }, + }, +} + +export const chain = chainsInfo.OsmosisTestnet diff --git a/utils/contants.ts b/utils/contants.ts new file mode 100644 index 00000000..44ae6526 --- /dev/null +++ b/utils/contants.ts @@ -0,0 +1,13 @@ +import { chain } from 'utils/chains' + +// StdFee +// TODO: decide some strategy to handle fees +export const hardcodedFee = { + amount: [ + { + denom: chain.stakeCurrency.coinMinimalDenom, + amount: '100000', + }, + ], + gas: '750000', +} diff --git a/utils/experimental-chains.ts b/utils/experimental-chains.ts index 7859472d..b9dfcdb5 100644 --- a/utils/experimental-chains.ts +++ b/utils/experimental-chains.ts @@ -1,10 +1,5 @@ -import { Bech32Address } from "@keplr-wallet/cosmos"; -import { - ChainId, - CosmosChainId, - DevnetCosmosChainId, - TestnetCosmosChainId, -} from "types"; +import { Bech32Address } from '@keplr-wallet/cosmos' +import { ChainId, CosmosChainId, DevnetCosmosChainId, TestnetCosmosChainId } from 'types' export const getEndpointsFromChainId = ( chainId: TestnetCosmosChainId | CosmosChainId | ChainId | DevnetCosmosChainId @@ -12,154 +7,154 @@ export const getEndpointsFromChainId = ( switch (chainId) { case CosmosChainId.Cosmoshub: return { - rpc: "https://tm.cosmos.injective.network", - rest: "https://lcd.cosmos.injective.network", - }; + rpc: 'https://tm.cosmos.injective.network', + rest: 'https://lcd.cosmos.injective.network', + } case CosmosChainId.Osmosis: return { - rpc: "https://tm.osmosis.injective.network", - rest: "https://lcd.osmosis.injective.network", - }; + rpc: 'https://tm.osmosis.injective.network', + rest: 'https://lcd.osmosis.injective.network', + } case CosmosChainId.Injective: return { - rpc: "https://tm.injective.network", - rest: "https://lcd.injective.network", - }; + rpc: 'https://tm.injective.network', + rest: 'https://lcd.injective.network', + } case CosmosChainId.Juno: return { - rpc: "https://tm.juno.injective.network", - rest: "https://lcd.juno.injective.network", - }; + rpc: 'https://tm.juno.injective.network', + rest: 'https://lcd.juno.injective.network', + } case CosmosChainId.Terra: return { - rpc: "https://tm.terra.injective.network", - rest: "https://lcd.terra.injective.network", - }; + rpc: 'https://tm.terra.injective.network', + rest: 'https://lcd.terra.injective.network', + } case CosmosChainId.TerraUST: return { - rpc: "https://tm.terra.injective.network", - rest: "https://lcd.terra.injective.network", - }; + rpc: 'https://tm.terra.injective.network', + rest: 'https://lcd.terra.injective.network', + } case TestnetCosmosChainId.Cosmoshub: return { - rpc: "https://testnet.tm.cosmos.injective.dev", - rest: "https://testnet.lcd.cosmos.injective.dev", - }; + rpc: 'https://testnet.tm.cosmos.injective.dev', + rest: 'https://testnet.lcd.cosmos.injective.dev', + } case TestnetCosmosChainId.Injective: return { - rpc: "https://testnet.tm.injective.dev", - rest: "https://testnet.lcd.injective.dev", - }; + rpc: 'https://testnet.tm.injective.dev', + rest: 'https://testnet.lcd.injective.dev', + } case DevnetCosmosChainId.Injective: return { - rpc: "https://devnet.tm.injective.dev", - rest: "https://devnet.lcd.injective.dev", - }; + rpc: 'https://devnet.tm.injective.dev', + rest: 'https://devnet.lcd.injective.dev', + } case CosmosChainId.Chihuahua: return { - rpc: "https://rpc.chihuahua.wtf", - rest: "https://api.chihuahua.wtf", - }; + rpc: 'https://rpc.chihuahua.wtf', + rest: 'https://api.chihuahua.wtf', + } case CosmosChainId.Axelar: return { - rpc: "https://tm.axelar.injective.network", - rest: "https://lcd.axelar.injective.network", - }; + rpc: 'https://tm.axelar.injective.network', + rest: 'https://lcd.axelar.injective.network', + } case CosmosChainId.Evmos: return { - rpc: "https://tm.evmos.injective.network", - rest: "https://lcd.evmos.injective.network", - }; + rpc: 'https://tm.evmos.injective.network', + rest: 'https://lcd.evmos.injective.network', + } case CosmosChainId.Persistence: return { - rpc: "https://tm.persistence.injective.network", - rest: "https://lcd.persistence.injective.network", - }; + rpc: 'https://tm.persistence.injective.network', + rest: 'https://lcd.persistence.injective.network', + } case CosmosChainId.Secret: return { - rpc: "https://tm.secret.injective.network", - rest: "https://lcd.secret.injective.network", - }; + rpc: 'https://tm.secret.injective.network', + rest: 'https://lcd.secret.injective.network', + } case CosmosChainId.Stride: return { - rpc: "https://tm.stride.injective.network", - rest: "https://lcd.stride.injective.network", - }; + rpc: 'https://tm.stride.injective.network', + rest: 'https://lcd.stride.injective.network', + } default: - throw new Error(`Endpoints for ${chainId} not found`); + throw new Error(`Endpoints for ${chainId} not found`) } -}; +} export const experimentalChainsConfig = { [TestnetCosmosChainId.Cosmoshub]: { ...getEndpointsFromChainId(TestnetCosmosChainId.Cosmoshub), rpcConfig: undefined, restConfig: undefined, - chainId: "cosmoshub-testnet", - chainName: "Cosmos Testnet", + chainId: 'cosmoshub-testnet', + chainName: 'Cosmos Testnet', stakeCurrency: { - coinDenom: "UPHOTON", - coinMinimalDenom: "uphoton", + coinDenom: 'UPHOTON', + coinMinimalDenom: 'uphoton', coinDecimals: 6, - coinGeckoId: "cosmos", + coinGeckoId: 'cosmos', }, - walletUrl: "https://wallet.keplr.app/#/cosmoshub/stake", - walletUrlForStaking: "https://wallet.keplr.app/#/cosmoshub/stake", + walletUrl: 'https://wallet.keplr.app/#/cosmoshub/stake', + walletUrlForStaking: 'https://wallet.keplr.app/#/cosmoshub/stake', bip44: { coinType: 118, }, - bech32Config: Bech32Address.defaultBech32Config("cosmos"), + bech32Config: Bech32Address.defaultBech32Config('cosmos'), currencies: [ { - coinDenom: "UPHOTON", - coinMinimalDenom: "uphoton", + coinDenom: 'UPHOTON', + coinMinimalDenom: 'uphoton', coinDecimals: 6, - coinGeckoId: "cosmos", + coinGeckoId: 'cosmos', }, ], feeCurrencies: [ { - coinDenom: "UPHOTON", - coinMinimalDenom: "uphoton", + coinDenom: 'UPHOTON', + coinMinimalDenom: 'uphoton', coinDecimals: 6, - coinGeckoId: "cosmos", + coinGeckoId: 'cosmos', }, ], coinType: 118, - features: ["ibc-transfer"], + features: ['ibc-transfer'], }, [TestnetCosmosChainId.Injective]: { ...getEndpointsFromChainId(TestnetCosmosChainId.Injective), rpcConfig: undefined, restConfig: undefined, - chainId: "injective-888", - chainName: "Injective Testnet", + chainId: 'injective-888', + chainName: 'Injective Testnet', stakeCurrency: { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, - walletUrl: "https://hub.injective.dev/", - walletUrlForStaking: "https://hub.injective.dev/", + walletUrl: 'https://hub.injective.dev/', + walletUrlForStaking: 'https://hub.injective.dev/', bip44: { coinType: 60, }, - bech32Config: Bech32Address.defaultBech32Config("inj"), + bech32Config: Bech32Address.defaultBech32Config('inj'), currencies: [ { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, ], feeCurrencies: [ { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, ], gasPriceStep: { @@ -168,40 +163,40 @@ export const experimentalChainsConfig = { high: 40000000000, }, coinType: 60, - features: ["ibc-transfer", "ibc-go", "eth-address-gen", "eth-key-sign"], + features: ['ibc-transfer', 'ibc-go', 'eth-address-gen', 'eth-key-sign'], }, [DevnetCosmosChainId.Injective]: { ...getEndpointsFromChainId(DevnetCosmosChainId.Injective), rpcConfig: undefined, restConfig: undefined, - chainId: "injective-777", - chainName: "Injective - Devnet", + chainId: 'injective-777', + chainName: 'Injective - Devnet', stakeCurrency: { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, - walletUrl: "https://hub.injective.dev/", - walletUrlForStaking: "https://hub.injective.dev/", + walletUrl: 'https://hub.injective.dev/', + walletUrlForStaking: 'https://hub.injective.dev/', bip44: { coinType: 60, }, - bech32Config: Bech32Address.defaultBech32Config("inj"), + bech32Config: Bech32Address.defaultBech32Config('inj'), currencies: [ { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, ], feeCurrencies: [ { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, ], gasPriceStep: { @@ -210,40 +205,40 @@ export const experimentalChainsConfig = { high: 40000000000, }, coinType: 60, - features: ["ibc-transfer", "ibc-go", "eth-address-gen", "eth-key-sign"], + features: ['ibc-transfer', 'ibc-go', 'eth-address-gen', 'eth-key-sign'], }, [CosmosChainId.Injective]: { ...getEndpointsFromChainId(CosmosChainId.Injective), rpcConfig: undefined, restConfig: undefined, - chainId: "injective-1", - chainName: "Injective - Beta", + chainId: 'injective-1', + chainName: 'Injective - Beta', stakeCurrency: { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, - walletUrl: "https://hub.injective.network/", - walletUrlForStaking: "https://hub.injective.network/", + walletUrl: 'https://hub.injective.network/', + walletUrlForStaking: 'https://hub.injective.network/', bip44: { coinType: 60, }, - bech32Config: Bech32Address.defaultBech32Config("inj"), + bech32Config: Bech32Address.defaultBech32Config('inj'), currencies: [ { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, ], feeCurrencies: [ { - coinDenom: "INJ", - coinMinimalDenom: "inj", + coinDenom: 'INJ', + coinMinimalDenom: 'inj', coinDecimals: 18, - coinGeckoId: "injective-protocol", + coinGeckoId: 'injective-protocol', }, ], gasPriceStep: { @@ -251,52 +246,52 @@ export const experimentalChainsConfig = { average: 25000000000, high: 40000000000, }, - features: ["ibc-transfer", "ibc-go", "eth-address-gen", "eth-key-sign"], + features: ['ibc-transfer', 'ibc-go', 'eth-address-gen', 'eth-key-sign'], beta: true, }, [CosmosChainId.Terra]: { ...getEndpointsFromChainId(CosmosChainId.Terra), rpcConfig: undefined, restConfig: undefined, - chainId: "columbus-5", - chainName: "Terra", + chainId: 'columbus-5', + chainName: 'Terra', stakeCurrency: { - coinDenom: "LUNA", - coinMinimalDenom: "uluna", + coinDenom: 'LUNA', + coinMinimalDenom: 'uluna', coinDecimals: 6, - coinGeckoId: "terra-luna", + coinGeckoId: 'terra-luna', }, - walletUrl: "https://station.terra.money/wallet", - walletUrlForStaking: "https://station.terra.money/wallet", + walletUrl: 'https://station.terra.money/wallet', + walletUrlForStaking: 'https://station.terra.money/wallet', bip44: { coinType: 118, }, - bech32Config: Bech32Address.defaultBech32Config("terra"), + bech32Config: Bech32Address.defaultBech32Config('terra'), currencies: [ { - coinDenom: "LUNA", - coinMinimalDenom: "uluna", + coinDenom: 'LUNA', + coinMinimalDenom: 'uluna', coinDecimals: 6, - coinGeckoId: "terra-luna", + coinGeckoId: 'terra-luna', }, { - coinDenom: "UST", - coinMinimalDenom: "uusd", - coinGeckoId: "terrausd", + coinDenom: 'UST', + coinMinimalDenom: 'uusd', + coinGeckoId: 'terrausd', coinDecimals: 6, }, ], feeCurrencies: [ { - coinDenom: "LUNA", - coinMinimalDenom: "uluna", - coinGeckoId: "terra-luna", + coinDenom: 'LUNA', + coinMinimalDenom: 'uluna', + coinGeckoId: 'terra-luna', coinDecimals: 6, }, { - coinDenom: "UST", - coinMinimalDenom: "uusd", - coinGeckoId: "terrausd", + coinDenom: 'UST', + coinMinimalDenom: 'uusd', + coinGeckoId: 'terrausd', coinDecimals: 6, }, ], @@ -306,32 +301,32 @@ export const experimentalChainsConfig = { average: 0.3, high: 0.04, }, - features: ["ibc-transfer"], + features: ['ibc-transfer'], }, [CosmosChainId.Chihuahua]: { ...getEndpointsFromChainId(CosmosChainId.Chihuahua), - chainId: "chihuahua-1", - chainName: "Chihuahua", + chainId: 'chihuahua-1', + chainName: 'Chihuahua', stakeCurrency: { - coinDenom: "HUAHUA", - coinMinimalDenom: "uhuahua", + coinDenom: 'HUAHUA', + coinMinimalDenom: 'uhuahua', coinDecimals: 6, }, bip44: { coinType: 118, }, - bech32Config: Bech32Address.defaultBech32Config("chihuahua"), + bech32Config: Bech32Address.defaultBech32Config('chihuahua'), currencies: [ { - coinDenom: "HUAHUA", - coinMinimalDenom: "uhuahua", + coinDenom: 'HUAHUA', + coinMinimalDenom: 'uhuahua', coinDecimals: 6, }, ], feeCurrencies: [ { - coinDenom: "HUAHUA", - coinMinimalDenom: "uhuahua", + coinDenom: 'HUAHUA', + coinMinimalDenom: 'uhuahua', coinDecimals: 6, }, ], @@ -340,10 +335,9 @@ export const experimentalChainsConfig = { average: 0.03, high: 0.035, }, - features: ["ibc-transfer", "ibc-go"], + features: ['ibc-transfer', 'ibc-go'], }, -} as Record; +} as Record -export const getExperimentalChainConfigBasedOnChainId = ( - chainId: string -): any | undefined => experimentalChainsConfig[chainId]; +export const getExperimentalChainConfigBasedOnChainId = (chainId: string): any | undefined => + experimentalChainsConfig[chainId] diff --git a/utils/formatters.ts b/utils/formatters.ts index 8d47265c..ba328841 100644 --- a/utils/formatters.ts +++ b/utils/formatters.ts @@ -1,17 +1,17 @@ -export const formatWalletAddress = ( - address: string, - substrLength = 6 -): string => { +export const formatWalletAddress = (address: string, substrLength = 6): string => { if (address.length <= 10) { - return address; + return address } return `${address.slice(0, substrLength)}...${address.slice( address.length - substrLength, address.length - )}`; -}; + )}` +} export const formatCurrency = (value: string | number) => { - return Number(value).toLocaleString(); -}; + return Number(value).toLocaleString('en-US', { + style: 'currency', + currency: 'USD', + }) +} diff --git a/utils/tokens.ts b/utils/tokens.ts new file mode 100644 index 00000000..340c9752 --- /dev/null +++ b/utils/tokens.ts @@ -0,0 +1,9 @@ +import tokenInfo from 'config/tokenInfo' + +export const getTokenSymbol = (denom: string) => { + return tokenInfo[denom]?.symbol ?? denom +} + +export const getTokenDecimals = (denom: string) => { + return tokenInfo[denom]?.decimals ?? 6 +} diff --git a/yarn.lock b/yarn.lock index 6d361120..ca77083b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -336,6 +336,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.13.10": + version "7.19.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.19.0.tgz#22b11c037b094d27a8a2504ea4dcff00f50e2259" + integrity sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.18.10", "@babel/template@^7.18.6": version "7.18.10" resolved "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz" @@ -370,6 +377,41 @@ "@babel/helper-validator-identifier" "^7.18.6" to-fast-properties "^2.0.0" +"@confio/ics23@^0.6.8": + version "0.6.8" + resolved "https://registry.yarnpkg.com/@confio/ics23/-/ics23-0.6.8.tgz#2a6b4f1f2b7b20a35d9a0745bb5a446e72930b3d" + integrity sha512-wB6uo+3A50m0sW/EWcU64xpV/8wShZ6bMTa7pF8eYsTrSkQA7oLUIJcs/wb8g4y2Oyq701BaGiO6n/ak5WXO1w== + dependencies: + "@noble/hashes" "^1.0.0" + protobufjs "^6.8.8" + +"@cosmjs/amino@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.29.0.tgz#35873a580a6102e48415ed2b5b97477f146fb50d" + integrity sha512-/ZUVx6nRN5YE36H3SDq9+i8g2nZ8DJQnN9fVRC8rSHQKauNkoEuK4NxTNcQ2o2EBLUT0kyYAFY2550HVsPMrgw== + dependencies: + "@cosmjs/crypto" "^0.29.0" + "@cosmjs/encoding" "^0.29.0" + "@cosmjs/math" "^0.29.0" + "@cosmjs/utils" "^0.29.0" + +"@cosmjs/cosmwasm-stargate@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.29.0.tgz#dea1c16fe80daf14072c3796574fe8cb34a3729b" + integrity sha512-KoNc0XpK6Gh4CITpyMXIuhIdZu59lF3wO1pHabeEZ0v7w3U0tFdCbDppe2RufCkERDZZCGFxnoRmr0KL2wK6Tw== + dependencies: + "@cosmjs/amino" "^0.29.0" + "@cosmjs/crypto" "^0.29.0" + "@cosmjs/encoding" "^0.29.0" + "@cosmjs/math" "^0.29.0" + "@cosmjs/proto-signing" "^0.29.0" + "@cosmjs/stargate" "^0.29.0" + "@cosmjs/tendermint-rpc" "^0.29.0" + "@cosmjs/utils" "^0.29.0" + cosmjs-types "^0.5.0" + long "^4.0.0" + pako "^2.0.2" + "@cosmjs/crypto@^0.24.1": version "0.24.1" resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.24.1.tgz#62da59c32b26344f26b10dd31a02b93655586d04" @@ -388,6 +430,19 @@ sha.js "^2.4.11" unorm "^1.5.0" +"@cosmjs/crypto@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.29.0.tgz#c914424a8b538f6624e505bc2015a71e3977c2fb" + integrity sha512-MPJoebRGh7AcZgbfR25ci7iV+XzJiKwVq4wL8n6M5P2QdrIv7DqqniyFXcBbn9dQjMLMHnOSgT9LRv+VXzUVCA== + dependencies: + "@cosmjs/encoding" "^0.29.0" + "@cosmjs/math" "^0.29.0" + "@cosmjs/utils" "^0.29.0" + "@noble/hashes" "^1" + bn.js "^5.2.0" + elliptic "^6.5.3" + libsodium-wrappers "^0.7.6" + "@cosmjs/encoding@^0.20.0": version "0.20.1" resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.20.1.tgz#1d1162b3eca51b7244cd45102e313612cea77281" @@ -406,6 +461,23 @@ bech32 "^1.1.4" readonly-date "^1.0.0" +"@cosmjs/encoding@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.29.0.tgz#75b1b41a2f31f71fcb0982cd1b210d6410739fd0" + integrity sha512-6HDBtid/YLbyXapY6PdMMIigAtGKyD1w0dUCLU1dOIkPf1q3y43kqoA7WnLkRw0g0/lZY1VGM2fX+2RWU0wxYg== + dependencies: + base64-js "^1.3.0" + bech32 "^1.1.4" + readonly-date "^1.0.0" + +"@cosmjs/json-rpc@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/json-rpc/-/json-rpc-0.29.0.tgz#481f282bcb3457c71f393342691e957a4fa56535" + integrity sha512-noCt91X+dSYjW1BYbp5jFaYaA/PWIQFXOgl4ZDW0ecGOAj8xh6/D/Vd8bDO97CQgJ1KVw0pyAqVhmrBOBUo1sA== + dependencies: + "@cosmjs/stream" "^0.29.0" + xstream "^11.14.0" + "@cosmjs/launchpad@^0.24.0-alpha.25", "@cosmjs/launchpad@^0.24.1": version "0.24.1" resolved "https://registry.yarnpkg.com/@cosmjs/launchpad/-/launchpad-0.24.1.tgz#fe7e80734dfd60ea093429a646d7a38634c70134" @@ -432,6 +504,13 @@ dependencies: bn.js "^4.11.8" +"@cosmjs/math@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.29.0.tgz#2c34f96d94055fe82ca310bec7b2d8a9f1c507cb" + integrity sha512-ufRRmyDQtJUrH8r1V4N7Q6rTOk9ZX7XIXjJto7cfXP8kcxm7IJXKYk+r0EfDnNHFkxTidYvW/1YXeeNoy8xZYw== + dependencies: + bn.js "^5.2.0" + "@cosmjs/proto-signing@^0.24.0-alpha.25": version "0.24.1" resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.24.1.tgz#4ee38d4e0d29c626344fb832235fda8e8d645c28" @@ -441,6 +520,70 @@ long "^4.0.0" protobufjs "~6.10.2" +"@cosmjs/proto-signing@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.29.0.tgz#4d9c10fc3a5c64b454bd2d9b407861fcffdfbbe0" + integrity sha512-zAdgDz5vRGAfJ5yyKYuTL7qg5UNUT7v4iV1/ZP8ZQn2fLh9QVxViAIovF4r/Y3EEI4JS5uYj/f8UeHMHQSu8hw== + dependencies: + "@cosmjs/amino" "^0.29.0" + "@cosmjs/crypto" "^0.29.0" + "@cosmjs/encoding" "^0.29.0" + "@cosmjs/math" "^0.29.0" + "@cosmjs/utils" "^0.29.0" + cosmjs-types "^0.5.0" + long "^4.0.0" + +"@cosmjs/socket@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/socket/-/socket-0.29.0.tgz#6f8f56799e69ead02f9ffe8925c782804635ac89" + integrity sha512-y7cOBp6YJ2Sn/DZne1eiJ6PVkgZlAi48d0Bz6hVuZ6CliutG0BzM/F3bSLxdw8m2fXNU+lYsi4uLPd0epf5Hig== + dependencies: + "@cosmjs/stream" "^0.29.0" + isomorphic-ws "^4.0.1" + ws "^7" + xstream "^11.14.0" + +"@cosmjs/stargate@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.29.0.tgz#55263ed9d414f2c3073a451527576e4c3d6f04a6" + integrity sha512-BsV3iA3vMclMm/B1LYO0djBYCALr/UIvL6u9HGvM7QvpdtpQiAvskuS4PieVO/gtF9iCCBJLPqa0scwFIgvDyg== + dependencies: + "@confio/ics23" "^0.6.8" + "@cosmjs/amino" "^0.29.0" + "@cosmjs/encoding" "^0.29.0" + "@cosmjs/math" "^0.29.0" + "@cosmjs/proto-signing" "^0.29.0" + "@cosmjs/stream" "^0.29.0" + "@cosmjs/tendermint-rpc" "^0.29.0" + "@cosmjs/utils" "^0.29.0" + cosmjs-types "^0.5.0" + long "^4.0.0" + protobufjs "~6.11.3" + xstream "^11.14.0" + +"@cosmjs/stream@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.29.0.tgz#df2d7ea23293170bc192e91c0fa3e9f8d993b7cc" + integrity sha512-KAJ9sNoXhF19wtkoJf3O2y4YXfklDZgmXhDotgAejLrw2ixoVfTodMHvnl6tpw3ZnmXKibTfUaNXWZD++sG6uQ== + dependencies: + xstream "^11.14.0" + +"@cosmjs/tendermint-rpc@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.29.0.tgz#db71e743d2ee8dde706c09bc92ac47cc6197f672" + integrity sha512-G+42oGh+tw8/KV0gLAGzNCTe/6mkf7VUE5noSTbsxbeliFR7Lt4i6H2aqvWzmlZFeRxunR7AsQr4wakvlVNWyg== + dependencies: + "@cosmjs/crypto" "^0.29.0" + "@cosmjs/encoding" "^0.29.0" + "@cosmjs/json-rpc" "^0.29.0" + "@cosmjs/math" "^0.29.0" + "@cosmjs/socket" "^0.29.0" + "@cosmjs/stream" "^0.29.0" + "@cosmjs/utils" "^0.29.0" + axios "^0.21.2" + readonly-date "^1.0.0" + xstream "^11.14.0" + "@cosmjs/utils@^0.20.0": version "0.20.1" resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.20.1.tgz#4d239b7d93c15523cdf109f225cbf61326fb69cd" @@ -451,6 +594,11 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.24.1.tgz#0adfefe63b7f17222bc2bc12f71296f35e7ad378" integrity sha512-VA3WFx1lMFb7esp9BqHWkDgMvHoA3D9w+uDRvWhVRpUpDc7RYHxMbWExASjz+gNblTCg556WJGzF64tXnf9tdQ== +"@cosmjs/utils@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.29.0.tgz#0a61e6d608e9f6f89a278cc71f4e7cee01199657" + integrity sha512-NiJk3ISX+FU1cQcTTgmJcY84A8mV/p8L5CRewp/2jc/lUmo8j9lMGbX17U7NxVQ9RX5RmrwgdjYnBASzhRCVmA== + "@eslint/eslintrc@^1.3.1": version "1.3.1" resolved "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz" @@ -770,6 +918,11 @@ resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.2.5.tgz#20fed129b04a0d3f632c6d0de135345bb623b1e4" integrity sha512-7h5/ahY7NeaO2xygqVrSG/Y8Vs4cdjxIjowTZ5W6CKoTKn7tmnuxlUc2h74x06FKmbhAd9agOjr/AOKyxYYm9Q== +"@noble/hashes@^1", "@noble/hashes@^1.0.0": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183" + integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" @@ -844,6 +997,123 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== +"@radix-ui/number@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/number/-/number-1.0.0.tgz#4c536161d0de750b3f5d55860fc3de46264f897b" + integrity sha512-Ofwh/1HX69ZfJRiRBMTy7rgjAzHmwe4kW9C9Y99HTRUcYLUuVT0KESFj15rPjRgKJs20GPq8Bm5aEDJ8DuA3vA== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/primitive@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/primitive/-/primitive-1.0.0.tgz#e1d8ef30b10ea10e69c76e896f608d9276352253" + integrity sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-collection@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-collection/-/react-collection-1.0.0.tgz#0ec4c72fabd35a03b5787075ac799e3b17ca5710" + integrity sha512-8i1pf5dKjnq90Z8udnnXKzdCEV3/FYrfw0n/b6NvB6piXEn3fO1bOh7HBcpG8XrnIXzxlYu2oCcR38QpyLS/mg== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-compose-refs" "1.0.0" + "@radix-ui/react-context" "1.0.0" + "@radix-ui/react-primitive" "1.0.0" + "@radix-ui/react-slot" "1.0.0" + +"@radix-ui/react-compose-refs@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.0.tgz#37595b1f16ec7f228d698590e78eeed18ff218ae" + integrity sha512-0KaSv6sx787/hK3eF53iOkiSLwAGlFMx5lotrqD2pTjB18KbybKoEIgkNZTKC60YECDQTKGTRcDBILwZVqVKvA== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-context@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-context/-/react-context-1.0.0.tgz#f38e30c5859a9fb5e9aa9a9da452ee3ed9e0aee0" + integrity sha512-1pVM9RfOQ+n/N5PJK33kRSKsr1glNxomxONs5c49MliinBY6Yw2Q995qfBUUo0/Mbg05B/sGA0gkgPI7kmSHBg== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-direction@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-direction/-/react-direction-1.0.0.tgz#a2e0b552352459ecf96342c79949dd833c1e6e45" + integrity sha512-2HV05lGUgYcA6xgLQ4BKPDmtL+QbIZYH5fCOTAOOcJ5O0QbWS3i9lKaurLzliYUDhORI2Qr3pyjhJh44lKA3rQ== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-primitive@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-1.0.0.tgz#376cd72b0fcd5e0e04d252ed33eb1b1f025af2b0" + integrity sha512-EyXe6mnRlHZ8b6f4ilTDrXmkLShICIuOTTj0GX4w1rp+wSxf3+TD05u1UOITC8VsJ2a9nwHvdXtOXEOl0Cw/zQ== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-slot" "1.0.0" + +"@radix-ui/react-slider@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-slider/-/react-slider-1.0.0.tgz#4cabadd243aa088eb45ac710cd7cdc518fafb07e" + integrity sha512-LMZET7vn7HYwYSjsc9Jcen8Vn4cJXZZxQT7T+lGlqp+F+FofX+H86TBF2yDq+L51d99f1KLEsflTGBz9WRLSig== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/number" "1.0.0" + "@radix-ui/primitive" "1.0.0" + "@radix-ui/react-collection" "1.0.0" + "@radix-ui/react-compose-refs" "1.0.0" + "@radix-ui/react-context" "1.0.0" + "@radix-ui/react-direction" "1.0.0" + "@radix-ui/react-primitive" "1.0.0" + "@radix-ui/react-use-controllable-state" "1.0.0" + "@radix-ui/react-use-layout-effect" "1.0.0" + "@radix-ui/react-use-previous" "1.0.0" + "@radix-ui/react-use-size" "1.0.0" + +"@radix-ui/react-slot@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.0.0.tgz#7fa805b99891dea1e862d8f8fbe07f4d6d0fd698" + integrity sha512-3mrKauI/tWXo1Ll+gN5dHcxDPdm/Df1ufcDLCecn+pnCIVcdWE7CujXo8QaXOWRJyZyQWWbpB8eFwHzWXlv5mQ== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-compose-refs" "1.0.0" + +"@radix-ui/react-use-callback-ref@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.0.tgz#9e7b8b6b4946fe3cbe8f748c82a2cce54e7b6a90" + integrity sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-use-controllable-state@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.0.0.tgz#a64deaafbbc52d5d407afaa22d493d687c538b7f" + integrity sha512-FohDoZvk3mEXh9AWAVyRTYR4Sq7/gavuofglmiXB2g1aKyboUD4YtgWxKj8O5n+Uak52gXQ4wKz5IFST4vtJHg== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-use-callback-ref" "1.0.0" + +"@radix-ui/react-use-layout-effect@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.0.0.tgz#2fc19e97223a81de64cd3ba1dc42ceffd82374dc" + integrity sha512-6Tpkq+R6LOlmQb1R5NNETLG0B4YP0wc+klfXafpUCj6JGyaUc8il7/kUZ7m59rGbXGczE9Bs+iz2qloqsZBduQ== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-use-previous@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-use-previous/-/react-use-previous-1.0.0.tgz#e48a69c3a7d8078a967084038df66d0d181c56ac" + integrity sha512-RG2K8z/K7InnOKpq6YLDmT49HGjNmrK+fr82UCVKT2sW0GYfVnYp4wZWBooT/EYfQ5faA9uIjvsuMMhH61rheg== + dependencies: + "@babel/runtime" "^7.13.10" + +"@radix-ui/react-use-size@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@radix-ui/react-use-size/-/react-use-size-1.0.0.tgz#a0b455ac826749419f6354dc733e2ca465054771" + integrity sha512-imZ3aYcoYCKhhgNpkNDh/aTiU05qw9hX+HHI1QDBTyIlcFjgeFlKKySNGMwTp7nYFLQg/j0VA2FmCY4WPDDHMg== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-use-layout-effect" "1.0.0" + "@rollup/plugin-sucrase@4.0.4": version "4.0.4" resolved "https://registry.npmjs.org/@rollup/plugin-sucrase/-/plugin-sucrase-4.0.4.tgz" @@ -1360,7 +1630,7 @@ axios@0.21.1: dependencies: follow-redirects "^1.10.0" -axios@^0.21.1: +axios@^0.21.1, axios@^0.21.2: version "0.21.4" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== @@ -1803,6 +2073,14 @@ core-util-is@~1.0.0: resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== +cosmjs-types@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/cosmjs-types/-/cosmjs-types-0.5.1.tgz#f9bc35e78c32b687fb6018dc573eb454b3ae2587" + integrity sha512-NcC58xUIVLlKdIimWWQAmSlmCjiMrJnuHf4i3LiD8PCextfHR0fT3V5/WlXZZreyMgdmh6ML1zPUfGTbbo3Z5g== + dependencies: + long "^4.0.0" + protobufjs "~6.11.2" + create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" @@ -2646,6 +2924,13 @@ globals@^13.15.0: dependencies: type-fest "^0.20.2" +globalthis@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" + integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== + dependencies: + define-properties "^1.1.3" + globby@^11.1.0: version "11.1.0" resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz" @@ -3058,6 +3343,11 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== +isomorphic-ws@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" + integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== + js-crypto-env@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/js-crypto-env/-/js-crypto-env-0.3.2.tgz#02195723469da14449338ca2789fd7ff6784c533" @@ -3724,6 +4014,11 @@ pako@1.0.11: resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== +pako@^2.0.2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.0.4.tgz#6cebc4bbb0b6c73b0d5b8d7e8476e2b2fbea576d" + integrity sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg== + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz" @@ -3900,7 +4195,7 @@ prop-types@^15.8.1: object-assign "^4.1.1" react-is "^16.13.1" -protobufjs@6.11.3, protobufjs@^6.11.2: +protobufjs@6.11.3, protobufjs@^6.11.2, protobufjs@^6.8.8, protobufjs@~6.11.2, protobufjs@~6.11.3: version "6.11.3" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.3.tgz#637a527205a35caa4f3e2a9a4a13ddffe0e7af74" integrity sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg== @@ -4519,6 +4814,11 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +symbol-observable@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-2.0.3.tgz#5b521d3d07a43c351055fa43b8355b62d33fd16a" + integrity sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA== + tailwindcss@^3.1.8: version "3.1.8" resolved "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz" @@ -4822,6 +5122,19 @@ write-file-atomic@^2.3.0: imurmurhash "^0.1.4" signal-exit "^3.0.2" +ws@^7: + version "7.5.9" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" + integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== + +xstream@^11.14.0: + version "11.14.0" + resolved "https://registry.yarnpkg.com/xstream/-/xstream-11.14.0.tgz#2c071d26b18310523b6877e86b4e54df068a9ae5" + integrity sha512-1bLb+kKKtKPbgTK6i/BaoAn03g47PpFstlbe1BA+y3pNS/LfvcaghS5BFf9+EE1J+KwSQsEpfJvFN5GqFtiNmw== + dependencies: + globalthis "^1.0.1" + symbol-observable "^2.0.3" + xtend@^4.0.2: version "4.0.2" resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz"