Skip to content

Commit

Permalink
Revert "checking in"
Browse files Browse the repository at this point in the history
This reverts commit 09fef5c.
  • Loading branch information
thal0x committed Sep 27, 2023
1 parent 09fef5c commit bcdebc0
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 3,035 deletions.
3,126 changes: 193 additions & 2,933 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@rainbow-me/rainbowkit": "^1.0.11",
"@skip-router/core": "^0.1.0-rc1",
"@skip-router/core": "^0.0.7",
"@tanstack/react-query": "^4.29.5",
"@types/node": "20.1.2",
"@types/react": "18.2.6",
Expand All @@ -62,9 +61,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.2",
"usehooks-ts": "^2.9.1",
"viem": "^1.10.14",
"wagmi": "^1.4.2"
"usehooks-ts": "^2.9.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
Expand Down
9 changes: 7 additions & 2 deletions src/components/ChainSelect/ChainSelectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FC, useEffect, useMemo, useRef, useState } from "react";
import { useWindowSize } from "usehooks-ts";

import { Chain } from "@/context/chains";
import { chainNameToChainlistURL } from "@/cosmos";

interface Props {
chains: Chain[];
Expand Down Expand Up @@ -106,8 +107,12 @@ const ChainSelectContent: FC<Props> = ({ chains, onChange, onClose }) => {
<img
alt={chain.prettyName}
className="w-12 h-12 rounded-full"
src={
chain.logoURI || "https://api.dicebear.com/6.x/shapes/svg"
src={`${chainNameToChainlistURL(
chain.chainName,
)}/chainImg/_chainImg.svg`}
onError={(e) =>
(e.currentTarget.src =
"https://api.dicebear.com/6.x/shapes/svg")
}
/>
<div>
Expand Down
15 changes: 0 additions & 15 deletions src/components/WalletModal/CosmosWalletList.tsx

This file was deleted.

30 changes: 6 additions & 24 deletions src/components/WalletModal/WalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { ArrowLeftIcon } from "@heroicons/react/20/solid";
import { FC } from "react";

import { DialogContent } from "@/elements/Dialog";
import { getChainByID, isEVMChain } from "@/utils/utils";
import { getChainByID } from "@/utils/utils";

import { useWalletModal } from "./context";
import CosmosWalletList from "./CosmosWalletList";

export interface MinimalWallet {
walletName: string;
Expand Down Expand Up @@ -95,35 +94,18 @@ export const WalletModal: FC<Props> = ({ onClose, wallets }) => {

const WalletModalWithContext: FC<{ chainID: string }> = ({ chainID }) => {
const { setIsOpen } = useWalletModal();
const chainName = isEVMChain(chainID)
? "cosmoshub"
: getChainByID(chainID).chain_name;
const chainName = getChainByID(chainID).chain_name;

const { getWalletRepo } = useManager();

const walletRepo = getWalletRepo(chainName);

const isEVM = isEVMChain(chainID);

return (
<DialogContent>
<div>
<div className="py-5 px-4 relative">
<p className="text-center font-bold">Wallets</p>
<div className="absolute inset-y-0 flex items-center">
<button
aria-label="Close wallet modal"
className="hover:bg-neutral-100 w-8 h-8 rounded-full flex items-center justify-center transition-colors -ml-2"
onClick={() => setIsOpen(false)}
>
<ArrowLeftIcon className="w-5 h-5" />
</button>
</div>
</div>
<div className="px-4 py-2 space-y-2">
{isEVM ? <div>EVM</div> : <CosmosWalletList />}
</div>
</div>
<WalletModal
wallets={walletRepo.wallets}
onClose={() => setIsOpen(false)}
/>
</DialogContent>
);
};
Expand Down
70 changes: 22 additions & 48 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import "../styles/globals.css";
import "@interchain-ui/react/styles";
import "@rainbow-me/rainbowkit/styles.css";

import { wallets as cosmostationWallets } from "@cosmos-kit/cosmostation-extension";
import { wallets as keplrWallets } from "@cosmos-kit/keplr-extension";
import { wallets as leapWallets } from "@cosmos-kit/leap-extension";
import { wallets as metamaskWallets } from "@cosmos-kit/leap-metamask-cosmos-snap";
import { ChainProvider } from "@cosmos-kit/react";
import * as RadixToast from "@radix-ui/react-toast";
import { getDefaultWallets, RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { QueryClientProvider } from "@tanstack/react-query";
import { Analytics } from "@vercel/analytics/react";
import { assets, chains } from "chain-registry";
import { AppProps } from "next/app";
import Head from "next/head";
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { arbitrum, base, mainnet, optimism, polygon, zora } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";

import MainLayout from "@/components/MainLayout";
import { AssetsProvider } from "@/context/assets";
Expand All @@ -25,23 +20,6 @@ import { ToastProvider } from "@/context/toast";
import { SkipProvider } from "@/solve";
import { queryClient } from "@/utils/query";

const { chains: evmChains, publicClient } = configureChains(
[mainnet, polygon, optimism, arbitrum, base, zora],
[publicProvider()],
);

const { connectors } = getDefaultWallets({
appName: "My RainbowKit App",
projectId: "YOUR_PROJECT_ID",
chains: evmChains,
});

const wagmiConfig = createConfig({
autoConnect: true,
connectors,
publicClient,
});

export default function App({ Component, pageProps }: AppProps) {
chains.push({
$schema: "../chain.schema.json",
Expand Down Expand Up @@ -206,32 +184,28 @@ export default function App({ Component, pageProps }: AppProps) {
</Head>
<main>
<QueryClientProvider client={queryClient}>
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider chains={evmChains}>
<ChainProvider
chains={chains}
assetLists={assets}
wallets={wallets}
wrappedWithChakra
throwErrors={false}
>
<SkipProvider>
<ChainsProvider>
<AssetsProvider>
<RadixToast.ToastProvider>
<ToastProvider>
<MainLayout>
<Component {...pageProps} />
</MainLayout>
</ToastProvider>
<RadixToast.Viewport className="w-[390px] max-w-[100vw] flex flex-col gap-2 p-6 fixed bottom-0 right-0 z-[999999]" />
</RadixToast.ToastProvider>
</AssetsProvider>
</ChainsProvider>
</SkipProvider>
</ChainProvider>
</RainbowKitProvider>
</WagmiConfig>
<ChainProvider
chains={chains}
assetLists={assets}
wallets={wallets}
wrappedWithChakra
throwErrors={false}
>
<SkipProvider>
<ChainsProvider>
<AssetsProvider>
<RadixToast.ToastProvider>
<ToastProvider>
<MainLayout>
<Component {...pageProps} />
</MainLayout>
</ToastProvider>
<RadixToast.Viewport className="w-[390px] max-w-[100vw] flex flex-col gap-2 p-6 fixed bottom-0 right-0 z-[999999]" />
</RadixToast.ToastProvider>
</AssetsProvider>
</ChainsProvider>
</SkipProvider>
</ChainProvider>
</QueryClientProvider>
</main>
<Analytics />
Expand Down
2 changes: 1 addition & 1 deletion src/solve/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const SkipContext = createContext<
export const SkipProvider: FC<PropsWithChildren> = ({ children }) => {
const { client: walletClient } = useWalletClient();

const skipClient = new SkipRouter("https://solve-dev.skip.money", {
const skipClient = new SkipRouter(SKIP_API_URL, {
getOfflineSigner: async (chainID) => {
if (!walletClient) {
throw new Error("No offline signer available");
Expand Down
7 changes: 0 additions & 7 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,3 @@ export async function signAmino(
signatures: [fromBase64(signature.signature)],
});
}

// This is error prone and should probably be exposed by the API itself
export function isEVMChain(chainID: string) {
return (
chainRegistry.chains.findIndex((chain) => chain.chain_id === chainID) === -1
);
}

0 comments on commit bcdebc0

Please sign in to comment.