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

enhancement: add warning on recipient input screen when sending l1 to a layer 2 address #2556

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
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
<script lang="ts">
import { getActiveNetworkId } from '@core/network'
import { Nft } from '@core/nfts/interfaces'
import { selectedAccountTokens } from '@core/token/stores'
import { getTokenFromSelectedAccountTokens } from '@core/token/stores'
import { Output, SendFlowParameters, SendFlowType, TokenTransferData } from '@core/wallet'
import { TransactionAssetSection } from '@ui'
import StardustTransactionDetails from './StardustTransactionDetails.svelte'
import { BASE_TOKEN_ID, TokenStandard } from '@core/token'
import { localize } from '@core/i18n'
import { Alert } from '@bloomwalletio/ui'
import { NftStandard } from '@core/nfts'

export let output: Output
export let sendFlowParameters: SendFlowParameters

const { destinationNetworkId } = sendFlowParameters
const { sourceNetworkId, destinationNetworkId } = sendFlowParameters

$: transactionFee =
sendFlowParameters.type === SendFlowType.BaseCoinTransfer
? BigInt(output.amount) - sendFlowParameters.baseCoinTransfer.rawAmount
? BigInt(output.amount) - (sendFlowParameters.baseCoinTransfer?.rawAmount ?? BigInt(0))
: BigInt(output.amount)

let nft: Nft | undefined
let tokenTransfer: TokenTransferData | undefined
let baseCoinTransfer: TokenTransferData | undefined
$: ({ nft, tokenTransfer, baseCoinTransfer } = getTransactionAssets(sendFlowParameters))

function getTransactionAssets(sendFlowParameters: SendFlowParameters): {
nft?: Nft
tokenTransfer?: TokenTransferData
baseCoinTransfer?: TokenTransferData
} {
const baseCoin = $selectedAccountTokens?.[getActiveNetworkId()].baseCoin
if (!sourceNetworkId) {
return {}
}

const baseCoin = getTokenFromSelectedAccountTokens(BASE_TOKEN_ID, sourceNetworkId)
const baseCoinTransfer = {
token: baseCoin,
rawAmount: sendFlowParameters.baseCoinTransfer?.rawAmount ?? BigInt(0),
Expand All @@ -45,7 +57,10 @@
</script>

<div class="w-full space-y-5">
<TransactionAssetSection {...getTransactionAssets(sendFlowParameters)} />
<TransactionAssetSection {baseCoinTransfer} {nft} {tokenTransfer} />
{#if nft?.standard === NftStandard.Irc27 || tokenTransfer?.token?.standard === TokenStandard.Irc30}
<Alert variant="warning" text={localize('popups.transaction.ircAssetsToL2Hint')} />
{/if}

<StardustTransactionDetails {transactionFee} {destinationNetworkId} disableAll />
</div>
1 change: 1 addition & 0 deletions packages/shared/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@
"selectAmount": "Send {tokenName}",
"selectRecipient": "Send {assetName} to",
"transactionSummary": "Transaction to {recipient}",
"ircAssetsToL2Hint": "You are about to send an IRC asset to an EVM network. Most EVM based wallets don't support displaying IRC assets correctly.",
"surplusIncluded": "This transaction contains a surplus amount. Please double check this is the amount you want to send."
},
"walletFinder": {
Expand Down
Loading