From 62fda68ab0bd6fa3dcf5f3df948f242570c41cef Mon Sep 17 00:00:00 2001 From: XTON wallet Date: Fri, 17 Nov 2023 18:41:44 +0300 Subject: [PATCH] added testOnly addresses --- src/background/controller.js | 2 +- src/common/tonLib.js | 4 ++-- src/common/tonweb/contract/index.js | 4 ++-- src/common/utils.js | 4 ++-- src/components/Elements/AccountsList.svelte | 4 ++-- .../Elements/Popup/AccountsList.svelte | 4 ++-- .../Popup/Modals/ConfirmRawTransaction.svelte | 4 ++-- .../Popup/Modals/ConfirmTransaction.svelte | 4 ++-- .../Popup/Modals/SendingTransaction.svelte | 6 +++--- .../Popup/Modals/ShowNftContent.svelte | 8 ++++---- .../Pages/Account/AccountMain.svelte | 12 ++++++------ src/components/Pages/Backup/ViewKeys.svelte | 18 ++++++++---------- .../Pages/FirstRun/DeployWallet.svelte | 4 ++-- src/components/Pages/Popup/PopupMain.svelte | 12 ++++++------ .../Pages/Popup/StatisticMain.svelte | 2 +- src/components/Pages/Restore/AddWallets.svelte | 6 +++++- src/components/Pages/Restore/Complete.svelte | 8 ++++++-- 17 files changed, 56 insertions(+), 50 deletions(-) diff --git a/src/background/controller.js b/src/background/controller.js index b29bfad..0ec6617 100644 --- a/src/background/controller.js +++ b/src/background/controller.js @@ -929,7 +929,7 @@ export const controller = () => { for (let i in parsedParams.messages) { const modalData = { ...data }; modalData.params = {}; - modalData.params.to = TonWeb.Address.parse(parsedParams.messages[i].address).toString({urlSafe: true, bounceable: false, testOnly: true}); + modalData.params.to = TonWeb.Address.parse(parsedParams.messages[i].address).toString({urlSafe: true, bounceable: false, testOnly: parsedParams.network != -239}); modalData.params.amount = parsedParams.messages[i].amount; totalBalance += Number(parsedParams.messages[i].amount).valueOf(); //(integer, optional): unix timestamp. after this moment transaction will be invalid. diff --git a/src/common/tonLib.js b/src/common/tonLib.js index ef6d984..609ed57 100644 --- a/src/common/tonLib.js +++ b/src/common/tonLib.js @@ -95,11 +95,11 @@ class TonLib { } const WalletClass = this.instance.wallet.all[version]; - const toAddress = TonWeb.Address.parse(address).toString({urlSafe: true, bounceable: false, testOnly: true}); + const toAddress = TonWeb.Address.parse(address).toString({urlSafe: true, bounceable: false, testOnly: false}); const walletContract = new WalletClass(this.instance.provider, {address: toAddress}); const seqno = await walletContract.methods.seqno().call(); - data.toAddress = TonWeb.Address.parse(data.toAddress).toString({urlSafe: true, bounceable: bounce, testOnly: true}); + data.toAddress = TonWeb.Address.parse(data.toAddress).toString({urlSafe: true, bounceable: bounce, testOnly: false}); data.seqno = seqno; data.secretKey = Unibabel.hexToBuffer(keyPair.secret); const transfer = walletContract.methods.transfer(data); diff --git a/src/common/tonweb/contract/index.js b/src/common/tonweb/contract/index.js index 28b58b6..c007caf 100644 --- a/src/common/tonweb/contract/index.js +++ b/src/common/tonweb/contract/index.js @@ -184,12 +184,12 @@ class Contract { const query = await queryPromise; const serialized = query.code ? // deploy { - address: query.address.toString({urlSafe: true, bounceable: false, testOnly: true}), + address: query.address.toString({urlSafe: true, bounceable: false, testOnly: false}), body: Buffer.from(await query.body.toBoc()).toString("base64"), init_code: Buffer.from(await query.code.toBoc()).toString("base64"), init_data: Buffer.from(await query.data.toBoc()).toString("base64"), } : { - address: query.address.toString({urlSafe: true, bounceable: true, testOnly: true}), + address: query.address.toString({urlSafe: true, bounceable: true, testOnly: false}), body: Buffer.from(await query.body.toBoc()).toString("base64"), }; diff --git a/src/common/utils.js b/src/common/utils.js index b8ca04e..f961af7 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -557,10 +557,10 @@ const sleep = async (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; -const unbounceble = (address) => { +const unbounceble = (address, testOnly = false) => { if (address != "") { const parsedAddress = TonWeb.Address.parse(address); - return parsedAddress.toString({urlSafe: true, bounceable: false, testOnly: true}); + return parsedAddress.toString({urlSafe: true, bounceable: false, testOnly: testOnly}); } else { return ""; } diff --git a/src/components/Elements/AccountsList.svelte b/src/components/Elements/AccountsList.svelte index c3ba068..d755289 100644 --- a/src/components/Elements/AccountsList.svelte +++ b/src/components/Elements/AccountsList.svelte @@ -205,10 +205,10 @@ on:keyup={() => changeAccount(account.address)} class:selected={account.address == $currentAccount.address} class="account-item is-vertical-align"> - {@html indenticon(unbounceble(account.address))} + {@html indenticon(unbounceble(account.address, $currentNetwork.server != "mainnet"))} {account.nickname} + title={shortAddress(unbounceble(account.address, $currentNetwork.server != "mainnet"))}>{account.nickname} {account.balance[$currentNetwork.server] ? fromNano(account.balance[$currentNetwork.server], 2) : 0} diff --git a/src/components/Elements/Popup/AccountsList.svelte b/src/components/Elements/Popup/AccountsList.svelte index 7b3ede6..30ec9d6 100644 --- a/src/components/Elements/Popup/AccountsList.svelte +++ b/src/components/Elements/Popup/AccountsList.svelte @@ -220,10 +220,10 @@ on:keyup={(event) => changeAccount(account.address)} class:selected={account.address == $currentAccount.address} class="account-item is-vertical-align"> - {@html indenticon(unbounceble(account.address))} + {@html indenticon(unbounceble(account.address, $currentNetwork.server != "mainnet"))} {account.nickname} + title={shortAddress(unbounceble(account.address, $currentNetwork.server != "mainnet"))}>{account.nickname} {account.balance[$currentNetwork.server] ? fromNano(account.balance[$currentNetwork.server], 2) : 0} diff --git a/src/components/Elements/Popup/Modals/ConfirmRawTransaction.svelte b/src/components/Elements/Popup/Modals/ConfirmRawTransaction.svelte index 4e541cf..1d664a7 100644 --- a/src/components/Elements/Popup/Modals/ConfirmRawTransaction.svelte +++ b/src/components/Elements/Popup/Modals/ConfirmRawTransaction.svelte @@ -193,11 +193,11 @@
{$_('Address')} - {shortAddress(unbounceble(modalData.accountAddress))} + {shortAddress(unbounceble(modalData.accountAddress, $currentNetwork.server != "mainnet"))}
{$_('Destination')} - {shortAddress(unbounceble(modalData.txData.params.to))} + {shortAddress(unbounceble(modalData.txData.params.to, $currentNetwork.server != "mainnet"))}
diff --git a/src/components/Elements/Popup/Modals/ConfirmTransaction.svelte b/src/components/Elements/Popup/Modals/ConfirmTransaction.svelte index 03c0341..747ed70 100644 --- a/src/components/Elements/Popup/Modals/ConfirmTransaction.svelte +++ b/src/components/Elements/Popup/Modals/ConfirmTransaction.svelte @@ -172,11 +172,11 @@
{$_('Address')} - {shortAddress(unbounceble(modalData.accountAddress))} + {shortAddress(unbounceble(modalData.accountAddress, $currentNetwork.server != "mainnet"))}
{$_('Destination')} - {shortAddress(unbounceble(modalData.txData.params.destination))} + {shortAddress(unbounceble(modalData.txData.params.destination, $currentNetwork.server != "mainnet"))}
diff --git a/src/components/Elements/Popup/Modals/SendingTransaction.svelte b/src/components/Elements/Popup/Modals/SendingTransaction.svelte index 89fc99b..69be4af 100644 --- a/src/components/Elements/Popup/Modals/SendingTransaction.svelte +++ b/src/components/Elements/Popup/Modals/SendingTransaction.svelte @@ -249,7 +249,7 @@ params: { amount: toNano(amount.value), message: message.value, - destination: unbounceble(destination.dataset.value), + destination: unbounceble(destination.dataset.value, $currentNetwork.server != "mainnet"), allBalance: allBalance, }, }; @@ -259,14 +259,14 @@ params: { amount: toNano(amount.value), message: message.value, - destination: unbounceble(destination.dataset.value), + destination: unbounceble(destination.dataset.value, $currentNetwork.server != "mainnet"), token: modalData.token }, }; } openModal("ModalConfirmTransaction", { id: modalData.id, - accountAddress: unbounceble($currentAccount.address), + accountAddress: unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"), server: $currentNetwork.server, fee: fee, txData: txData, diff --git a/src/components/Elements/Popup/Modals/ShowNftContent.svelte b/src/components/Elements/Popup/Modals/ShowNftContent.svelte index db511de..794bd0e 100644 --- a/src/components/Elements/Popup/Modals/ShowNftContent.svelte +++ b/src/components/Elements/Popup/Modals/ShowNftContent.svelte @@ -47,7 +47,7 @@ const viewAddressOnExplorer = (explorer, address) => { browser.tabs.create({ - url: `${explorer}/address/${unbounceble(address)}`, + url: `${explorer}/address/${unbounceble(address, $currentNetwork.server != "mainnet")}`, }); }; @@ -142,9 +142,9 @@

{$_("Owner")} - {viewAddressOnExplorer($currentNetwork.explorer, unbounceble(owner));}} href={"#"}> - - {shortAddress(unbounceble(owner))} + {viewAddressOnExplorer($currentNetwork.explorer, unbounceble(owner, $currentNetwork.server != "mainnet"));}} href={"#"}> + + {shortAddress(unbounceble(owner, $currentNetwork.server != "mainnet"))}

