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,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user