glob["debug"] = 1; glob["btn_action"] = new Array(); glob["nick"] = new Array(); glob["balance"] = new Array(); glob["modal_hartbeat"] = 0; glob["page_hartbeat"] = 0; glob["access_balance"] = new Array(); glob["tarif_addr_list"] = new Array(); glob["tarif_addr_list2"] = new Array(); glob["tarif_addr_list2"]["matic"] = new Array(); glob["tarif_addr_list2"]["bsc"] = new Array(); glob["tarif_addr_list2"]["eth"] = new Array(); glob["circle_net"] = "matic"; glob["circle_net"] = "eth"; glob["gov_net"] = "mumbai"; glob["gov_net"] = "matic"; glob["governance"] = new Array(); glob["factory3_net"] = "eth"; function log(txt) { if(glob["debug"]) { console.log("LOG: "+txt); } } "use strict"; var chain_name = ''; const btn_class = "btn-success"; var chainId = 0; const Web3Modal = window.Web3Modal.default; const WalletConnectProvider = window.WalletConnectProvider.default; const evmChains = window.evmChains; let web3Modal; let provider; let selectedAccount; function init() { console.log("Initializing example"); console.log("WalletConnectProvider is", WalletConnectProvider); console.log("window.web3 is", window.web3, "window.ethereum is", window.ethereum); if(location.protocol !== 'https:') { const alert = document.querySelector("#alert-error-https"); alert.style.display = "block"; document.querySelector("#btn-connect").setAttribute("disabled", "disabled"); return; } const providerOptions = { walletconnect: { package: WalletConnectProvider, options: { infuraId: "0903c0eda4b6458386b9ce8b22020a94", rpc: { 1: "https://mainnet.infura.io/v3/0903c0eda4b6458386b9ce8b22020a94", 3: "https://ropsten.infura.io/v3/0903c0eda4b6458386b9ce8b22020a94", 56: "https://bsc-dataseed1.binance.org", 137: "https://matic-rpc.infocoin.pro/", }, } }, }; web3Modal = new Web3Modal({ cacheProvider: true, providerOptions, disableInjectedProvider: false, }); console.log("Web3Modal instance is", web3Modal); } async function fetchAccountData() { var t = ""; var x = ""; var y = ""; try { prov = await web3Modal.connect(); } catch(e) { console.log("Could not get a wallet connection", e); return; } const web3 = new Web3(prov); chainId = await web3.eth.getChainId(); var this_val = ''; var this_err = "ok"; var network_name = ""; var network_txt = ""; switch(chainId+'') { case "80001": case "137": this_val = 'matic'; network_name = "Polygon"; network_txt += ""; network_txt += "" + network_name + ""; break; case "56": case "97": this_val = 'bsc'; network_name = "BSC"; network_txt += ""; network_txt += ""+network_name+""; break; case "1": case "3": this_val = 'eth'; network_name = "Ethereum"; network_txt += ""; network_txt += ""+network_name+""; break; default: this_val = ""; this_err = "err"; network_name = "Unsupported"; network_txt = network_name; } const accounts = await web3.eth.getAccounts(); selectedAccount = accounts[0]; auth_on_off(selectedAccount?1:0); if(selectedAccount) { wallet_id_set(selectedAccount); check_white_list(); } const rowResolvers = accounts.map(async (address) => { const balance = await web3.eth.getBalance(address); const ethBalance = web3.utils.fromWei(balance, "ether"); const humanFriendlyBalance = parseFloat(ethBalance).toFixed(4); }); await Promise.all(rowResolvers); } async function refreshAccountData() { await fetchAccountData(provider); } async function onConnect() { console.log("Opening a dialog", web3Modal); glob["onConnected"] = 1; try { provider = await web3Modal.connect(); } catch(e) { console.log("Could not get a wallet connection", e); return; } if(provider !== null) { const provider2 = new ethers.providers.Web3Provider(provider); } provider.on("accountsChanged", (accounts) => { console.log("accountsChanged"); fetchAccountData(); }); provider.on("chainChanged", (chainId) => { log("CHAIN CHANGED"); fetchAccountData(); }); provider.on("networkChanged", (networkId) => { log("NETWORK CHANGED"); fetchAccountData(); }); await refreshAccountData(); } async function onDisconnect() { await web3Modal.clearCachedProvider(); provider = null; provider2 = null; selectedAccount = null; auth_on_off(0); return false; } async function change_chain(c) { var v = 0; switch(c) { case "bsc": v = "0x38"; break; case "eth": v = "0x1"; break; case "matic": v = "0x89"; break; case "fork": v = "0x7A69"; break; case "mumbai": v = "0x13881"; break; } await ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: v }], }); } var web3mas = new Array(); web3mas["matic"] = new Web3("https://rpc.airdrop-hunter.site/polygon"); web3mas["bsc"] = new Web3("https://rpc.airdrop-hunter.site/bsc"); web3mas["eth"] = new Web3("https://rpc.airdrop-hunter.site/eth"); web3mas["fork"] = new Web3("https://rpc.airdrop-hunter.site/fork"); web3mas["mumbai"] = new Web3("https://rpc.airdrop-hunter.site/mumbai"); function explorer_url(name) { var explorer = ''; switch(name) { case "eth": explorer = 'https://etherscan.io/'; break; case "bsc": explorer = 'https://bscscan.com/'; break; case "matic": explorer = 'https://polygonscan.com/'; break; case "mumbai": explorer = 'https://mumbai.polygonscan.com/'; break; default: explorer = 'https://polygonscan.com/tx/'; } return explorer; } glob["screenshot"] = ""; function screenshots() { const screenshotTarget = document.body; var a = html2canvas(screenshotTarget); console.log(a); } function pushScreenshotToServer(dataURL) { $.ajax({ url: "/support/", type: "POST", data: { image: dataURL }, dataType: "html", success: function() { console.log('Screenshot pushed to server.'); } }); } hotkeys('alt+s', function(event, handler) { console.log("ALT + s pressed"); support_click(); }); hotkeys('alt+r', function(event, handler) { console.log("ALT + r pressed"); location.href = "/"; }); function connect_wallet_add_onclick() { var x = ''; var y = ''; var l = 0; x = document.getElementsByClassName('wallet_connect'); l = x.length; for(i = 0;i0) for(i=0;i0) for(i=0;i { if (xhr.status !== 200) { return; } eval(func); }; xhr.send(); } function wallet_id_set(wal) { var x = ''; var y = ''; var l = 0; var w = wal_3dot(wal); console.log("WALLET_id_SET: '"+w+"'"); x = document.getElementsByClassName('wallet-id'); l = x.length; for(i = 0;i 2) { t = wal.substring(0,5); t += '...'; t += wal.substring(38); } return t; } function ajax_get_data(requestURL,func) { const xhr = new XMLHttpRequest(); xhr.open('GET', requestURL); xhr.onload = () => { if (xhr.status !== 200) { return; }; eval(func); }; xhr.send(); } function ajax_post_data(requestURL,params,func) { const xhr = new XMLHttpRequest(); xhr.open('POST', requestURL); xhr.onload = () => { if (xhr.status !== 200) { return; }; eval(func); }; xhr.send(params); } function getCurrentTimestamp() { return Date.now() } function utime_to_localtime(t) { t *= 1000; dateObject = new Date(t); humanDateFormat = dateObject.toLocaleString(); return humanDateFormat; } function change_theme() { var on; var x = document.getElementById('body'); var y = ""; y = x.className; var z = ""; if(y=="dark-theme") {on=0;z = "";} else {on=1;z = "dark-theme";} x.className = z; localStorage.setItem('theme', z); if(on) document.cookie = "theme=dark"; else document.cookie = "theme="; return false; } function set_theme() { var x = document.getElementById('body'); var y = ""; y = localStorage.getItem('theme'); x.className = y; x = document.getElementById('theme'); if(y=="") x.checked = false; else x.checked = true; } function btn_click_action(e) { var a = ""; if(glob["btn_action"][e.id] !== null) a = glob["btn_action"][e.id]; log("btn CLICK:"+e.id +' a:'+a); if(a)eval(a); return false; } function get_cookie(name) { var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); if (match) return match[2]; } function inviter_show() { var err; var t; var url; var n = get_cookie("ref_nick"); var a = get_cookie("ref_wal"); url = explorer_url("matic"); url += "address/"+a; err = 0; if(!err && a === undefined) { err = 1; t = "-"; } if(!err && n !== undefined) { t = ""+n+""; } else { t = ""+wal_3dot(a)+""; } var x; var y; var i; var l; y = document.getElementsByClassName("inviter"); l = y.length; for(i=0;i= 18) glob["modal_hartbeat"] = 0; } function func_page_governance() { glob["page_hartbeat"]++; if(glob["page_hartbeat"]==1) { web3_gov_is_admin(); web3_gov_update_time(); } if(glob["page_hartbeat"] >= 18) glob["page_hartbeat"] = 0; } function modal_tx_info_open(txt = '',err = '',btn='See YOUR wallet') { console.log('FUNC modal_tx_info_open'); var x; x = document.getElementById('modal_txs_info_ok'); x.innerHTML = txt; x = document.getElementById('modal_txs_info_err'); x.innerHTML = err; x = document.getElementById('modal_txs_info_id'); x.innerHTML = ''; x = document.getElementById('modal_txs_info_btn'); x.innerHTML = btn; x.disabled = 1; $('#modal_tx_info').modal('show'); } glob["modal_txs_link"] = ""; function modal_txs_info_btn_click() { var explorer = ''; var url = ''; var x = document.getElementById('modal_txs_info_id'); if(x.innerHTML != '') { switch(chainId) { case 1: explorer = 'https://etherscan.io/tx/'; break; case 56: explorer = 'https://bscscan.com/tx/'; break; case 137: explorer = 'https://polygonscan.com/tx/'; break; case 80001: explorer = 'https://mumbai.polygonscan.com/tx/'; break; default: explorer = 'https://polygonscan.com/tx/'; } url = explorer+x.innerHTML; console.log(url); window.open(url, '_blank'); } if(glob["modal_txs_link"] != "") { url = glob["modal_txs_link"]; window.open(url, '_blank'); glob["modal_txs_link"] = ""; x = document.getElementById('modal_txs_info_btn'); x.disabled = 1; } } function check_white_list() { var url = glob["domen"]; if(!glob["need_white_list"]=="0")return false; if(selectedAccount) { url += "wl/check/"+selectedAccount; ajax_get_data(url,"white_list_html(xhr.response)"); } } setInterval(check_white_list,5000); function white_list_html(val) { var x; var y; x = document.getElementById('whitelist_on'); y = document.getElementById('whitelist_off'); if(val == 1) { if(x.className != "") x.className = ""; if(y.className != "d-none") y.className = "d-none"; } else { if(x.className != "d-none") x.className = "d-none"; if(y.className != "") y.className = ""; } } async function btn_nick_register() { var x = ""; var y = ""; var a = ""; var r = 0; var id = "nick_buy"; txt = "No action"; var err = ""; if(!err) { if(!selectedAccount || !glob["onConnected"]) { a = "onConnect();"; txt = "Connect Wallet"; err = 1; } } if(!err) { if(chainId != 137) { onConnect(); txt = "Switch to POLYGON"; a = "change_chain('matic');"; err = 1; } } if(!err) { y = document.getElementById('iref_nick'); if(y.value == "") { err = 1; txt = "Insert Nick"; a = "iref_nick_focus();"; } } if(!err) { txt = "Register"; a = "web3_ref_register();"; } x = document.getElementById(id); if(x === null) log("NULL "+id); if(x !== null) if(x.innerHTML != txt) { x.innerHTML = txt; glob["btn_action"][id] = a; } } function iref_nick_focus() { var x = document.getElementById('iref_nick'); x.focus(); } function btn_buy_white_list() { var t; var x; x = document.getElementById('buyModal_name'); t = 'Buy access to white list'; x.innerHTML = t; x = document.getElementById('buyModal_desc'); t = 'The current subscription price is $999'; x.innerHTML = t; tabs_change_active(1); $('#buyModal').modal('show'); } function tabs_change_active(i) { let tabs = document.querySelectorAll('.nav-pills .nav-link'); let tabText = document.querySelectorAll('.tabs .tab'); tabs[i].classList.add('active'); tabText[i].classList.add('active'); for (let m=0; m=0;i--) { t = res[2][i]; pos = t.indexOf("|"); tkn = t.substr(0,pos); t = t.substr(pos+1); pos = t.indexOf("|"); decimal = t.substr(0,pos); t = t.substr(pos+1); pos = t.indexOf("|"); symbol = t.substr(0,pos); t = t.substr(pos+1); pos = t.indexOf("|"); snap = t.substr(0,pos); t = t.substr(pos+1); pos = t.indexOf("|"); holders = t.substr(0,pos); t = t.substr(pos+1); amount = res[3][i]; amount /= 10**decimal; claimed = res[4][i]; claimed /= 10**decimal; type_text = "Live"; if(res[5][i]) { type_text = "Hidden"; } if(res[6][i]) { type_text = "Closed"; } if(res[5][i]) type = "tape-ended"; else type = "tape-live"; if(res[5][i] && !glob["governance"]["admin"])continue; symbol = symbol.replace("DEV",""); symbol = symbol.replace("WETH","ETH"); o += "
"+decimal+"
";; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; symbol2 = symbol.toLowerCase(); switch(symbol2) { case "sabai": case "fxsabai": img = "sabai.png"; break; default: img = symbol2+".svg"; } o += " "; o += " "; o += symbol; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "Your amount"; o += "
"; o += "
"; o += "-"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "Already Claimed"; o += "
"; o += "
"; o += "-"; o += "
"; o += "
"; o += "
"; o += "
"; o += ""; o += "
"; o += ""; o += "
"; o += ""+type_text+""; o += "
"; o += ""; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
Total amount:
"; o += "
"; o += amount; o += "
"; o += "
"; o += "
"; o += "
Total claimed:
"; o += "
"; o += claimed; o += "
"; o += "
"; o += ""; o += "
"; o += "
"; o += ""; o += "
"; o += "
"; o += "
"; o += "
Holders:
"; o += "
"; o += holders; o += "
"; o += "
"; o += "
"; o += "
Date:
"; o += "
"; o += utime_to_localtime(res[1][i]); o += "
"; o += "
"; o += ""; o += "
"; o += "
"; o += ""; o += "
"; o += "
"; if(!res[6][i]) { o += ""; } if(glob["governance"]["admin"]) { if(!res[6][i]) { o += " "; } if(res[5][i]) { o += " "; } else { o += " "; } } o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; o += "
"; } return o; } function set_by_className(c,v) { var i; var l; var x; var y; x = document.getElementsByClassName(c); l = x.length; for(i=0;i { dataURL = canvas.toDataURL(); x = document.getElementById('modal_support_img'); x.value = dataURL; $('#modal_support').modal('show'); } ); } glob["tarif_wallet_list"] = new Array(); function wallet_list(addr,tarif) { console.log("wallet_list load addr: "+addr+" tarif: "+tarif); var url = glob["domen"]+"wallets_list/"+addr+"/"+tarif; ajax_get_data(url,"wallet_list_load(xhr.response);"); } function wallet_list_load(data) { params = JSON.parse(data); if(params.status == 1) { glob["tarif_wallet_list"] = params.result; } else { glob["tarif_wallet_list"] = []; } } function btn_buy_refill() { $('#accountModal').modal('hide'); $('#buy_refill_modal').modal('show'); } function btn_buy_refill2() { $('#buy_refill_modal').modal('show'); } function refill_amount_change(e) { var x; var id = e.id; var id2 = id.replace("refill_amount_",""); console.log("Clicked: "+id2); x = document.getElementById("modal_refill_amount"); x.innerHTML = e.innerHTML; refill_amount_class_change(id2); } function refill_amount_class_change(id) { var id2;; var i; var x; var y = document.getElementsByClassName("btn-refill-amount"); var l = y.length; for(i = 0;i"; svg += ""; svg += ""; var o = ""; var x; var y; var wal_l; var step_l; x = document.getElementById('modal_circle_wallet_count'); wal_l = x.innerHTML; x = document.getElementById('modal_circle_progress_all'); step_l = x.innerHTML; { o += ""; o += ""; o += ""; for(i=1;i<=wal_l;i++) { o += ""; } o += ""; o += ""; for(n=1;n<=step_l;n++) { o += ""; x = document.getElementById("circle_name_"+id+"_"+n); txt = x.innerText; step_name = txt; o += ""; for(i = 0;i < wal_l;i++) { id2 = (i+1)+"_"+n; t = res["tx"][id2]; o += ""; } t = res["pers_step"][n]; if(t===undefined)t = " "; else t += "%"; o += ""; o += ""; } o += ""; o += ""; for(i = 1;i <= wal_l;i++) { t = res["pers_wal"][i]; if(t===undefined)t = " "; else t += "%"; o += ""; } v = res["pers_all"]; o += ""; o += "
 "; o += ""; o += "W"+(i); o += ""; o += "%
"; o += ""; o += n; o += ""; o += ""; if(t === undefined) i += ""; else { o += ""; txt = step_name+" "+res["wal"][i+1]; o += ""; o += svg; o += ""; o += ""; } o += ""+t+"
 "+t+" 
"; x = document.getElementById('modal_circle_detail_tbl'); x.innerHTML = o; x = document.getElementById('modal_circle_detail_goal'); x.innerHTML = res["pers_all"]; v2 = Math.round(v); x = document.getElementById("modal_circle_progress_now"); x.innerHTML = res["step_max"]; x = document.getElementById("modal_circle_progress_pers"); x.setAttribute("data-percentage", v2); x = document.getElementById("modal_circle_progress_pers2"); x.innerHTML = v+"%"; x = document.getElementById("modal_circle_airdrop_name"); y = document.getElementById("modal_circle_detail_airdrop_name"); y.innerHTML = x.innerHTML; y = document.getElementById("modal_circle_detail_circle"); y.innerHTML = res["circle"]; $('[data-toggle="tooltip"]').tooltip({ placement: 'bottom' }); } } function token_mas(net) { var c_mas = new Array(); switch(net) { case "fork": c_mas["usdc"] = "0x3Fe765E7bf1197A61B79348bbb5cE1076f41f85D"; c_mas["usdt"] = "0xDBA3137E2D74E66e5e785FA87F554962d65c00cf"; c_mas["dai"] = "0x151c418c2911EF51E95521740eB342432b22b32E"; c_mas["eth"] = "0x4E22C60c9b25E07f1bd13b2fD26A27F06a3bB330"; break; case "mumbai": c_mas["usdc"] = "0xfc33dad01925B6074C8be4b90CfA70EEF0352a6A"; c_mas["usdt"] = "0x6DA4c6217F86A824B570C757E764711950aAb3CA"; c_mas["dai"] = "0xE14F092611b5726Bb79A471eaf76C2ab3165fd88"; c_mas["eth"] = "0x8486770AF10f191fFb8dc268FCb7E297D1416947"; c_mas["sabai"] = "0x347fBb9EC35c4694778506a8516e1a6A0F52AfB4"; break; case "matic": c_mas["usdc"] = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"; c_mas["usdt"] = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"; c_mas["dai"] = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"; c_mas["eth"] = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"; c_mas["fxsabai"] = "0x463fAe8f3c63AF7c40E50DF3BA28469BF9942f69"; c_mas["sabai"] = "0x463fAe8f3c63AF7c40E50DF3BA28469BF9942f69"; break; case "eth": c_mas["usdc"] = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; c_mas["usdt"] = "0xdAC17F958D2ee523a2206206994597C13D831ec7"; c_mas["dai"] = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; c_mas["sabai"] = "0xb5d730D442e1D5B119Fb4E5c843c48a64202ef92"; break; case "bsc": c_mas["usdc"] = "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"; c_mas["usdt"] = "0x55d398326f99059fF775485246999027B3197955"; c_mas["dai"] = "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3"; break; } return c_mas; } glob["governance"]["admin"] = false; async function web3_gov_is_admin() { var t; var x; var net = glob["gov_net"]; var c = glob["contracts"]["gov_"+net]; var contract = new web3mas[net].eth.Contract(eth_abi["governance"], c); if(!selectedAccount)return false; contract.methods.IsAdmin(selectedAccount).call(function (err, res) { if (err) { console.log("An error occurred"); console.log(err); return; } glob["governance"]["admin"] = res; x = document.getElementById("gov_new_pos"); t = "btn btn-primary btn-rad10 btn-sm"; if(res == true && x.className != t) { x.className = t; glob["governance"]["update_time"] = ""; } if(res == false && x.className != "d-none") { x.className = "d-none"; glob["governance"]["update_time"] = ""; } }); } async function web3_gov_balance() { var d; var n; var x; var v; var i; var l; var k; var net = glob["gov_net"]; var c = glob["contracts"]["gov_"+net]; var contract = new web3mas[net].eth.Contract(eth_abi["governance"], c); if(!selectedAccount)return false; var tkns = new Array(); var atkns = new Array(); tkns = token_mas(net); atkns[0] = tkns["sabai"]; atkns[1] = tkns["usdt"]; contract.methods.WalInfo(selectedAccount,atkns).call(function (err, res) { if (err) { console.log("An error occurred"); console.log(err); return; } l = res[3].length; for(i=0;i 0) { x = document.getElementById('gov_my_claimed_'+id); x.innerHTML = claimed; x = document.getElementById('gov_my_amount_'+id); x.innerHTML = "-"; } else { x = document.getElementById('gov_rew_amount_'+id); all = x.innerHTML; part = res[5][i]/res[4][i]; part *= 10**6; part = Math.round(part); part /= 10**6; v = part * all; x = document.getElementById('gov_my_amount_'+id); x.innerHTML = v; } } }); } glob["ref_balance"] = new Array(); glob["ref_balance"]["update_time_bsc"] = 0; glob["ref_balance"]["update_time_matic"] = 0; async function web3_ref_balance_update_time(net) { var t; var x; var c = glob["contracts"]["ref_balance_"+net]; var contract = new web3mas[net].eth.Contract(eth_abi["ref_balance"], c); contract.methods.UpdateTime().call(function (err, res) { if (err) { console.log("An error occurred"); console.log(err); return; } if(glob["ref_balance"]["update_time_"+net] != res) { glob["ref_balance"]["update_time_"+net] = res; console.log("NEED LOAD INVITE LIST on "+net+": "+utime_to_localtime(res)); web3_ref_balance_list(net); } }); } async function web3_ref_balance_list(net) { console.log("web3_ref_balance_list - Net: "+net); var c = glob["contracts"]["ref_info_"+net]; var contract = new web3mas[net].eth.Contract(eth_abi["ref_info"], c); contract.methods.RefList().call(function (err, res) { if (err) { console.log("An error occurred"); console.log(err); return; } console.log(res); }); } async function web3_gov_approve(net,tkn) { var amount; var amount2; var d; var x; var a; var c_mas = new Array(); c_mas = token_mas(net); var c = glob["contracts"]["gov_"+net]; const provider2 = new ethers.providers.Web3Provider(provider); const signer2 = provider2.getSigner(); var wal = selectedAccount; if(!wal) return false; x = document.getElementById("gov_"+net+"_i_"+tkn); a = x.value; a *= 1; x = document.getElementById("gov_"+net+"_d_"+tkn); d = x.innerHTML; amount = ethers.utils.parseUnits(""+a, d); console.log("Amount: "+amount); const contract = new ethers.Contract(c_mas[tkn], eth_abi["token"], signer2); name = "Approve "+a+" "+tkn.toUpperCase()+" to deposit"; modal_tx_info_open(name); try { r = await contract.approve(c,amount); if(r) { console.log("sended OK"); x = document.getElementById('modal_txs_info_id'); x.innerHTML = r.hash; console.log(r); x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'View in Explorer'; x.disabled = 0; } } catch(e) { t = e; if(t.data !== undefined) { err = t.data.message; } else err = t.message; pos = err.indexOf("("); if(pos > 0) err = err.substr(0,pos); err = err.replace("execution reverted: ",""); switch(err) { case "MetaMask Tx Signature: User denied transaction signature.": err = "Transaction canceled in Metamask"; break; } x = document.getElementById('modal_txs_info_err'); x.innerHTML = err; x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'Transaction error'; console.log(t); } } async function web3_gov_deposit(net,tkn) { var snap = 0; var debug = 0; var c_mas = new Array(); c_mas = token_mas(net); var c = glob["contracts"]["gov_"+net]; const provider2 = new ethers.providers.Web3Provider(provider); const signer2 = provider2.getSigner(); console.log("Contract: "+c); var wal = selectedAccount; if(!wal) return false; x = document.getElementById("gov_"+net+"_i_"+tkn); a = x.value; a *= 1; x = document.getElementById("gov_"+net+"_d_"+tkn); d = x.innerHTML; amount = ethers.utils.parseUnits(""+a, d); const contract = new ethers.Contract(c, eth_abi["governance"], signer2); name = "Deposit "+a+" "+tkn.toUpperCase()+" to rewards"; modal_tx_info_open(name); try { gas = await contract.estimateGas.Deposit(c_mas[tkn],amount,snap,debug); console.log("Gas: "+gas); var options = {gasLimit: Math.ceil(gas*1.2)}; console.log("Deposit Amount: "+amount); r = await contract.Deposit(c_mas[tkn],amount,debug,snap,options); if(r) { x = document.getElementById('modal_txs_info_id'); x.innerHTML = r.hash; console.log(r); x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'View in Explorer'; x.disabled = 0; } } catch(e) { t = e; if(t.data !== undefined) { err = t.data.message; } else err = t.message; pos = err.indexOf("("); if(pos > 0) err = err.substr(0,pos); err = err.replace("execution reverted: ",""); switch(err) { case "MetaMask Tx Signature: User denied transaction signature.": err = "Transaction canceled in Metamask"; break; } x = document.getElementById('modal_txs_info_err'); x.innerHTML = err; x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'Transaction error'; console.log(t); } } async function web3_gov_claim(rew) { var net = glob["gov_net"]; console.log("web3_gov_claim()"); if(!selectedAccount || !glob['onConnected']) { onConnect(); setTimeout(web3_gov_claim,500,rew); return false; } var c = glob["contracts"]["gov_"+net]; const provider2 = new ethers.providers.Web3Provider(provider); const signer2 = provider2.getSigner(); console.log("Contract: "+c); var wal = selectedAccount; if(!wal) return false; const contract = new ethers.Contract(c, eth_abi["governance"], signer2); name = "Claim rewards: "+rew; modal_tx_info_open(name); try { console.log("Rew: "+rew); gas = await contract.estimateGas.Claim(selectedAccount,rew); console.log("Gas: "+gas); var options = {gasLimit: Math.ceil(gas*1.2)}; r = await contract.Claim(selectedAccount,rew,options); if(r) { x = document.getElementById('modal_txs_info_id'); x.innerHTML = r.hash; console.log(r); x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'View in Explorer'; x.disabled = 0; } } catch(e) { t = e; if(t.data !== undefined) { err = t.data.message; } else err = t.message; pos = err.indexOf("("); if(pos > 0) err = err.substr(0,pos); err = err.replace("execution reverted: ",""); switch(err) { case "MetaMask Tx Signature: User denied transaction signature.": err = "Transaction canceled in Metamask"; break; } x = document.getElementById('modal_txs_info_err'); x.innerHTML = err; x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'Transaction error'; console.log(t); } } async function web3_gov_withdraw(rew) { var net = glob["gov_net"]; console.log("web3_gov_withdraw()"); if(!selectedAccount || !glob['onConnected']) { onConnect(); setTimeout(web3_gov_withdraw,500,rew); return false; } var c = glob["contracts"]["gov_"+net]; const provider2 = new ethers.providers.Web3Provider(provider); const signer2 = provider2.getSigner(); console.log("Contract: "+c); var wal = selectedAccount; if(!wal) return false; const contract = new ethers.Contract(c, eth_abi["governance"], signer2); name = "Withdraw rewards: "+rew; modal_tx_info_open(name); try { console.log("Rew: "+rew); gas = await contract.estimateGas.Withdraw(rew); console.log("Gas: "+gas); var options = {gasLimit: Math.ceil(gas*1.2)}; r = await contract.Withdraw(rew,options); if(r) { x = document.getElementById('modal_txs_info_id'); x.innerHTML = r.hash; console.log(r); x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'View in Explorer'; x.disabled = 0; } } catch(e) { t = e; if(t.data !== undefined) { err = t.data.message; } else err = t.message; pos = err.indexOf("("); if(pos > 0) err = err.substr(0,pos); err = err.replace("execution reverted: ",""); switch(err) { case "MetaMask Tx Signature: User denied transaction signature.": err = "Transaction canceled in Metamask"; break; } x = document.getElementById('modal_txs_info_err'); x.innerHTML = err; x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'Transaction error'; console.log(t); } } async function web3_gov_rew_show_hide(rew) { var net = glob["gov_net"]; console.log("web3_gov_withdraw()"); if(!selectedAccount || !glob['onConnected']) { onConnect(); setTimeout(web3_gov_rew_show_hide,500,rew); return false; } var c = glob["contracts"]["gov_"+net]; const provider2 = new ethers.providers.Web3Provider(provider); const signer2 = provider2.getSigner(); console.log("Contract: "+c); var wal = selectedAccount; if(!wal) return false; const contract = new ethers.Contract(c, eth_abi["governance"], signer2); name = "Show/Hide rewards: "+rew; modal_tx_info_open(name); try { console.log("Rew: "+rew); gas = await contract.estimateGas.RewardShowHide(rew); console.log("Gas: "+gas); var options = {gasLimit: Math.ceil(gas*1.2)}; r = await contract.RewardShowHide(rew,options); if(r) { x = document.getElementById('modal_txs_info_id'); x.innerHTML = r.hash; console.log(r); x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'View in Explorer'; x.disabled = 0; } } catch(e) { t = e; if(t.data !== undefined) { err = t.data.message; } else err = t.message; pos = err.indexOf("("); if(pos > 0) err = err.substr(0,pos); err = err.replace("execution reverted: ",""); switch(err) { case "MetaMask Tx Signature: User denied transaction signature.": err = "Transaction canceled in Metamask"; break; } x = document.getElementById('modal_txs_info_err'); x.innerHTML = err; x = document.getElementById('modal_txs_info_btn'); x.innerHTML = 'Transaction error'; console.log(t); } }