add wallet adapter
This commit is contained in:
1 parent
0eceac1587
commit
ae96bae795
7 files changed
+12601
-117
No files matched your search
Generated
+12463
-115
File diff suppressed because it is too large.
Load diff
+7
-1
@@ -22,6 +22,12 @@
|
|||||||
"@mui/x-data-grid": "7.26.0",
|
"@mui/x-data-grid": "7.26.0",
|
||||||
"@mui/x-date-pickers": "7.26.0",
|
"@mui/x-date-pickers": "7.26.0",
|
||||||
"@reduxjs/toolkit": "2.5.1",
|
"@reduxjs/toolkit": "2.5.1",
|
||||||
|
"@solana/wallet-adapter-base": "0.9.23",
|
||||||
|
"@solana/wallet-adapter-material-ui": "0.16.34",
|
||||||
|
"@solana/wallet-adapter-react": "0.15.35",
|
||||||
|
"@solana/wallet-adapter-react-ui": "0.9.35",
|
||||||
|
"@solana/wallet-adapter-wallets": "0.19.32",
|
||||||
|
"@solana/web3.js": "1.98.0",
|
||||||
"axios": "^1.7.4",
|
"axios": "^1.7.4",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
"flag-icons": "7.3.2",
|
"flag-icons": "7.3.2",
|
||||||
@@ -31,7 +37,7 @@
|
|||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
"maplibre-gl": "5.1.0",
|
"maplibre-gl": "5.1.0",
|
||||||
"mui-color-input": "^5.0.1",
|
"mui-color-input": "^5.0.1",
|
||||||
"react": "^18.2.0",
|
"react": "18.3.1",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Stack } from "@mui/material";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import { ConnectionProvider, WalletProvider } from "@solana/wallet-adapter-react";
|
||||||
|
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
|
||||||
|
import {
|
||||||
|
UnsafeBurnerWalletAdapter,
|
||||||
|
PhantomWalletAdapter,
|
||||||
|
} from "@solana/wallet-adapter-wallets";
|
||||||
|
|
||||||
|
import {
|
||||||
|
WalletModalProvider,
|
||||||
|
WalletMultiButton,
|
||||||
|
WalletDisconnectButton,
|
||||||
|
} from "@solana/wallet-adapter-react-ui";
|
||||||
|
import { clusterApiUrl } from "@solana/web3.js";
|
||||||
|
|
||||||
|
// Default styles that can be overridden by your app
|
||||||
|
import "@solana/wallet-adapter-react-ui/styles.css";
|
||||||
|
|
||||||
|
export const Wallet = () => {
|
||||||
|
// The network can be set to 'devnet', 'testnet', or 'mainnet-beta'.
|
||||||
|
const network = WalletAdapterNetwork.Devnet;
|
||||||
|
|
||||||
|
// You can also provide a custom RPC endpoint.
|
||||||
|
const endpoint = useMemo(() => clusterApiUrl(network), [network]);
|
||||||
|
|
||||||
|
const wallets = useMemo(
|
||||||
|
() => [new UnsafeBurnerWalletAdapter(), new PhantomWalletAdapter()],
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[network]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConnectionProvider endpoint={endpoint}>
|
||||||
|
<WalletProvider
|
||||||
|
wallets={wallets}
|
||||||
|
autoConnect
|
||||||
|
>
|
||||||
|
<WalletModalProvider>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
>
|
||||||
|
<WalletMultiButton />
|
||||||
|
<WalletDisconnectButton />
|
||||||
|
</Stack>
|
||||||
|
{/* Your app's components go here, nested within the context providers. */}
|
||||||
|
</WalletModalProvider>
|
||||||
|
</WalletProvider>
|
||||||
|
</ConnectionProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Wallet;
|
||||||
@@ -7,6 +7,7 @@ import LoadingButton from "@mui/lab/LoadingButton";
|
|||||||
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
||||||
import Dialog from "../../Components/Dialog";
|
import Dialog from "../../Components/Dialog";
|
||||||
import ConfigBox from "../../Components/ConfigBox";
|
import ConfigBox from "../../Components/ConfigBox";
|
||||||
|
import WalletConnector from "../../Components/WalletConnector";
|
||||||
|
|
||||||
//Utils
|
//Utils
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
@@ -360,6 +361,19 @@ const Settings = () => {
|
|||||||
/>
|
/>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
)}
|
)}
|
||||||
|
{isAdmin && (
|
||||||
|
<ConfigBox>
|
||||||
|
<Box>
|
||||||
|
<Typography component="h1">Wallet</Typography>
|
||||||
|
<Typography sx={{ mt: theme.spacing(2) }}>
|
||||||
|
Connect your wallet here
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<WalletConnector />
|
||||||
|
</Box>
|
||||||
|
</ConfigBox>
|
||||||
|
)}
|
||||||
|
|
||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Box>
|
<Box>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import {
|
||||||
|
WalletNotConnectedError,
|
||||||
|
WalletAdapterNetwork,
|
||||||
|
} from "@solana/wallet-adapter-base";
|
||||||
|
|
||||||
|
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
|
||||||
|
import { Keypair, SystemProgram, Transaction } from "@solana/web3.js";
|
||||||
|
import { ConnectionProvider, WalletProvider } from "@solana/wallet-adapter-react";
|
||||||
|
import { clusterApiUrl } from "@solana/web3.js";
|
||||||
|
import { useMemo, useEffect } from "react";
|
||||||
|
import {
|
||||||
|
UnsafeBurnerWalletAdapter,
|
||||||
|
PhantomWalletAdapter,
|
||||||
|
} from "@solana/wallet-adapter-wallets";
|
||||||
|
const Wallet = () => {
|
||||||
|
const { connection } = useConnection();
|
||||||
|
const { publicKey, sendTransaction } = useWallet();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
if (!publicKey) return;
|
||||||
|
const getBalance = async () => {
|
||||||
|
const balance = await connection.getBalance(publicKey);
|
||||||
|
console.log({ balance });
|
||||||
|
};
|
||||||
|
getBalance();
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}, [connection, publicKey]);
|
||||||
|
return <div>Wallet</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const Provider = () => {
|
||||||
|
const network = WalletAdapterNetwork.Devnet;
|
||||||
|
const wallets = useMemo(
|
||||||
|
() => [new UnsafeBurnerWalletAdapter(), new PhantomWalletAdapter()],
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[network]
|
||||||
|
);
|
||||||
|
const endpoint = useMemo(() => clusterApiUrl(network), [network]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConnectionProvider endpoint={endpoint}>
|
||||||
|
<WalletProvider
|
||||||
|
wallets={wallets}
|
||||||
|
autoConnect
|
||||||
|
>
|
||||||
|
<Wallet />
|
||||||
|
</WalletProvider>
|
||||||
|
</ConnectionProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Provider;
|
||||||
@@ -52,6 +52,8 @@ import Settings from "../Pages/Settings";
|
|||||||
|
|
||||||
import Maintenance from "../Pages/Maintenance";
|
import Maintenance from "../Pages/Maintenance";
|
||||||
|
|
||||||
|
import Wallet from "../Pages/Wallet";
|
||||||
|
|
||||||
import ProtectedRoute from "../Components/ProtectedRoute";
|
import ProtectedRoute from "../Components/ProtectedRoute";
|
||||||
import ProtectedDistributedUptimeRoute from "../Components/ProtectedDistributedUptimeRoute";
|
import ProtectedDistributedUptimeRoute from "../Components/ProtectedDistributedUptimeRoute";
|
||||||
import CreateNewMaintenanceWindow from "../Pages/Maintenance/CreateMaintenance";
|
import CreateNewMaintenanceWindow from "../Pages/Maintenance/CreateMaintenance";
|
||||||
@@ -267,6 +269,11 @@ const Routes = () => {
|
|||||||
element={<DistributedUptimeStatus />}
|
element={<DistributedUptimeStatus />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path="/wallet"
|
||||||
|
element={<Wallet />}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path="*"
|
path="*"
|
||||||
element={<NotFound />}
|
element={<NotFound />}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ const baseTheme = (palette) => ({
|
|||||||
return (
|
return (
|
||||||
props.variant === "contained" &&
|
props.variant === "contained" &&
|
||||||
props.disabled &&
|
props.disabled &&
|
||||||
props.classes.loadingIndicator === undefined // Do not apply to loading button
|
props?.classes?.loadingIndicator === undefined // Do not apply to loading button
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
|
|||||||
Reference in new issue
Block a user