Skip to content

Commit

Permalink
fix: error when a transaction is rejected with ledger (#7531)
Browse files Browse the repository at this point in the history
* fix: error when a transaction is rejected with ledger

* fix: close send popup for ledger devices

---------

Co-authored-by: Begoña Alvarez <[email protected]>
  • Loading branch information
cpl121 and begonaalvarezd authored Nov 20, 2023
1 parent c3b62e7 commit 91dbe2b
Showing 1 changed file with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<script lang="ts">
import { onMount } from 'svelte'
import { get } from 'svelte/store'
import { FontWeight, Tab, TextHintVariant, TextType } from 'shared/components/enums'
import { PopupId, closePopup, openPopup, updatePopupProps } from '@auxiliary/popup'
import { prepareOutput, selectedAccount } from '@core/account'
import { handleError } from '@core/error/handlers/handleError'
import { localize } from '@core/i18n'
import { ledgerPreparedOutput } from '@core/ledger'
import { checkActiveProfileAuth, isActiveLedgerProfile } from '@core/profile'
import { TimePeriod } from '@core/utils'
import { sendOutput } from '@core/wallet/actions'
import { TokenStandard } from '@core/wallet/enums'
import { NewTransactionType, newTransactionDetails, updateNewTransactionDetails } from '@core/wallet/stores'
import { NewTokenTransactionDetails, NftActivity, TransactionActivity, VestingActivity } from '@core/wallet/types'
import {
getDefaultTransactionOptions,
getOutputParameters,
getStorageDepositFromOutput,
validateSendConfirmation,
} from '@core/wallet/utils'
import { getInitialExpirationDate, rebuildActivity } from '@core/wallet/utils/send/sendUtils'
import { CommonOutput, Output } from '@iota/sdk/out/types'
import {
ActivityInformation,
BasicActivityDetails,
Expand All @@ -13,26 +29,10 @@
TextHint,
Toggle,
} from '@ui'
import { prepareOutput, selectedAccount } from '@core/account'
import { localize } from '@core/i18n'
import { checkActiveProfileAuth, isActiveLedgerProfile } from '@core/profile'
import { TimePeriod } from '@core/utils'
import { TokenStandard } from '@core/wallet/enums'
import { newTransactionDetails, NewTransactionType, updateNewTransactionDetails } from '@core/wallet/stores'
import { sendOutput } from '@core/wallet/actions'
import {
validateSendConfirmation,
getStorageDepositFromOutput,
getOutputParameters,
getDefaultTransactionOptions,
} from '@core/wallet/utils'
import { closePopup, openPopup, PopupId, updatePopupProps } from '@auxiliary/popup'
import { NewTokenTransactionDetails, NftActivity, TransactionActivity, VestingActivity } from '@core/wallet/types'
import { CommonOutput, Output } from '@iota/sdk/out/types'
import { ledgerPreparedOutput } from '@core/ledger'
import { handleError } from '@core/error/handlers/handleError'
import { ToggleColor } from '@ui/inputs/Toggle.svelte'
import { getInitialExpirationDate, rebuildActivity } from '@core/wallet/utils/send/sendUtils'
import { FontWeight, Tab, TextHintVariant, TextType } from 'shared/components/enums'
import { onMount } from 'svelte'
import { get } from 'svelte/store'
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
export let isSendAndClosePopup: boolean = false
Expand Down Expand Up @@ -164,8 +164,17 @@
}
async function sendOutputAndClosePopup(): Promise<void> {
await sendOutput(preparedOutput)
closePopup()
try {
await sendOutput(preparedOutput)
closePopup()
} catch (err) {
handleError(err)
} finally {
// make sure to close the popup if the user is using a ledger device
if ($isActiveLedgerProfile) {
closePopup(true)
}
}
}
async function onConfirmClick(): Promise<void> {
Expand Down

0 comments on commit 91dbe2b

Please sign in to comment.