()
| 31 | |
| 32 | |
| 33 | async function init(){ |
| 34 | if (ready) return; |
| 35 | try { |
| 36 | if (window.location.protocol == 'file:') throw new Error("Please load this App from HTTP/HTTPS server(local web server should work good), because of browser security reason you can't connect remote server from local file script."); |
| 37 | |
| 38 | if (!window.ethereum) throw new Error("Ethereum Wallet doesnt work at this page, please enable it and reload page."); |
| 39 | |
| 40 | // if (!Web3 && !window.ethers) { |
| 41 | if (!Web3) { |
| 42 | // throw new Error("Please load Web3 or ethers.js library before this App"); |
| 43 | throw new Error("Please load Web3 library before this App"); |
| 44 | } |
| 45 | if (!window.ethers) { |
| 46 | throw new Error("Please load ethers.js library before this App"); |
| 47 | } |
| 48 | |
| 49 | web3 = new Web3(Web3.givenProvider || "ws://localhost:8545"); |
| 50 | |
| 51 | lang = parseDocumentLang(); |
| 52 | lang = lang ? lang : config.lang; |
| 53 | |
| 54 | await parseXML(); |
| 55 | |
| 56 | // if (tokens.length) |
| 57 | bar = createFloatingBox(); |
| 58 | |
| 59 | ready = true; |
| 60 | } catch (e) { |
| 61 | let message = ' ;init error happened -> ' + e; |
| 62 | catchDebug && console.log(message); |
| 63 | catchDebug && console.log(e); |
| 64 | throw new Error(message); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | Get document lang |
no test coverage detected