Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ledger updates #343

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/extension/src/components/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Notifications = () => {
} | null) => {
if (!data) return;
if (result) {
sendBackground.message('approveRequest', { id: data.id, payload: result });
sendBackground.message('approveRequest', { id: data.id, payload: result.replyItems });
} else {
sendBackground.message('rejectRequest', data.id);
}
Expand Down
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
Loading