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

feature: Fixes error related to NFT transfer on ledger #2499

Merged
merged 3 commits into from
Jun 13, 2023
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
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