Skip to content

Commit

Permalink
Merge pull request #335 from P4-Games/fix/offers-bsc
Browse files Browse the repository at this point in the history
Fix/offers bsc
  • Loading branch information
dappsar authored Feb 14, 2024
2 parents b9a47ca + 67e4c95 commit 9d9ecb7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const NETWORKS = {
alphaAddress: '0x4eE8C9cc2cF081f11F56A264EF52e3FeaDe1b35e',
gammaCardsAddress: '0x25f85D878972f9506b4De49cEff480f627935521',
gammaPackAddress: '0x71aA05fD8532a1395DffaB6FdA8be191fC8168FE',
gammaOffersAddress: '0x71aA05fD8532a1395DffaB6FdA8be191fC8168FE',
gammaOffersAddress: '0x168eE5cfE8b7EDC7F24cA0326DFfF3Ef6DF37f2F',
gammaTicketsAddress: '0xA5c3Cd20AB6FF1e299D93ee268370BCC19a32E71'
}
},
Expand Down
96 changes: 51 additions & 45 deletions src/sections/Gamma/GammaCardInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,58 +168,64 @@ const GammaCardInfo = (props) => {
const handlePublishClick = async () => {
startLoading()

const canUserPublishResult = await canUserPublishOffer(gammaOffersContract, walletAddress)
if (!canUserPublishResult) {
emitInfo(t('offer_user_limit'), 7000)
stopLoading()
return
}
try {
const canUserPublishResult = await canUserPublishOffer(gammaOffersContract, walletAddress)
if (!canUserPublishResult) {
emitInfo(t('offer_user_limit'), 7000)
stopLoading()
return
}

const canAnyUserPublishResult = await canAnyUserPublishOffer(gammaOffersContract)
if (!canAnyUserPublishResult) {
emitInfo(t('offer_game_limit'), 7000)
stopLoading()
return
}
const canAnyUserPublishResult = await canAnyUserPublishOffer(gammaOffersContract)
if (!canAnyUserPublishResult) {
emitInfo(t('offer_game_limit'), 7000)
stopLoading()
return
}

const missingCardsQtty = await getUserMissingCardsQtty(gammaCardsContract, walletAddress)
const missingCardsQtty = await getUserMissingCardsQtty(gammaCardsContract, walletAddress)

if (missingCardsQtty > 0) {
stopLoading()
const result = await Swal.fire({
title: `${t('publish_offer_auto_title')}`,
text: `${t('publish_offer_auto_msg')}`,
showCancelButton: true,
confirmButtonText: `${t('publish_offer_auto_confirm')}`,
cancelButtonText: `${t('publish_offer_auto_denied')}`,
confirmButtonColor: '#005EA3',
color: 'black',
background: 'white',
customClass: {
image: 'cardalertimg',
input: 'alertinput'
}
})
if (missingCardsQtty > 0) {
stopLoading()
const result = await Swal.fire({
title: `${t('publish_offer_auto_title')}`,
text: `${t('publish_offer_auto_msg')}`,
showCancelButton: true,
confirmButtonText: `${t('publish_offer_auto_confirm')}`,
cancelButtonText: `${t('publish_offer_auto_denied')}`,
confirmButtonColor: '#005EA3',
color: 'black',
background: 'white',
customClass: {
image: 'cardalertimg',
input: 'alertinput'
}
})

if (result.isConfirmed) {
try {
startLoading()
await createOffer(gammaOffersContract, userCard.name, [])
stopLoading()
emitSuccess(t('confirmado'), 2000)
handleFinishPublish(true)
} catch (e) {
stopLoading()
console.error({ e })
if (e.message == 'publish_offer_error_own_card_number')
emitWarning(t('publish_offer_error_own_card_number'))
else emitError(t('publish_offer_error'))
if (result.isConfirmed) {
try {
startLoading()
await createOffer(gammaOffersContract, userCard.name, [])
stopLoading()
emitSuccess(t('confirmado'), 2000)
handleFinishPublish(true)
} catch (e) {
stopLoading()
console.error({ e })
if (e.message == 'publish_offer_error_own_card_number')
emitWarning(t('publish_offer_error_own_card_number'))
else emitError(t('publish_offer_error'))
}
return
}
return
}
setCardPublish(true)
stopLoading()
} catch (e) {
stopLoading()
console.error({ e })
emitError(t('publish_offer_error'))
}
setCardPublish(true)
stopLoading()
}

const OfferButton = () => (
Expand Down
4 changes: 2 additions & 2 deletions src/sections/Gamma/GammaCardOffers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ const GammaCardOffers = (props) => {
return paginationObj.user[item]?.quantity && paginationObj.user[item]?.quantity !== 0
}

const userOfferHasCard = (item, userOfferWalletAddress) => {
const userOfferHasCard = async (item, userOfferWalletAddress) => {
let result = false
try {
startLoading()
result = hasCard(gammaCardsContract, userOfferWalletAddress, item)
result = await hasCard(gammaCardsContract, userOfferWalletAddress, item)
} catch (e) {
stopLoading()
console.error({ e })
Expand Down

0 comments on commit 9d9ecb7

Please sign in to comment.