Skip to content

Commit

Permalink
Merge pull request #364 from P4-Games/develop
Browse files Browse the repository at this point in the history
Deploy 20240626
  • Loading branch information
dappsar committed Jun 26, 2024
2 parents e9f901b + 5c8cd5a commit f1d0894
Show file tree
Hide file tree
Showing 16 changed files with 1,997 additions and 430 deletions.
29 changes: 26 additions & 3 deletions public/locales/br/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"FRIENDS": "AMIGOS",

"connect_wallet": "Conecte-se Carteira",
"whitepaper": "Papel Branco",
"whitepaper": "Whitepaper",

"reglas": "Regras",
"ver_cartas": "Ver cartas",
Expand All @@ -58,7 +58,7 @@
"no_mas_packs": "Não há mais pacotes disponíveis.",
"no_dai": "Você não tem DAI suficiente!",
"album_completo": "Parabéns! Você completou o álbum!",
"carta_en_album": "Sua carta está no álbum",
"carta_en_album": "Brilhante! Sua carta está no álbum!",
"direccion_destino_error": "O endereço de destino é inválido.",
"carta_enviada": "Sua carta foi enviada",
"usuario_no_en_temporada": "Este usuário não está jogando nesta temporada.",
Expand Down Expand Up @@ -139,7 +139,27 @@
"rules_gamma_right_text_3": "NoFTown permite interagir com outros jogadores de forma rápida e segura, facilitando a troca de NFTs.",
"rules_gamma_right_text_4": "Contas múltiplas não são permitidas.",

"no_season_nampes": "Nenhuma temporada encontrada",
"no_season_names": "Nenhuma temporada encontrada",
"alpha_create_new_season": "Criar nova temporada",
"alpha_buy_pack_text": "Você está prestes a comprar um pacote de temporada de '{SEASON_NAME}' por {PRICE} DAI. Você confirma a compra?",
"alpha_buy_pack_error": "Ocorreu um erro ao tentar comprar pacotes.",
"alpha_season_create_title": "Criar nova temporada",
"alpha_season_name": "Nome",
"alpha_season_pack_price": "Preço do pacote (DAI)",
"alpha_season_cards_quantity": "Número de cartões",
"alpha_season_folder": "Arquivo",
"alpha_confirm_new_season": "Criar",
"alpha_season_name_error": "Nome inválido",
"alpha_season_price_error": "Preço inválido",
"alpha_create_new_season_error": "Ocorreu um erro ao tentar criar a temporada",
"alpha_no_cards_error_text": "Você deve comprar cartas para jogar.",
"alpha_season_authorization": "Você deve estar autorizado a criar novas temporadas.",
"alpha_transfer_card_title": "Enviar carta da álbum #",
"alpha_transfer_card_address_error": "Endereço inválido",
"alpha_transfer_card_must_wait": "Você deve esperar que todos os jogadores comprem pacotes antes de poder transferir cartas.",
"alpha_transfer_card_error": "Ocorreu um erro ao tentar transferir o cartão.",
"alpha_paste_card_error": "Ocorreu um erro ao tentar colar o cartão.",
"alpha_show_cards_error": "Ocorreu um erro ao tentar mostrar as cartas.",
"user_has_card_error": "Erro ao verificar se o usuário possui um cartão",

"alpha_fetch_albums_error": "Houve um erro ao tentar obter os álbuns",
Expand All @@ -162,9 +182,12 @@
"account_text_copied": "Copiado",
"account_balance_zero": "Você não tem saldo suficiente para enviar.",
"account_send_dai_title": "Transferência de token",
"account_mint_dai_title": "Mint DAI",
"quantity": "Cantidad",
"quantity_invalid": "Cantidad Inválida.",
"amount_invalid": "Montante inválido.",
"account_send_dai_error": "Ocorreu um erro ao tentar transferir tokens.",
"account_mint_dai_error": "Ocorreu um erro ao tentar mint DAI.",

