diff --git a/deploy-web/public/images/leap-cosmos-logo.png b/deploy-web/public/images/leap-cosmos-logo.png new file mode 100644 index 000000000..a0efe9d05 Binary files /dev/null and b/deploy-web/public/images/leap-cosmos-logo.png differ diff --git a/deploy-web/src/components/address/SendAktModal.tsx b/deploy-web/src/components/address/SendAktModal.tsx index 0dfc16c3c..27c64cc6c 100644 --- a/deploy-web/src/components/address/SendAktModal.tsx +++ b/deploy-web/src/components/address/SendAktModal.tsx @@ -1,7 +1,7 @@ import { ReactNode, useEffect, useState } from "react"; import { Popup } from "../shared/Popup"; import { Box, Paper } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import SendIcon from "@mui/icons-material/Send"; import { Address } from "../shared/Address"; import { AKTAmountInput } from "../shared/AKTAmountInput"; @@ -20,7 +20,7 @@ type Props = { export const SendAktModal: React.FunctionComponent = ({ open, toAddress, onClose }) => { const [amount, setAmount] = useState(1); const [isKeplrOpened, setIsKeplrOpened] = useState(false); - const { signAndBroadcastTx, address } = useKeplr(); + const { signAndBroadcastTx, address } = useWallet(); useEffect(() => { setAmount(1); @@ -102,3 +102,4 @@ export const SendAktModal: React.FunctionComponent = ({ open, toAddress, ); }; + diff --git a/deploy-web/src/components/certificates/CertificateDisplay.tsx b/deploy-web/src/components/certificates/CertificateDisplay.tsx index 28a4fab03..568af07fc 100644 --- a/deploy-web/src/components/certificates/CertificateDisplay.tsx +++ b/deploy-web/src/components/certificates/CertificateDisplay.tsx @@ -11,7 +11,7 @@ import { ExportCertificate } from "./ExportCertificate"; import { makeStyles } from "tss-react/mui"; import { Box, Button, CircularProgress, IconButton, Menu, Paper, Tooltip, Typography, useTheme } from "@mui/material"; import { CustomMenuItem } from "../shared/CustomMenuItem"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import CheckIcon from "@mui/icons-material/Check"; const useStyles = makeStyles()({ @@ -37,7 +37,7 @@ export function CertificateDisplay() { revokeCertificate } = useCertificate(); const { classes } = useStyles(); - const { address } = useKeplr(); + const { address } = useWallet(); const [anchorEl, setAnchorEl] = useState(null); const theme = useTheme(); @@ -159,3 +159,4 @@ export function CertificateDisplay() { ); } + diff --git a/deploy-web/src/components/certificates/CertificateList.tsx b/deploy-web/src/components/certificates/CertificateList.tsx index 000747f24..9761cda57 100644 --- a/deploy-web/src/components/certificates/CertificateList.tsx +++ b/deploy-web/src/components/certificates/CertificateList.tsx @@ -4,14 +4,14 @@ import { FormattedDate } from "react-intl"; import { Box, Button, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from "@mui/material"; import { CertificateDisplay } from "./CertificateDisplay"; import { CustomTableHeader, CustomTableRow } from "../shared/CustomTable"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ConnectWallet } from "../shared/ConnectWallet"; type Props = {}; export const CertificateList: React.FunctionComponent = ({}) => { const { validCertificates, localCert, selectedCertificate, revokeCertificate, revokeAllCertificates, isLoadingCertificates } = useCertificate(); - const { address } = useKeplr(); + const { address } = useWallet(); return ( @@ -82,3 +82,4 @@ export const CertificateList: React.FunctionComponent = ({}) => { ); }; + diff --git a/deploy-web/src/components/deployment/DeploymentListRow.tsx b/deploy-web/src/components/deployment/DeploymentListRow.tsx index c319d5dd8..3e5814749 100644 --- a/deploy-web/src/components/deployment/DeploymentListRow.tsx +++ b/deploy-web/src/components/deployment/DeploymentListRow.tsx @@ -20,7 +20,7 @@ import { UrlService } from "@src/utils/urlUtils"; import { cx } from "@emotion/css"; import { CustomMenuItem } from "../shared/CustomMenuItem"; import { DeploymentDepositModal } from "../deploymentDetail/DeploymentDepositModal"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; import { AnalyticsEvents } from "@src/utils/analytics"; @@ -104,7 +104,7 @@ export const DeploymentListRow: React.FunctionComponent = ({ deployment, const [isDepositingDeployment, setIsDepositingDeployment] = useState(false); const [anchorEl, setAnchorEl] = useState(null); const { changeDeploymentName, getDeploymentData } = useLocalNotes(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const isActive = deployment.state === "active"; const { data: leases, isLoading: isLoadingLeases } = useAllLeases(address, { enabled: !!deployment && isActive }); const filteredLeases = leases?.filter(l => l.dseq === deployment.dseq); @@ -367,3 +367,4 @@ export const DeploymentListRow: React.FunctionComponent = ({ deployment, ); }; + diff --git a/deploy-web/src/components/deploymentDetail/DeploymentDepositModal.tsx b/deploy-web/src/components/deploymentDetail/DeploymentDepositModal.tsx index c34ad0384..08053d09c 100644 --- a/deploy-web/src/components/deploymentDetail/DeploymentDepositModal.tsx +++ b/deploy-web/src/components/deploymentDetail/DeploymentDepositModal.tsx @@ -7,7 +7,7 @@ import { coinToUDenom, uaktToAKT } from "@src/utils/priceUtils"; import { Snackbar } from "../shared/Snackbar"; import { uAktDenom } from "@src/utils/constants"; import { Alert, Box, Checkbox, FormControl, FormControlLabel, InputAdornment, InputLabel, MenuItem, Select, TextField } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { LinkTo } from "../shared/LinkTo"; import { event } from "nextjs-google-analytics"; import { AnalyticsEvents } from "@src/utils/analytics"; @@ -36,7 +36,7 @@ export const DeploymentDepositModal: React.FunctionComponent = ({ handleC const { enqueueSnackbar } = useSnackbar(); const [error, setError] = useState(""); const [isCheckingDepositor, setIsCheckingDepositor] = useState(false); - const { walletBalances, address } = useKeplr(); + const { walletBalances, address } = useWallet(); const { data: granteeGrants } = useGranteeGrants(address); const { handleSubmit, @@ -268,3 +268,4 @@ export const DeploymentDepositModal: React.FunctionComponent = ({ handleC ); }; + diff --git a/deploy-web/src/components/deploymentDetail/DeploymentDetailTopBar.tsx b/deploy-web/src/components/deploymentDetail/DeploymentDetailTopBar.tsx index bf948da7c..4c01f44e4 100644 --- a/deploy-web/src/components/deploymentDetail/DeploymentDetailTopBar.tsx +++ b/deploy-web/src/components/deploymentDetail/DeploymentDetailTopBar.tsx @@ -13,7 +13,7 @@ import { UrlService } from "@src/utils/urlUtils"; import { Box, Button, IconButton, Menu, Typography } from "@mui/material"; import { cx } from "@emotion/css"; import { CustomMenuItem } from "../shared/CustomMenuItem"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; import { AnalyticsEvents } from "@src/utils/analytics"; @@ -54,7 +54,7 @@ export const DeploymentDetailTopBar: React.FunctionComponent = ({ address const [anchorEl, setAnchorEl] = useState(null); const { changeDeploymentName, getDeploymentData, getDeploymentName } = useLocalNotes(); const router = useRouter(); - const { signAndBroadcastTx } = useKeplr(); + const { signAndBroadcastTx } = useWallet(); const [isDepositingDeployment, setIsDepositingDeployment] = useState(false); const storageDeploymentData = getDeploymentData(deployment?.dseq); const deploymentName = getDeploymentName(deployment?.dseq); @@ -213,3 +213,4 @@ export const DeploymentDetailTopBar: React.FunctionComponent = ({ address ); }; + diff --git a/deploy-web/src/components/deploymentDetail/ManifestUpdate.tsx b/deploy-web/src/components/deploymentDetail/ManifestUpdate.tsx index 61b99d198..0b1436693 100644 --- a/deploy-web/src/components/deploymentDetail/ManifestUpdate.tsx +++ b/deploy-web/src/components/deploymentDetail/ManifestUpdate.tsx @@ -4,7 +4,7 @@ import { useSnackbar } from "notistack"; import InfoIcon from "@mui/icons-material/Info"; import WarningIcon from "@mui/icons-material/Warning"; import { makeStyles } from "tss-react/mui"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useCertificate } from "@src/context/CertificateProvider"; import { getDeploymentLocalData, saveDeploymentManifest } from "@src/utils/deploymentLocalDataUtils"; import { deploymentData } from "@src/utils/deploymentData"; @@ -45,7 +45,7 @@ export const ManifestUpdate: React.FunctionComponent = ({ deployment, lea const [showOutsideDeploymentMessage, setShowOutsideDeploymentMessage] = useState(false); const { settings } = useSettings(); const { classes } = useStyles(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const { enqueueSnackbar, closeSnackbar } = useSnackbar(); const { data: providers } = useProviderList(); const { localCert, isLocalCertMatching, createCertificate, isCreatingCert } = useCertificate(); @@ -282,3 +282,4 @@ export const ManifestUpdate: React.FunctionComponent = ({ deployment, lea ); }; + diff --git a/deploy-web/src/components/get-started/GetStartedStepper.tsx b/deploy-web/src/components/get-started/GetStartedStepper.tsx index 54276a69f..91e7718ed 100644 --- a/deploy-web/src/components/get-started/GetStartedStepper.tsx +++ b/deploy-web/src/components/get-started/GetStartedStepper.tsx @@ -1,6 +1,6 @@ import { cx } from "@emotion/css"; import { Box, Button, Paper, Step, StepContent, StepLabel, Stepper, Typography } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { UrlService } from "@src/utils/urlUtils"; import Link from "next/link"; import { useEffect, useState } from "react"; @@ -37,7 +37,7 @@ type Props = {}; export const GetStartedStepper: React.FunctionComponent = () => { const { classes } = useStyles(); const [activeStep, setActiveStep] = useState(0); - const { isKeplrInstalled, isKeplrConnected, walletBalances } = useKeplr(); + const { isKeplrInstalled, isLeapInstalled, isWalletConnected, walletBalances } = useWallet(); const aktBalance = walletBalances ? uaktToAKT(walletBalances.uakt) : null; const usdcBalance = walletBalances ? udenomToDenom(walletBalances.usdc) : null; @@ -79,7 +79,7 @@ export const GetStartedStepper: React.FunctionComponent = () => { onClick={() => (activeStep > 0 ? onStepClick(0) : null)} classes={{ label: cx(classes.stepLabel, { [classes.activeLabel]: activeStep > 0 }) }} > - Keplr wallet + Wallet @@ -97,30 +97,30 @@ export const GetStartedStepper: React.FunctionComponent = () => { - {!isKeplrInstalled && ( + {!isKeplrInstalled && !isLeapInstalled && ( - Keplr is not installed + Wallet is not installed )} - {isKeplrInstalled && ( + {(isKeplrInstalled || isLeapInstalled) && ( <> - Keplr is installed + Wallet is installed - {isKeplrConnected ? ( + {isWalletConnected ? ( - Keplr is connected + Wallet is connected ) : ( - Keplr is not connected + Wallet is not connected @@ -213,3 +213,4 @@ export const GetStartedStepper: React.FunctionComponent = () => { ); }; + diff --git a/deploy-web/src/components/home/YourAccount.tsx b/deploy-web/src/components/home/YourAccount.tsx index 1b08e2789..81da93175 100644 --- a/deploy-web/src/components/home/YourAccount.tsx +++ b/deploy-web/src/components/home/YourAccount.tsx @@ -14,7 +14,7 @@ import Link from "next/link"; import { FormattedNumber, FormattedPlural } from "react-intl"; import { useRouter } from "next/router"; import RocketLaunchIcon from "@mui/icons-material/RocketLaunch"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ConnectWallet } from "../shared/ConnectWallet"; import { Balances } from "@src/types"; import { ApiProviderList } from "@src/types/provider"; @@ -66,7 +66,7 @@ export const YourAccount: React.FunctionComponent = ({ balances, isLoadin const { classes } = useStyles(); const theme = useTheme(); const router = useRouter(); - const { address } = useKeplr(); + const { address } = useWallet(); const usdcIbcDenom = useUsdcDenom(); const [selectedDataId, setSelectedDataId] = useState(null); const [costPerMonth, setCostPerMonth] = useState(null); @@ -449,3 +449,4 @@ const BalancePie: React.FunctionComponent = ({ label, data, get ); }; + diff --git a/deploy-web/src/components/layout/Header.tsx b/deploy-web/src/components/layout/Header.tsx index e692ef810..44ed58040 100644 --- a/deploy-web/src/components/layout/Header.tsx +++ b/deploy-web/src/components/layout/Header.tsx @@ -8,7 +8,7 @@ import { accountBarHeight } from "@src/utils/constants"; import { Badge, Button, IconButton, styled, useMediaQuery, useTheme } from "@mui/material"; import { makeStyles } from "tss-react/mui"; import Image from "next/legacy/image"; -import { KeplrWalletStatus } from "./KeplrWalletStatus"; +import { WalletStatus } from "./WalletStatus"; import Link from "next/link"; import { UrlService } from "@src/utils/urlUtils"; import { useRouter } from "next/router"; @@ -137,7 +137,7 @@ export const Header: React.FunctionComponent = ({ children, isMobileOpen, - + @@ -148,3 +148,4 @@ export const Header: React.FunctionComponent = ({ children, isMobileOpen, ); }; + diff --git a/deploy-web/src/components/layout/Layout.tsx b/deploy-web/src/components/layout/Layout.tsx index 3d14340dc..bde3544a3 100644 --- a/deploy-web/src/components/layout/Layout.tsx +++ b/deploy-web/src/components/layout/Layout.tsx @@ -12,7 +12,7 @@ import { useSettings } from "@src/context/SettingsProvider"; import { LinearLoadingSkeleton } from "../shared/LinearLoadingSkeleton"; import { Header } from "./Header"; import { NewsletterModal } from "../shared/NewsletterModal"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; type Props = { isLoading?: boolean; @@ -64,7 +64,7 @@ const LayoutApp: React.FunctionComponent = ({ children, isLoading, isUsin const [isNavOpen, setIsNavOpen] = useState(true); const [isMobileOpen, setIsMobileOpen] = useState(false); const { refreshNodeStatuses, isSettingsInit } = useSettings(); - const { isWalletLoaded } = useKeplr(); + const { isWalletLoaded } = useWallet(); const smallScreen = useMediaQuery(theme.breakpoints.down("md")); useEffect(() => { @@ -173,3 +173,4 @@ const Loading: React.FunctionComponent<{ text: string }> = ({ text }) => { }; export default Layout; + diff --git a/deploy-web/src/components/layout/MobileSidebarUser.tsx b/deploy-web/src/components/layout/MobileSidebarUser.tsx index f84eabb11..a600413d6 100644 --- a/deploy-web/src/components/layout/MobileSidebarUser.tsx +++ b/deploy-web/src/components/layout/MobileSidebarUser.tsx @@ -11,7 +11,7 @@ import Logout from "@mui/icons-material/Logout"; import MenuBookIcon from "@mui/icons-material/MenuBook"; import { useCustomUser } from "@src/hooks/useCustomUser"; import { SidebarRouteButton } from "./SidebarRouteButton"; -import { KeplrWalletStatus } from "./KeplrWalletStatus"; +import { WalletStatus } from "./WalletStatus"; import Settings from "@mui/icons-material/Settings"; const useStyles = makeStyles()(theme => ({ @@ -41,7 +41,7 @@ export const MobileSidebarUser: React.FunctionComponent = ({}) => { - + @@ -114,3 +114,4 @@ export const MobileSidebarUser: React.FunctionComponent = ({}) => { ); }; + diff --git a/deploy-web/src/components/layout/KeplrWalletStatus.tsx b/deploy-web/src/components/layout/WalletStatus.tsx similarity index 94% rename from deploy-web/src/components/layout/KeplrWalletStatus.tsx rename to deploy-web/src/components/layout/WalletStatus.tsx index 81d42c4a2..c2aec9f2f 100644 --- a/deploy-web/src/components/layout/KeplrWalletStatus.tsx +++ b/deploy-web/src/components/layout/WalletStatus.tsx @@ -1,6 +1,6 @@ import AccountBalanceWalletIcon from "@mui/icons-material/AccountBalanceWallet"; import Box from "@mui/material/Box"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import React, { ReactNode, useState } from "react"; import { makeStyles } from "tss-react/mui"; import { udenomToDenom } from "@src/utils/mathHelpers"; @@ -35,10 +35,10 @@ const useStyles = makeStyles()(theme => ({ } })); -export const KeplrWalletStatus: React.FunctionComponent = ({}) => { - const popupState = usePopupState({ variant: "popover", popupId: "keplrMenu" }); +export const WalletStatus: React.FunctionComponent = ({}) => { + const popupState = usePopupState({ variant: "popover", popupId: "walletMenu" }); const { classes } = useStyles(); - const { isKeplrConnected, walletName, address, walletBalances, logout, isWalletLoaded } = useKeplr(); + const { isWalletConnected, walletName, address, walletBalances, logout, isWalletLoaded } = useWallet(); const [isShowingGrantModal, setIsShowingGrantModal] = useState(false); const walletBalance = useTotalWalletBalance(); @@ -57,7 +57,7 @@ export const KeplrWalletStatus: React.FunctionComponent = ({}) => { return ( <> {isWalletLoaded ? ( - isKeplrConnected ? ( + isWalletConnected ? ( <> @@ -132,3 +132,4 @@ export const KeplrWalletStatus: React.FunctionComponent = ({}) => { ); }; + diff --git a/deploy-web/src/components/layout/WelcomeModal.tsx b/deploy-web/src/components/layout/WelcomeModal.tsx index 3dfcf4821..147afc7a2 100644 --- a/deploy-web/src/components/layout/WelcomeModal.tsx +++ b/deploy-web/src/components/layout/WelcomeModal.tsx @@ -1,5 +1,4 @@ import { Button, Dialog, DialogContent, DialogActions, Typography, Box, Paper, useTheme } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; // import { feePercent, maxFee } from "@src/utils/constants"; import { FormattedNumber } from "react-intl"; import { makeStyles } from "tss-react/mui"; @@ -56,3 +55,4 @@ export const WelcomeModal = ({ open, onClose }) => { ); }; + diff --git a/deploy-web/src/components/newDeploymentWizard/CreateLease.tsx b/deploy-web/src/components/newDeploymentWizard/CreateLease.tsx index 9a1f7a312..da1c50d2e 100644 --- a/deploy-web/src/components/newDeploymentWizard/CreateLease.tsx +++ b/deploy-web/src/components/newDeploymentWizard/CreateLease.tsx @@ -23,7 +23,7 @@ import InfoIcon from "@mui/icons-material/Info"; import { useLocalNotes } from "../../context/LocalNoteProvider"; import { makeStyles } from "tss-react/mui"; import { useRouter } from "next/router"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useBidList } from "@src/queries/useBidQuery"; import { useDeploymentDetail } from "@src/queries/useDeploymentQuery"; import { sendManifestToProvider } from "@src/utils/deploymentUtils"; @@ -82,7 +82,7 @@ export const CreateLease: React.FunctionComponent = ({ dseq }) => { const [selectedBids, setSelectedBids] = useState<{ [gseq: string]: BidDto }>({}); const [filteredBids, setFilteredBids] = useState>([]); const [search, setSearch] = useState(""); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const { localCert } = useCertificate(); const { enqueueSnackbar, closeSnackbar } = useSnackbar(); const router = useRouter(); @@ -476,3 +476,4 @@ export const CreateLease: React.FunctionComponent = ({ dseq }) => { ); }; + diff --git a/deploy-web/src/components/newDeploymentWizard/ManifestEdit.tsx b/deploy-web/src/components/newDeploymentWizard/ManifestEdit.tsx index 375dd21e9..93d509363 100644 --- a/deploy-web/src/components/newDeploymentWizard/ManifestEdit.tsx +++ b/deploy-web/src/components/newDeploymentWizard/ManifestEdit.tsx @@ -4,7 +4,7 @@ import InfoIcon from "@mui/icons-material/Info"; import ArrowForwardIosIcon from "@mui/icons-material/ArrowForward"; import { useSettings } from "../../context/SettingsProvider"; import { makeStyles } from "tss-react/mui"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useRouter } from "next/router"; import { Timer } from "@src/utils/timer"; import { defaultInitialDeposit, RouteStepKeys } from "@src/utils/constants"; @@ -57,7 +57,7 @@ export const ManifestEdit: React.FunctionComponent = ({ editedManifest, s const [isCheckingPrerequisites, setIsCheckingPrerequisites] = useState(false); const [sdlDenom, setSdlDenom] = useState("uakt"); const { settings } = useSettings(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const router = useRouter(); const { classes } = useStyles(); const { loadValidCertificates, localCert, isLocalCertMatching, loadLocalCert, setSelectedCertificate } = useCertificate(); @@ -314,3 +314,4 @@ export const ManifestEdit: React.FunctionComponent = ({ editedManifest, s ); }; + diff --git a/deploy-web/src/components/newDeploymentWizard/PrerequisiteList.tsx b/deploy-web/src/components/newDeploymentWizard/PrerequisiteList.tsx index cfc308102..7c4d685af 100644 --- a/deploy-web/src/components/newDeploymentWizard/PrerequisiteList.tsx +++ b/deploy-web/src/components/newDeploymentWizard/PrerequisiteList.tsx @@ -4,7 +4,7 @@ import { green } from "@mui/material/colors"; import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline"; import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline"; import { makeStyles } from "tss-react/mui"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ConnectWallet } from "../shared/ConnectWallet"; import { Popup } from "../shared/Popup"; @@ -25,7 +25,7 @@ export const PrerequisiteList: React.FunctionComponent = ({ onClose, onCo const theme = useTheme(); const [isLoadingPrerequisites, setIsLoadingPrerequisites] = useState(false); const [isBalanceValidated, setIsBalanceValidated] = useState(null); - const { address, walletBalances, refreshBalances } = useKeplr(); + const { address, walletBalances, refreshBalances } = useWallet(); useEffect(() => { async function loadPrerequisites() { @@ -99,3 +99,4 @@ export const PrerequisiteList: React.FunctionComponent = ({ onClose, onCo ); }; + diff --git a/deploy-web/src/components/providers/EditProviderForm.tsx b/deploy-web/src/components/providers/EditProviderForm.tsx index c3821c2d9..0cd53028d 100644 --- a/deploy-web/src/components/providers/EditProviderForm.tsx +++ b/deploy-web/src/components/providers/EditProviderForm.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useRef, HTMLInputTypeAttribute } from "react"; import { makeStyles } from "tss-react/mui"; import { useRouter } from "next/router"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ApiProviderDetail } from "@src/types/provider"; import { Alert, @@ -59,7 +59,7 @@ export const EditProviderForm: React.FunctionComponent = ({ provider, pro const router = useRouter(); const [error, setError] = useState(null); const formRef = useRef(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const { handleSubmit, reset, @@ -805,3 +805,4 @@ const ProviderSelect: React.FunctionComponent = ({ /> ); }; + diff --git a/deploy-web/src/components/providers/ProviderDetailLayout.tsx b/deploy-web/src/components/providers/ProviderDetailLayout.tsx index 360eb8968..18d6885f0 100644 --- a/deploy-web/src/components/providers/ProviderDetailLayout.tsx +++ b/deploy-web/src/components/providers/ProviderDetailLayout.tsx @@ -12,7 +12,7 @@ import PageContainer from "../shared/PageContainer"; import { ProviderSummary } from "./ProviderSummary"; import { ClientProviderDetailWithStatus } from "@src/types/provider"; import Link from "next/link"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { usePreviousRoute } from "@src/hooks/usePreviousRoute"; export enum ProviderDetailTabs { @@ -49,7 +49,7 @@ const ProviderDetailLayout: React.FunctionComponent = ({ children, page, const theme = useTheme(); const { classes } = useStyles(); const router = useRouter(); - const { address: walletAddress } = useKeplr(); + const { address: walletAddress } = useWallet(); const previousRoute = usePreviousRoute(); const handleTabChange = (event: React.SyntheticEvent, newValue: ProviderDetailTabs) => { @@ -135,3 +135,4 @@ const ProviderDetailLayout: React.FunctionComponent = ({ children, page, }; export default ProviderDetailLayout; + diff --git a/deploy-web/src/components/shared/AKTAmountInput.tsx b/deploy-web/src/components/shared/AKTAmountInput.tsx index 611ce964b..6e468b728 100644 --- a/deploy-web/src/components/shared/AKTAmountInput.tsx +++ b/deploy-web/src/components/shared/AKTAmountInput.tsx @@ -1,5 +1,5 @@ import { Box, FormControl, InputAdornment, InputLabel, OutlinedInput } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { FormattedDecimal } from "../shared/FormattedDecimal"; import { AKTLabel } from "../shared/AKTLabel"; import { FormattedNumber } from "react-intl"; @@ -12,7 +12,7 @@ type Props = { }; export const AKTAmountInput: React.FunctionComponent = ({ disabled, amount, onAmountChange }) => { - const { walletBalances } = useKeplr(); + const { walletBalances } = useWallet(); const { isLoaded: isPricingLoaded, aktToUSD } = usePricing(); const isValidAmount = !!amount; @@ -51,3 +51,4 @@ export const AKTAmountInput: React.FunctionComponent = ({ disabled, amoun ); }; + diff --git a/deploy-web/src/components/shared/ConnectWallet.tsx b/deploy-web/src/components/shared/ConnectWallet.tsx index 741cdd9e7..c3368bad5 100644 --- a/deploy-web/src/components/shared/ConnectWallet.tsx +++ b/deploy-web/src/components/shared/ConnectWallet.tsx @@ -1,7 +1,7 @@ import React, { ReactNode } from "react"; import Box from "@mui/material/Box"; import { Typography } from "@mui/material"; -import { KeplrWalletStatus } from "../layout/KeplrWalletStatus"; +import { WalletStatus } from "../layout/WalletStatus"; type Props = { text: string | ReactNode; @@ -14,7 +14,8 @@ export const ConnectWallet: React.FunctionComponent = ({ children, text } {text} - + ); }; + diff --git a/deploy-web/src/components/shared/SendModal.tsx b/deploy-web/src/components/shared/SendModal.tsx index 208e2062c..2c220affc 100644 --- a/deploy-web/src/components/shared/SendModal.tsx +++ b/deploy-web/src/components/shared/SendModal.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { makeStyles } from "tss-react/mui"; import { txFeeBuffer } from "@src/utils/constants"; import { Alert, Box, Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, InputAdornment, TextField } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { aktToUakt, uaktToAKT } from "@src/utils/priceUtils"; const useStyles = makeStyles()(theme => ({ @@ -25,7 +25,7 @@ export const SendModal = ({ onClose, onSendTransaction }) => { const formRef = useRef(null); const [isBalanceClicked, setIsBalanceClicked] = useState(false); const [error, setError] = useState(""); - const { walletBalances } = useKeplr(); + const { walletBalances } = useWallet(); const { handleSubmit, control, @@ -154,3 +154,4 @@ export const SendModal = ({ onClose, onSendTransaction }) => { ); }; + diff --git a/deploy-web/src/components/validator/DelegateModal.tsx b/deploy-web/src/components/validator/DelegateModal.tsx index 05bc2ff97..f38298ce0 100644 --- a/deploy-web/src/components/validator/DelegateModal.tsx +++ b/deploy-web/src/components/validator/DelegateModal.tsx @@ -1,7 +1,7 @@ import { ReactNode, useState } from "react"; import { Popup } from "../shared/Popup"; import { Box, Paper } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import SendIcon from "@mui/icons-material/Send"; import { AKTAmountInput } from "../shared/AKTAmountInput"; import { denomToUdenom } from "@src/utils/mathHelpers"; @@ -20,7 +20,7 @@ type Props = { export const DelegateModal: React.FunctionComponent = ({ open, validatorAddress, validatorMoniker, onClose }) => { const [amount, setAmount] = useState(1); const [isKeplrOpened, setIsKeplrOpened] = useState(false); - const { signAndBroadcastTx, address } = useKeplr(); + const { signAndBroadcastTx, address } = useWallet(); async function onDelegateClick() { setIsKeplrOpened(true); @@ -97,3 +97,4 @@ export const DelegateModal: React.FunctionComponent = ({ open, validatorA ); }; + diff --git a/deploy-web/src/components/validator/RedelegateModal.tsx b/deploy-web/src/components/validator/RedelegateModal.tsx index 97bdb34f1..5d5660bf3 100644 --- a/deploy-web/src/components/validator/RedelegateModal.tsx +++ b/deploy-web/src/components/validator/RedelegateModal.tsx @@ -1,7 +1,7 @@ import { ReactNode, useState } from "react"; import { Popup } from "../shared/Popup"; import { Box, FormControl, InputLabel, MenuItem, Paper, Select, SelectChangeEvent } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import SendIcon from "@mui/icons-material/Send"; import { AKTAmountInput } from "../shared/AKTAmountInput"; import { useValidators } from "@src/queries/useValidatorsQuery"; @@ -24,7 +24,7 @@ export const RedelegateModal: React.FunctionComponent = ({ open, validato const [selectedValidator, setSelectedValidator] = useState(""); const [isKeplrOpened, setIsKeplrOpened] = useState(false); const { data: validators, isLoading } = useValidators(); - const { signAndBroadcastTx, address } = useKeplr(); + const { signAndBroadcastTx, address } = useWallet(); async function onRedelegateClick() { setIsKeplrOpened(true); @@ -122,3 +122,4 @@ export const RedelegateModal: React.FunctionComponent = ({ open, validato ); }; + diff --git a/deploy-web/src/components/validator/ValidatorRow.tsx b/deploy-web/src/components/validator/ValidatorRow.tsx index 74edcb786..ddebe2c63 100644 --- a/deploy-web/src/components/validator/ValidatorRow.tsx +++ b/deploy-web/src/components/validator/ValidatorRow.tsx @@ -10,7 +10,7 @@ import { makeStyles } from "tss-react/mui"; import { getShortText } from "@src/hooks/useShortText"; import { CustomTableRow } from "../shared/CustomTable"; import { AKTAmount } from "../shared/AKTAmount"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import MoreVertIcon from "@mui/icons-material/MoreVert"; import { useState } from "react"; import { usePopupState, bindTrigger, bindPopper } from "material-ui-popup-state/hooks"; @@ -35,7 +35,7 @@ export const ValidatorRow: React.FunctionComponent = ({ validator, reward const popupState = usePopupState({ variant: "popper", popupId: "delegationActionMenu" }); const theme = useTheme(); const { classes } = useStyles(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const isTop10 = validator.rank <= 10; async function claimClick() { @@ -168,3 +168,4 @@ export const ValidatorRow: React.FunctionComponent = ({ validator, reward ); }; + diff --git a/deploy-web/src/components/wallet/AllowanceModal.tsx b/deploy-web/src/components/wallet/AllowanceModal.tsx index 79ffd2fb6..eaabbbb19 100644 --- a/deploy-web/src/components/wallet/AllowanceModal.tsx +++ b/deploy-web/src/components/wallet/AllowanceModal.tsx @@ -3,7 +3,7 @@ import { useForm, Controller } from "react-hook-form"; import { FormControl, TextField, Typography, Box, Alert, InputAdornment } from "@mui/material"; import { addYears, format } from "date-fns"; import { makeStyles } from "tss-react/mui"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { aktToUakt, coinToDenom } from "@src/utils/priceUtils"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { LinkTo } from "../shared/LinkTo"; @@ -31,7 +31,7 @@ export const AllowanceModal: React.FunctionComponent = ({ editingAllowanc const formRef = useRef(null); const [error, setError] = useState(""); const { classes } = useStyles(); - const { signAndBroadcastTx } = useKeplr(); + const { signAndBroadcastTx } = useWallet(); const { handleSubmit, control, @@ -220,3 +220,4 @@ export const AllowanceModal: React.FunctionComponent = ({ editingAllowanc ); }; + diff --git a/deploy-web/src/components/wallet/ConnectWalletButton.tsx b/deploy-web/src/components/wallet/ConnectWalletButton.tsx index 6e8d7bc64..22884b73e 100644 --- a/deploy-web/src/components/wallet/ConnectWalletButton.tsx +++ b/deploy-web/src/components/wallet/ConnectWalletButton.tsx @@ -4,7 +4,7 @@ import Box from "@mui/material/Box"; import Button, { ButtonProps } from "@mui/material/Button"; import { ConnectWalletModal } from "./ConnectWalletModal"; import AccountBalanceWalletIcon from "@mui/icons-material/AccountBalanceWallet"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; interface Props extends ButtonProps { children?: ReactNode; @@ -13,7 +13,7 @@ interface Props extends ButtonProps { const useStyles = makeStyles()(theme => ({})); export const ConnectWalletButton: React.FunctionComponent = ({ ...rest }) => { - const { isKeplrConnected } = useKeplr(); + const { isWalletConnected } = useWallet(); const [isConnectingWallet, setIsConnectingWallet] = useState(false); const { classes } = useStyles(); @@ -22,7 +22,7 @@ export const ConnectWalletButton: React.FunctionComponent = ({ ...rest }) }; const onClose = () => { - if (!isKeplrConnected) { + if (!isWalletConnected) { setIsConnectingWallet(false); } }; @@ -40,3 +40,4 @@ export const ConnectWalletButton: React.FunctionComponent = ({ ...rest }) ); }; + diff --git a/deploy-web/src/components/wallet/ConnectWalletModal.tsx b/deploy-web/src/components/wallet/ConnectWalletModal.tsx index 2e5c54bb7..958631c79 100644 --- a/deploy-web/src/components/wallet/ConnectWalletModal.tsx +++ b/deploy-web/src/components/wallet/ConnectWalletModal.tsx @@ -7,7 +7,7 @@ import { CustomDialogTitle } from "@src/components/shared/CustomDialogTitle"; import Paper from "@mui/material/Paper"; import Box from "@mui/material/Box"; import { Alert, CircularProgress, Typography } from "@mui/material"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet, Wallets } from "@src/context/WalletProvider"; import OpenInNewIcon from "@mui/icons-material/OpenInNew"; import { UrlService } from "@src/utils/urlUtils"; import Link from "next/link"; @@ -50,26 +50,33 @@ const useStyles = makeStyles()(theme => ({ })); const keplrUrl = "https://www.keplr.app/"; +const leapUrl = "https://chrome.google.com/webstore/detail/leap-cosmos-wallet/fcfcfllfndlomdhbehjjcoimbgofdncg"; export const ConnectWalletModal: React.FunctionComponent = ({ onClose }) => { - const { isKeplrInstalled, connectWallet } = useKeplr(); + const { isKeplrInstalled, connectWallet, isLeapInstalled } = useWallet(); const [isConnectingWallet, setIsConnectingWallet] = useState(false); const { classes } = useStyles(); - const onConnectKeplrClick = async (event: React.MouseEvent) => { + const onConnectWalletClick = async (event: React.MouseEvent, walletSource: Wallets) => { if (isConnectingWallet) return; - if (isKeplrInstalled) { - try { - setIsConnectingWallet(true); - await connectWallet(); - } catch (error) { - console.log(error); - } finally { - setIsConnectingWallet(false); - } - } else { + if (walletSource === "keplr" && !isKeplrInstalled) { window.open(keplrUrl, "_blank").focus(); + return; + } + + if (walletSource === "leap" && !isLeapInstalled) { + window.open(leapUrl, "_blank").focus(); + return; + } + + try { + setIsConnectingWallet(true); + await connectWallet(walletSource); + } catch (error) { + console.log(error); + } finally { + setIsConnectingWallet(false); } }; @@ -80,7 +87,30 @@ export const ConnectWalletModal: React.FunctionComponent = ({ onClose }) {isConnectingWallet && } - + onConnectWalletClick(event, Wallets.LEAP)}> + + Leap Wallet Logo + + + + + + {isLeapInstalled ? ( + "Leap Wallet" + ) : ( + <> + Install Leap  + + + )} + + + + {isLeapInstalled ? "Leap Browser Extension" : leapUrl} + + + + onConnectWalletClick(event, Wallets.KEPLR)}> Keplr Wallet Logo @@ -126,3 +156,4 @@ export const ConnectWalletModal: React.FunctionComponent = ({ onClose }) ); }; + diff --git a/deploy-web/src/components/wallet/GrantModal.tsx b/deploy-web/src/components/wallet/GrantModal.tsx index 8b22edb05..4f5d8dd42 100644 --- a/deploy-web/src/components/wallet/GrantModal.tsx +++ b/deploy-web/src/components/wallet/GrantModal.tsx @@ -3,7 +3,7 @@ import { useForm, Controller } from "react-hook-form"; import { FormControl, TextField, Typography, Box, Alert, Select, MenuItem, InputLabel } from "@mui/material"; import { addYears, format } from "date-fns"; import { makeStyles } from "tss-react/mui"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { aktToUakt, coinToDenom } from "@src/utils/priceUtils"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { LinkTo } from "../shared/LinkTo"; @@ -38,7 +38,7 @@ export const GrantModal: React.FunctionComponent = ({ editingGrant, addre const formRef = useRef(null); const [error, setError] = useState(""); const { classes } = useStyles(); - const { signAndBroadcastTx } = useKeplr(); + const { signAndBroadcastTx } = useWallet(); const usdcDenom = useUsdcDenom(); const { handleSubmit, @@ -257,3 +257,4 @@ export const GrantModal: React.FunctionComponent = ({ editingGrant, addre ); }; + diff --git a/deploy-web/src/context/CertificateProvider/CertificateProviderContext.tsx b/deploy-web/src/context/CertificateProvider/CertificateProviderContext.tsx index 16e49dba6..683ed45ac 100644 --- a/deploy-web/src/context/CertificateProvider/CertificateProviderContext.tsx +++ b/deploy-web/src/context/CertificateProvider/CertificateProviderContext.tsx @@ -6,7 +6,7 @@ import { networkVersion } from "@src/utils/constants"; import { generateCertificate, getCertPem, openCert } from "@src/utils/certificateUtils"; import { Snackbar } from "@src/components/shared/Snackbar"; import { getSelectedStorageWallet, getStorageWallets, updateWallet } from "@src/utils/walletUtils"; -import { useKeplr } from "../KeplrWalletProvider"; +import { useWallet } from "../WalletProvider"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; import { AnalyticsEvents } from "@src/utils/analytics"; @@ -69,7 +69,7 @@ export const CertificateProvider = ({ children }) => { const [isLocalCertMatching, setIsLocalCertMatching] = useState(false); const { settings } = useSettings(); const { enqueueSnackbar } = useSnackbar(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const { apiEndpoint } = settings; const loadValidCertificates = useCallback( @@ -335,3 +335,4 @@ export const CertificateProvider = ({ children }) => { export const useCertificate = () => { return { ...React.useContext(CertificateProviderContext) }; }; + diff --git a/deploy-web/src/context/KeplrWalletProvider/index.ts b/deploy-web/src/context/KeplrWalletProvider/index.ts deleted file mode 100644 index 4a977af15..000000000 --- a/deploy-web/src/context/KeplrWalletProvider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { useKeplr, KeplrWalletProvider } from "./KeplrWalletProvider"; diff --git a/deploy-web/src/context/KeplrWalletProvider/KeplrWalletProvider.tsx b/deploy-web/src/context/WalletProvider/WalletProvider.tsx similarity index 80% rename from deploy-web/src/context/KeplrWalletProvider/KeplrWalletProvider.tsx rename to deploy-web/src/context/WalletProvider/WalletProvider.tsx index 99ba55b3b..76ed64449 100644 --- a/deploy-web/src/context/KeplrWalletProvider/KeplrWalletProvider.tsx +++ b/deploy-web/src/context/WalletProvider/WalletProvider.tsx @@ -8,7 +8,7 @@ import { useSnackbar } from "notistack"; import { Snackbar } from "@src/components/shared/Snackbar"; import { customRegistry } from "@src/utils/customRegistry"; import { TransactionModal } from "@src/components/layout/TransactionModal"; -import { OpenInNew } from "@mui/icons-material"; +import { OpenInNew, WindowSharp } from "@mui/icons-material"; import { useTheme } from "@mui/material"; import { event } from "nextjs-google-analytics"; import { AnalyticsEvents } from "@src/utils/analytics"; @@ -29,22 +29,29 @@ type ContextType = { address: string; walletName: string; walletBalances: Balances; + isLeapInstalled: boolean; isKeplrInstalled: boolean; - isKeplrConnected: boolean; + isWalletConnected: boolean; isWalletLoaded: boolean; - connectWallet: () => Promise; + connectWallet: (walletSource: Wallets) => Promise; logout: () => void; setIsWalletLoaded: React.Dispatch>; signAndBroadcastTx: (msgs: EncodeObject[]) => Promise; refreshBalances: (address?: string) => Promise; }; -const KeplrWalletProviderContext = React.createContext({ +export enum Wallets { + KEPLR = "keplr", + LEAP = "leap" +} + +const WalletProviderContext = React.createContext({ address: null, walletName: null, walletBalances: null, + isLeapInstalled: false, isKeplrInstalled: false, - isKeplrConnected: false, + isWalletConnected: false, isWalletLoaded: false, connectWallet: null, logout: null, @@ -53,11 +60,12 @@ const KeplrWalletProviderContext = React.createContext({ refreshBalances: null }); -export const KeplrWalletProvider = ({ children }) => { +export const WalletProvider = ({ children }) => { const [walletAddress, setWalletAddress] = useState(null); const [walletName, setWalletName] = useState(null); const [walletBalances, setWalletBalances] = useState(null); const [isKeplrInstalled, setIsKeplrInstalled] = useState(false); + const [isLeapInstalled, setIsLeapInstalled] = useState(false); const [isWindowLoaded, setIsWindowLoaded] = useState(false); const [isWalletLoaded, setIsWalletLoaded] = useState(false); const [isBroadcastingTx, setIsBroadcastingTx] = useState(false); @@ -69,7 +77,7 @@ export const KeplrWalletProvider = ({ children }) => { const usdcIbcDenom = useUsdcDenom(); useEffect(() => { - console.log("useKeplr on mount"); + console.log("useWallet on mount"); if (document.readyState === "complete") { setIsWindowLoaded(true); @@ -85,29 +93,45 @@ export const KeplrWalletProvider = ({ children }) => { useEffect(() => { if (isWindowLoaded && isSettingsInit) { - if (!!window.keplr) { - setIsKeplrInstalled(true); + if (!!window.keplr || !!window.leap) { + if (!!window.keplr) { + setIsKeplrInstalled(true); + } + + if (!!window.leap) { + setIsLeapInstalled(true); + } + + if (localStorage.getItem("wallet_autoconnect")) { + const storedWallet = localStorage.getItem("wallet_autoconnect"); - window.keplr.defaultOptions = { - sign: { - preferNoSetMemo: true + if (storedWallet === Wallets.KEPLR) { + window.wallet = window.keplr; + } else if (storedWallet === Wallets.LEAP) { + window.wallet = window.leap; } - }; - if (localStorage.getItem("keplr_autoconnect")) { + window.wallet.defaultOptions = { + sign: { + preferNoSetMemo: true + } + }; + loadWallet(); } else { setIsWalletLoaded(true); } - window.addEventListener("keplr_keystorechange", onKeystoreChange); + const keplrOnKeystoreChange = () => onKeystoreChange(Wallets.KEPLR); + const leapOnKeystoreChange = () => onKeystoreChange(Wallets.LEAP); + window.addEventListener("keplr_keystorechange", keplrOnKeystoreChange); + window.addEventListener("leap_keystorechange", leapOnKeystoreChange); return () => { isMounted.current = false; - console.log("useKeplr on unmount"); - - window.removeEventListener("keplr_keystorechange", onKeystoreChange); + window.removeEventListener("keplr_keystorechange", keplrOnKeystoreChange); + window.removeEventListener("leap_keystorechange", leapOnKeystoreChange); }; } else { setIsWalletLoaded(true); @@ -121,8 +145,8 @@ export const KeplrWalletProvider = ({ children }) => { } }, [settings?.rpcEndpoint]); - const onKeystoreChange = () => { - console.log("Key store in Keplr is changed."); + const onKeystoreChange = (wallet: Wallets) => { + console.log(`Key store in ${wallet} is changed.`); loadWallet(); @@ -132,7 +156,7 @@ export const KeplrWalletProvider = ({ children }) => { async function createStargateClient() { const selectedNetwork = getSelectedNetwork(); - const offlineSigner = window.keplr.getOfflineSigner(selectedNetwork.chainId); + const offlineSigner = window.wallet.getOfflineSigner(selectedNetwork.chainId); let rpc = settings?.rpcEndpoint ? settings?.rpcEndpoint : selectedNetwork.rpcEndpoint; try { @@ -165,7 +189,7 @@ export const KeplrWalletProvider = ({ children }) => { setWalletName(null); setWalletBalances(null); - localStorage.removeItem("keplr_autoconnect"); + localStorage.removeItem("wallet_autoconnect"); event(AnalyticsEvents.DISCONNECT_WALLET, { category: "wallet", @@ -175,15 +199,17 @@ export const KeplrWalletProvider = ({ children }) => { router.push(UrlService.home()); } - async function connectWallet(): Promise { - console.log("connecting to keplr"); + async function connectWallet(walletSource: Wallets): Promise { + console.log(`connecting to ${walletSource}`); + + window.wallet = window[walletSource]; const selectedNetwork = getSelectedNetwork(); - if (selectedNetwork.suggestKeplrChain) { - await selectedNetwork.suggestKeplrChain(); + if (selectedNetwork.suggestWalletChain) { + await selectedNetwork.suggestWalletChain(); } - await window.keplr.enable(selectedNetwork.chainId); + await window.wallet.enable(selectedNetwork.chainId); await loadWallet(); @@ -192,7 +218,7 @@ export const KeplrWalletProvider = ({ children }) => { label: "Connect wallet" }); - localStorage.setItem("keplr_autoconnect", "true"); + localStorage.setItem("wallet_autoconnect", walletSource); } async function loadWallet(): Promise { @@ -200,13 +226,13 @@ export const KeplrWalletProvider = ({ children }) => { let selectedNetwork = null; try { selectedNetwork = getSelectedNetwork(); - wallet = await window.keplr.getKey(selectedNetwork.chainId); + wallet = await window.wallet.getKey(selectedNetwork.chainId); } catch (err) { console.error(err); if (err.message.includes("There is no chain info for")) { - await selectedNetwork?.suggestKeplrChain(); - wallet = await window.keplr.getKey(selectedNetwork.chainId); + await selectedNetwork?.suggestWalletChain(); + wallet = await window.wallet.getKey(selectedNetwork.chainId); } else { setIsWalletLoaded(true); return; @@ -382,13 +408,14 @@ export const KeplrWalletProvider = ({ children }) => { } return ( - { {children} setIsBroadcastingTx(false)} /> - + ); }; // Hook -export function useKeplr() { - return { ...React.useContext(KeplrWalletProviderContext) }; +export function useWallet() { + return { ...React.useContext(WalletProviderContext) }; } const TransactionSnackbarContent = ({ snackMessage, transactionHash }) => { @@ -428,3 +455,4 @@ const TransactionSnackbarContent = ({ snackMessage, transactionHash }) => { ); }; + diff --git a/deploy-web/src/context/WalletProvider/index.ts b/deploy-web/src/context/WalletProvider/index.ts new file mode 100644 index 000000000..1b0179bdd --- /dev/null +++ b/deploy-web/src/context/WalletProvider/index.ts @@ -0,0 +1,2 @@ +export { useWallet, WalletProvider, Wallets } from "./WalletProvider"; + diff --git a/deploy-web/src/hooks/useLocalStorage.ts b/deploy-web/src/hooks/useLocalStorage.ts index 7b6578ce1..481429d52 100644 --- a/deploy-web/src/hooks/useLocalStorage.ts +++ b/deploy-web/src/hooks/useLocalStorage.ts @@ -1,9 +1,9 @@ -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useEffect, useState } from "react"; import { useEventListener } from "usehooks-ts"; export const useLocalStorage = () => { - const { address } = useKeplr(); + const { address } = useWallet(); const getLocalStorageItem = (key: string) => { const selectedNetworkId = localStorage.getItem("selectedNetworkId"); @@ -103,3 +103,4 @@ function parseJSON(value: string) { return value === "undefined" ? undefined : value; } } + diff --git a/deploy-web/src/hooks/useSelectedNetwork.ts b/deploy-web/src/hooks/useSelectedNetwork.ts index e3f1ceb64..48d6ce421 100644 --- a/deploy-web/src/hooks/useSelectedNetwork.ts +++ b/deploy-web/src/hooks/useSelectedNetwork.ts @@ -21,3 +21,4 @@ export const useSelectedNetwork = () => { return selectedNetwork ?? networks[0]; }; + diff --git a/deploy-web/src/hooks/useWalletBalance.ts b/deploy-web/src/hooks/useWalletBalance.ts index 88a65f7ce..671b8e90e 100644 --- a/deploy-web/src/hooks/useWalletBalance.ts +++ b/deploy-web/src/hooks/useWalletBalance.ts @@ -1,4 +1,4 @@ -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { usePricing } from "@src/context/PricingProvider"; import { txFeeBuffer, uAktDenom } from "@src/utils/constants"; import { udenomToDenom } from "@src/utils/mathHelpers"; @@ -8,7 +8,7 @@ import { useUsdcDenom } from "./useDenom"; export const useTotalWalletBalance = () => { const { isLoaded, price } = usePricing(); - const { walletBalances } = useKeplr(); + const { walletBalances } = useWallet(); const [walletBalance, setWalletBalance] = useState(0); useEffect(() => { @@ -31,7 +31,7 @@ type DenomData = { export const useDenomData = (denom: string) => { const { isLoaded, price } = usePricing(); - const { walletBalances } = useKeplr(); + const { walletBalances } = useWallet(); const [depositData, setDepositData] = useState(null); const usdcIbcDenom = useUsdcDenom(); @@ -63,3 +63,4 @@ export const useDenomData = (denom: string) => { return depositData; }; + diff --git a/deploy-web/src/pages/_app.tsx b/deploy-web/src/pages/_app.tsx index f7d8d3ec3..140524e3c 100644 --- a/deploy-web/src/pages/_app.tsx +++ b/deploy-web/src/pages/_app.tsx @@ -11,7 +11,7 @@ import withDarkMode from "next-dark-mode"; import "../styles/index.css"; import { QueryClientProvider } from "react-query"; import { queryClient } from "@src/queries"; -import { KeplrWalletProvider } from "@src/context/KeplrWalletProvider"; +import { WalletProvider } from "@src/context/WalletProvider"; import { PricingProvider } from "@src/context/PricingProvider/PricingProvider"; import { BackgroundTaskProvider } from "@src/context/BackgroundTaskProvider"; import { SettingsProvider } from "@src/context/SettingsProvider"; @@ -72,7 +72,7 @@ const App: React.FunctionComponent = ({ Component, pageProps, emotionCach - + @@ -83,7 +83,7 @@ const App: React.FunctionComponent = ({ Component, pageProps, emotionCach - + @@ -98,3 +98,4 @@ const App: React.FunctionComponent = ({ Component, pageProps, emotionCach }; export default withDarkMode(App); + diff --git a/deploy-web/src/pages/deployment/[owner]/[dseq].tsx b/deploy-web/src/pages/deployment/[owner]/[dseq].tsx index 3ba3df106..a43520faf 100644 --- a/deploy-web/src/pages/deployment/[owner]/[dseq].tsx +++ b/deploy-web/src/pages/deployment/[owner]/[dseq].tsx @@ -22,7 +22,7 @@ import { Title } from "@src/components/shared/Title"; import { NextSeo } from "next-seo"; import { CustomTableHeader, CustomTableRow } from "@src/components/shared/CustomTable"; import AddIcon from "@mui/icons-material/Add"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useState } from "react"; import { DeploymentDepositModal } from "@src/components/deploymentDetail/DeploymentDepositModal"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; @@ -42,7 +42,7 @@ const DeploymentDetailPage: React.FunctionComponent = ({ owner, dseq, dep const [showDepositModal, setShowDepositModal] = useState(false); const { classes } = useStyles(); const theme = useTheme(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const canDeposit = address && address === owner && deployment?.status === "active"; @@ -276,3 +276,4 @@ async function fetchDeploymentData(owner: string, dseq: string, network: string) const response = await axios.get(`${apiUrl}/deployment/${owner}/${dseq}`); return response.data; } + diff --git a/deploy-web/src/pages/deployments/[dseq].tsx b/deploy-web/src/pages/deployments/[dseq].tsx index b2de3523d..8e24781ce 100644 --- a/deploy-web/src/pages/deployments/[dseq].tsx +++ b/deploy-web/src/pages/deployments/[dseq].tsx @@ -7,7 +7,7 @@ import { Alert, Box, Button, CircularProgress, Tab, Tabs, Typography } from "@mu import { LeaseRow } from "@src/components/deploymentDetail/LeaseRow"; import { useRouter } from "next/router"; import { createRef, useEffect, useState } from "react"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useDeploymentDetail } from "@src/queries/useDeploymentQuery"; import { useDeploymentLeaseList } from "@src/queries/useLeaseQuery"; import { useCertificate } from "@src/context/CertificateProvider"; @@ -48,7 +48,7 @@ const DeploymentDetailPage: React.FunctionComponent = ({ dseq }) => { const router = useRouter(); const [activeTab, setActiveTab] = useState("LEASES"); const [selectedLogsMode, setSelectedLogsMode] = useState("logs"); - const { address, isWalletLoaded } = useKeplr(); + const { address, isWalletLoaded } = useWallet(); const { isSettingsInit } = useSettings(); const [leaseRefs, setLeaseRefs] = useState>([]); const { @@ -271,3 +271,4 @@ export async function getServerSideProps({ params }) { } }; } + diff --git a/deploy-web/src/pages/deployments/index.tsx b/deploy-web/src/pages/deployments/index.tsx index a9acdae11..ce9ea1ef6 100644 --- a/deploy-web/src/pages/deployments/index.tsx +++ b/deploy-web/src/pages/deployments/index.tsx @@ -1,7 +1,7 @@ import { makeStyles } from "tss-react/mui"; import Layout from "@src/components/layout/Layout"; import { NextSeo } from "next-seo"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { useDeploymentList } from "@src/queries/useDeploymentQuery"; import { useEffect, useState } from "react"; import { useSettings } from "@src/context/SettingsProvider"; @@ -61,7 +61,7 @@ const useStyles = makeStyles()(theme => ({ })); const DeploymentsPage: React.FunctionComponent = ({}) => { - const { address, signAndBroadcastTx, isWalletLoaded } = useKeplr(); + const { address, signAndBroadcastTx, isWalletLoaded } = useWallet(); const { data: providers, isFetching: isLoadingProviders } = useProviderList(); const { data: deployments, isFetching: isLoadingDeployments, refetch: getDeployments } = useDeploymentList(address, { enabled: false }); const [page, setPage] = useState(1); @@ -340,3 +340,4 @@ export async function getServerSideProps({ params }) { props: {} }; } + diff --git a/deploy-web/src/pages/get-started/index.tsx b/deploy-web/src/pages/get-started/index.tsx index e8c0c66ca..999086fbd 100644 --- a/deploy-web/src/pages/get-started/index.tsx +++ b/deploy-web/src/pages/get-started/index.tsx @@ -40,3 +40,4 @@ const GetStarted: React.FunctionComponent = ({}) => { }; export default GetStarted; + diff --git a/deploy-web/src/pages/index.tsx b/deploy-web/src/pages/index.tsx index 42c9cf7b3..b7bdadd49 100644 --- a/deploy-web/src/pages/index.tsx +++ b/deploy-web/src/pages/index.tsx @@ -5,7 +5,7 @@ import { useDeploymentList } from "@src/queries/useDeploymentQuery"; import { useLocalNotes } from "@src/context/LocalNoteProvider"; import { useSettings } from "@src/context/SettingsProvider"; import { useBalances } from "@src/queries/useBalancesQuery"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { YourAccount } from "@src/components/home/YourAccount"; import PageContainer from "@src/components/shared/PageContainer"; import { useAllLeases } from "@src/queries/useLeaseQuery"; @@ -19,7 +19,7 @@ type Props = { }; const IndexPage: React.FunctionComponent = ({}) => { - const { address, isWalletLoaded } = useKeplr(); + const { address, isWalletLoaded } = useWallet(); const [activeDeployments, setActiveDeployments] = useState([]); const { isFetching: isLoadingDeployments, refetch: getDeployments } = useDeploymentList(address, { enabled: false, @@ -99,3 +99,4 @@ export async function getServerSideProps() { } export default IndexPage; + diff --git a/deploy-web/src/pages/providers/[owner]/index.tsx b/deploy-web/src/pages/providers/[owner]/index.tsx index 9852ba025..7536d52e3 100644 --- a/deploy-web/src/pages/providers/[owner]/index.tsx +++ b/deploy-web/src/pages/providers/[owner]/index.tsx @@ -3,7 +3,7 @@ import { Typography, Box, Paper, useTheme, CircularProgress, Alert } from "@mui/ import { useRouter } from "next/router"; import { useAllLeases } from "@src/queries/useLeaseQuery"; import Layout from "@src/components/layout/Layout"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ApiProviderDetail, ClientProviderDetailWithStatus } from "@src/types/provider"; import { useProviderAttributesSchema, useProviderDetail, useProviderStatus } from "@src/queries/useProvidersQuery"; import ProviderDetailLayout, { ProviderDetailTabs } from "@src/components/providers/ProviderDetailLayout"; @@ -45,7 +45,7 @@ const ProviderDetailPage: React.FunctionComponent = ({ owner, _provider } const { classes } = useStyles(); const router = useRouter(); const theme = useTheme(); - const { address } = useKeplr(); + const { address } = useWallet(); const { isLoading: isLoadingProvider, refetch: getProviderDetail } = useProviderDetail(owner, { enabled: false, retry: false, @@ -251,3 +251,4 @@ export async function getServerSideProps({ params, query }) { } }; } + diff --git a/deploy-web/src/pages/providers/[owner]/leases.tsx b/deploy-web/src/pages/providers/[owner]/leases.tsx index 024184d6e..7aaccec5a 100644 --- a/deploy-web/src/pages/providers/[owner]/leases.tsx +++ b/deploy-web/src/pages/providers/[owner]/leases.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import { useAllLeases } from "@src/queries/useLeaseQuery"; import Layout from "@src/components/layout/Layout"; import { LeaseList } from "@src/components/providers/LeaseList"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ClientProviderDetailWithStatus } from "@src/types/provider"; import { useProviderDetail, useProviderStatus } from "@src/queries/useProvidersQuery"; import ProviderDetailLayout, { ProviderDetailTabs } from "@src/components/providers/ProviderDetailLayout"; @@ -25,7 +25,7 @@ const ProviderLeasesPage: React.FunctionComponent = ({ owner }) => { setProvider(provider => (provider ? { ...provider, ..._providerDetail } : _providerDetail)); } }); - const { address } = useKeplr(); + const { address } = useWallet(); const { data: leases, isFetching: isLoadingLeases, refetch: getLeases } = useAllLeases(address, { enabled: false }); const { data: providerStatus, @@ -86,3 +86,4 @@ export async function getServerSideProps({ params }) { } }; } + diff --git a/deploy-web/src/pages/providers/[owner]/raw.tsx b/deploy-web/src/pages/providers/[owner]/raw.tsx index c950619e2..21ffd8784 100644 --- a/deploy-web/src/pages/providers/[owner]/raw.tsx +++ b/deploy-web/src/pages/providers/[owner]/raw.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from "react"; import { useAllLeases } from "@src/queries/useLeaseQuery"; import Layout from "@src/components/layout/Layout"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { ClientProviderDetailWithStatus } from "@src/types/provider"; import { useProviderDetail, useProviderStatus } from "@src/queries/useProvidersQuery"; import ProviderDetailLayout, { ProviderDetailTabs } from "@src/components/providers/ProviderDetailLayout"; @@ -22,7 +22,7 @@ const ProviderRawPage: React.FunctionComponent = ({ owner }) => { setProvider(provider => (provider ? { ...provider, ..._providerDetail } : _providerDetail)); } }); - const { address } = useKeplr(); + const { address } = useWallet(); const { data: leases, isFetching: isLoadingLeases, refetch: getLeases } = useAllLeases(address, { enabled: false }); const { data: providerStatus, @@ -76,3 +76,4 @@ export async function getServerSideProps({ params }) { } }; } + diff --git a/deploy-web/src/pages/providers/index.tsx b/deploy-web/src/pages/providers/index.tsx index 5e72086d2..3fb64ab68 100644 --- a/deploy-web/src/pages/providers/index.tsx +++ b/deploy-web/src/pages/providers/index.tsx @@ -22,7 +22,7 @@ import { makeStyles } from "tss-react/mui"; import { useSettings } from "@src/context/SettingsProvider"; import { useLocalNotes } from "@src/context/LocalNoteProvider"; import { useAllLeases } from "@src/queries/useLeaseQuery"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import Layout from "@src/components/layout/Layout"; import { useNetworkCapacity, useProviderList } from "@src/queries/useProvidersQuery"; import PageContainer from "@src/components/shared/PageContainer"; @@ -71,7 +71,7 @@ const sortOptions = [ const ProvidersPage: React.FunctionComponent = ({}) => { const { classes } = useStyles(); - const { address } = useKeplr(); + const { address } = useWallet(); const [page, setPage] = useState(1); const [isFilteringActive, setIsFilteringActive] = useState(true); const [isFilteringFavorites, setIsFilteringFavorites] = useState(false); @@ -419,3 +419,4 @@ export async function getServerSideProps({ params }) { } export default ProvidersPage; + diff --git a/deploy-web/src/pages/settings/authorizations.tsx b/deploy-web/src/pages/settings/authorizations.tsx index 34323f4eb..511a37a22 100644 --- a/deploy-web/src/pages/settings/authorizations.tsx +++ b/deploy-web/src/pages/settings/authorizations.tsx @@ -5,7 +5,7 @@ import SettingsLayout, { SettingsTabs } from "@src/components/settings/SettingsL import { Fieldset } from "@src/components/shared/Fieldset"; import { Box, Button, CircularProgress, Table, TableBody, TableCell, TableContainer, TableRow, Typography } from "@mui/material"; import { useEffect, useState } from "react"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import { CustomTableHeader } from "@src/components/shared/CustomTable"; import { Address } from "@src/components/shared/Address"; import { GrantModal } from "@src/components/wallet/GrantModal"; @@ -38,7 +38,7 @@ const refreshingInterval = 1000; const SettingsSecurityPage: React.FunctionComponent = ({}) => { const { classes } = useStyles(); - const { address } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); const [editingGrant, setEditingGrant] = useState(null); const [editingAllowance, setEditingAllowance] = useState(null); const [showGrantModal, setShowGrantModal] = useState(false); @@ -58,7 +58,6 @@ const SettingsSecurityPage: React.FunctionComponent = ({}) => { const { data: allowancesGranted, isLoading: isLoadingAllowancesGranted } = useAllowancesGranted(address, { refetchInterval: isRefreshing === "allowancesGranted" ? refreshingInterval : defaultRefetchInterval }); - const { signAndBroadcastTx } = useKeplr(); useEffect(() => { let timeout: NodeJS.Timeout; @@ -357,3 +356,4 @@ export async function getServerSideProps({ params }) { props: {} }; } + diff --git a/deploy-web/src/pages/validators/index.tsx b/deploy-web/src/pages/validators/index.tsx index d16755a25..db82092aa 100644 --- a/deploy-web/src/pages/validators/index.tsx +++ b/deploy-web/src/pages/validators/index.tsx @@ -16,7 +16,7 @@ import { Title } from "@src/components/shared/Title"; import { BASE_API_URL, validatorAddress } from "@src/utils/constants"; import { CustomTableHeader } from "@src/components/shared/CustomTable"; import { useEffect, useState } from "react"; -import { useKeplr } from "@src/context/KeplrWalletProvider"; +import { useWallet } from "@src/context/WalletProvider"; import axios from "axios"; import { AddressDetail } from "@src/types"; import { AKTAmount } from "@src/components/shared/AKTAmount"; @@ -39,7 +39,7 @@ const ValidatorsPage: React.FunctionComponent = ({}) => { const { classes } = useStyles(); const theme = useTheme(); const { data: validators, isLoading } = useValidators(); - const { address, signAndBroadcastTx } = useKeplr(); + const { address, signAndBroadcastTx } = useWallet(); useEffect(() => { setWalletAddressData(null); @@ -224,3 +224,4 @@ export async function getServerSideProps({ params }) { props: {} }; } + diff --git a/deploy-web/src/store/networkStore.ts b/deploy-web/src/store/networkStore.ts index a6f556934..8a6412166 100644 --- a/deploy-web/src/store/networkStore.ts +++ b/deploy-web/src/store/networkStore.ts @@ -25,8 +25,8 @@ export let networks: Network[] = [ versionUrl: ApiUrlService.testnetVersion(), enabled: false, version: null, // Set asynchronously - suggestKeplrChain: async () => { - await window.keplr.experimentalSuggestChain({ + suggestWalletChain: async () => { + await window.wallet.experimentalSuggestChain({ // Chain-id of the Craft chain. chainId: "testnet-02", // The name of the chain to be displayed to the user. @@ -109,8 +109,8 @@ export let networks: Network[] = [ versionUrl: ApiUrlService.sandboxVersion(), version: null, // Set asynchronously enabled: true, - suggestKeplrChain: async () => { - await window.keplr.experimentalSuggestChain({ + suggestWalletChain: async () => { + await window.wallet.experimentalSuggestChain({ // Chain-id of the Craft chain. chainId: "sandbox-01", // The name of the chain to be displayed to the user. @@ -213,3 +213,4 @@ const selectedNetwork = atom(networks[0]); export default { selectedNetwork }; + diff --git a/deploy-web/src/types/global.ts b/deploy-web/src/types/global.ts index f875c1029..d16e64d6e 100644 --- a/deploy-web/src/types/global.ts +++ b/deploy-web/src/types/global.ts @@ -1,6 +1,7 @@ -import { Window as KeplrWindow } from "@keplr-wallet/types"; - +import { Keplr, Window as KeplrWindow } from "@keplr-wallet/types"; declare global { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Window extends KeplrWindow {} + interface Window extends KeplrWindow { + wallet: Keplr; + leap: Keplr; + } } diff --git a/deploy-web/src/types/network.ts b/deploy-web/src/types/network.ts index 4d253061c..69ed5aa7e 100644 --- a/deploy-web/src/types/network.ts +++ b/deploy-web/src/types/network.ts @@ -8,5 +8,6 @@ export type Network = { rpcEndpoint?: string; version: string; enabled: boolean; - suggestKeplrChain?: () => Promise; + suggestWalletChain?: () => Promise; }; +