Skip to content

Commit

Permalink
v3.0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Oct 7, 2024
1 parent b9b5eea commit c93bd52
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 57 deletions.
1 change: 1 addition & 0 deletions changelogs/3.0.28.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bug fixes and performance improvements
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mytonwallet",
"version": "3.0.27",
"version": "3.0.28",
"description": "The most feature-rich web wallet and browser extension for TON – with support of multi-accounts, tokens (jettons), NFT, TON DNS, TON Sites, TON Proxy, and TON Magic.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.27
3.0.28
9 changes: 6 additions & 3 deletions src/api/chains/ton/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,15 @@ export async function buildTokenTransfer(options: {
toAddress: string;
amount: bigint;
payload?: AnyPayload;
shouldSkipMintless?: boolean;
}) {
const {
network,
tokenAddress,
fromAddress,
toAddress,
amount,
shouldSkipMintless,
} = options;
let { payload } = options;

Expand All @@ -201,7 +203,7 @@ export async function buildTokenTransfer(options: {
customPayload,
stateInit,
} = await getMintlessParams({
network, fromAddress, token, tokenWalletAddress,
network, fromAddress, token, tokenWalletAddress, shouldSkipMintless,
});

if (isTokenWalletDeployed) {
Expand Down Expand Up @@ -244,9 +246,10 @@ export async function getMintlessParams(options: {
fromAddress: string;
token: ApiToken;
tokenWalletAddress: string;
shouldSkipMintless?: boolean;
}) {
const {
network, fromAddress, token, tokenWalletAddress,
network, fromAddress, token, tokenWalletAddress, shouldSkipMintless,
} = options;

let isTokenWalletDeployed = true;
Expand All @@ -257,7 +260,7 @@ export async function getMintlessParams(options: {
let isMintlessClaimed: boolean | undefined;
let mintlessTokenBalance: bigint | undefined;

if (isMintlessToken) {
if (isMintlessToken && !shouldSkipMintless) {
isTokenWalletDeployed = !!(await isActiveSmartContract(network, tokenWalletAddress));
isMintlessClaimed = isTokenWalletDeployed && await checkMintlessTokenWalletIsClaimed(network, tokenWalletAddress);

Expand Down
54 changes: 28 additions & 26 deletions src/api/chains/ton/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
ApiSubmitTransferOptions,
ApiSubmitTransferTonResult,
ApiSubmitTransferWithDieselResult,
ApiTonWalletVersion,
ApiTransactionExtra,
TonTransferParams,
} from './types';
Expand Down Expand Up @@ -461,7 +462,7 @@ export async function submitTransferWithDiesel(options: {

const { network } = parseAccountId(accountId);

const [{ address: fromAddress, version }, keyPair] = await Promise.all([
const [{ address: fromAddress }, keyPair] = await Promise.all([
fetchStoredTonWallet(accountId),
fetchKeyPair(accountId, password),
]);
Expand Down Expand Up @@ -495,24 +496,17 @@ export async function submitTransferWithDiesel(options: {
fromAddress,
toAddress: DIESEL_ADDRESS,
amount: dieselAmount,
shouldSkipMintless: true,
}), ['tokenWallet']),
);
}

let result;
const gaslessType = version === 'W5' ? 'w5' : 'diesel';
if (version === 'W5') {
result = await submitMultiTransfer({
accountId,
password,
messages,
gaslessType,
});
} else {
result = await submitMultiTransfer({
accountId, password, messages, gaslessType,
});
}
const result = await submitMultiTransfer({
accountId,
password,
messages,
isGasless: true,
});

return { ...result, encryptedComment };
} catch (err) {
Expand Down Expand Up @@ -845,7 +839,7 @@ export async function checkMultiTransactionDraft(

let totalAmount: bigint = 0n;

const { isInitialized } = await fetchStoredTonWallet(accountId);
const { isInitialized, version } = await fetchStoredTonWallet(accountId);

try {
for (const { toAddress, amount } of messages) {
Expand All @@ -870,7 +864,7 @@ export async function checkMultiTransactionDraft(

const { balance } = await getWalletInfo(network, wallet);

const { transaction } = await signMultiTransaction(network, wallet, messages);
const { transaction } = await signMultiTransaction(network, wallet, messages, undefined, version);

const realFee = await calculateFee(network, wallet, transaction, isInitialized);

Expand All @@ -895,17 +889,17 @@ interface SubmitMultiTransferOptions {
password: string;
messages: TonTransferParams[];
expireAt?: number;
gaslessType?: GaslessType;
isGasless?: boolean;
}

export async function submitMultiTransfer({
accountId, password, messages, expireAt, gaslessType,
accountId, password, messages, expireAt, isGasless,
}: SubmitMultiTransferOptions): Promise<ApiSubmitMultiTransferResult> {
const { network } = parseAccountId(accountId);

try {
const account = await fetchStoredAccount<ApiAccountWithMnemonic>(accountId);
const { address: fromAddress, isInitialized } = account.ton;
const { address: fromAddress, isInitialized, version } = account.ton;
const wallet = await getTonWallet(accountId, account.ton);
const privateKey = await fetchPrivateKey(accountId, password, account);

Expand All @@ -918,12 +912,14 @@ export async function submitMultiTransfer({

const { balance } = await getWalletInfo(network, wallet!);

const isW5 = gaslessType === 'w5';
const gaslessType = isGasless ? version === 'W5' ? 'w5' : 'diesel' : undefined;
const withW5Gasless = gaslessType === 'w5';

const { seqno, transaction } = await signMultiTransaction(
network, wallet!, messages, privateKey, expireAt, isW5,
network, wallet!, messages, privateKey, version, expireAt, withW5Gasless,
);

if (!gaslessType) {
if (!isGasless) {
const fee = await calculateFee(network, wallet!, transaction, isInitialized);
if (balance < totalAmount + fee) {
return { error: ApiTransactionError.InsufficientBalance };
Expand All @@ -935,7 +931,7 @@ export async function submitMultiTransfer({
client, wallet!, transaction, gaslessType,
);

if (!gaslessType) {
if (!isGasless) {
addPendingTransfer(network, fromAddress, seqno, boc);
}

Expand Down Expand Up @@ -965,8 +961,9 @@ async function signMultiTransaction(
wallet: TonWallet,
messages: TonTransferParams[],
privateKey: Uint8Array = new Uint8Array(64),
version: ApiTonWalletVersion,
expireAt?: number,
withW5Diesel = false,
withW5Gasless = false,
) {
const { seqno } = await getWalletInfo(network, wallet);
if (!expireAt) {
Expand Down Expand Up @@ -996,8 +993,13 @@ async function signMultiTransaction(
});
});

if (version === 'W5' && !withW5Gasless) {
// TODO Remove it. There is bug in @ton/ton library that causes transactions to be executed in reverse order.
preparedMessages.reverse();
}

let transaction;
if (withW5Diesel) {
if (withW5Gasless) {
const actionList = packActionsList(preparedMessages.map(
(msg) => new ActionSendMsg(SendMode.PAY_GAS_SEPARATELY, msg),
));
Expand Down
12 changes: 4 additions & 8 deletions src/api/methods/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function swapSubmit(
password: string,
transfers: ApiSwapTransfer[],
historyItem: ApiSwapHistoryItem,
withDiesel?: boolean,
isGasless?: boolean,
) {
const { address } = await fetchStoredTonWallet(accountId);
const transferList: TonTransferParams[] = transfers.map((transfer) => ({
Expand All @@ -89,13 +89,9 @@ export async function swapSubmit(
transferList[0] = await ton.insertMintlessPayload('mainnet', address, historyItem.from, transferList[0]);
}

const gaslessType = withDiesel ? 'diesel' : undefined;

const result = await ton.submitMultiTransfer(
{
accountId, password, messages: transferList, gaslessType,
},
);
const result = await ton.submitMultiTransfer({
accountId, password, messages: transferList, isGasless,
});

if ('error' in result) {
return result;
Expand Down
17 changes: 13 additions & 4 deletions src/components/main/sections/Content/NftSelectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import styles from './NftCollectionHeader.module.scss';
interface StateProps {
byAddress?: Record<string, ApiNft>;
selectedAddresses?: string[];
currentCollectionAddress?: string;
}

const MENU_ITEMS: DropdownItem[] = [{
Expand All @@ -37,11 +38,15 @@ const MENU_ITEMS: DropdownItem[] = [{
name: 'Burn',
value: 'burn',
isDangerous: true,
}, {
name: 'Select All',
value: 'select-all',
withSeparator: true,
}];

function NftSelectionHeader({ selectedAddresses, byAddress }: StateProps) {
function NftSelectionHeader({ selectedAddresses, byAddress, currentCollectionAddress }: StateProps) {
const {
clearNftsSelection, startTransfer, burnNfts, openHideNftModal,
selectAllNfts, clearNftsSelection, startTransfer, burnNfts, openHideNftModal,
} = getActions();

const lang = useLang();
Expand Down Expand Up @@ -120,6 +125,10 @@ function NftSelectionHeader({ selectedAddresses, byAddress }: StateProps) {
handleBurnClick();
break;
}
case 'select-all': {
selectAllNfts({ collectionAddress: currentCollectionAddress });
break;
}
}
});

Expand Down Expand Up @@ -161,8 +170,8 @@ function NftSelectionHeader({ selectedAddresses, byAddress }: StateProps) {

export default memo(withGlobal((global): StateProps => {
const {
selectedAddresses, byAddress,
selectedAddresses, byAddress, currentCollectionAddress,
} = selectCurrentAccountState(global)?.nfts || {};

return { selectedAddresses, byAddress };
return { selectedAddresses, byAddress, currentCollectionAddress };
})(NftSelectionHeader));
Loading

0 comments on commit c93bd52

Please sign in to comment.