Skip to content

Commit

Permalink
connection test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-vahn committed Apr 16, 2024
1 parent 1ff8e37 commit b3ac68a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ function App() {
});
};

const handleConnect = () => {
setView(View.CONNECTED);
};

// Handle MainButton changes on view change
useEffect(() => {
if (view === View.LANDING) {
Expand Down Expand Up @@ -222,8 +226,9 @@ function App() {
</div>
{showConnectOverlay && (
<ConnectOverlay
close={closeConnectOverlay}
slideAnimation={slideAnimation}
close={closeConnectOverlay}
onConnect={handleConnect}
/>
)}
</div>
Expand Down
24 changes: 21 additions & 3 deletions src/components/connectOverlay/ConnectOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ import './ConnectOverlay.css';
type Props = {
slideAnimation: string;
close: () => void;
onConnect: () => void;
};

const BRIDGE_URL = import.meta.env.VITE_BRIDGE_URL || '';

const ConnectOverlay: React.FC<Props> = ({ close, slideAnimation }) => {
const ConnectOverlay: React.FC<Props> = ({
slideAnimation,
close,
onConnect,
}) => {
const [networksExpanded, setNetworksExpanded] = useState(true);
const [walletsExpanded, setWalletsExpanded] = useState(false);

Expand All @@ -36,15 +41,28 @@ const ConnectOverlay: React.FC<Props> = ({ close, slideAnimation }) => {
};

// connect function
const connectMetamask = () => {
axios.post(BRIDGE_URL + '/connect').then((response) => {
const connectMetamask = async () => {
await axios.post(BRIDGE_URL + '/connect').then((response) => {
try {
WebApp.openLink(response.data.universalLink);
close();
} catch (error) {
console.error(error);
}
});

// check if connected
await axios.get(BRIDGE_URL + '/is-connected').then((response) => {
try {
if (response.data.connected) {
onConnect();
} else {
console.log('Not Connected');
}
} catch (error) {
console.error(error);
}
});
};

// Toggle Wallets
Expand Down

0 comments on commit b3ac68a

Please sign in to comment.