diff --git a/package-lock.json b/package-lock.json index 39c7d63..76c98c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ecto", - "version": "1.1.3", + "version": "1.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7866398..a0a8a35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ecto", - "version": "1.1.3", + "version": "1.1.4", "private": true, "scripts": { "build": "vue-cli-service build", diff --git a/src/locales/cn.json b/src/locales/cn.json index 30db2e3..e5f88d5 100644 --- a/src/locales/cn.json +++ b/src/locales/cn.json @@ -184,7 +184,8 @@ "crossChain": "异链传送", "sameChain": "同链传送", "sendOn": "发送到", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "已选择", diff --git a/src/locales/de.json b/src/locales/de.json index a96ee83..df7012d 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -184,7 +184,8 @@ "crossChain": "CROSS CHAIN ÜBERWEISUNGEN", "sameChain": "ÜBERWEISUNGEN AUF GLEICHER CHAIN", "sendOn": "Versand auf", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "ausgewählt", diff --git a/src/locales/en.json b/src/locales/en.json index 5616398..ee240f0 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -184,7 +184,8 @@ "crossChain": "CROSS CHAIN TRANSFERS", "sameChain": "SAME CHAIN TRANSFERS", "sendOn": "Send on", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "selected", diff --git a/src/locales/es.json b/src/locales/es.json index 0f5b84d..a1a5e28 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -184,7 +184,8 @@ "crossChain": "TRANSFERENCIA ENTRE CHAINS", "sameChain": "TRANSFERENCIA NORMAL", "sendOn": "Enviar en", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "seleccionado", diff --git a/src/locales/fr.json b/src/locales/fr.json index 8649c87..fc750a5 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -184,7 +184,8 @@ "crossChain": "TRANSFERTS INTER CHAINES", "sameChain": "TRANSFERTS INTRA CHAINES", "sendOn": "Envoi vers", - "cosmicSwap": "Vous n'avez pas assez de KCAL pour effectuer cette transaction. Désirez-vous utiliser des SOUL pour effectuer un cosmic swap?" + "cosmicSwap": "Vous n'avez pas assez de KCAL pour effectuer cette transaction. Désirez-vous utiliser des SOUL pour effectuer un cosmic swap?", + "viewOnExplorer": "voir adresse sur explorateur" }, "nfts": { "selected": "sélectionné", diff --git a/src/locales/it.json b/src/locales/it.json index 1d06649..3213ba4 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -184,7 +184,8 @@ "crossChain": "TRASFERIMENTI CROSS-CHAIN", "sameChain": "TRASFERIMENTI SU CHAIN SINGOLA", "sendOn": "Manda su", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "selezionato", diff --git a/src/locales/nb.json b/src/locales/nb.json index d8f01d5..a422d90 100644 --- a/src/locales/nb.json +++ b/src/locales/nb.json @@ -184,7 +184,8 @@ "crossChain": "OVERFØRING MELLOM ULIKE BLOKKKJEDER", "sameChain": "SEND PÅ SAMME BLOKKJEDE", "sendOn": "Send på", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "valgte", diff --git a/src/locales/nl.json b/src/locales/nl.json index 1f49490..7b0d9d2 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -8,7 +8,7 @@ "minted": "Minted", "sent": "Verstuurd", "sentTo": "Verstuurd naar", - "burned": "Burned", + "burned": "Verbrand", "claimed": "Claimed", "paid": "Betaald", "received": "Ontvangen", @@ -87,7 +87,7 @@ "claim": "Claim", "view": "Bekijk", "send": "Verstuur", - "burn": "Burn", + "burn": "Verbrand", "load": "Laad meer", "agree": "Eens", "disagree": "Oneens", @@ -97,11 +97,11 @@ "removeStakes": "Verwijder Stakes", "sendAmount": "Verstuur Aantal", "sendAmount2": "Welk aantal wil je versturen?", - "burnAmount": "Burn Amount", - "burnAmount2": "How many do you want to burn?", - "burnConfirmation": "Burn Confirmation", - "burnConfirmation1": "Please confirm that you are going to burn", - "burnConfirmation2": "

IMPORTANT NOTE: this is definitive and irreversible.", + "burnAmount": "Aantal verbrand", + "burnAmount2": "Welk aantal wil je verbranden?", + "burnConfirmation": "Verbrand Bevestiging", + "burnConfirmation1": "Bevestig de verbranding", + "burnConfirmation2": "

