Skip to content
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
15 changes: 15 additions & 0 deletions src/frontend/src/lib/components/swap/SwapNearIntentsTos.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script lang="ts">
import { Html } from '@dfinity/gix-components';
import MessageBox from '$lib/components/ui/MessageBox.svelte';
import { NEAR_INTENTS_TOS_LINK } from '$lib/constants/swap.constants';
import { i18n } from '$lib/stores/i18n.store';
import { replacePlaceholders } from '$lib/utils/i18n.utils';
</script>

<MessageBox styleClass="sm:text-sm">
<Html
text={replacePlaceholders($i18n.swap.text.near_intents_tos, {
$link: NEAR_INTENTS_TOS_LINK
})}
/>
</MessageBox>
21 changes: 20 additions & 1 deletion src/frontend/src/lib/components/swap/SwapReview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import { Checkbox, Html } from '@dfinity/gix-components';
import { isEmptyString, nonNullish } from '@dfinity/utils';
import { getContext, type Snippet, untrack } from 'svelte';
import { NEAR_INTENTS_SWAP_ENABLED } from '$env/rest/near-intents.env';
import SwapCrossChainInfo from '$lib/components/swap/SwapCrossChainInfo.svelte';
import SwapNearIntentsTos from '$lib/components/swap/SwapNearIntentsTos.svelte';
import SwapProvider from '$lib/components/swap/SwapProvider.svelte';
import SwapValueDifference from '$lib/components/swap/SwapValueDifference.svelte';
import TokensReview from '$lib/components/tokens/TokensReview.svelte';
Expand All @@ -22,9 +24,13 @@
SWAP_VALUE_DIFFERENCE_ERROR_VALUE
} from '$lib/constants/swap.constants';
import { i18n } from '$lib/stores/i18n.store';
import {
SWAP_AMOUNTS_CONTEXT_KEY,
type SwapAmountsContext
} from '$lib/stores/swap-amounts.store';
import { SWAP_CONTEXT_KEY, type SwapContext } from '$lib/stores/swap.store';
import type { OptionAmount } from '$lib/types/send';
import { SwapErrorCodes } from '$lib/types/swap';
import { SwapErrorCodes, SwapProvider as SwapProviderEnum } from '$lib/types/swap';
import { calculateValueDifference } from '$lib/utils/swap.utils';

interface Props {
Expand All @@ -49,6 +55,8 @@
isSwapAmountsLoading = false
}: Props = $props();

const { store: swapAmountsStore } = getContext<SwapAmountsContext>(SWAP_AMOUNTS_CONTEXT_KEY);

const {
sourceToken,
destinationToken,
Expand All @@ -57,6 +65,11 @@
failedSwapError
} = getContext<SwapContext>(SWAP_CONTEXT_KEY);

let isNearIntentsProvider = $derived(
NEAR_INTENTS_SWAP_ENABLED &&
$swapAmountsStore?.selectedProvider?.provider === SwapProviderEnum.NEAR_INTENTS
);
Comment thread
AntonioVentilii marked this conversation as resolved.

const handleBack = () => {
failedSwapError.set(undefined);
onBack();
Expand Down Expand Up @@ -141,6 +154,12 @@

<SwapCrossChainInfo hrSpacing="md" />

{#if isNearIntentsProvider}
<div class="mt-4">
<SwapNearIntentsTos />
</div>
{/if}

{#if isValueDifferenceError}
<div class="mt-4">
<MessageBox level="error">
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/lib/constants/swap.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const NEAR_INTENTS_POLL_MAX_ATTEMPTS = 120;
export const OISY_DOCS_SWAP_WIDTHDRAW_FROM_ICPSWAP_LINK =
'https://docs.oisy.com/using-oisy-wallet/how-tos/swapping-tokens#manually-withdraw-funds-from-icpswap';

export const NEAR_INTENTS_TOS_LINK =
'https://docs.near-intents.org/security-compliance/terms-of-service';

export const SWAP_MODE = 'all';
export const SWAP_SIDE = 'SELL';

Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "",
"cross_chain_networks_info": "",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Poplatky za swap",
"cross_chain_networks_info": "Přesouváte tokeny ze sítě <b>$sourceNetwork</b> do sítě <b>$destinationNetwork</b>",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Swap Gebühren",
"cross_chain_networks_info": "Du tauschst deine Token vom Netzwerk <b>$sourceNetwork</b> ins <b>$destinationNetwork</b> Netzwerk",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Swap Fees",
"cross_chain_networks_info": "You move tokens from <b>$sourceNetwork</b> to <b>$destinationNetwork</b> network",
"near_intents_estimated_time": "NEAR Intents (~$minutes min)",
"near_intents_tos": "By clicking the \"Swap now\" button, you agree to the <a href=\"$link\" target=\"_blank\" rel=\"external noopener noreferrer\" class=\"underline\">Terms of Service</a> of 1Click Swap API. If you do not agree with those terms, do not use this swap provider.",
Comment thread
AntonioVentilii marked this conversation as resolved.
"value_difference_error_confirmation": "The value difference is very high, and you would lose a significant value in this swap. Please confirm that you want to proceed."
Comment thread
AntonioVentilii marked this conversation as resolved.
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Comisiones de Intercambio",
"cross_chain_networks_info": "Mover tokens de la red <b>$sourceNetwork</b> a la red <b>$destinationNetwork</b>",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Frais d'échange",
"cross_chain_networks_info": "Vous déplacez des tokens du réseau <b>$sourceNetwork</b> vers le réseau <b>$destinationNetwork</b>",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "स्वैप शुल्क",
"cross_chain_networks_info": "आप टोकन <b>$sourceNetwork</b> से <b>$destinationNetwork</b> नेटवर्क पर ले जाते हैं",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "",
"cross_chain_networks_info": "",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "スワップ手数料",
"cross_chain_networks_info": "<b>$sourceNetwork</b>ネットワークから<b>$destinationNetwork</b>ネットワークにトークンを移動します。",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "스왑 수수료",
"cross_chain_networks_info": "<b>$sourceNetwork</b>에서 <b>$destinationNetwork</b> 네트워크로 토큰을 이동합니다",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Opłaty za wymianę",
"cross_chain_networks_info": "Przenosisz tokeny z sieci <b>$sourceNetwork</b> do sieci <b>$destinationNetwork</b>",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "",
"cross_chain_networks_info": "",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Комиссия за обмен",
"cross_chain_networks_info": "Информация о кросс-чейн сетях",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "Phí giao dịch",
"cross_chain_networks_info": "Bạn di chuyển token từ mạng <b>$sourceNetwork</b> sang mạng <b>$destinationNetwork</b>",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
"swap_fees": "交易费",
"cross_chain_networks_info": "跨链网络信息",
"near_intents_estimated_time": "",
"near_intents_tos": "",
"value_difference_error_confirmation": ""
},
"error": {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/lib/types/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ interface I18nSwap {
swap_fees: string;
cross_chain_networks_info: string;
near_intents_estimated_time: string;
near_intents_tos: string;
value_difference_error_confirmation: string;
};
error: {
Expand Down
Loading