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

feat(suite): added blockbook link to approval tx #16434

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
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 blockchain = 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 blockchainForSend = symbol && blockchain[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 && blockchainForSend && (
<InfoItem label={<Translation id="TR_EXCHANGE_APPROVAL_TXID" />}>
{selectedQuote.approvalSendTxHash}
<IOAddress
txAddress={selectedQuote.approvalSendTxHash}
explorerUrl={blockchainForSend.explorer.tx}
explorerUrlQueryString={blockchainForSend.explorer.queryString}
/>
</InfoItem>
)}
{selectedQuote.status === 'APPROVAL_PENDING' && (
Expand Down
Loading