"notification_title": "Notificações",
"notification_no_messages": "Você não tem mensagens",
Expand Down
27 changes: 25 additions & 2 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"no_mas_packs": "No more packs available.",
"no_dai": "You don't have enough DAI!",
"album_completo": "Congratulations! You have completed the album!",
"carta_en_album": "Your card is already in the album",
"carta_en_album": "Great! your card is in the album!",
"direccion_destino_error": "The destination address is invalid.",
"carta_enviada": "Your card has been sent",
"usuario_no_en_temporada": "This user is not playing this season.",
Expand Down Expand Up @@ -139,7 +139,27 @@
"rules_gamma_right_text_3": "NoFTown enables you to interact with other players quickly and safely, facilitating NFT exchanges.",
"rules_gamma_right_text_4": "Multiple accounts are not allowed.",

"no_season_nampes": "No seasons found",
"no_season_names": "No seasons found",
"alpha_create_new_season": "Create New Season",
"alpha_buy_pack_text": "You are about to buy a pack from season '{SEASON_NAME}' for {PRICE} DAI. Do you confirm the purchase?",
"alpha_buy_pack_error": "There was an error while buying the pack.",
"alpha_season_create_title": "Create New Season",
"alpha_season_name": "Name",
"alpha_season_pack_price": "Pack price (DAI)",
"alpha_season_cards_quantity": "Cards quantity",
"alpha_season_folder": "Folder",
"alpha_confirm_new_season": "Create",
"alpha_season_name_error": "Invalid name",
"alpha_season_price_error": "Invalid price",
"alpha_create_new_season_error": "There was an error trying to create the new season.",
"alpha_no_cards_error_text": "You must buy cards to play.",
"alpha_season_authorization": "You are not authorized to create a new season.",
"alpha_transfer_card_title": "Transfer card from album #",
"alpha_transfer_card_address_error": "Invalid address",
"alpha_transfer_card_must_wait": "You must wait until all players are ready to transfer the card.",
"alpha_transfer_card_error": "There was an error trying to transfer the card.",
"alpha_paste_card_error": "There was an error trying to paste the card.",
"alpha_show_cards_error": "There was an error trying to get the cards.",
"user_has_card_error": "Error checking if the user has a card",

"alpha_fetch_albums_error": "There was an error while trying to fetch the albums",
Expand All @@ -162,9 +182,12 @@
"account_text_copied": "Copied",
"account_balance_zero": "You do not have enough balance to send.",
"account_send_dai_title": "Token Transfer",
"account_mint_dai_title": "Mint DAI",
"quantity": "Quantity",
"quantity_invalid": "Invalid Quantity.",
"amount_invalid": "Invalid Amount.",
"account_send_dai_error": "There was an error trying to transfer tokens.",
"account_mint_dai_error": "There was an error trying to mint DAI.",

"notification_title": "Notifications",
"notification_no_messages": "No Messages",
Expand Down
29 changes: 26 additions & 3 deletions public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"FRIENDS": "AMIGOS",

"connect_wallet": "Conectar Billetera",
"whitepaper": "Papel Blanco",
"whitepaper": "Whitepaper",

"reglas": "Reglas",
"ver_cartas": "Ver cartas",
Expand All @@ -58,7 +58,7 @@
"no_mas_packs": "No hay más packs disponibles.",
"no_dai": "No tienes sucientes DAI!",
"album_completo": "Felicidades! Has completado el album!",
"carta_en_album": "Tu carta ya está en el album",
"carta_en_album": "Genial! Tu carta está en el album!",
"direccion_destino_error": "La dirección de destino es inválida.",
"carta_enviada": "Tu carta ha sido enviada",
"usuario_no_en_temporada": "Este usuario no está jugando esta temporada.",
Expand Down Expand Up @@ -140,7 +140,27 @@
"rules_gamma_right_text_3": "NofTown te permite interactuar con otros jugadores de forma rápida y segura, realizando intercambios de NFT de forma sencilla.",
"rules_gamma_right_text_4": "No están permitidas las multicuentas.",

