Skip to content
Open
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
27 changes: 19 additions & 8 deletions components/SignForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ export default function SignForm({
}

if (signRequest.action === 'nftTransfer') {
tx.Amount = '0'
if (!tx.TransactionType === 'Remit') tx.Amount = '0'
// For Remit transactions, no Amount field is needed
if (!agreedToRisks) {
setScreen('nftTransfer')
return
Expand Down Expand Up @@ -904,13 +905,23 @@ export default function SignForm({
const xls35Sell = signRequest?.request?.TransactionType === 'URITokenCreateSellOffer'

const checkBoxText = (screen, signRequest) => {
if (screen === 'nftTransfer')
return (
<Trans i18nKey="signin.confirm.nft-transfer">
I'm offering that NFT for FREE to the Destination account,{' '}
<span className="orange bold">the destination account would need to accept the NFT transfer</span>.
</Trans>
)
if (screen === 'nftTransfer') {
if (signRequest.request?.TransactionType === 'Remit') {
return (
<span>
I'm sending this NFT directly to the Destination account using Remit.{' '}
<span className="orange bold">The destination will receive the NFT immediately, and I will pay for the NFT reserve requirements.</span>
</span>
)
} else {
return (
<Trans i18nKey="signin.confirm.nft-transfer">
I'm offering that NFT for FREE to the Destination account,{' '}
<span className="orange bold">the destination account would need to accept the NFT transfer</span>.
</Trans>
)
}
}

if (screen === 'NFTokenBurn') return t('signin.confirm.nft-burn')
if (screen === 'NFTokenModify') return 'I understand that URI will be updated for this NFT.'
Expand Down
66 changes: 65 additions & 1 deletion components/SignForms/NftTransfer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,53 @@
import { useTranslation } from 'next-i18next'
import { isAddressValid } from '../../utils'
import { useState, useEffect } from 'react'
import { isAddressValid, xahauNetwork } from '../../utils'
import AddressInput from '../UI/AddressInput'
import CheckBox from '../UI/CheckBox'
import axios from 'axios'

export default function NftTransfer({ setSignRequest, signRequest, setStatus, setFormError }) {
const { t } = useTranslation()
const [useRemit, setUseRemit] = useState(false)
const [destinationRemitDisabled, setDestinationRemitDisabled] = useState(false)

// Check if destination allows incoming remit when address changes
useEffect(() => {
const checkDestinationRemit = async () => {
if (!signRequest.request?.Destination || !xahauNetwork) {
setDestinationRemitDisabled(false)
return
}

try {
const response = await axios(`/v2/address/${signRequest.request.Destination}?ledgerInfo=true`)
const accountData = response?.data

if (accountData?.ledgerInfo?.flags) {
const flags = accountData.ledgerInfo.flags
const disallowIncomingRemit = flags.disallowIncomingRemit
setDestinationRemitDisabled(disallowIncomingRemit)
} else {
setDestinationRemitDisabled(false)
}
} catch (error) {
console.error('Error checking destination remit status:', error)
setDestinationRemitDisabled(false)
}
}

checkDestinationRemit()
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [signRequest.request?.Destination])

useEffect(() => {
if (xahauNetwork) {
setSignRequest({ ...signRequest, request: { ...signRequest.request, TransactionType: useRemit ? 'Remit' : 'URITokenCreateSellOffer' } })
if(useRemit) {
setSignRequest({ ...signRequest, request: { ...signRequest.request, URITokenIDs: [signRequest.request.URITokenID] } })
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [useRemit])

const onAddressChange = (value) => {
let newRequest = signRequest
Expand Down Expand Up @@ -33,6 +77,26 @@ export default function NftTransfer({ setSignRequest, signRequest, setStatus, se
hideButton={true}
/>
</span>

{/* Remit option for Xahau network */}
{xahauNetwork && (
<div className="terms-checkbox">
<CheckBox
checked={useRemit}
setChecked={setUseRemit}
name="use-remit"
disabled={destinationRemitDisabled}
>
Use Remit (Xahau)
{destinationRemitDisabled && (
<span className="red">
{' '}
(Disabled - destination has incoming remit disabled)
</span>
)}
</CheckBox>
</div>
)}
</div>
)
}