Skip to content

Commit 946f419

Browse files
feat(frontend): implement SwapDetailsOneSec component (#12627)
# Motivation We need to implement a component for displaying an information about the OneSec provider. <img width="540" height="65" alt="Screenshot 2026-04-28 at 11 34 28" src="https://github.com/user-attachments/assets/03bcb784-426f-4704-a321-e18e1b68e091" />
1 parent 6d49f1b commit 946f419

18 files changed

Lines changed: 171 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<script lang="ts">
2+
import { nonNullish } from '@dfinity/utils';
3+
import { getContext } from 'svelte';
4+
import ModalValue from '$lib/components/ui/ModalValue.svelte';
5+
import { i18n } from '$lib/stores/i18n.store';
6+
import { SWAP_CONTEXT_KEY, type SwapContext } from '$lib/stores/swap.store';
7+
import type { SwapMappedResult, SwapProvider } from '$lib/types/swap';
8+
import { formatToken } from '$lib/utils/format.utils';
9+
10+
interface Props {
11+
provider: Extract<SwapMappedResult, { provider: SwapProvider.ONE_SEC }>;
12+
}
13+
14+
const { provider }: Props = $props();
15+
16+
const { destinationToken } = getContext<SwapContext>(SWAP_CONTEXT_KEY);
17+
18+
const formattedTransferFee = $derived(
19+
nonNullish($destinationToken?.decimals)
20+
? formatToken({
21+
value: provider.swapDetails.transferFeeInUnits,
22+
unitName: $destinationToken.decimals
23+
})
24+
: undefined
25+
);
26+
27+
const formattedProtocolFee = $derived(`${provider.swapDetails.protocolFeeInPercent.toFixed(2)}%`);
28+
</script>
29+
30+
{#if nonNullish(formattedTransferFee) && nonNullish($destinationToken?.symbol)}
31+
<ModalValue>
32+
{#snippet label()}
33+
{$i18n.swap.text.onesec_transfer_fee}
34+
{/snippet}
35+
36+
{#snippet mainValue()}
37+
{formattedTransferFee}
38+
{$destinationToken.symbol}
39+
{/snippet}
40+
</ModalValue>
41+
{/if}
42+
43+
<ModalValue>
44+
{#snippet label()}
45+
{$i18n.swap.text.onesec_protocol_fee}
46+
{/snippet}
47+
48+
{#snippet mainValue()}
49+
{formattedProtocolFee}
50+
{/snippet}
51+
</ModalValue>

src/frontend/src/lib/i18n/ar.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/cs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "Přesouváte tokeny ze sítě <b>$sourceNetwork</b> do sítě <b>$destinationNetwork</b>",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "Du tauschst deine Token vom Netzwerk <b>$sourceNetwork</b> ins <b>$destinationNetwork</b> Netzwerk",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "You move tokens from <b>$sourceNetwork</b> to <b>$destinationNetwork</b> network",
11581158
"near_intents_estimated_time": "NEAR Intents (~$minutes min)",
11591159
"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.",
1160+
"onesec_transfer_fee": "Transfer fee",
1161+
"onesec_protocol_fee": "Protocol fee",
11601162
"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."
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/es.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "Mover tokens de la red <b>$sourceNetwork</b> a la red <b>$destinationNetwork</b>",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "Vous déplacez des tokens du réseau <b>$sourceNetwork</b> vers le réseau <b>$destinationNetwork</b>",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/hi.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "आप टोकन <b>$sourceNetwork</b> से <b>$destinationNetwork</b> नेटवर्क पर ले जाते हैं",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/it.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

src/frontend/src/lib/i18n/ja.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@
11571157
"cross_chain_networks_info": "<b>$sourceNetwork</b>ネットワークから<b>$destinationNetwork</b>ネットワークにトークンを移動します。",
11581158
"near_intents_estimated_time": "",
11591159
"near_intents_tos": "",
1160+
"onesec_transfer_fee": "",
1161+
"onesec_protocol_fee": "",
11601162
"value_difference_error_confirmation": ""
11611163
},
11621164
"error": {

0 commit comments

Comments
 (0)