修正几个在钱包未安装的情况下, 可能引起无法获取数据的bug
This commit is contained in:
parent
87d8bc7a9c
commit
bab12f4ba9
@ -6,4 +6,7 @@ VITE_TOKENID_ID='0x34a1'
|
||||
VITE_ERC_ADDRESS='0xFd42bfb03212dA7e1A4608a44d7658641D99CF34'
|
||||
VITE_CFNFT_ADDRESS='0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D'
|
||||
VITE_CLAIM_ADDRESS='0xf45702180314187a3549FEDac3B78349b47ca6A0'
|
||||
VITE_CLAIMWL_ADDRESS='0xc43Efb17C24e4e027d3F2613DB858181abE2994e'
|
||||
VITE_CLAIMWL_ADDRESS='0xc43Efb17C24e4e027d3F2613DB858181abE2994e'
|
||||
|
||||
VITE_PASSPORT_PUBLISHABLE_KEY=pk_imapik-test-1E-detBXtG7U$5961WuL
|
||||
VITE_PASSPORT_CLIENT_ID=gYQrjtct7CN4UVwDG2sb8yACfYRo3xQJ
|
@ -53,16 +53,25 @@ export const queryMintStatus = async(user) => {
|
||||
* feeToAddress: 0x1231231 // 接收代币的钱包地址, 前端不需要管
|
||||
* }
|
||||
*/
|
||||
const fetchMintConfig = async() => {
|
||||
export const fetchMintConfig = async() => {
|
||||
const data = '0xe7cc7244'
|
||||
return queryMintData(MINT_CONTRACT_ADDRESS, data)
|
||||
const res = await queryMintData(MINT_CONTRACT_ADDRESS, data)
|
||||
let nums = res.slice(2).match(/.{64}/g)
|
||||
const maxSupply = parseInt(nums[0], 16)
|
||||
// remove all '0' of left side, and add '0x'
|
||||
const currency = '0x' + nums[1].slice(-40)
|
||||
const mintPrice = parseInt(nums[2], 16)
|
||||
const feeToAddress = '0x' + nums[3].slice(-40)
|
||||
const airdropCount = parseInt(nums[4], 16)
|
||||
return {currency, mintPrice, maxSupply, feeToAddress, airdropCount}
|
||||
}
|
||||
|
||||
|
||||
// 所有用户已mint的nft总数
|
||||
const fetchMintedCount = async()=> {
|
||||
export const fetchAllMintedCount = async()=> {
|
||||
const data = '0x34eafb11'
|
||||
return queryMintData(MINT_CONTRACT_ADDRESS, data)
|
||||
const res = await queryMintData(MINT_CONTRACT_ADDRESS, data)
|
||||
return parseInt(res)
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ import ERC_abi from './../abi/ImmutableERC20MinterBurnerPermit.json'
|
||||
import CFNFT_abi from './../abi/CFNFTGame.json'
|
||||
import CLAIM_abi from './../abi/NFTClaimStage2.json'
|
||||
import CLAIMWL_abi from './../abi/NFTClaimStage2WL.json'
|
||||
import { queryMintStatus } from '../abi/mint.js'
|
||||
import { queryMintStatus, fetchMintConfig, fetchAllMintedCount } from '../abi/mint.js'
|
||||
var abis = {
|
||||
"ERC": ERC_abi,
|
||||
"CFNFT": CFNFT_abi,
|
||||
@ -38,14 +38,6 @@ const requestChain = async (rpc, method, params) => {
|
||||
}
|
||||
return fetch(rpc, options, DEFAULT_TIMEOUT).then(res => res.json())
|
||||
}
|
||||
const queryMintData = async (user, data) => {
|
||||
const params = [{
|
||||
from: user,
|
||||
to: MINT_CONTRACT_ADDRESS,
|
||||
data,
|
||||
}, 'latest']
|
||||
return requestChain(RPC, 'eth_call', params)
|
||||
}
|
||||
|
||||
|
||||
export async function linkWallet(val) {
|
||||
@ -237,33 +229,13 @@ export const claimStage2Nft = async (name, myAddress, params, mintPrice, web3) =
|
||||
|
||||
// 查询已Mint NFT数量
|
||||
export const balanceOfAmount = async (name, myAddress) => {
|
||||
let web3
|
||||
if (name == 'ethereum') {
|
||||
web3 = new Web3(window.ethereum);
|
||||
} else if (name == 'okxwallet') {
|
||||
web3 = new Web3(okxwallet)
|
||||
} else if (name == 'connect') {
|
||||
web3 = new Web3(provider)
|
||||
}
|
||||
let contract = new web3.eth.Contract(abis['CLAIMWL'].abi, claimWlAddress, { from: myAddress })
|
||||
const tokenId = await contract.methods.totalCount(myAddress).call();
|
||||
return parseInt(tokenId)
|
||||
return fetchAllMintedCount()
|
||||
}
|
||||
|
||||
|
||||
// mint配置
|
||||
export const mintConfig = async (name, myAddress) => {
|
||||
let web3
|
||||
if (name == 'ethereum') {
|
||||
web3 = new Web3(window.ethereum);
|
||||
} else if (name == 'okxwallet') {
|
||||
web3 = new Web3(okxwallet)
|
||||
} else if (name == 'connect') {
|
||||
web3 = new Web3(provider)
|
||||
}
|
||||
let contract = new web3.eth.Contract(abis['CLAIMWL'].abi, claimWlAddress, { from: myAddress })
|
||||
const mintArr = await contract.methods.mintConfig(myAddress).call();
|
||||
return mintArr
|
||||
return fetchMintConfig()
|
||||
}
|
||||
|
||||
// 当前用户白单数量
|
||||
|
@ -1,13 +1,12 @@
|
||||
import { Web3 } from "web3"
|
||||
import { config, passport } from '@imtbl/sdk';
|
||||
console.log(import.meta.env.VITE_GPAL_ROUTER,'import.meta.env.VITE_GPAL_ROUTER')
|
||||
const passportInstance = new passport.Passport({
|
||||
baseConfig: {
|
||||
environment: config.Environment.SANDBOX, // or Environment.PRODUCTION
|
||||
publishableKey: 'pk_imapik-test-1E-detBXtG7U$5961WuL', // replace with your publishable API key from Hub pk_imapik-tU10buLqoyLZ0o54rcub pk_imapik-test-1E-detBXtG7U$5961WuL
|
||||
publishableKey: import.meta.env.VITE_PASSPORT_PUBLISHABLE_KEY, // replace with your publishable API key from Hub pk_imapik-tU10buLqoyLZ0o54rcub pk_imapik-test-1E-detBXtG7U$5961WuL
|
||||
// publishableKey: '', // replace with your publishable API key from Hub
|
||||
},
|
||||
clientId: 'gYQrjtct7CN4UVwDG2sb8yACfYRo3xQJ', // replace with your client ID from Hub gYQrjtct7CN4UVwDG2sb8yACfYRo3xQJ tTB5eEedqDOHPHMI41sRDGmqAQwus9oE
|
||||
clientId: import.meta.env.VITE_PASSPORT_CLIENT_ID, // replace with your client ID from Hub gYQrjtct7CN4UVwDG2sb8yACfYRo3xQJ tTB5eEedqDOHPHMI41sRDGmqAQwus9oE
|
||||
redirectUri: `${import.meta.env.VITE_GPAL_ROUTER}/redirect`, // replace with one of your redirect URIs from Hub
|
||||
logoutRedirectUri: `${import.meta.env.VITE_GPAL_ROUTER}`, // replace with one of your logout URIs from Hub
|
||||
logoutMode: 'silent',
|
||||
|
Loading…
x
Reference in New Issue
Block a user