1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-29 00:57:50 +02:00

catch user signing rejection on download (#1237)

* catch user signing rejection on download

* change LoggerInstance.log to LoggerInstance.error

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
EnzoVezzaro 2022-03-23 10:59:57 -04:00 committed by GitHub
parent 5f174bca88
commit aeb6f06f75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,16 +87,17 @@ export default function Download({
async function handleOrderOrDownload() { async function handleOrderOrDownload() {
setIsLoading(true) setIsLoading(true)
if (isOwned) { try {
setStatusText( if (isOwned) {
getOrderFeedback( setStatusText(
asset.accessDetails?.baseToken?.symbol, getOrderFeedback(
asset.accessDetails?.datatoken?.symbol asset.accessDetails?.baseToken?.symbol,
)[3] asset.accessDetails?.datatoken?.symbol
) )[3]
await downloadFile(web3, asset, accountId, validOrderTx) )
} else {
try { await downloadFile(web3, asset, accountId, validOrderTx)
} else {
if (!hasDatatoken && asset.accessDetails.type === 'dynamic') { if (!hasDatatoken && asset.accessDetails.type === 'dynamic') {
setStatusText( setStatusText(
getOrderFeedback( getOrderFeedback(
@ -106,9 +107,7 @@ export default function Download({
) )
const tx = await buyDtFromPool(asset.accessDetails, accountId, web3) const tx = await buyDtFromPool(asset.accessDetails, accountId, web3)
if (!tx) { if (!tx) {
toast.error('Failed to buy datatoken from pool!') throw new Error()
setIsLoading(false)
return
} }
} }
setStatusText( setStatusText(
@ -119,18 +118,18 @@ export default function Download({
) )
const orderTx = await order(web3, asset, orderPriceAndFees, accountId) const orderTx = await order(web3, asset, orderPriceAndFees, accountId)
if (!orderTx) { if (!orderTx) {
toast.error('Failed to buy datatoken from pool!') throw new Error()
setIsLoading(false)
return
} }
setIsOwned(true) setIsOwned(true)
setValidOrderTx(orderTx.transactionHash) setValidOrderTx(orderTx.transactionHash)
} catch (ex) {
LoggerInstance.log(ex.message)
setIsLoading(false)
} }
} catch (error) {
LoggerInstance.error(error)
const message = isOwned
? 'Failed to download file!'
: 'Failed to buy datatoken from pool!'
toast.error(message)
} }
setIsLoading(false) setIsLoading(false)
} }