Skip to content

Commit

Permalink
feature: Fixes error related to NFT transfer on ledger (#2499)
Browse files Browse the repository at this point in the history
* Fixes error related to NFT transfer on ledger

* Fix notification UX and z-index issues

* Fix flow
  • Loading branch information
comountainclimber authored Jun 13, 2023
1 parent 9a54592 commit 421cbf3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 19 additions & 7 deletions app/components/Modals/TransferNftModal/TransferNftModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Props = {
dispatch: any => any,
isHardwareLogin: boolean,
signingFunction: () => void,
publicKey: string,
}

export default function TransferNftModal(props: Props) {
Expand All @@ -55,6 +56,7 @@ export default function TransferNftModal(props: Props) {
showErrorNotification,
showInfoNotification,
hideNotification,
publicKey,
} = props
function handleSubmit() {}

Expand All @@ -66,6 +68,7 @@ export default function TransferNftModal(props: Props) {
const [recipientAddress, setRecipientAddress] = useState('')
const [recipientAddressError, setRecipientAddressError] = useState('')
const [gasFee, setGasFee] = useState(DEFAULT_FEES)
const [feesInitialized, setFeesInitialized] = useState(false)
const [sendButtonDisabled, setSendButtonDisabled] = useState(false)
const [loading, setLoading] = useState(true)

Expand All @@ -74,7 +77,7 @@ export default function TransferNftModal(props: Props) {
}

function isValidAddress(address: string) {
if (address[0].toLocaleUpperCase() !== 'N') {
if (address && address[0] && address[0].toLocaleUpperCase() !== 'N') {
setRecipientAddressError(
intl.formatMessage({
id: 'errors.send.invalidN3Address',
Expand Down Expand Up @@ -117,7 +120,7 @@ export default function TransferNftModal(props: Props) {
if (!endpoint) {
endpoint = await getRPCEndpoint(net)
}
const account = new n3Wallet.Account(wif)
const account = new n3Wallet.Account(isHardwareLogin ? publicKey : wif)
const testReq = {
params: {
request: {
Expand All @@ -142,7 +145,15 @@ export default function TransferNftModal(props: Props) {
},
},
}
const results = await new N3Helper(endpoint, 0).rpcCall(account, testReq)

const results = await new N3Helper(endpoint, 0).rpcCall(
account,
testReq,
isHardwareLogin,
signingFunction,
showInfoNotification,
hideNotification,
)

const { result } = results

Expand All @@ -165,11 +176,11 @@ export default function TransferNftModal(props: Props) {
setLoading(false)
hideModal()
} catch (e) {
setLoading(false)
console.error({ e })
hideModal()
showErrorNotification({
message: 'An unknown error has occurred. Please try again.',
message: e.message,
})
setLoading(false)
}
}

Expand Down Expand Up @@ -218,6 +229,7 @@ export default function TransferNftModal(props: Props) {
networkFee: fee,
systemFee: 0,
})
setFeesInitialized(true)
setLoading(false)
}
testInvoke()
Expand Down Expand Up @@ -252,7 +264,7 @@ export default function TransferNftModal(props: Props) {
/>

<N3Fees
fees={loading ? DEFAULT_FEES : gasFee}
fees={loading && !feesInitialized ? DEFAULT_FEES : gasFee}
notEnoughGasCallback={toggleHasEnoughGas}
/>

Expand Down
3 changes: 2 additions & 1 deletion app/containers/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,15 @@ const App = ({
return (
<ErrorBoundary>
<div style={themes[theme]} className={styles.container}>
<Notifications />
{address &&
routesWithSideBar.includes(location.pathname) && (
<Sidebar store={store} theme={theme} className={styles.sidebar} />
)}
<div className={styles.wrapper}>
<FramelessNavigation />
<div className={styles.content}>{children}</div>
<Notifications />

<ModalRenderer />
</div>
</div>
Expand Down

0 comments on commit 421cbf3

Please sign in to comment.