Skip to content

Commit

Permalink
[NO CHANGELOG] [Add Funds Widget] Add funds legal footer (#2340)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl authored Oct 22, 2024
1 parent fcca155 commit a4353ff
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/checkout/widgets-lib/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@
"caption": "evolution",
"buttonText": "Choose the Wallet to Pay with"
}
},
"footer": {
"body": "Swap functionality is powered by a third party, Squid. Immutable neither builds, owns, operates or deploys <squidLink>Squid</squidLink>."
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Body, Link } from '@biom3/react';
import { Trans, useTranslation } from 'react-i18next';

export function SquidFooter() {
const { t } = useTranslation();

return (
<Body
size="xSmall"
sx={{
textAlign: 'center',
color: 'base.color.text.body.secondary',
}}
>
<Trans
i18nKey={t('views.ADD_FUNDS.footer.body')}
components={{
squidLink: <Link
size="xSmall"
rc={<a target="_blank" href=" https://app.squidrouter.com" rel="noreferrer" />}
/>,
}}
/>
</Body>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const fetchTokens = async (integratorId: string): Promise<Token[]> => {

const data: SquidTokensResponse = await response.json();

if (!data.tokens) {
return [];
}

return data.tokens.map((tokenResponse: SquidTokenResponse) => ({
chainId: tokenResponse.chainId.toString(),
address: tokenResponse.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ export function getFormattedNumber(

return getFormattedAmounts(formattedValue, maxDecimals);
}

export function getFormattedNumberWithDecimalPlaces(value: string | number, decimals = 2) : string {
const amount = typeof value === 'number' ? value : parseFloat(value);

return amount.toLocaleString('en-US', {
minimumFractionDigits: 0,
maximumFractionDigits: decimals,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import {
import { validateToAmount } from '../functions/amountValidation';
import { OnboardingDrawer } from '../components/OnboardingDrawer';
import { useError } from '../hooks/useError';
import { SquidFooter } from '../components/SquidFooter';
import {
getFormattedNumberWithDecimalPlaces,
} from '../functions/getFormattedNumber';

interface AddFundsProps {
checkout: Checkout;
Expand Down Expand Up @@ -620,7 +624,7 @@ export function AddFunds({

<HeroFormControl.Caption>
USD $
{selectedAmountUsd.toFixed(2)}
{getFormattedNumberWithDecimalPlaces(selectedAmountUsd)}
</HeroFormControl.Caption>
</HeroFormControl>
)}
Expand All @@ -630,12 +634,12 @@ export function AddFunds({
sx={{
alignSelf: 'stretch',
p: 'base.spacing.x3',
pb: 'base.spacing.x10',
pb: 'base.spacing.x5',
bg: 'base.color.neutral.800',
bradtl: 'base.borderRadius.x8',
bradtr: 'base.borderRadius.x8',
}}
gap="base.spacing.x6"
gap="base.spacing.x4"
>
<Stack gap="0px">
<SelectedWallet
Expand Down Expand Up @@ -700,6 +704,9 @@ export function AddFunds({
>
Review
</Button>

<SquidFooter />

<PayWithWalletDrawer
visible={showPayWithDrawer}
walletOptions={walletOptions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ import { getRouteChains } from '../functions/getRouteChains';
import {
getFormattedAmounts,
getFormattedNumber,
getFormattedNumberWithDecimalPlaces,
} from '../functions/getFormattedNumber';
import { convertToNetworkChangeableProvider } from '../functions/convertToNetworkChangeableProvider';
import { SquidFooter } from '../components/SquidFooter';

interface ReviewProps {
data: AddFundsReviewData;
Expand Down Expand Up @@ -524,11 +526,12 @@ export function Review({
Powered by Squid
<br />
1
{route.route.estimate.fromToken.name}
{' '}
{route.route.estimate.fromToken.symbol}
{' '}
=
{' '}
{route.route.estimate.exchangeRate}
{getFormattedNumberWithDecimalPlaces(route.route.estimate.exchangeRate)}
{' '}
{route.route.estimate.toToken.name}
</Body>
Expand Down Expand Up @@ -666,10 +669,12 @@ export function Review({
size="large"
onClick={handleTransaction}
disabled={proceedDisabled}
sx={{ mt: 'auto', mb: 'base.spacing.x4', mx: 'base.spacing.x3' }}
sx={{ mx: 'base.spacing.x3' }}
>
{proceedDisabled ? 'Processing' : 'Proceed'}
</Button>

<SquidFooter />
</>
)}

Expand Down

0 comments on commit a4353ff

Please sign in to comment.