diff --git a/webapp/src/modules/nft/sagas.ts b/webapp/src/modules/nft/sagas.ts index 46be96cf4..75aa71b06 100644 --- a/webapp/src/modules/nft/sagas.ts +++ b/webapp/src/modules/nft/sagas.ts @@ -167,49 +167,50 @@ export function* nftSaga(getIdentity: () => AuthIdentity | undefined) { } } -function* handleTransferNFTRequest(action: TransferNFTRequestAction) { - const { nft, address } = action.payload - try { - const vendor: Vendor = yield call( - VendorFactory.build, - nft.vendor - ) - - const wallet: ReturnType = yield select(getWallet) - if (!wallet) { - throw new Error('A wallet is needed to perform a NFT transfer request') - } + function* handleTransferNFTRequest(action: TransferNFTRequestAction) { + const { nft, address } = action.payload + try { + const vendor: Vendor = yield call( + VendorFactory.build, + nft.vendor + ) + + const wallet: ReturnType = yield select(getWallet) + if (!wallet) { + throw new Error('A wallet is needed to perform a NFT transfer request') + } - const txHash: string = yield call( - [vendor.nftService, 'transfer'], - wallet, - address, - nft - ) - yield put(transferNFTransactionSubmitted(nft, address, txHash)) - if (nft?.openRentalId) { - yield call(waitForTx, txHash) - const rental: RentalListing | null = yield select( - getRentalById, - nft.openRentalId + const txHash: string = yield call( + [vendor.nftService, 'transfer'], + wallet, + address, + nft ) - if (isRentalListingOpen(rental)) { - yield call(waitUntilRentalChangesStatus, nft, RentalStatus.CANCELLED) + yield put(transferNFTransactionSubmitted(nft, address, txHash)) + if (nft?.openRentalId) { + yield call(waitForTx, txHash) + const rental: RentalListing | null = yield select( + getRentalById, + nft.openRentalId + ) + if (isRentalListingOpen(rental)) { + yield call(waitUntilRentalChangesStatus, nft, RentalStatus.CANCELLED) + } } - } - yield put(transferNFTSuccess(nft, address)) - } catch (error) { - const errorMessage = isErrorWithMessage(error) - ? error.message - : t('global.unknown_error') - const errorCode = - error !== undefined && - error !== null && - typeof error === 'object' && - 'code' in error - ? (error as { code: ErrorCode }).code - : undefined - yield put(transferNFTFailure(nft, address, errorMessage, errorCode)) + yield put(transferNFTSuccess(nft, address)) + } catch (error) { + const errorMessage = isErrorWithMessage(error) + ? error.message + : t('global.unknown_error') + const errorCode = + error !== undefined && + error !== null && + typeof error === 'object' && + 'code' in error + ? (error as { code: ErrorCode }).code + : undefined + yield put(transferNFTFailure(nft, address, errorMessage, errorCode)) + } } }