"no_season_nampes": "No se encontraron temporadas",
"no_season_names": "No se encontraron temporadas",
"alpha_create_new_season": "Crear nueva temporada",
"alpha_buy_pack_text": "Estás por comprar un pack de la temporada '{SEASON_NAME}' por {PRICE} DAI. ¿Confirmas la compra?",
"alpha_buy_pack_error": "Ocurrió un error al intentar comprar el pack.",
"alpha_season_create_title": "Crear nueva temporada",
"alpha_season_name": "Nombre",
"alpha_season_pack_price": "Precio del paquete (DAI)",
"alpha_season_cards_quantity": "Cantidad de cartas",
"alpha_season_folder": "Carpeta",
"alpha_confirm_new_season": "Crear",
"alpha_season_name_error": "Nombre inválido",
"alpha_season_price_error": "Precio inválido",
"alpha_create_new_season_error": "Ocurrió un error al intentar crear la temporada",
"alpha_no_cards_error_text": "Debes comprar cartas para poder jugar.",
"alpha_season_authorization": "Debes estar autorizado a crear nuevas temporadas.",
"alpha_transfer_card_title": "Transferir carta de album #",
"alpha_transfer_card_address_error": "Dirección inválida",
"alpha_transfer_card_must_wait": "Debes esperar a que todos los jugadores compren packs para poder transferir cartas.",
"alpha_transfer_card_error": "Ocurrió un error al intentar transferir la carta",
"alpha_paste_card_error": "Ocurrió un error intentando pegar la carta.",
"alpha_show_cards_error": "Ocurrió un error al intentar obtener las cartas",
"user_has_card_error": "Error verificando si el usuario tiene carta",

"alpha_fetch_albums_error": "Ocurrió un error al intentar obtener los álbumes",
Expand All @@ -163,9 +183,12 @@
"account_text_copied": "Copiado",
"account_balance_zero": "No tienes saldo suficiente para enviar.",
"account_send_dai_title": "Transferencia de Tokens",
"account_mint_dai_title": "Mintear DAI",
"quantity": "Cantidad",
"quantity_invalid": "Cantidad Inválida.",
"amount_invalid": "Monto Inválido.",
"account_send_dai_error": "Ocurrió un error al intentar transferir tokens.",
"account_mint_dai_error": "Ocurrió un error al intentar mintear DAI.",

"notification_title": "Notificaciones",
"notification_no_messages": "No tienes mensajes",
Expand Down
59 changes: 57 additions & 2 deletions src/components/Navbar/AccountInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useTranslation } from 'next-i18next'
import Swal from 'sweetalert2'
import { HiOutlineClipboardDocument } from 'react-icons/hi2'
import { GoLinkExternal } from 'react-icons/go'
import { AiOutlineSend } from 'react-icons/ai'
import { AiOutlineSend, AiOutlineBank } from 'react-icons/ai'

import { useWeb3Context, useLayoutContext } from '../../hooks'
import { getBalance, getTokenName, transfer } from '../../services/dai'
import { getBalance, getTokenName, transfer, mintDai } from '../../services/dai'
import { emitError, emitInfo, emitSuccess } from '../../utils/alert'
import { checkInputAddress, checkFloatValue1GTValue2 } from '../../utils/InputValidators'
import { getAccountAddressText } from '../../utils/stringUtils'
Expand Down Expand Up @@ -74,6 +74,56 @@ const AccountInfo = ({ showAccountInfo, setShowAccountInfo }) => {
}, 1000)
}

const handleMintDaiClick = async () => {
try {
setShowAccountInfo(false)

// swal2-inputerror
const result = await Swal.fire({
title: `${t('account_mint_dai_title')}`,
html: `
<input id="amount" type='number' class="swal2-input" placeholder="${t('quantity')}">
`,
showDenyButton: false,
showCancelButton: true,
confirmButtonText: `${t('mintear')}`,
confirmButtonColor: '#005EA3',
color: 'black',
background: 'white',
customClass: {
image: 'cardalertimg',
input: 'alertinput'
},
preConfirm: () => {
const amountInput = Swal.getPopup().querySelector('#amount')
const amount = amountInput.value

if (isNaN(amount)) {
amountInput.classList.add('swal2-inputerror')
Swal.showValidationMessage(`${t('amount_invalid')}`)
} else {
if (isNaN(amount)) {
amountInput.classList.add('swal2-inputerror')
Swal.showValidationMessage(`${t('amount_invalid')}`)
}
}
return { amount: amount }
}
})

if (result.isConfirmed) {
startLoading()
await mintDai(daiContract, walletAddress, result.value.amount)
emitSuccess(t('confirmado'), 2000)
stopLoading()
}
} catch (e) {
stopLoading()
console.error({ e })
emitError(t('account_mint_dai_error'))
}
}

