Skip to content

Commit

Permalink
Merge pull request #114 from P4-Games/feature/transfer-pack
Browse files Browse the repository at this point in the history
Feature/transfer pack
  • Loading branch information
dappsar authored Nov 15, 2023
2 parents a174bc9 + 0d494d2 commit 93524b2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
1 change: 1 addition & 0 deletions public/locales/br/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"mint_error": "Ocorreu um erro ao tentar cunhar uma estatueta",

"transfer_card_error": "Ocorreu um erro ao tentar transferir o cartão",
"transfer_pack_error": "Ocorreu um erro ao tentar transferir o pacote",

"rules_alpha_left_text_1": "Um minijogo temático com 60 cartas que completam 10 coleções temáticas diferentes, cada uma com 5 personagens e um álbum.",
"rules_alpha_left_text_2": "O objetivo é completar um álbum com os 5 personagens correspondentes à coleção.",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"mint_error": "There was an error trying to mint a figurine",

"transfer_card_error": "There was an error trying to transfer the card",
"transfer_pack_error": "There was an error trying to transfer one pack",

"rules_alpha_left_text_1": "A thematic minigame with 60 cards that complete 10 different thematic collections, each with 5 characters and an album.",
"rules_alpha_left_text_2": "The goal is to complete an album with the 5 characters corresponding to the collection.",
Expand Down
1 change: 1 addition & 0 deletions public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"mint_error": "Hubo un error al intentar mintear una figurita",

"transfer_card_error": "Hubo un error al intentar transferir la carta",
"transfer_pack_error": "Hubo un error al intentar transferir un pack",

"rules_alpha_left_text_1": "Un minijuego temático con 60 cartas que completan 10 colecciones temáticas diferentes con 5 personajes y un álbum cada uno.",
"rules_alpha_left_text_2": "El objetivo es completar un álbum con los 5 personajes correspondientes a la colección.",
Expand Down
1 change: 0 additions & 1 deletion src/sections/Gamma/GammaInfoCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ const GammaInfoCard = React.forwardRef((props, book) => {

if (result.isConfirmed) {
startLoading()
console.log(result.value, imageNumber)
const transaction = await gammaCardsContract.transferCard(result.value, imageNumber)
transaction.wait()
Swal.fire({
Expand Down
53 changes: 50 additions & 3 deletions src/sections/Gamma/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { showRules, closeRules } from '../../utils/rules'
import { useWeb3Context } from '../../hooks'
import { useLayoutContext } from '../../hooks'
import gammaCardsPages from './gammaCardsPages'
import { checkInputAddress } from '../../utils/addresses'

const index = React.forwardRef(() => {
const {t} = useTranslation()
Expand Down Expand Up @@ -94,7 +95,53 @@ const index = React.forwardRef(() => {
}

const handleTransferPack = async () => {
// TODO
try {
const result = await Swal.fire({
text: `${t('wallet_destinatario')}`,
input: 'text',
inputAttributes: {
min: 43,
max: 43
},
inputValidator: (value) => {
if (!checkInputAddress(value, walletAddress))
return `${t('direccion_destino_error')}`
},
showDenyButton: false,
showCancelButton: true,
confirmButtonText: `${t('trasnferir')}`,
confirmButtonColor: '#005EA3',
color: 'black',
background: 'white',
customClass: {
image: 'cardalertimg',
input: 'alertinput'
}
})

if (result.isConfirmed) {

startLoading()

const packs = await checkPacksByUser(walletAddress, gammaPacksContract)
const packNumber = ethers.BigNumber.from(packs[0]).toNumber()
const transaction = await gammaPacksContract.transferPack(result.value, packNumber)
transaction.wait()
Swal.fire({
title: '',
text: t('confirmado'),
icon: 'success',
showConfirmButton: false,
timer: 1500
})
await checkNumberOfPacks()
stopLoading()
}
} catch (ex) {
stopLoading()
console.error({ ex })
emitError(t('transfer_pack_error'))
}
}

const handleOpenPack = async () => {
Expand Down Expand Up @@ -142,7 +189,7 @@ const index = React.forwardRef(() => {
}
}

const buyPackscontact = async (numberOfPacks) => {
const buyPacksContract = async (numberOfPacks) => {

gammaPacksContract.on('PackPurchase', (returnValue, theEvent) => {
console.log('evento PacksPurchase', returnValue)
Expand Down Expand Up @@ -204,7 +251,7 @@ const index = React.forwardRef(() => {

if (result.isConfirmed) {
const packsToBuy = result.value
await buyPackscontact(packsToBuy)
await buyPacksContract(packsToBuy)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/sections/Hero/Hero.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ const Hero = React.forwardRef((_, book) => {
{!mobile && (
<div className='hero__top__conteiner__swiper'>
<div className='hero__top__swiper'>
<Swiper
{swipper && <Swiper
effect='cards'
grabCursor
modules={[EffectCards, Autoplay, Pagination]}
Expand All @@ -417,7 +417,7 @@ const Hero = React.forwardRef((_, book) => {
<SwiperSlide />
<SwiperSlide />
<SwiperSlide />
</Swiper>
</Swiper>}
<div className='pagination' />
</div>
</div>
Expand Down

0 comments on commit 93524b2

Please sign in to comment.