Skip to content

Commit

Permalink
Merge pull request #343 from tonkeeper/feature/ledger-updates
Browse files Browse the repository at this point in the history
Ledger updates
  • Loading branch information
KuznetsovNikita authored Jan 2, 2025
2 parents 9e7be2c + b1ea81c commit 5373eb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MultisigEncoder } from '../encoder/multisig-encoder/multisig-encoder';
import { WalletMessageSender } from './wallet-message-sender';
import BigNumber from 'bignumber.js';
import { LedgerMessageSender } from './ledger-message-sender';
import { internal, SendMode } from '@ton/core';
import { fromNano, internal, SendMode } from '@ton/core';
import { TON_ASSET } from '../../../entries/crypto/asset/constants';

export class MultisigCreateOrderSender implements ISender {
Expand All @@ -26,6 +26,7 @@ export class MultisigCreateOrderSender implements ISender {
}

public async send(outgoing: WalletOutgoingMessage) {
await this.checkTransactionPossibility();
const wrappedMessage = await this.wrapMessage(outgoing);

if (this.signer.type === 'ledger') {
Expand Down Expand Up @@ -89,4 +90,10 @@ export class MultisigCreateOrderSender implements ISender {
}
});
}

private async checkTransactionPossibility() {
const requiredBalance = new BigNumber(fromNano(MultisigEncoder.createOrderAmount) + 0.02);

await assertBalanceEnough(this.api, requiredBalance, TON_ASSET, this.hostWallet.rawAddress);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@ import { useMutation } from '@tanstack/react-query';
import { useActiveMultisigAccountHost, useActiveMultisigWalletInfo } from '../../../state/multisig';
import { useAsyncQueryData } from '../../useAsyncQueryData';
import { MultisigOrder } from '@tonkeeper/core/dist/tonApiV2';
import {
useActiveAccount,
useActiveApi,
useInvalidateActiveWalletQueries
} from '../../../state/wallet';
import { useTonRawTransactionService } from '../useBlockchainService';
import { useActiveApi, useInvalidateActiveWalletQueries } from '../../../state/wallet';
import { EXTERNAL_SENDER_CHOICE, useGetSender } from '../useSender';

import { useNotifyErrorHandle } from '../../useNotification';
import { MultisigEncoder } from '@tonkeeper/core/dist/service/ton-blockchain/encoder/multisig-encoder/multisig-encoder';
import { zeroFee } from '@tonkeeper/core/dist/service/ton-blockchain/utils';
import { TonRawTransactionService } from '@tonkeeper/core/dist/service/ton-blockchain/ton-raw-transaction.service';

export function useSendExisitingMultisigOrder(orderAddress: MultisigOrder['address']) {
const { data: multisigInfoData } = useActiveMultisigWalletInfo();
const multisigInfoPromise = useAsyncQueryData(multisigInfoData);
const { mutateAsync: invalidateAccountQueries } = useInvalidateActiveWalletQueries();
const { signerWallet } = useActiveMultisigAccountHost();
const api = useActiveApi();

const rawTransactionService = useTonRawTransactionService();
const getSender = useGetSender();
const notifyError = useNotifyErrorHandle();
const account = useActiveAccount();
const api = useActiveApi();

return useMutation<boolean, Error>(async () => {
try {
Expand All @@ -38,7 +32,7 @@ export function useSendExisitingMultisigOrder(orderAddress: MultisigOrder['addre
orderAddress
);

await rawTransactionService.send(
await new TonRawTransactionService(api, signerWallet).send(
await getSender(EXTERNAL_SENDER_CHOICE),
zeroFee,
message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { TonAssetTransactionService } from '@tonkeeper/core/dist/service/ton-blockchain/ton-asset-transaction.service';
import { useActiveAccount, useActiveApi } from '../../state/wallet';
import { useAppContext } from '../appContext';
import { useMemo } from 'react';
import { TonRawTransactionService } from '@tonkeeper/core/dist/service/ton-blockchain/ton-raw-transaction.service';
import { TonConnectTransactionService } from '@tonkeeper/core/dist/service/ton-blockchain/ton-connect-transaction.service';
Expand Down

0 comments on commit 5373eb3

Please sign in to comment.