const handleSendTokenClick = async () => {
try {
setShowAccountInfo(false)
Expand Down Expand Up @@ -224,7 +274,12 @@ const AccountInfo = ({ showAccountInfo, setShowAccountInfo }) => {
<div>
<p>{`${walletBalance} ${tokenName}`}</p>
</div>

<div className='account__info__icon__container'>
{(currentNwk?.config.environment == 'testing' ||
currentNwk?.config.chainName == 'sepolia') && (
<AiOutlineBank onClick={() => handleMintDaiClick()} className='account__info__icon' />
)}
<AiOutlineSend
onClick={() => {
handleSendTokenClick()
Expand Down
22 changes: 22 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,28 @@ export const NETWORKS = {
gammaOffersAddress: '0x94Ac8Cb81Ef3c3B056dca42974bF8A57A7B9BA03',
gammaTicketsAddress: '0x0DC4f203E9113018010720484d35a4bfa1c0beA5'
}
},
sepolia: {
config: {
enabled: 'true',
environment: 'testing',
chainName: 'sepolia',
chainId: '0xaa36a7',
chainCurrency: 'ETH',
ChainRpcUrl: 'https://sepolia.gateway.tenderly.co',
chainExplorerUrl: 'https://sepolia.etherscan.io',
chainOpenSeaBaseUrl: 'https://testnets.opensea.io',
chainNftUrl: '',
chainNodeProviderUrl: NodeProviderUrlPolygon // visible ONLY in server side code! (in cliente side will be undefined)
},
contracts: {
daiAddress: '0x916153db00beD5Df8D242d54FE116226Fd9Aa12F',
alphaAddress: '0x08EDe954E7582c14E59E295dCb9a2c7f211d2B9c',
gammaCardsAddress: '0xaf1BDeFC663a5f9A47679f1B0468BCa2f41650F5',
gammaPackAddress: '0x2C5e7B01639621ff5A402984E3d18454190f30Ee',
gammaOffersAddress: '0x0d0E683E567881C714a2E1096dEC774D72591D02',
gammaTicketsAddress: '0xD96c2655c8c04b4Bab2E0664F7ed3179a2d05d14'
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/context/Web3Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createWeb3Modal, defaultConfig } from '@web3modal/ethers5/react'
import { useWeb3ModalProvider, useWeb3ModalAccount } from '@web3modal/ethers5/react'
import { useWeb3Modal, useDisconnect } from '@web3modal/ethers5/react'
import daiAbi from './abis/testDai/TestDAI.v3.sol/NofTestDAIV3.json'
import alphaAbi from './abis/alpha/Alpha.v3.sol/NofAlphaV3.json'
import alphaAbi from './abis/alpha/Alpha.v4.sol/NofAlphaV4.json'
import gammaPacksAbi from './abis/gamma/GammaPacks.v3.sol/NofGammaPacksV3.json'
import gammaCardsAbi from './abis/gamma/GammaCards.v5.sol/NofGammaCardsV5.json'
import gammaOffersAbi from './abis/gamma/GammaOffers.v4.sol/NofGammaOffersV4.json'
Expand Down Expand Up @@ -262,7 +262,7 @@ function Web3ContextProvider({ children }) {

if (window && window.ethereum !== undefined) {
window.ethereum.on('accountsChanged', (accounts) => {
console.log('chainChanged event', accounts, address)
console.log('accountsChanged event', accounts, address)
})

window.ethereum.on('chainChanged', (newChain) => {
Expand Down
Loading

0 comments on commit f1d0894

Please sign in to comment.