mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Feature/issue 1175 catch user rejection buy (#1177)
* fix approval rejection on buyDtFromPool * fix approval rejection on order
This commit is contained in:
parent
1eacf9d93e
commit
fc6e00669c
@ -60,6 +60,9 @@ export async function order(
|
|||||||
orderPriceAndFees.price,
|
orderPriceAndFees.price,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
if (!txApprove) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const freParams = {
|
const freParams = {
|
||||||
exchangeContract: config.fixedRateExchangeAddress,
|
exchangeContract: config.fixedRateExchangeAddress,
|
||||||
|
@ -56,6 +56,9 @@ export async function buyDtFromPool(
|
|||||||
dtPrice.tokenAmount,
|
dtPrice.tokenAmount,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
if (!approveTx) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const result = await pool.swapExactAmountOut(
|
const result = await pool.swapExactAmountOut(
|
||||||
accountId,
|
accountId,
|
||||||
accessDetails.addressOrId,
|
accessDetails.addressOrId,
|
||||||
|
@ -146,9 +146,7 @@ export default function Download({
|
|||||||
asset.accessDetails.datatoken?.symbol
|
asset.accessDetails.datatoken?.symbol
|
||||||
)[0]
|
)[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
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!')
|
toast.error('Failed to buy datatoken from pool!')
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
@ -162,7 +160,11 @@ export default function Download({
|
|||||||
)[asset.accessDetails?.type === 'fixed' ? 2 : 1]
|
)[asset.accessDetails?.type === 'fixed' ? 2 : 1]
|
||||||
)
|
)
|
||||||
const orderTx = await order(web3, asset, orderPriceAndFees, accountId)
|
const orderTx = await order(web3, asset, orderPriceAndFees, accountId)
|
||||||
|
if (!orderTx) {
|
||||||
|
toast.error('Failed to buy datatoken from pool!')
|
||||||
|
setIsLoading(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
setIsOwned(true)
|
setIsOwned(true)
|
||||||
setValidOrderTx(orderTx.transactionHash)
|
setValidOrderTx(orderTx.transactionHash)
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user