Skip to content

Commit

Permalink
feat(suite): added blockbook link to approval tx
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasBoda committed Jan 17, 2025
1 parent 14d3525 commit 556c1fd
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import { CoinmarketTradeExchangeType } from 'src/types/coinmarket/coinmarket';
import { useCoinmarketFormContext } from 'src/hooks/wallet/coinmarket/form/useCoinmarketCommonForm';
import { useCoinmarketInfo } from 'src/hooks/wallet/coinmarket/useCoinmarketInfo';
import { useCoinmarketExchangeWatchSendApproval } from 'src/hooks/wallet/coinmarket/form/useCoinmarketExchangeWatchSendApproval';
import { useDispatch } from 'src/hooks/suite';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { saveSelectedQuote } from 'src/actions/wallet/coinmarketExchangeActions';
import { parseCryptoId } from 'src/utils/wallet/coinmarket/coinmarketUtils';
import { cryptoIdToSymbol, parseCryptoId } from 'src/utils/wallet/coinmarket/coinmarketUtils';
import { IOAddress } from 'src/components/suite/copy/IOAddress';

// add APPROVED means no approval request is necessary
type ExtendedDexApprovalType = DexApprovalType | 'APPROVED';
Expand All @@ -51,6 +52,8 @@ export const CoinmarketOfferExchangeSendApproval = () => {
selectedQuote?.status === 'CONFIRM' ? 'APPROVED' : 'MINIMAL',
);

const blockchainNetworks = useSelector(state => state.wallet.blockchain);

const { navigateToExchangeForm } = useCoinmarketNavigation(account);

useCoinmarketExchangeWatchSendApproval({
Expand All @@ -70,6 +73,9 @@ export const CoinmarketOfferExchangeSendApproval = () => {

if (!selectedQuote.send) return null;

const symbol = cryptoIdToSymbol(selectedQuote.send);
const blockchain = symbol && blockchainNetworks[symbol];

const isToken = parseCryptoId(selectedQuote.send)?.contractAddress !== undefined;

if (isFullApproval && approvalType === 'ZERO') {
Expand Down Expand Up @@ -139,9 +145,13 @@ export const CoinmarketOfferExchangeSendApproval = () => {
>
{dexTx.to}
</InfoItem>
{selectedQuote.approvalSendTxHash && (
{selectedQuote.approvalSendTxHash && blockchain && (
<InfoItem label={<Translation id="TR_EXCHANGE_APPROVAL_TXID" />}>
{selectedQuote.approvalSendTxHash}
<IOAddress
txAddress={selectedQuote.approvalSendTxHash}
explorerUrl={blockchain.explorer.tx}
explorerUrlQueryString={blockchain.explorer.queryString}
/>
</InfoItem>
)}
{selectedQuote.status === 'APPROVAL_PENDING' && (
Expand Down

0 comments on commit 556c1fd

Please sign in to comment.