diff --git a/packages/sado-connect/src/components/SadoConnectKit.tsx b/packages/sado-connect/src/components/SadoConnectKit.tsx
index e898e35a..87d71986 100644
--- a/packages/sado-connect/src/components/SadoConnectKit.tsx
+++ b/packages/sado-connect/src/components/SadoConnectKit.tsx
@@ -1,4 +1,3 @@
-import { useState } from "react";
import "./style.css";
import { useSadoContext } from "../providers/SadoContext";
import { PreConnectButton } from "./PreConnectButton";
@@ -24,16 +23,8 @@ export function SadoConnectKit({
customStyle,
onViewWallet,
}: SadoConnectKitProp) {
- const [isOpen, setIsOpen] = useState(false);
- const { address, network } = useSadoContext();
-
- function closeModal() {
- setIsOpen(false);
- }
-
- async function openModal() {
- setIsOpen(true);
- }
+ const { address, network, isModalOpen, openModal, closeModal } =
+ useSadoContext();
return (
<>
@@ -47,7 +38,7 @@ export function SadoConnectKit({
/>
)}
-
+
>
);
}
diff --git a/packages/sado-connect/src/providers/SadoContext.tsx b/packages/sado-connect/src/providers/SadoContext.tsx
index aba9d705..001b0677 100644
--- a/packages/sado-connect/src/providers/SadoContext.tsx
+++ b/packages/sado-connect/src/providers/SadoContext.tsx
@@ -20,6 +20,9 @@ interface SadoContextI {
updateNetwork: (network: Network) => void;
wallet: Wallet | null;
updateWallet: (wallet: Wallet | null) => void;
+ isModalOpen: boolean;
+ openModal: () => void;
+ closeModal: () => void;
}
const SadoContext = createContext({
@@ -31,6 +34,9 @@ const SadoContext = createContext({
updateNetwork: () => {},
wallet: null,
updateWallet: () => {},
+ isModalOpen: false,
+ openModal: () => {},
+ closeModal: () => {},
});
const ADDRESS = "address";
@@ -66,6 +72,7 @@ export function SadoConnectProvider({
const [network, setNetwork] = useState(Network.TESTNET);
const [wallet, setWallet] = useState(null);
const [publicKey, setPublicKey] = useState(null);
+ const [isModalOpen, setIsModalOpen] = useState(false);
useEffect(() => {
try {
@@ -133,6 +140,9 @@ export function SadoConnectProvider({
updateNetwork: setNetwork,
wallet,
updateWallet: setWallet,
+ isModalOpen,
+ openModal: () => setIsModalOpen(true),
+ closeModal: () => setIsModalOpen(false),
};
return (