Skip to content

Commit

Permalink
added testOnly addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
xtonwallet committed Nov 17, 2023
1 parent ec62ad0 commit 62fda68
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/background/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/common/tonLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/common/tonweb/contract/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
};

Expand Down
4 changes: 2 additions & 2 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Elements/AccountsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@
on:keyup={() => changeAccount(account.address)}
class:selected={account.address == $currentAccount.address}
class="account-item is-vertical-align">
<span class="identicon">{@html indenticon(unbounceble(account.address))}</span>
<span class="identicon">{@html indenticon(unbounceble(account.address, $currentNetwork.server != "mainnet"))}</span>
<span
class="nickname"
title={shortAddress(unbounceble(account.address))}>{account.nickname}</span>
title={shortAddress(unbounceble(account.address, $currentNetwork.server != "mainnet"))}>{account.nickname}</span>
<span class="balance is-center">
{account.balance[$currentNetwork.server] ? fromNano(account.balance[$currentNetwork.server], 2) : 0}
</span>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Elements/Popup/AccountsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@
on:keyup={(event) => changeAccount(account.address)}
class:selected={account.address == $currentAccount.address}
class="account-item is-vertical-align">
<span class="identicon">{@html indenticon(unbounceble(account.address))}</span>
<span class="identicon">{@html indenticon(unbounceble(account.address, $currentNetwork.server != "mainnet"))}</span>
<span
class="nickname"
title={shortAddress(unbounceble(account.address))}>{account.nickname}</span>
title={shortAddress(unbounceble(account.address, $currentNetwork.server != "mainnet"))}>{account.nickname}</span>
<span class="balance is-center">
{account.balance[$currentNetwork.server] ? fromNano(account.balance[$currentNetwork.server], 2) : 0}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@
<div class="flex-row">
<div class="flex-column input-box-50 flex-center-center">
<span class="weight-500">{$_('Address')}</span>
<span>{shortAddress(unbounceble(modalData.accountAddress))}</span>
<span>{shortAddress(unbounceble(modalData.accountAddress, $currentNetwork.server != "mainnet"))}</span>
</div>
<div class="flex-column input-box-50 flex-center-center">
<span class="weight-500">{$_('Destination')}</span>
<span>{shortAddress(unbounceble(modalData.txData.params.to))}</span>
<span>{shortAddress(unbounceble(modalData.txData.params.to, $currentNetwork.server != "mainnet"))}</span>
</div>
</div>
<div class="flex-row flex-center-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@
<div class="flex-row">
<div class="flex-column input-box-50 flex-center-center">
<span class="weight-500">{$_('Address')}</span>
<span>{shortAddress(unbounceble(modalData.accountAddress))}</span>
<span>{shortAddress(unbounceble(modalData.accountAddress, $currentNetwork.server != "mainnet"))}</span>
</div>
<div class="flex-column input-box-50 flex-center-center">
<span class="weight-500">{$_('Destination')}</span>
<span>{shortAddress(unbounceble(modalData.txData.params.destination))}</span>
<span>{shortAddress(unbounceble(modalData.txData.params.destination, $currentNetwork.server != "mainnet"))}</span>
</div>
</div>
<div class="flex-row flex-center-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/components/Elements/Popup/Modals/ShowNftContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
const viewAddressOnExplorer = (explorer, address) => {
browser.tabs.create({
url: `${explorer}/address/${unbounceble(address)}`,
url: `${explorer}/address/${unbounceble(address, $currentNetwork.server != "mainnet")}`,
});
};
Expand Down Expand Up @@ -142,9 +142,9 @@
</p>
<p class="owner">
{$_("Owner")}
<a on:click={() => {viewAddressOnExplorer($currentNetwork.explorer, unbounceble(owner));}} href={"#"}>
<span title={unbounceble(owner)}>
{shortAddress(unbounceble(owner))}
<a on:click={() => {viewAddressOnExplorer($currentNetwork.explorer, unbounceble(owner, $currentNetwork.server != "mainnet"));}} href={"#"}>
<span title={unbounceble(owner, $currentNetwork.server != "mainnet")}>
{shortAddress(unbounceble(owner, $currentNetwork.server != "mainnet"))}
</span>
</a>
</p>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Pages/Account/AccountMain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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) => {
Expand Down Expand Up @@ -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")}`,
});
};
Expand Down Expand Up @@ -629,9 +629,9 @@
</div>
<div class="address">
{#if ($currentResolution.innerWidth < 768)}
<span title={unbounceble($currentAccount.address)}> {shortAddress(unbounceble($currentAccount.address))} </span>
<span title={unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")}> {shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))} </span>
{:else}
<span title={unbounceble($currentAccount.address)}> {unbounceble($currentAccount.address)} </span>
<span title={unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")}> {unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")} </span>
{/if}
</div>
</div>
Expand Down
18 changes: 8 additions & 10 deletions src/components/Pages/Backup/ViewKeys.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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"))}
/>
<div class="key-text">{unbounceble(account.address)}</div>
<div class="key-text">{unbounceble(account.address, $currentNetwork.server != "mainnet")}</div>
</div>
</div>
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Pages/FirstRun/DeployWallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -171,7 +171,7 @@
<Col size=6>
<div id="qrcode"></div>
<Icon src={mdiContentCopy} class="copy-text" size="1.5" color="grey" on:click={(e) => copyAddress(e)}/>
<span title="{unbounceble($currentAccount.address)}"> {shortAddress(unbounceble($currentAccount.address))} </span>
<span title="{unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")}"> {shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))} </span>
</Col>
<Col size=6>
{$_("Balance")}: <b>{fromNano(balance)} {$currentNetwork.coinName}</b>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Pages/Popup/PopupMain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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) => {
Expand Down Expand Up @@ -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")}`,
});
};
Expand Down Expand Up @@ -622,8 +622,8 @@
{$currentAccount.nickname}
</div>
<div class="address">
<span title={unbounceble($currentAccount.address)}>
{shortAddress(unbounceble($currentAccount.address))}
<span title={unbounceble($currentAccount.address, $currentNetwork.server != "mainnet")}>
{shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))}
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pages/Popup/StatisticMain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</div>
<div class="address">
<span title={$currentAccount.address}>
{shortAddress(unbounceble($currentAccount.address))}
{shortAddress(unbounceble($currentAccount.address, $currentNetwork.server != "mainnet"))}
</span>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Pages/Restore/AddWallets.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
unbounceble,
} from "../../../common/utils.js";
import {
currentNetwork,
} from "../../../common/stores.js";
//Context
const { setKeys, nextPage, cancel } = getContext("functions");
Expand Down Expand Up @@ -194,7 +198,7 @@
{#if $currentResolution.innerWidth > 768 && !$currentResolution.condition}
<div title="{key.address}">{key.address}</div>
{:else}
<div title="{key.address}">{shortAddress(unbounceble(key.address))}</div>
<div title="{key.address}">{shortAddress(unbounceble(key.address, $currentNetwork.server != "mainnet"))}</div>
{/if}
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/components/Pages/Restore/Complete.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -138,9 +142,9 @@
</div>
<div id={`div-address-${i}`} class="address">
{#if $currentResolution.innerWidth > 768 && !$currentResolution.condition}
<div title="{key.address}">{unbounceble(key.address)}</div>
<div title="{key.address}">{unbounceble(key.address, $currentNetwork.server != "mainnet")}</div>
{:else}
<div title="{key.address}">{shortAddress(unbounceble(key.address))}</div>
<div title="{key.address}">{shortAddress(unbounceble(key.address, $currentNetwork.server != "mainnet"))}</div>
{/if}
</div>
</div>
Expand Down

0 comments on commit 62fda68

Please sign in to comment.