diff --git a/suchwowx/static/js/main.js b/suchwowx/static/js/main.js
index 992760e..e46f41c 100644
--- a/suchwowx/static/js/main.js
+++ b/suchwowx/static/js/main.js
@@ -8,51 +8,3 @@ async function notif(s, t) {
}).show();
return
}
-
-async function confirmAvalanche(){
- let debug = true;
- let chainId;
- let rpcUrl;
- let explorerUrl;
- let name;
- if (debug) {
- name = 'Avalance Testnet';
- chainId = '0xA869';
- rpcUrl = 'https://api.avax-test.network/ext/bc/C/rpc';
- explorerUrl = 'https://testnet.snowtrace.io';
- } else {
- name = 'Avalanche Mainnet';
- chainId = '0xA86A';
- rpcUrl = 'https://api.avax.network/ext/bc/C/rpc';
- explorerUrl = 'https://snowtrace.io';
- }
- try {
- await ethereum.request({
- method: 'wallet_switchEthereumChain',
- params: [{ chainId: chainId }],
- });
- } catch (switchError) {
- // This error code indicates that the chain has not been added to MetaMask.
- if (switchError.code === 4902) {
- try {
- await ethereum.request({
- method: 'wallet_addEthereumChain',
- params: [{
- chainId: chainId,
- chainName: name,
- nativeCurrency: {
- name: 'Avalanche',
- symbol: 'AVAX',
- decimals: 18,
- },
- rpcUrls: [rpcUrl],
- blockExplorerUrls: [explorerUrl],
- }],
- });
- } catch (addError) {
- // handle "add" error
- }
- }
- // handle other "switch" errors
- }
-}
diff --git a/suchwowx/static/js/metamask.js b/suchwowx/static/js/metamask.js
index 6f0beb8..901bcc1 100644
--- a/suchwowx/static/js/metamask.js
+++ b/suchwowx/static/js/metamask.js
@@ -30,10 +30,11 @@ async function onboardMetaMask(){
onboarding.stopOnboarding();
} else {
onboardButton.onclick = async () => {
+ try {
onboardButton.classList.add('is-loading');
onboardButton.disabled = true;
let userExists;
- await confirmAvalanche();
+ await addAvalancheNetwork();
const allAccounts = await window.ethereum.request({
method: 'eth_requestAccounts',
});
@@ -74,7 +75,11 @@ async function onboardMetaMask(){
window.location.href = '/';
}
})
+ } catch(e) {
+ console.log(e);
+ onboardButton.classList.remove('is-loading');
}
+ }
}
};
diff --git a/suchwowx/templates/includes/scripts.html b/suchwowx/templates/includes/scripts.html
index af6439d..7edc457 100644
--- a/suchwowx/templates/includes/scripts.html
+++ b/suchwowx/templates/includes/scripts.html
@@ -1,5 +1,6 @@
-
+
+{% include 'includes/web3.html' %}
{% if not current_user.is_authenticated %}
@@ -7,6 +8,7 @@
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
+