Skip to content

Commit

Permalink
feat: adjust View on explorer url (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryenguyen7411 authored Jul 21, 2023
1 parent acab903 commit a59bcfd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/modules/env/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export const walletConnectBridge = process.env.NEXT_PUBLIC_WALLET_CONNECT_BRIDGE
export const isServer = typeof window === 'undefined';

export const rebalanceRewardsUrl = 'https://swingby.substack.com/p/bridge-rebalancing-guide';

export const explorerSwapDetailUrl = 'https://app.swingby.network/explorer/{swapId}';
2 changes: 1 addition & 1 deletion src/scenes/SwapDetails/Vertical/Top/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const Top = ({
id="widget.swap-network-fees"
values={{
value: <FormattedNumber value={Number(swap.feeTotal)} maximumFractionDigits={4} />,
symbol: swap.feeCurrency,
symbol: swingbyTextDisplay(swap.feeCurrency!),
}}
/>
</FeeText>
Expand Down
31 changes: 5 additions & 26 deletions src/scenes/SwapDetails/Vertical/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useSdkContext } from '../../../modules/store/sdkContext';
import { useAssertTermsSignature } from '../../../modules/terms';
import { isWeb3ableCurrency, useOnboard, useTransferToken } from '../../../modules/web3';
import { SwapData } from '../../../modules/store/swaps';
import { explorerSwapDetailUrl } from '../../../modules/env';

import {
ExplorerContainer,
Expand Down Expand Up @@ -39,23 +40,7 @@ export const Vertical = ({ resource, swap }: VerticalProps) => {
const [hasTransactionSucceeded, setTransactionSucceeded] = useState(false);
const { assertTermsSignature } = useAssertTermsSignature();

const outboundLink = useMemo(() => {
if (!swap || !swap.txReceivingId) return undefined;
return buildExplorerLink({
context,
coin: swap.currencyReceiving,
transactionId: swap.txReceivingId,
});
}, [context, swap]);

const inboundLink = useMemo(() => {
if (!swap || !swap.txDepositId) return undefined;
return buildExplorerLink({
context,
coin: swap.currencyDeposit,
transactionId: swap.txDepositId,
});
}, [context, swap]);
const goToExplorerUrl = explorerSwapDetailUrl.replace('{swapId}', swap?.hash || '');

const doTransfer = useCallback(async () => {
try {
Expand All @@ -73,13 +58,10 @@ export const Vertical = ({ resource, swap }: VerticalProps) => {

const supportsWeb3 = isWeb3ableCurrency(swap.currencyDeposit);

const explorerLink = ({ url, txType }: { url: string; txType: 'inbound' | 'outbound' }) => (
const explorerLink = ({ url }: { url: string }) => (
<div>
<ExplorerLink href={url} target="_blank" data-testid={buildTestId('explorer-link')}>
<RowLink>
<FormattedMessage
id={txType === 'inbound' ? 'widget.explorer-deposit' : 'widget.explorer-swap'}
/>
<div>
<FormattedMessage id="widget.explorer-link-long" />
<ExplorerLinkCaret />
Expand Down Expand Up @@ -133,13 +115,10 @@ export const Vertical = ({ resource, swap }: VerticalProps) => {
/>
</ProgressContainer>
)}
{(inboundLink || outboundLink) && (
{(swap.txDepositId || swap.txReceivingId) && (
<>
<Space size="town" shape="fill" />
<ExplorerContainer>
{inboundLink && explorerLink({ url: inboundLink, txType: 'inbound' })}
{outboundLink && explorerLink({ url: outboundLink, txType: 'outbound' })}
</ExplorerContainer>
<ExplorerContainer>{explorerLink({ url: goToExplorerUrl })}</ExplorerContainer>
</>
)}
</VerticalWidgetView>
Expand Down

1 comment on commit a59bcfd

@vercel
Copy link

@vercel vercel bot commented on a59bcfd Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.