Skip to content
Open
3 changes: 3 additions & 0 deletions components/Layout/Header/MobileMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export default function MobileMenu({
<Link href="/services/check" className="mobile-menu-item" onClick={mobileMenuToggle}>
Issue Check
</Link>
<Link href="/services/issue-currency" className="mobile-menu-item" onClick={mobileMenuToggle}>
Issue Currency
</Link>
<Link href="/services/escrow" className="mobile-menu-item" onClick={mobileMenuToggle}>
Create Escrow
</Link>
Expand Down
1 change: 1 addition & 0 deletions components/Layout/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export default function Header({
<Link href="/services/send">Send Payment</Link>
<Link href="/services/trustline">Set Trust (Trustline)</Link>
<Link href="/services/check">Issue Check</Link>
<Link href="/services/issue-currency">Issue Currency</Link>
<Link href="/services/escrow">Create Escrow</Link>
{!xahauNetwork && !devNet && <Link href="/services/amm">AMM Services</Link>}
<Link href="/services/account-settings/">Account Settings</Link>
Expand Down
2 changes: 1 addition & 1 deletion components/UI/AddressInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function AddressInput({
const hasRun = useRef(false)
const initialRawData = useRef(rawData)

const [inputValue, setInputValue] = useState('')
const [inputValue, setInputValue] = useState(rawData || '')
const [errorMessage, setErrorMessage] = useState('')
const [isMounted, setIsMounted] = useState(false)
const [searchSuggestions, setSearchSuggestions] = useState([])
Expand Down
3 changes: 0 additions & 3 deletions hooks/useEmailLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export const useEmailLogin = () => {
}, [])

const handleLoginSuccess = useCallback(() => {
if (onLoginSuccess) {
onLoginSuccess()
}
closeEmailLogin()
}, [onLoginSuccess, closeEmailLogin])

Expand Down
1 change: 1 addition & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const WalletConnectModalSign = dynamic(
import '../styles/globals.css'
import '../styles/ui.scss'
import '../styles/components/nprogress.css'
import '../styles/pages/issue-currency.scss'

import { ThemeProvider } from '../components/Layout/ThemeContext'
import { fetchCurrentFiatRate } from '../utils/common'
Expand Down
109 changes: 109 additions & 0 deletions pages/services/account-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export default function AccountSettings({
const [currentEmailHash, setCurrentEmailHash] = useState('')
const [messageKeyInput, setMessageKeyInput] = useState('')
const [currentMessageKey, setCurrentMessageKey] = useState('')
const [regularKeyInput, setRegularKeyInput] = useState('')
const [currentRegularKey, setCurrentRegularKey] = useState('')
const [transferRateInput, setTransferRateInput] = useState('')
const [currentTransferRate, setCurrentTransferRate] = useState(null)
const [tickSizeInput, setTickSizeInput] = useState('')
Expand Down Expand Up @@ -282,6 +284,8 @@ export default function AccountSettings({
setEmailHashInput(response.data?.ledgerInfo?.emailHash || '')
setCurrentMessageKey(response.data?.ledgerInfo?.messageKey || '')
setMessageKeyInput(response.data?.ledgerInfo?.messageKey || '')
setCurrentRegularKey(response.data?.ledgerInfo?.regularKey || '')
setRegularKeyInput(response.data?.ledgerInfo?.regularKey || '')
setCurrentTransferRate(
typeof response.data?.ledgerInfo?.transferRate === 'number'
? multiply(response.data.ledgerInfo.transferRate, 1000000000)
Expand Down Expand Up @@ -607,6 +611,68 @@ export default function AccountSettings({
})
}

const handleSetRegularKey = () => {
const value = regularKeyInput.trim()
if (!isAddressValid(value)) {
setErrorMessage('Please enter a valid RegularKey address.')
return
}
if (account?.address && value === account.address) {
setErrorMessage('RegularKey must not be the same as your account address (master key).')
return
}

const tx = {
TransactionType: 'SetRegularKey',
Account: account.address,
RegularKey: value
}

setSignRequest({
request: tx,
callback: () => {
setSuccessMessage('RegularKey set successfully.')
setErrorMessage('')
setCurrentRegularKey(value)
setRegularKeyInput('')
setAccountData((prev) => {
if (prev && prev.ledgerInfo) {
return {
...prev,
ledgerInfo: { ...prev.ledgerInfo, regularKey: value }
}
}
return prev
})
}
})
}

const handleClearRegularKey = () => {
const tx = {
TransactionType: 'SetRegularKey',
Account: account.address
}

setSignRequest({
request: tx,
callback: () => {
setSuccessMessage('RegularKey cleared successfully.')
setErrorMessage('')
setCurrentRegularKey('')
setRegularKeyInput('')
setAccountData((prev) => {
if (prev && prev.ledgerInfo) {
const updatedLedgerInfo = { ...prev.ledgerInfo }
delete updatedLedgerInfo.regularKey
return { ...prev, ledgerInfo: updatedLedgerInfo }
}
return prev
})
}
})
}

const handleSetTransferRate = () => {
const percent = Number(transferRateInput)
if (isNaN(percent) || percent < 0 || percent > 100) {
Expand Down Expand Up @@ -1127,6 +1193,49 @@ export default function AccountSettings({
</div>
</div>

<div className="flag-item">
<div className="flag-header" style={{marginBottom: '-20px'}}>
<div className="flag-info">
<span className="flag-name">RegularKey</span>
{account?.address && (
<span className="flag-status">{currentRegularKey ? currentRegularKey : 'Not Set'}</span>
)}
</div>
<div className="flag-info-buttons">
{currentRegularKey && (
<button
className="button-action thin"
onClick={handleClearRegularKey}
disabled={!account?.address}
>
Clear
</button>
)}
<button
className="button-action thin"
onClick={handleSetRegularKey}
disabled={!account?.address}
>
Set
</button>
</div>
</div>
<div className="nft-minter-input">
<AddressInput
title=''
placeholder="Enter RegularKey address"
setInnerValue={setRegularKeyInput}
rawData={currentRegularKey}
disabled={!account?.address}
hideButton={true}
/>
<small>
Assign a regular key pair for signing. Must not equal your account address.
</small>
</div>
{errorMessage && <small className="error-text red">{errorMessage}</small>}
</div>

<div className="flag-item">
<div className="flag-header">
<div className="flag-info">
Expand Down
Loading