From 6bcdc6c25ef2b7ce8e0710ed792e624619356bfd Mon Sep 17 00:00:00 2001 From: trevorjtclarke Date: Thu, 25 Apr 2024 11:46:09 -0700 Subject: [PATCH] remove changes to example --- example/next/pages/index.tsx | 12 ++----- example/next/ui/chain-signer.tsx | 51 ------------------------------ example/next/ui/chain-switcher.tsx | 12 +------ example/next/utils/graz.ts | 3 +- 4 files changed, 4 insertions(+), 74 deletions(-) delete mode 100644 example/next/ui/chain-signer.tsx diff --git a/example/next/pages/index.tsx b/example/next/pages/index.tsx index b374d9fd..cc23a7ad 100644 --- a/example/next/pages/index.tsx +++ b/example/next/pages/index.tsx @@ -1,10 +1,9 @@ import { Center, HStack, Spacer, Stack, Text, useColorMode } from "@chakra-ui/react"; -import { useAccount, getRecentChainIds, useCapsule } from "graz"; +import { useAccount, useCapsule } from "graz"; import type { NextPage } from "next"; import dynamic from "next/dynamic"; import { BalanceList } from "ui/balance-list"; import { ChainSwitcher } from "ui/chain-switcher"; -import { ChainSigner } from "ui/chain-signer"; import { ConnectButton } from "ui/connect-button"; import { ConnectStatus } from "ui/connect-status"; import { ToggleTheme } from "ui/toggle-theme"; @@ -15,16 +14,11 @@ const LeapSocialLogin = dynamic( ); const HomePage: NextPage = () => { - const recentChainIds = getRecentChainIds() || []; - const latestChainId = recentChainIds[recentChainIds.length - 1] || 'cosmoshub-4'; - const { data: accountData } = useAccount({ - chainId: latestChainId, - multiChain: false, + chainId: "cosmoshub-4", }); const { client, modalState, onAfterLoginSuccessful, setModalState, onLoginFailure } = useCapsule(); const { colorMode } = useColorMode(); - return (
@@ -40,8 +34,6 @@ const HomePage: NextPage = () => { Wallet address: {accountData.bech32Address} - {latestChainId && } - diff --git a/example/next/ui/chain-signer.tsx b/example/next/ui/chain-signer.tsx deleted file mode 100644 index 264767bf..00000000 --- a/example/next/ui/chain-signer.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { Button } from "@chakra-ui/react"; -import { useAccount, useActiveChains, getRecentChainIds, useCosmWasmSigningClient } from "graz"; -import type { ChainInfo } from "@keplr-wallet/types"; -import { GasPrice } from '@cosmjs/stargate'; -import type { FC } from "react"; - -export const ChainSigner: FC = () => { - const activeChains: ChainInfo[] | undefined = useActiveChains(); - const recentChainIds = getRecentChainIds() || []; - const latestChainId = recentChainIds[recentChainIds.length - 1] || 'cosmoshub-4'; - if (!activeChains) return; - const activeChain = activeChains?.find(chain => chain.chainId === latestChainId); - if (!activeChain) return; - const { coinMinimalDenom: coinAmountDenom } = activeChain?.currencies[0]; - - const { data: accountData } = useAccount({ - chainId: latestChainId, - multiChain: false, - }); - - const { data: signingCosmwasmClient } = useCosmWasmSigningClient({ - chainId: latestChainId, - opts: { - gasPrice: GasPrice.fromString('0ustars'), - }, - }); - - const signTx = async () => { - // Send 1 micro amount of the current chain account - const { coinMinimalDenom } = activeChain.feeCurrencies[0]; - const msgs = [{"typeUrl":"/cosmos.bank.v1beta1.MsgSend","value":{"fromAddress":accountData.bech32Address,"toAddress":accountData.bech32Address,"amount":[{"amount":"1","denom":coinAmountDenom}]}}] - const fee = { - amount: [{amount: '80828', denom: coinMinimalDenom}], - gas: '80828', - }; - - try { - await signingCosmwasmClient - .signAndBroadcast(accountData.bech32Address, msgs, fee, '') - .then((res: any) => { - console.log('SUCCESS', res); - }) - } catch (error: unknown) { - console.log('ERROR', error); - } - } - - return ( - - ); -}; diff --git a/example/next/ui/chain-switcher.tsx b/example/next/ui/chain-switcher.tsx index e7633bf7..149624e6 100644 --- a/example/next/ui/chain-switcher.tsx +++ b/example/next/ui/chain-switcher.tsx @@ -1,6 +1,6 @@ import { Button, ButtonGroup, Stack, Text } from "@chakra-ui/react"; import { useAccount, useSuggestChainAndConnect } from "graz"; -import { osmosistestnet, stargaze } from "graz/chains"; +import { osmosistestnet } from "graz/chains"; import type { FC } from "react"; export const ChainSwitcher: FC = () => { @@ -29,16 +29,6 @@ export const ChainSwitcher: FC = () => { > {osmosistestnet.chainId} - ); diff --git a/example/next/utils/graz.ts b/example/next/utils/graz.ts index ad293b3c..85444a1e 100644 --- a/example/next/utils/graz.ts +++ b/example/next/utils/graz.ts @@ -1,7 +1,6 @@ -import { cosmoshub, osmosistestnet, stargaze } from "graz/chains"; +import { cosmoshub, osmosistestnet } from "graz/chains"; export const chains = [ { ...cosmoshub, rpc: "https://rpc.cosmos.directory/cosmoshub", rest: "https://rest.cosmos.directory/cosmoshub" }, osmosistestnet, - stargaze, ];