Feature/issue 1175 catch user rejection buy (#1177)

* fix approval rejection on buyDtFromPool

* fix approval rejection on order
This commit is contained in:
EnzoVezzaro 2022-03-11 07:25:51 -04:00 committed by GitHub
parent 1eacf9d93e
commit fc6e00669c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -60,6 +60,9 @@ export async function order(
orderPriceAndFees.price,
false
)
if (!txApprove) {
return
}
const freParams = {
exchangeContract: config.fixedRateExchangeAddress,

View File

@ -56,6 +56,9 @@ export async function buyDtFromPool(
dtPrice.tokenAmount,
false
)
if (!approveTx) {
return
}
const result = await pool.swapExactAmountOut(
accountId,
accessDetails.addressOrId,

View File

@ -146,9 +146,7 @@ export default function Download({
asset.accessDetails.datatoken?.symbol
)[0]
)
const tx = await buyDtFromPool(asset.accessDetails, accountId, web3)
if (!tx) {
toast.error('Failed to buy datatoken from pool!')
setIsLoading(false)
@ -162,7 +160,11 @@ export default function Download({
)[asset.accessDetails?.type === 'fixed' ? 2 : 1]
)
const orderTx = await order(web3, asset, orderPriceAndFees, accountId)
if (!orderTx) {
toast.error('Failed to buy datatoken from pool!')
setIsLoading(false)
return
}
setIsOwned(true)
setValidOrderTx(orderTx.transactionHash)
} catch (ex) {