diff --git a/app/(private)/assets/burn-active.png b/app/(private)/assets/burn-active.png new file mode 100644 index 0000000..ec0cfbf Binary files /dev/null and b/app/(private)/assets/burn-active.png differ diff --git a/app/(private)/assets/burn-inactive.png b/app/(private)/assets/burn-inactive.png new file mode 100644 index 0000000..3bb6352 Binary files /dev/null and b/app/(private)/assets/burn-inactive.png differ diff --git a/app/(private)/assets/gem-burn.png b/app/(private)/assets/gem-burn.png new file mode 100644 index 0000000..080472d Binary files /dev/null and b/app/(private)/assets/gem-burn.png differ diff --git a/app/(private)/assets/redeem-active.png b/app/(private)/assets/redeem-active.png index 09b9f84..a109aed 100644 Binary files a/app/(private)/assets/redeem-active.png and b/app/(private)/assets/redeem-active.png differ diff --git a/app/(private)/assets/redeem-inactive.png b/app/(private)/assets/redeem-inactive.png index 4665d60..ee0b2d2 100644 Binary files a/app/(private)/assets/redeem-inactive.png and b/app/(private)/assets/redeem-inactive.png differ diff --git a/app/(private)/burn/page.tsx b/app/(private)/burn/page.tsx index 94d08e6..f87323e 100644 --- a/app/(private)/burn/page.tsx +++ b/app/(private)/burn/page.tsx @@ -1,12 +1,9 @@ 'use client' -import IconClose from '@/assets/ic_close.svg' -import ShieldItem from '@/assets/mat khien.png' import FilledButton from '@/components/button/filled' -import Checkbox from '@/components/checkbox' -import Gem from '@/components/gem' import GemWithFrame from '@/components/gem/gemWithFrame' +import { initList } from '@/constants' import { Bangkok, Context } from '@/provider' -import { forgeGem } from '@/services' +import { burn, forgeGem } from '@/services' import { useChain } from '@cosmos-kit/react' import { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, useDisclosure } from '@nextui-org/react' import Immutable, { Map } from 'immutable' @@ -15,16 +12,11 @@ import getConfig from 'next/config' import Image from 'next/image' import { useContext, useEffect, useMemo, useState } from 'react' import { toast } from 'react-toastify' -import ForgeBg from '../assets/force-bg.svg' -import GemSlot from '../assets/gem-slot.svg' -import GemSlotActive from '../assets/gem-slot_active.svg' -import Shield from '../assets/shield.svg' import TopBar2 from '../assets/top-bar-2.svg' import TopBar from '../assets/top-bar.svg' import TopBarMobile from '../assets/top-bar_mobile.svg' import { RevealForgingResult } from '../components/revealForgingResult' -import { initList } from '@/constants' - +import GemBurn from '@/app/(private)/assets/gem-burn.png' export default function Home() { const config = getConfig() const { assets, lastAssetsUpdate, fetchAssets, setBlackListId } = useContext(Context) @@ -106,33 +98,16 @@ export default function Home() { } } - const forgeGemHandler = async () => { + const burnHandler = async () => { try { setLoading(true) - const bl = [] - const main = assets.find((asset) => asset.type == mainGem) - const msgs = [ - { - contract: main?.cw721_contract.smart_contract.address, - msg: { - approve: { - spender: config.OPERATOR_CONTRACT_ADDRESS, - token_id: main?.token_id, - }, - }, - }, - ] - bl.push(main?.token_id) - + const bl: any[] = [] const material: any[] = [] - for (let i = 0; i < 5; i++) { - if (materialGems[i] != undefined) { - const asset = assets.find( - (a) => - a.type == materialGems[i] && - !material.find((g) => g.tokenId == a.token_id) && - main?.token_id != a.token_id - ) + const msgs: any[] = [] + + list.forEach((gem) => { + for (let i = 0; i < gem.amount; i++) { + const asset = assets.find((a) => a.type == gem.type && !material.find((g) => g.tokenId == a.token_id)) material.push({ contractAddress: asset?.cw721_contract.smart_contract.address as string, tokenId: asset?.token_id as string, @@ -148,23 +123,11 @@ export default function Home() { }) bl.push(asset?.token_id) } - } - let shield - if (useShield) { - shield = assets.find((asset) => asset.type == 'shield') - msgs.push({ - contract: shield?.cw721_contract.smart_contract.address, - msg: { - approve: { - spender: config.OPERATOR_CONTRACT_ADDRESS, - token_id: shield?.token_id, - }, - }, - }) - bl.push(shield?.token_id) - } + }) + setTempBlackList(bl) - console.log('forge', main, material, shield) + console.log('burn', material) + return const client = await getSigningCosmWasmClient() await client.executeMultiple( address as string, @@ -175,19 +138,7 @@ export default function Home() { 'auto' ) - const result = await forgeGem( - { - contractAddress: main?.cw721_contract.smart_contract.address as string, - tokenId: main?.token_id as string, - }, - material, - useShield - ? { - contractAddress: shield?.cw721_contract.smart_contract.address as string, - tokenId: shield?.token_id as string, - } - : undefined - ) + const result = await burn(material) if (result?.data?.data?.requestId) { setRequestId(result?.data?.data?.requestId) @@ -218,6 +169,8 @@ export default function Home() { } } + const gemCount = list.reduce((total, current) => (total += +current.amount), 0) + return ( <> {requestId && ( @@ -422,73 +375,89 @@ export default function Home() { {list.length ? ( list.map((gem) => { return ( -