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(frontend): convert to ckBTC button for BTC mainnet #3215

Merged
merged 1 commit into from
Oct 30, 2024
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
12 changes: 12 additions & 0 deletions src/frontend/src/btc/convert/ConvertToCkBTC.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import { BTC_MAINNET_TOKEN } from '$env/tokens.btc.env';
import IconCkConvert from '$lib/components/icons/IconCkConvert.svelte';
import ButtonHero from '$lib/components/ui/ButtonHero.svelte';
import { isBusy } from '$lib/derived/busy.derived';
import { i18n } from '$lib/stores/i18n.store';
</script>

<ButtonHero disabled={$isBusy} ariaLabel={$i18n.convert.text.convert_to_ckbtc}>
<IconCkConvert size="28" slot="icon" />
<span>{BTC_MAINNET_TOKEN.twinTokenSymbol}</span>
AntonioVentilii-DFINITY marked this conversation as resolved.
Show resolved Hide resolved
</ButtonHero>
17 changes: 14 additions & 3 deletions src/frontend/src/lib/components/hero/Actions.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import { page } from '$app/stores';
import BtcReceive from '$btc/components/receive/BtcReceive.svelte';
import ConvertToCkBTC from '$btc/convert/ConvertToCkBTC.svelte';
import { BTC_TO_CKBTC_EXCHANGE_ENABLED } from '$env/networks.btc.env';
import EthReceive from '$eth/components/receive/EthReceive.svelte';
import ConvertToCkERC20 from '$eth/components/send/ConvertToCkERC20.svelte';
import ConvertToCkETH from '$eth/components/send/ConvertToCkETH.svelte';
Expand All @@ -18,19 +20,24 @@
networkEthereum,
networkICP,
networkBitcoin,
pseudoNetworkChainFusion
pseudoNetworkChainFusion,
networkId
} from '$lib/derived/network.derived';
import { tokenWithFallback } from '$lib/derived/token.derived';
import { isRouteTransactions } from '$lib/utils/nav.utils';
import { isNetworkIdBTCMainnet } from '$lib/utils/network.utils';

let convertEth = false;
$: convertEth = $ethToCkETHEnabled && $erc20UserTokensInitialized;

let convertErc20 = false;
$: convertErc20 = $erc20ToCkErc20Enabled && $erc20UserTokensInitialized;

let convertCkBtc = false;
$: convertCkBtc = $tokenCkBtcLedger && $erc20UserTokensInitialized;

let convertBtc = false;
$: convertBtc = $tokenCkBtcLedger && $erc20UserTokensInitialized;
$: convertBtc = BTC_TO_CKBTC_EXCHANGE_ENABLED && isNetworkIdBTCMainnet($networkId);
AntonioVentilii-DFINITY marked this conversation as resolved.
Show resolved Hide resolved

let isTransactionsPage = false;
$: isTransactionsPage = isRouteTransactions($page);
Expand Down Expand Up @@ -67,9 +74,13 @@
{/if}
{/if}

{#if convertBtc}
{#if convertCkBtc}
<ConvertToBTC />
{/if}

{#if convertBtc}
<ConvertToCkBTC />
{/if}
{/if}

<Buy />
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 @@ -364,6 +364,7 @@
"text": {
"converting": "Converting...",
"convert_to_btc": "Convert to BTC",
"convert_to_ckbtc": "Convert to ckBTC",
"convert_to_token": "Convert to $token",
"convert_to_cketh": "Convert to ckETH",
"convert_to_ckerc20": "Convert to $ckErc20",
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 @@ -330,6 +330,7 @@ interface I18nConvert {
text: {
converting: string;
convert_to_btc: string;
convert_to_ckbtc: string;
convert_to_token: string;
convert_to_cketh: string;
convert_to_ckerc20: string;
Expand Down