1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-26 03:06:49 +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() {
setIsLoading(true)
if (isOwned) {
setStatusText(
getOrderFeedback(
asset.accessDetails?.baseToken?.symbol,
asset.accessDetails?.datatoken?.symbol
)[3]
)
await downloadFile(web3, asset, accountId, validOrderTx)
} else {
try {
try {
if (isOwned) {
setStatusText(
getOrderFeedback(
asset.accessDetails?.baseToken?.symbol,
asset.accessDetails?.datatoken?.symbol
)[3]
)
await downloadFile(web3, asset, accountId, validOrderTx)
} else {
if (!hasDatatoken && asset.accessDetails.type === 'dynamic') {
setStatusText(
getOrderFeedback(
@ -106,9 +107,7 @@ export default function Download({
)
const tx = await buyDtFromPool(asset.accessDetails, accountId, web3)
if (!tx) {
toast.error('Failed to buy datatoken from pool!')
setIsLoading(false)
return
throw new Error()
}
}
setStatusText(
@ -119,18 +118,18 @@ export default function Download({
)
const orderTx = await order(web3, asset, orderPriceAndFees, accountId)
if (!orderTx) {
toast.error('Failed to buy datatoken from pool!')
setIsLoading(false)
return
throw new Error()
}
setIsOwned(true)
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)
}