diff --git a/src/components/Pages/Account/AccountMain.svelte b/src/components/Pages/Account/AccountMain.svelte index cf6fea4..9f5e294 100644 --- a/src/components/Pages/Account/AccountMain.svelte +++ b/src/components/Pages/Account/AccountMain.svelte @@ -93,7 +93,7 @@ $: showGiver = $currentNetwork.test && $currentNetwork.giver != ""; const copyAddress = (event) => { - copyToClipboard(unbounceble($currentAccount.address)); + copyToClipboard(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")); const element = event.currentTarget; element.classList.toggle("fade-half"); setTimeout(() => { @@ -102,11 +102,11 @@ }; const showQRCode = (event) => { - openModal("ModalQRCode", { data: "ton://transfer/" + unbounceble($currentAccount.address) }); + openModal("ModalQRCode", { data: "ton://transfer/" + unbounceble($currentAccount.address, $currentNetwork.server != "mainnet") }); }; const sendLink = (event) => { - openModal("ModalSendLink", { data: "ton://transfer/" + unbounceble($currentAccount.address) }); + openModal("ModalSendLink", { data: "ton://transfer/" + unbounceble($currentAccount.address, $currentNetwork.server != "mainnet") }); }; const showNftContent = (event, asset) => { @@ -232,7 +232,7 @@ const viewOnExplorer = () => { browser.tabs.create({ - url: `${$currentNetwork.explorer}/address/${unbounceble($currentAccount.address)}`, + url: `${$currentNetwork.explorer}/address/${unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")}`, }); }; @@ -629,9 +629,9 @@
{#if ($currentResolution.innerWidth < 768)} - {shortAddress(unbounceble($currentAccount.address))} + {shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))} {:else} - {unbounceble($currentAccount.address)} + {unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")} {/if}
diff --git a/src/components/Pages/Backup/ViewKeys.svelte b/src/components/Pages/Backup/ViewKeys.svelte index 8570f6f..baaa59f 100644 --- a/src/components/Pages/Backup/ViewKeys.svelte +++ b/src/components/Pages/Backup/ViewKeys.svelte @@ -4,26 +4,24 @@ import { Button, Icon } from "svelte-chota"; import { _ } from "svelte-i18n"; /* Icons https://materialdesignicons.com/ */ - import { mdiCheck, mdiContentCopy } from "@mdi/js"; + import { mdiContentCopy } from "@mdi/js"; //Stores import { steps } from "../../../common/stores.js"; + import { + currentNetwork, + } from "../../../common/stores.js"; + import { copyToClipboard, unbounceble, } from "../../../common/utils.js"; - //Components - import Loading from "../../Elements/Loading.svelte"; - //Context const { appHome } = getContext("app_functions"); const { changeStep } = getContext("functions"); - //DOM Nodes - let formObj; - $: accounts = undefined; $: errorMsg = ""; @@ -158,10 +156,10 @@ class="copy-text" size="1.5" color="grey" - on:click={() => copyText(unbounceble(account.address))} - on:keyup={() => copyText(unbounceble(account.address))} + on:click={() => copyText(unbounceble(account.address, $currentNetwork.server != "mainnet"))} + on:keyup={() => copyText(unbounceble(account.address, $currentNetwork.server != "mainnet"))} /> -
{unbounceble(account.address)}
+
{unbounceble(account.address, $currentNetwork.server != "mainnet")}
diff --git a/src/components/Pages/FirstRun/DeployWallet.svelte b/src/components/Pages/FirstRun/DeployWallet.svelte index 28ce277..2b49ae0 100644 --- a/src/components/Pages/FirstRun/DeployWallet.svelte +++ b/src/components/Pages/FirstRun/DeployWallet.svelte @@ -132,7 +132,7 @@ }; const copyAddress = (event) => { - copyToClipboard(unbounceble($currentAccount.address)); + copyToClipboard(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")); const element = event.currentTarget; element.classList.toggle("fade-half"); setTimeout(() => { @@ -171,7 +171,7 @@
copyAddress(e)}/> - {shortAddress(unbounceble($currentAccount.address))} + {shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))} {$_("Balance")}: {fromNano(balance)} {$currentNetwork.coinName} diff --git a/src/components/Pages/Popup/PopupMain.svelte b/src/components/Pages/Popup/PopupMain.svelte index 0f72c84..345d207 100644 --- a/src/components/Pages/Popup/PopupMain.svelte +++ b/src/components/Pages/Popup/PopupMain.svelte @@ -93,7 +93,7 @@ $: showGiver = $currentNetwork.test && $currentNetwork.giver != ""; const copyAddress = (event) => { - copyToClipboard(unbounceble($currentAccount.address)); + copyToClipboard(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")); const element = event.currentTarget; element.classList.toggle("fade-half"); setTimeout(() => { @@ -102,11 +102,11 @@ }; const showQRCode = (event) => { - openModal("ModalQRCode", { data: "ton://transfer/" + unbounceble($currentAccount.address) }); + openModal("ModalQRCode", { data: "ton://transfer/" + unbounceble($currentAccount.address, $currentNetwork.server != "mainnet") }); }; const sendLink = (event) => { - openModal("ModalSendLink", { data: "ton://transfer/" + unbounceble($currentAccount.address) }); + openModal("ModalSendLink", { data: "ton://transfer/" + unbounceble($currentAccount.address, $currentNetwork.server != "mainnet") }); }; const showNftContent = (event, asset) => { @@ -236,7 +236,7 @@ const viewAddressOnExplorer = () => { browser.tabs.create({ - url: `${$currentNetwork.explorer}/address/${unbounceble($currentAccount.address)}`, + url: `${$currentNetwork.explorer}/address/${unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")}`, }); }; @@ -622,8 +622,8 @@ {$currentAccount.nickname}
- - {shortAddress(unbounceble($currentAccount.address))} + + {shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))}
diff --git a/src/components/Pages/Popup/StatisticMain.svelte b/src/components/Pages/Popup/StatisticMain.svelte index c63064a..7ece3ab 100644 --- a/src/components/Pages/Popup/StatisticMain.svelte +++ b/src/components/Pages/Popup/StatisticMain.svelte @@ -103,7 +103,7 @@
- {shortAddress(unbounceble($currentAccount.address))} + {shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))}
diff --git a/src/components/Pages/Restore/AddWallets.svelte b/src/components/Pages/Restore/AddWallets.svelte index 47f8208..d5c1dd5 100644 --- a/src/components/Pages/Restore/AddWallets.svelte +++ b/src/components/Pages/Restore/AddWallets.svelte @@ -12,6 +12,10 @@ unbounceble, } from "../../../common/utils.js"; + import { + currentNetwork, + } from "../../../common/stores.js"; + //Context const { setKeys, nextPage, cancel } = getContext("functions"); @@ -194,7 +198,7 @@ {#if $currentResolution.innerWidth > 768 && !$currentResolution.condition}
{key.address}
{:else} -
{shortAddress(unbounceble(key.address))}
+
{shortAddress(unbounceble(key.address, $currentNetwork.server != "mainnet"))}
{/if} diff --git a/src/components/Pages/Restore/Complete.svelte b/src/components/Pages/Restore/Complete.svelte index ef94dee..7d5e006 100644 --- a/src/components/Pages/Restore/Complete.svelte +++ b/src/components/Pages/Restore/Complete.svelte @@ -15,6 +15,10 @@ unbounceble, } from "../../../common/utils.js"; + import { + currentNetwork, + } from "../../../common/stores.js"; + //Context const { switchPage } = getContext("app_functions"); const { changeStep } = getContext("functions"); @@ -138,9 +142,9 @@
{#if $currentResolution.innerWidth > 768 && !$currentResolution.condition} -
{unbounceble(key.address)}
+
{unbounceble(key.address, $currentNetwork.server != "mainnet")}
{:else} -
{shortAddress(unbounceble(key.address))}
+
{shortAddress(unbounceble(key.address, $currentNetwork.server != "mainnet"))}
{/if}