IMPORTANT NOTE: dit is definitief en onomkeerbaar.", "remaining": "Restant", "next": "Verder", "insertWIF": "Type jouw WIF in om een transactie goed te keuren.", @@ -136,7 +136,7 @@ "swap": "verwissel", "swapUppercase": "Verwissel", "swapHowMany": "Welk aantal wil je verwisselen?", - "swapFrom": "Swap van", + "swapFrom": "Verwissel van", "noSwapsNEO": "Er zijn geen bezittingen aan de NEO kant van jouw wallet die verwisseld kunnen worden.", "noSwapsETH": "Er zijn geen bezittingen aan de Ethereum kant van jouw wallet die verwisseld kunnen worden.", "sendAssetsSwap": "Stuur de bezittingen die je wilt verwisselen naar", @@ -184,14 +184,15 @@ "crossChain": "OVERDRACHTEN TUSSEN CHAINS", "sameChain": "OVERDRACHTEN OP DEZELFDE CHAIN", "sendOn": "Verstuur op", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "Onvoldoende KCAL om deze transactie uit te voeren. Gebruik SOUL voor deze transactie?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "gekozen", "send": "stuur NFT's", - "burn": "burn nfts", - "burnTitle": "Burn NFTs", - "confirmBurn": "Bevestig burn", + "burn": "verbrand nfts", + "burnTitle": "Verbrand NFTs", + "confirmBurn": "Bevestig verbranding", "confirmBurnSecond": "Dit is onherroepelijk, vernietigt deze NFTs en claimt de ingevoegde bezittingen, indien aanwezig.", "infused": "Ingevoegde bezittingen", "destination": "Bestemming", diff --git a/src/locales/pt.json b/src/locales/pt.json index 59fe0d9..9ca6d4d 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -184,7 +184,8 @@ "crossChain": "TRANSFERÊNCIAS ENTRE CHAINS", "sameChain": "TRANSFERÊNCIAS NA MESMA CHAIN", "sendOn": "Envia em", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "selecionado", diff --git a/src/locales/ru.json b/src/locales/ru.json index 12fc878..655b780 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -184,7 +184,8 @@ "crossChain": "КРОСС-ЧЕЙН ПЕРЕСЫЛКИ", "sameChain": "ПЕРЕСЫЛКИ В РАМКАХ ОДНОГО БЛОКЧЕЙНА", "sendOn": "Отправить в", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "выбрано", diff --git a/src/locales/tr.json b/src/locales/tr.json index 2fdd192..25b21b7 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -184,7 +184,8 @@ "crossChain": "ZİNCİR DEĞİŞİM İŞLEMLERİ", "sameChain": "DİĞER ZİNCİRLERDE TRANSFERLER", "sendOn": "Burada Gönder-Al,", - "cosmicSwap": "Hesabınızda yeterli KCAL bulunmamaktadır. Biraz SOUL kullanarak kozmik değişim yapılsın mı?" + "cosmicSwap": "Hesabınızda yeterli KCAL bulunmamaktadır. Biraz SOUL kullanarak kozmik değişim yapılsın mı?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "Seçildi", diff --git a/src/locales/vn.json b/src/locales/vn.json index 57e721d..18c5710 100644 --- a/src/locales/vn.json +++ b/src/locales/vn.json @@ -184,7 +184,8 @@ "crossChain": "CHUYỂN ĐỔI CHUỖI CHÉO", "sameChain": "CÙNG CHUYỂN ĐỔI CHUỖI", "sendOn": "Gửi tiếp", - "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?" + "cosmicSwap": "You do not have enough KCAL to perform this transaction. Use some SOUL to perform a cosmic swap?", + "viewOnExplorer": "view address on explorer" }, "nfts": { "selected": "đã chọn", diff --git a/src/manifest.development.json b/src/manifest.development.json index ea84109..48a9c3c 100644 --- a/src/manifest.development.json +++ b/src/manifest.development.json @@ -3,7 +3,7 @@ "name": "__MSG_appName__", "description": "__MSG_appDesc__", "default_locale": "en", - "version": "1.1.3", + "version": "1.1.4", "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" diff --git a/src/manifest.production.json b/src/manifest.production.json index f393b89..48ac573 100644 --- a/src/manifest.production.json +++ b/src/manifest.production.json @@ -3,7 +3,7 @@ "name": "__MSG_appName__", "description": "__MSG_appDesc__", "default_locale": "en", - "version": "1.1.3", + "version": "1.1.4", "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" diff --git a/src/neo/index.ts b/src/neo/index.ts index 7b2f486..761d0bc 100644 --- a/src/neo/index.ts +++ b/src/neo/index.ts @@ -20,6 +20,15 @@ const tokens = { GAS: "0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7", }; +let isPrimaryRpcDead = false; + +function getNeoRpc(isMainnet: boolean) { + if (!isMainnet) return "http://mankinighost.phantasma.io:30333"; + return !isPrimaryRpcDead + ? "http://seed.neoeconomy.io:10332" + : "http://jpc.phantasma.io:10332"; +} + function ab2hexstring(arr: ArrayBuffer | ArrayLike): string { if (typeof arr !== "object") { throw new Error(`ab2hexstring expects an array.Input was ${arr}`); @@ -50,10 +59,18 @@ export async function getNeoBalances( neoAddress: string, isMainnet: boolean ): Promise { - const neoRpc = isMainnet - ? "http://seed.neoeconomy.io:10332" - : "http://mankinighost.phantasma.io:30333"; - const account = await rpc.Query.getAccountState(neoAddress).execute(neoRpc); + let neoRpc = getNeoRpc(isMainnet); + + let account = null; + try { + account = await rpc.Query.getAccountState(neoAddress).execute(neoRpc); + } catch { + isPrimaryRpcDead = true; + console.log("primary neo rpc", neoRpc, "is not working"); + neoRpc = getNeoRpc(isMainnet); + console.log("trying secondary neo rpc", neoRpc); + account = await rpc.Query.getAccountState(neoAddress).execute(neoRpc); + } console.log("neo account", account); @@ -168,9 +185,7 @@ async function sendNep5( ); // Send raw transaction - const neoRpc = isMainnet - ? "http://seed.neoeconomy.io:10332" - : "http://mankinighost.phantasma.io:30333"; + const neoRpc = getNeoRpc(isMainnet); const client = new rpc.RPCClient(neoRpc); const res = await client.sendRawTransaction(rawTransaction); console.log("sendNep5 Raw Tx", res, rawTransaction); @@ -207,9 +222,7 @@ async function sendNative( } // Send raw transaction - const neoRpc = isMainnet - ? "http://seed.neoeconomy.io:10332" - : "http://mankinighost.phantasma.io:30333"; + const neoRpc = getNeoRpc(isMainnet); const client = new rpc.RPCClient(neoRpc); const transaction = await createTxWithNeoScan(); diff --git a/src/phan-js/rpc/phantasma.ts b/src/phan-js/rpc/phantasma.ts index 0e683c9..68f4815 100644 --- a/src/phan-js/rpc/phantasma.ts +++ b/src/phan-js/rpc/phantasma.ts @@ -289,12 +289,20 @@ export class PhantasmaAPI { var http = new XMLHttpRequest(); http.open("GET", host + "/rpc", true); + http.timeout = 4500; http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { var ended = new Date().getTime(); var milliseconds = ended - started; resolve(milliseconds); } + + http.ontimeout = function() { + resolve(100000); + }; + http.onerror = function() { + resolve(100000); + }; }; try { http.send(null); diff --git a/src/popup/PopupState.ts b/src/popup/PopupState.ts index 3330260..d2aff66 100644 --- a/src/popup/PopupState.ts +++ b/src/popup/PopupState.ts @@ -109,7 +109,7 @@ export class PopupState { allSwaps: Swap[] = []; - payload = "4543542D312E312E33"; + payload = "4543542D312E312E34"; $i18n: any = { t: (s: string) => s, diff --git a/src/views/Home.vue b/src/views/Home.vue index db4f126..5476112 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -197,9 +197,7 @@ small text style="padding: 0 6px;" - v-if=" - state.isBurnable(item.symbol) - " + v-if="state.isBurnable(item.symbol)" @click="burnAsset($event, item)" :disabled="item.amount == 0" >mdi-fire {{ $t("home.burn") }}mdi-content-copy +
+ {{ $t("home.viewOnExplorer") }}
{{ $t("home.swappableAssets") }} @@ -391,6 +397,14 @@ @click="copyToClipboard(account.neoAddress)" >mdi-content-copy +
+ {{ $t("home.viewOnExplorer") }} mdi-content-copy +
+ {{ $t("home.viewOnExplorer") }}
{{ $t("home.swappableAssets") }} @@ -476,6 +498,14 @@ @click="copyToClipboard(account.ethAddress)" >mdi-content-copy +
+ {{ $t("home.viewOnExplorer") }} {{ $t("home.importETHWallet") }} - {{ $t("home.withYourKey") }}mdi-content-copy +
+ {{ $t("home.viewOnExplorer") }} mdi-content-copy +
+ {{ $t("home.viewOnExplorer") }} @@ -1169,7 +1212,8 @@ - {{ $t("home.burnConfirmation1") }} {{ burnAmount }} {{ burnSymbol }}. + {{ $t("home.burnConfirmation1") }} {{ burnAmount }} + {{ burnSymbol }}. @@ -1177,7 +1221,11 @@ - + {{ $t("home.cancel") }} @@ -2542,15 +2590,7 @@ export default class extends Vue { ) as number; this.swapAmountDialog = true; - const res = await fetch("https://gasprice.poa.network/"); - - const resJson = await res.json(); - - this.ethGasPrices[0] = resJson.slow; - this.ethGasPrices[1] = resJson.standard; - this.ethGasPrices[2] = parseFloat( - ((resJson.fast + resJson.instant) / 2).toFixed(2) - ); + await this.fetchEthGasPrices(); } async askSendEth(bal: ISymbolAmount) { @@ -2571,15 +2611,7 @@ export default class extends Vue { } this.swapAmountDialog = true; - const res = await fetch("https://gasprice.poa.network/"); - - const resJson = await res.json(); - - this.ethGasPrices[0] = resJson.slow; - this.ethGasPrices[1] = resJson.standard; - this.ethGasPrices[2] = parseFloat( - ((resJson.fast + resJson.instant) / 2).toFixed(2) - ); + await this.fetchEthGasPrices(); } askSwapFromNeo(bal: ISymbolAmount) { @@ -2648,7 +2680,7 @@ export default class extends Vue { console.log("hash from sendNeo", hash); const neoApi = isMainnet - ? "https://neoscan.io/transaction/" + ? "https://dora.coz.io/transaction/neo2/" : "http://mankinighost.phantasma.io:4000/transaction/"; this.lastSwapTxUrl = neoApi + hash; this.swapInProgressDialog = true; @@ -3187,7 +3219,7 @@ export default class extends Vue { async burnFT() { if (!this.account) return; - console.log("burning " + this.burnAmount + ' of ' + this.burnSymbol); + console.log("burning " + this.burnAmount + " of " + this.burnSymbol); const address = this.account.address; const gasPrice = 100000; @@ -3197,7 +3229,11 @@ export default class extends Vue { sb.beginScript(); sb.allowGas(address, sb.nullAddress, gasPrice, minGasLimit); - sb.callInterop("Runtime.BurnTokens", [address, this.burnSymbol, Math.floor(this.burnAmount * 10 ** this.burnDecimals)]); + sb.callInterop("Runtime.BurnTokens", [ + address, + this.burnSymbol, + Math.floor(this.burnAmount * 10 ** this.burnDecimals), + ]); sb.spendGas(address); const script = sb.endScript(); @@ -3407,15 +3443,7 @@ export default class extends Vue { ).replace(/ /gi, "") ); - const res = await fetch("https://gasprice.poa.network/"); - - const resJson = await res.json(); - - this.ethGasPrices[0] = resJson.slow; - this.ethGasPrices[1] = resJson.standard; - this.ethGasPrices[2] = parseFloat( - ((resJson.fast + resJson.instant) / 2).toFixed(2) - ); + await this.fetchEthGasPrices(); if (this.sendSymbol == "GAS") { this.sendMaxAmount -= 0.1; @@ -3451,15 +3479,54 @@ export default class extends Vue { } async onSwapsTab() { - const res = await fetch("https://gasprice.poa.network/"); + await this.fetchEthGasPrices(); + } - const resJson = await res.json(); + async fetchEthGasPrices() { + const minPrices = [10, 30, 50]; + const prices = [10, 30, 50]; + let hasSetPrices = false; - this.ethGasPrices[0] = resJson.slow; - this.ethGasPrices[1] = resJson.standard; - this.ethGasPrices[2] = parseFloat( - ((resJson.fast + resJson.instant) / 2).toFixed(2) - ); + try { + const res = await fetch("https://gasprice.poa.network/"); + const resJson = await res.json(); + + if (resJson) { + const slow = resJson.slow; + const standard = resJson.standard; + const fast = (resJson.fast + resJson.instant) / 2; + if (slow > minPrices[0]) prices[0] = slow; + if (standard > minPrices[1]) prices[1] = standard; + if (fast > minPrices[2]) prices[2] = fast; + hasSetPrices = true; + } + } catch { + console.log("Error fetching gas prices from gasprice.poa.network"); + } + + try { + const res = await fetch("https://www.etherchain.org/api/gasPriceOracle"); + const resJson = await res.json(); + + if (resJson) { + const slow = resJson.safeLow; + const standard = resJson.standard; + const fast = (resJson.fast + resJson.fastest) / 2; + if (slow > minPrices[0]) + prices[0] = hasSetPrices ? (prices[0] + slow) / 2 : slow; + if (standard > minPrices[1]) + prices[1] = hasSetPrices ? (prices[1] + standard) / 2 : standard; + if (fast > minPrices[2]) { + prices[2] = hasSetPrices ? prices[2] + fast / 2 : fast; + } + } + } catch { + console.log("Error fetching gas prices from etherchain"); + } + + this.ethGasPrices[0] = parseFloat(prices[0].toFixed(1)); + this.ethGasPrices[1] = parseFloat(prices[1].toFixed(1)); + this.ethGasPrices[2] = parseFloat(prices[2].toFixed(1)); } async loadMoreTxs() {