Skip to content

Commit

Permalink
Merge pull request #359 from zkLinkProtocol/feat/mysterybox-v3-rewards
Browse files Browse the repository at this point in the history
Feat/mysterybox v3 rewards
  • Loading branch information
MickWang authored Aug 27, 2024
2 parents 515df0b + 75e8f6d commit fac5263
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
Binary file added public/img/m3box-id-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/m3box-id-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 28 additions & 9 deletions src/components/Dashboard/MysteryBoxIII.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ const CustomButton = styled(GradientButton)`
const TRADEMARK_TOKEN_ID_MAP: Record<number, string> = {
1: "Oak Tree Roots",
2: "Magnifying Glass",
3: "Chess Knight",
4: "Binary Code Metrix Cube",
10: "+100 Nova points",
12: "+300 Nova points",
};

const PRIZE_ID_NFT_MAP_V2: Record<number, number> = {
1: 1,
2: 2,
3: 3,
4: 4,
1: 0,
2: 1,
10: 2,
12: 3,
};

const getDrawIndexWithPrizeTokenId = (tokenId: number) => {
Expand Down Expand Up @@ -172,7 +172,7 @@ export default function MysteryBoxIII() {
return;
}

if (!drawedNftId) {
if (!drawedNftId || drawedNftId === 5) {
setDrawing(true);
const res = await drawMystery3(address);

Expand All @@ -181,8 +181,22 @@ export default function MysteryBoxIII() {
setTrademarkMintParams({ tokenId, nonce, signature, expiry, mintType });
await drawRef?.current?.start(PRIZE_ID_NFT_MAP_V2[tokenId]);

const drawPrizeId = PRIZE_ID_NFT_MAP_V2[tokenId];
setDrawedNftId(drawPrizeId);
if (tokenId === 5) {
setUpdate((update) => update + 1);
} else if ([10, 12].includes(tokenId)) {
await sleep(2000);
setDrawedNftId(undefined);
setTrademarkMintStatus(MintStatus.Success);
setMintResult({
name: TRADEMARK_TOKEN_ID_MAP[tokenId!],
img: `/img/m3box-id-${tokenId}.png`,
});
trademarkMintModal.onOpen();
drawModal.onClose();
} else {
// const drawPrizeId = PRIZE_ID_NFT_MAP_V2[tokenId];
setDrawedNftId(tokenId);
}

setUpdate((update) => update + 1);
return; // draw first and then mint as step2.
Expand Down Expand Up @@ -253,6 +267,11 @@ export default function MysteryBoxIII() {
if (result && result?.remainMintNum) {
setRemainDrawCount(Number(result.remainMintNum) || 0);
}

if (result?.unMintedRecord) {
const { nftId } = result.unMintedRecord;
setDrawedNftId(nftId);
}
};

useEffect(() => {
Expand Down
11 changes: 9 additions & 2 deletions src/components/DrawAnimationV3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ interface IProps {
const TrademarkItems = [
{ name: "Oak Tree Roots", img: "img-trademark-1.png" },
{ name: "Magnifying Glass", img: "img-trademark-2.png" },
{ name: "Chess Knight", img: "img-trademark-3.png" },
{ name: "Binary Code Metrix Cube", img: "img-trademark-4.png" },
{
name: "+100 Nova points",
img: "m3box-id-10.png",
},
{
name: "+300 Nova points",
img: "m3box-id-12.png",
},
];

const LotteryAnimation = React.forwardRef<Ref, IProps>((props, ref) => {
Expand Down Expand Up @@ -72,6 +78,7 @@ const LotteryAnimation = React.forwardRef<Ref, IProps>((props, ref) => {
};

useEffect(() => {
console.log("targetImageIndex", targetImageIndex);
if (targetImageIndex !== undefined) {
setCurrentImageIndex(targetImageIndex);
} else {
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default defineConfig({
port: 3001,
proxy: {
"/app-api": {
// target: "https://goerli.app.zklink.io",
target: "https://app-api.zklink.io",
target: "https://goerli.app.zklink.io",
// target: "https://app-api.zklink.io",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/app-api/, ""),
},
Expand Down

0 comments on commit fac5263

Please sign in to comment.