diff --git a/configs/partner_nft_list.json b/configs/partner_nft_list.json index 264401d..8ac3706 100644 --- a/configs/partner_nft_list.json +++ b/configs/partner_nft_list.json @@ -1,246 +1,292 @@ [ { - "projectName": "Test", - "link": "https://x.com/sparky-chain", - "contract": "0x50A8e60041A206AcaA5F844a1104896224be6F39", - "collection": "Test Collection", - "guild": "1222509817411665920", - "role": "1229658972793999391" + "Project": "L3E7", + "Twitter": "https://twitter.com/L3E7_Official", + "Contract": "0x20577896ea6113ed8c94b2f08f3893bdc08eba22", + "Collection name": "L3E7 Worlds", + "Supply": "600", + "Floor Price": "-", + "ROLE ID": "1229439602142613564", + "TIER": "Tier 1" }, { - "projectName": "L3E7", - "link": "https://twitter.com/L3E7_Official", - "contract": "0x20577896ea6113ed8c94b2f08f3893bdc08eba22", - "collection": "L3E7 Worlds", - "guild": "930002266868555827", - "role": "1229439602142613564" + "Project": "Ultiverse", + "Twitter": "https://twitter.com/UltiverseDAO", + "Contract": "0x3fd36d72f05fb1af76ee7ce9257ca850faba91ed", + "Collection name": "Eletric Sheep", + "Supply": "6992", + "Floor Price": "-", + "ROLE ID": "1229439712650067978", + "TIER": "Tier 1" }, { - "projectName": "Ultiverse", - "link": "https://twitter.com/UltiverseDAO", - "contract": "0x3fd36d72f05fb1af76ee7ce9257ca850faba91ed", - "collection": "Eletric Sheep", - "guild": "930002266868555827", - "role": "1229439712650067978" + "Project": "Pixelmon", + "Twitter": "https://twitter.com/Pixelmon", + "Contract": "0x32973908faee0bf825a343000fe412ebe56f802a", + "Collection name": "Pixelmon - Gen1", + "Supply": "12566", + "Floor Price": "1.5e", + "ROLE ID": "1229439784552763482", + "TIER": "Tier 1" }, { - "projectName": "Pixelmon", - "link": "https://twitter.com/Pixelmon", - "contract": "0x32973908faee0bf825a343000fe412ebe56f802a", - "collection": "Pixelmon - Gen1", - "guild": "930002266868555827", - "role": "1229439784552763482" + "Project": "Pixelmon", + "Twitter": "https://twitter.com/Pixelmon", + "Contract": "0x8a3749936e723325c6b645a0901470cd9e790b94", + "Collection name": "Pixelmon - Trainers", + "Supply": "7000", + "Floor Price": "0.34e", + "ROLE ID": "1229439872503255092", + "TIER": "Tier 2" }, { - "projectName": "Pixelmon", - "link": "https://twitter.com/Pixelmon", - "contract": "0x8a3749936e723325c6b645a0901470cd9e790b94", - "collection": "Pixelmon - Trainers", - "guild": "930002266868555827", - "role": "1229439872503255092" + "Project": "Metacene", + "Twitter": "https://twitter.com/MetaCeneGame", + "Contract": "0xebb8cb5d88cc02f781fc23e40a558f177109226c", + "Collection name": "Metacene Apostle", + "Supply": "500", + "Floor Price": "1.27e", + "ROLE ID": "1229439964819886123", + "TIER": "Tier 1" }, { - "projectName": "Metacene", - "link": "https://twitter.com/MetaCeneGame", - "contract": "0xebb8cb5d88cc02f781fc23e40a558f177109226c", - "collection": "Metacene Apostle", - "guild": "930002266868555827", - "role": "1229439964819886123" + "Project": "Metacene", + "Twitter": "https://twitter.com/MetaCeneGame", + "Contract": "0xca7c484cbaa83900ab91b6aefa1de0478ba71eb7", + "Collection name": "Cece Cube", + "Supply": "2043", + "Floor Price": "0.26e", + "ROLE ID": "1229440053810561195", + "TIER": "Tier 2" }, { - "projectName": "Metacene", - "link": "https://twitter.com/MetaCeneGame", - "contract": "0xca7c484cbaa83900ab91b6aefa1de0478ba71eb7", - "collection": "Cece Cube", - "guild": "930002266868555827", - "role": "1229440053810561195" + "Project": "Metacene", + "Twitter": "https://twitter.com/MetaCeneGame", + "Contract": "0xd406dc865e45e28c43dd791512b4d844745f314a", + "Collection name": "Burned cube", + "Supply": "", + "Floor Price": "", + "ROLE ID": "1229440053810561195", + "TIER": "Tier 2" }, { - "projectName": "Metacene", - "link": "", - "contract": "0xd406dc865e45e28c43dd791512b4d844745f314a", - "collection": "Burned cube", - "Supply": "", - "Floor Price": "", - "guild": "930002266868555827", - "role": "1229440053810561195" + "Project": "Matr1x", + "Twitter": "https://twitter.com/Matr1xOfficial", + "Contract": "0x00723c39194f7f449be736da0d1c4ec809dde793", + "Collection name": "Matr1x - YATC", + "Supply": "520", + "Floor Price": "19.5e", + "ROLE ID": "1229440105069023374", + "TIER": "Tier 1" }, { - "projectName": "Matr1x", - "link": "https://twitter.com/Matr1xOfficial", - "contract": "0x00723c39194f7f449be736da0d1c4ec809dde793", - "collection": "Matr1x - YATC", - "guild": "930002266868555827", - "role": "1229440105069023374" + "Project": "Matr1x", + "Twitter": "https://twitter.com/Matr1xOfficial", + "Contract": "0x596a5cd859ad53fec23cd3fcd77522f0b407920d", + "Collection name": "Matr1x - KUKU", + "Supply": "6666", + "Floor Price": "1.6", + "ROLE ID": "1229440209398272081", + "TIER": "Tier 1" }, { - "projectName": "Matr1x", - "link": "https://twitter.com/Matr1xOfficial", - "contract": "0x596a5cd859ad53fec23cd3fcd77522f0b407920d", - "collection": "Matr1x - KUKU", - "guild": "930002266868555827", - "role": "1229440209398272081" + "Project": "Memeland", + "Twitter": "https://twitter.com/Memeland", + "Contract": "0x6efc003d3f3658383f06185503340c2cf27a57b6", + "Collection name": "MVP", + "Supply": "420", + "Floor Price": "63e", + "ROLE ID": "1229440774261833879", + "TIER": "Tier 1" }, { - "projectName": "Memeland", - "link": "https://twitter.com/Memeland", - "contract": "0x6efc003d3f3658383f06185503340c2cf27a57b6", - "collection": "MVP", - "guild": "930002266868555827", - "role": "1229440774261833879" + "Project": "Memeland", + "Twitter": "https://twitter.com/Memeland", + "Contract": "0x769272677fab02575e84945f03eca517acc544cc", + "Collection name": "The Captainz", + "Supply": "9999", + "Floor Price": "3.35e", + "ROLE ID": "1229440836639391866", + "TIER": "Tier 1" }, { - "projectName": "Memeland", - "link": "https://twitter.com/Memeland", - "contract": "0x769272677fab02575e84945f03eca517acc544cc", - "collection": "The Captainz", - "guild": "930002266868555827", - "role": "1229440836639391866" + "Project": "Today", + "Twitter": "https://twitter.com/todaythegame", + "Contract": "0x2a478d7b790346c7c4f19c223d368d1cf41c7a1e", + "Collection name": "TODAY - Ancient Seed", + "Supply": "777", + "Floor Price": "1.3e", + "ROLE ID": "1229440890951434281", + "TIER": "Tier 1" }, { - "projectName": "Today", - "link": "https://twitter.com/todaythegame", - "contract": "0x2a478d7b790346c7c4f19c223d368d1cf41c7a1e", - "collection": "TODAY - Ancient Seed", - "guild": "930002266868555827", - "role": "1229440890951434281" + "Project": "Asterix", + "Twitter": "https://twitter.com/asterixlabs", + "Contract": "0x0000000000c26fabfe894d13233d5ec73f61cc72", + "Collection name": "Asterix", + "Supply": "7565", + "Floor Price": "0.79", + "ROLE ID": "1229441161031061545", + "TIER": "Tier 2" }, { - "projectName": "Asterix", - "link": "https://twitter.com/asterixlabs", - "contract": "0x0000000000c26fabfe894d13233d5ec73f61cc72", - "collection": "Asterix", - "guild": "930002266868555827", - "role": "1229441161031061545" + "Project": "PG", + "Twitter": "https://twitter.com/PGodjira", + "Contract": "0x9ada21a8bc6c33b49a089cfc1c24545d2a27cd81", + "Collection name": "PG Genesis", + "Supply": "333", + "Floor Price": "7e", + "ROLE ID": "1229441706366210059", + "TIER": "Tier 1" }, { - "projectName": "PG", - "link": "https://twitter.com/PGodjira", - "contract": "0x9ada21a8bc6c33b49a089cfc1c24545d2a27cd81", - "collection": "PG Genesis", - "guild": "930002266868555827", - "role": "1229441706366210059" + "Project": "PG", + "Twitter": "https://twitter.com/PGodjira", + "Contract": "0xEDc3AD89f7b0963fe23D714B34185713706B815b", + "Collection name": "PG Gen 2 ", + "Supply": "3333", + "Floor Price": "0.26", + "ROLE ID": "1229441916173684849", + "TIER": "Tier 2" }, { - "projectName": "PG", - "link": "https://twitter.com/PGodjira", - "contract": "0xEDc3AD89f7b0963fe23D714B34185713706B815b", - "collection": "PG Gen 2 ", - "guild": "930002266868555827", - "role": "1229441916173684849" + "Project": "Delabs Games", + "Twitter": "https://twitter.com/delabsOfficial", + "Contract": "0xa7088ed1a460a154404adbfd7d6a3873e9f90340", + "Collection name": "Delabs Adventure Pass Official", + "Supply": "3433", + "Floor Price": "0.31e", + "ROLE ID": "1229441983794249798", + "TIER": "Tier 2" }, { - "projectName": "Delabs Games", - "link": "https://twitter.com/delabsOfficial", - "contract": "0xa7088ed1a460a154404adbfd7d6a3873e9f90340", - "collection": "Delabs Adventure Pass Official", - "guild": "930002266868555827", - "role": "1229441983794249798" + "Project": "Delabs Games", + "Twitter": "https://twitter.com/delabsOfficial", + "Contract": "0x36267105d35e765f40c34d062bc569bf93eb810e", + "Collection name": "Delabs Metabolts", + "Supply": "4444", + "Floor Price": "0.04e", + "ROLE ID": "1229442168167333888", + "TIER": "Tier 2" }, { - "projectName": "Delabs Games", - "link": "https://twitter.com/delabsOfficial", - "contract": "0x36267105d35e765f40c34d062bc569bf93eb810e", - "collection": "Delabs Metabolts", - "guild": "930002266868555827", - "role": "1229442168167333888" + "Project": "Space Nation", + "Twitter": "https://twitter.com/spacenationol", + "Contract": "0xff2b4721f997c242ff406a626f17df083bd2c568", + "Collection name": "Alpha Gate", + "Supply": "515", + "Floor Price": ".2.12e", + "ROLE ID": "1229442236140355645", + "TIER": "Tier 1" }, { - "projectName": "Space Nation", - "link": "https://twitter.com/spacenationol", - "contract": "0xff2b4721f997c242ff406a626f17df083bd2c568", - "collection": "Alpha Gate", - "guild": "930002266868555827", - "role": "1229442236140355645" + "Project": "Space Nation", + "Twitter": "https://twitter.com/spacenationol", + "Contract": "0xcb65bac4d4a2e400af9e1aaa999b3e7a4c42930a", + "Collection name": "Prime Navigator", + "Supply": "3056", + "Floor Price": "0.6e", + "ROLE ID": "1229442283867471976", + "TIER": "Tier 2" }, { - "projectName": "Space Nation", - "link": "https://twitter.com/spacenationol", - "contract": "0xcb65bac4d4a2e400af9e1aaa999b3e7a4c42930a", - "collection": "Prime Navigator", - "guild": "930002266868555827", - "role": "1229442283867471976" + "Project": "Pirate Nation", + "Twitter": "https://twitter.com/PirateNation", + "Contract": "0x1b41d54b3f8de13d58102c50d7431fd6aa1a2c48", + "Collection name": "Founder's Pirate", + "Supply": "9999", + "Floor Price": "0.83e", + "ROLE ID": "1229442333565653013", + "TIER": "Tier 1" }, { - "projectName": "Pirate Nation", - "link": "https://twitter.com/PirateNation", - "contract": "0x1b41d54b3f8de13d58102c50d7431fd6aa1a2c48", - "collection": "Founder's Pirate", - "guild": "930002266868555827", - "role": "1229442333565653013" + "Project": "Neo Tokyo", + "Twitter": "https://twitter.com/NeoTokyoCode", + "Contract": "0xb9951b43802dcf3ef5b14567cb17adf367ed1c0f", + "Collection name": "Neo Tokyo Citizens\r", + "Supply": "1989", + "Floor Price": "8.5e", + "ROLE ID": "1229442539787128832", + "TIER": "Tier 1" }, { - "projectName": "Neo Tokyo", - "link": "https://twitter.com/NeoTokyoCode", - "contract": "0xb9951b43802dcf3ef5b14567cb17adf367ed1c0f", - "collection": "Neo Tokyo Citizens\r\n", - "guild": "930002266868555827", - "role": "1229442539787128832" + "Project": "Neo Tokyo", + "Twitter": "https://twitter.com/NeoTokyoCode", + "Contract": "0x4481507cc228fa19d203bd42110d679571f7912e", + "Collection name": "Neo Tokyo Outer Citizens", + "Supply": "3497", + "Floor Price": "1.2e", + "ROLE ID": "1229442539787128832", + "TIER": "Tier 1" }, { - "projectName": "Neo Tokyo", - "link": "", - "contract": "0x4481507cc228fa19d203bd42110d679571f7912e", - "collection": "Neo Tokyo Outer Citizens", - "guild": "930002266868555827", - "role": "1229442539787128832" + "Project": "Neo Tokyo", + "Twitter": "https://twitter.com/NeoTokyoCode", + "Contract": "0xd37ea75dd3c499eda76304f538cbf356ed9e7ed9", + "Collection name": "Staked ( citizen / outer)", + "Supply": "", + "Floor Price": "", + "ROLE ID": "1229442539787128832", + "TIER": "Tier 1" }, { - "projectName": "Neo Tokyo", - "link": "", - "contract": "0xd37ea75dd3c499eda76304f538cbf356ed9e7ed9", - "collection": "Staked ( citizen / outer)", - "Supply": "", - "Floor Price": "", - "guild": "930002266868555827", - "role": "1229442539787128832" + "Project": "Cheers Up", + "Twitter": "https://twitter.com/CheersUP_NFT", + "Contract": "0x3113a3c04aebec2b77eb38eabf6a2257b580c54b", + "Collection name": "Cheers UP", + "Supply": "3953", + "Floor Price": "0.03e", + "ROLE ID": "1229442708561461268", + "TIER": "Tier 2" }, { - "projectName": "Cheers Up", - "link": "https://twitter.com/CheersUP_NFT", - "contract": "0x3113a3c04aebec2b77eb38eabf6a2257b580c54b", - "collection": "Cheers UP", - "guild": "930002266868555827", - "role": "1229442708561461268" + "Project": "Llamaverse", + "Twitter": "https://twitter.com/Llamaverse_", + "Contract": "0x9df8aa7c681f33e442a0d57b838555da863504f3", + "Collection name": "Llamaverse Genesis", + "Supply": "4000", + "Floor Price": "0.07e", + "ROLE ID": "1229653356126011483", + "TIER": "Tier 2" }, { - "projectName": "Llamaverse", - "link": "https://twitter.com/Llamaverse_", - "contract": "0x9df8aa7c681f33e442a0d57b838555da863504f3", - "collection": "Llamaverse Genesis", - "guild": "930002266868555827", - "role": "1229653356126011483" + "Project": "Weirdo Ghost Gang", + "Twitter": "https://twitter.com/WeirdoGhostGang", + "Contract": "0x9401518f4ebba857baa879d9f76e1cc8b31ed197", + "Collection name": "Weirdo Ghost Gang", + "Supply": "5556", + "Floor Price": "0.2", + "ROLE ID": "1229442751037177987", + "TIER": "Tier 2" }, { - "projectName": "Weirdo Ghost Gang", - "link": "https://twitter.com/WeirdoGhostGang", - "contract": "0x9401518f4ebba857baa879d9f76e1cc8b31ed197", - "collection": "Weirdo Ghost Gang", - "guild": "930002266868555827", - "role": "1229442751037177987" + "Project": "ZooVerse", + "Twitter": "https://twitter.com/ZooVerseNFT", + "Contract": "0x73382b19fe136907e9fd4cb1d55228237566324c", + "Collection name": "ZooVerse Genesis", + "Supply": "444", + "Floor Price": "0.27e", + "ROLE ID": "1229653380834525305", + "TIER": "Tier 2" }, { - "projectName": "ZooVerse", - "link": "https://twitter.com/ZooVerseNFT", - "contract": "0x73382b19fe136907e9fd4cb1d55228237566324c", - "collection": "ZooVerse Genesis", - "guild": "930002266868555827", - "role": "1229653380834525305" + "Project": "WolvesDAO", + "Twitter": "https://twitter.com/WolvesDAO", + "Contract": "0x0433882c60ada1077a9f652ca2d1d36422c62c6c", + "Collection name": "Carv Membership", + "Supply": "156", + "Floor Price": "SBT", + "ROLE ID": "1230052718224347146", + "TIER": "Tier 1" }, { - "projectName": "WolvesDAO", - "link": "https://twitter.com/WolvesDAO", - "contract": "0x0433882c60ada1077a9f652ca2d1d36422c62c6c", - "collection": "Carv Membership", - "guild": "930002266868555827", - "role": "1230052718224347146" - }, - { - "projectName": "Mofu Mofu", - "link": "https://twitter.com/MofuMofuMC", - "contract": "0x6276eC64Ed808C76594f682cdFA8Ce83963Ee17f", - "collection": "Mofu Mofu Music Caravan", - "guild": "930002266868555827", - "role": "1230052932817518644" + "Project": "Mofu Mofu", + "Twitter": "https://twitter.com/MofuMofuMC", + "Contract": "0x6276eC64Ed808C76594f682cdFA8Ce83963Ee17f", + "Collection name": "Mofu Mofu Music Caravan", + "Supply": "500", + "Floor Price": "0.2", + "ROLE ID": "1230052932817518644", + "TIER": "Tier 2" } ] \ No newline at end of file diff --git a/src/common/Constants.ts b/src/common/Constants.ts index 8d27177..f85a980 100644 --- a/src/common/Constants.ts +++ b/src/common/Constants.ts @@ -65,3 +65,6 @@ export const RECAPTCHA_MIN_SCORE = 0.5 export const RANK_SCORE_SCALE = 100 export const BASE52_ALPHABET = '3fBCM8j17XNA9xYun4wmLWep2oHFlhPcgyEJskqOz6GK0UtV5ZRaDSvrTbidQI' + +// 检查role时默认的工会id +export const DEFAULT_GUILD = '930002266868555827' diff --git a/src/controllers/nft.controller.ts b/src/controllers/nft.controller.ts index 907360a..6ea19ca 100644 --- a/src/controllers/nft.controller.ts +++ b/src/controllers/nft.controller.ts @@ -1,3 +1,4 @@ +import { DEFAULT_GUILD } from 'common/Constants' import logger from 'logger/logger' import { ChestStatusEnum } from 'models/ActivityChest' import { NFTHolderRecord } from 'models/NFTHodlerRecord' @@ -6,7 +7,18 @@ import { generateChestLevel, generateNewChest } from 'services/game.svr' import { checkDiscordRole } from 'services/oauth.svr' import { SyncLocker, BaseController, router, role, ROLE_ANON, ZError } from 'zutils' -const nftList = require('../../configs/partner_nft_list.json') +const sourceList = require('../../configs/partner_nft_list.json') +const nftList = sourceList.map(o => { + return { + contract: o['Contract'], + projectName: o['Project'], + link: o['Twitter'], + collection: o['Collection name'], + guild: o['SERVER ID'] || DEFAULT_GUILD, + role: o['ROLE ID'], + tier: o['TIER'] == 'Tier 2' ? 2 : 1, + } +}) const nftListStr = JSON.stringify(nftList) const nftMap = new Map() nftList.forEach(o => nftMap.set(o.contract.toLowerCase(), o)) @@ -19,7 +31,7 @@ class NftController extends BaseController { */ @role(ROLE_ANON) @router('get /api/partner/nfts') - async nftList(req) { + async fetchNftList(req) { const user = req.user let list = JSON.parse(nftListStr) list.forEach(o => { @@ -86,27 +98,28 @@ class NftController extends BaseController { } let { contract } = req.params if (!contract) { - throw new ZError(11, 'contract not found') + throw new ZError(11, 'params error') } contract = contract.toLowerCase() if (!nftMap.has(contract)) { - throw new ZError(12, 'contract not found') + throw new ZError(12, 'cfg not found') } let record = await NFTHolderRecord.findOne({ user: user.id, contract }) if (record) { throw new ZError(13, 'already claimed') } const cfg = nftMap.get(contract) - let rpcRes = await checkDiscordRole(user.address.toLowerCase(), cfg.guild, cfg.role) + const guild = cfg.guild || DEFAULT_GUILD + let rpcRes = await checkDiscordRole(user.address.toLowerCase(), guild, cfg.role) console.log('check result:', rpcRes) if (rpcRes.errcode) { - throw new ZError(20, `check error: ${rpcRes.errmsg}`) + throw new ZError(rpcRes.errcode, `rpcRes.errmsg`) } if (!rpcRes.data.result) { - throw new ZError(14, 'not match claim condition') + throw new ZError(14, 'had no role') } - let randomLevel = generateChestLevel() - let chest = generateNewChest(user.id, user.activity, randomLevel, ChestStatusEnum.NORMAL) + let chestLevel = cfg.tier || 1 + let chest = generateNewChest(user.id, user.activity, chestLevel, ChestStatusEnum.NORMAL) await chest.save() let recordNew = new NFTHolderRecord({ user: user.id,