Skip to content

Commit

Permalink
add missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
djeck1432 committed Sep 26, 2024
1 parent 3b08ff2 commit 9e71e41
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web_app/api/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
<script src="https://cdn.jsdelivr.net/npm/@argent/get-starknet@latest/dist/index.umd.js"></script>

<!-- Custom JS for Wallet Connection and Logout -->
<script src="{{ url_for('static', filename='js/wallet.js') }}"></script>
<script src="{{ url_for('static', path='js/wallet.js') }}"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion web_app/api/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ <h2>Submit your lending details</h2>
{% endblock %}

{% block scripts %}
<script src="{{ url_for('static', filename='js/form.js') }}"></script>
<script src="{{ url_for('static', path='js/form.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion web_app/api/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ <h3 style="font-size: 2rem; font-weight: bold;">Amplify Your DeFi Power</h3>
{% endblock %}

{% block scripts %}
<script src="{{ url_for('static', filename='js/login.js') }}"></script>
<script src="{{ url_for('static', path='js/login.js') }}"></script>
{% endblock %}
37 changes: 37 additions & 0 deletions web_app/static/js/wallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
async function connectWallet() {
try {
const starknet = window.starknet;
const wallet = await starknet.enable();

if (wallet) {
console.log("Wallet object:", wallet); // Logs the entire wallet object

const walletAddress = starknet.selectedAddress;
console.log("Wallet Address:", walletAddress); // Logs the wallet address
alert(`Wallet connected: ${walletAddress}`);

// Save wallet address in session
const formData = new FormData();
formData.append("wallet_id", walletAddress);

await fetch("/login", {
method: "POST",
body: formData
});

// Redirect or reload the page after connection
window.location.reload();
} else {
alert("Connection failed. Please try again.");
}
} catch (error) {
console.error("Error connecting wallet:", error); // Logs any error
alert("An error occurred. Please check the console.");
}
}

async function logout() {
// Remove wallet_id from session and redirect to login page
await fetch("/logout", { method: "POST" });
window.location.href = "/login";
}

0 comments on commit 9e71e41

Please sign in to comment.