mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01: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:
parent
5f174bca88
commit
aeb6f06f75
@ -87,6 +87,7 @@ export default function Download({
|
||||
|
||||
async function handleOrderOrDownload() {
|
||||
setIsLoading(true)
|
||||
try {
|
||||
if (isOwned) {
|
||||
setStatusText(
|
||||
getOrderFeedback(
|
||||
@ -94,9 +95,9 @@ export default function Download({
|
||||
asset.accessDetails?.datatoken?.symbol
|
||||
)[3]
|
||||
)
|
||||
|
||||
await downloadFile(web3, asset, accountId, validOrderTx)
|
||||
} else {
|
||||
try {
|
||||
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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user