修改mint方法调用的接口

This commit is contained in:
CounterFire2023 2024-07-17 14:29:45 +08:00
parent 164d68a484
commit 66a8fc4852
2 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { apiUnlockOrMint } from '@/utils/marketplace' import { apiUnlockOrMint, apiMintNft } from '@/utils/marketplace'
const lockAbi = [ const lockAbi = [
'function lock(address nft, address to, uint256[] tokenIds) external', 'function lock(address nft, address to, uint256[] tokenIds) external',
@ -78,17 +78,15 @@ export class Locker {
} }
// 游戏内资产上链, 只用于mint // 游戏内资产上链, 只用于mint
// 该方法会显示一个确认弹窗, 由用户选择mint到哪个地址 // 该方法会显示一个确认弹窗, 由用户选择mint到哪个地址
async mintNft(nft, tokenIds) { async mintNft(tokenIds) {
console.log('mint nft', nft, tokenIds) console.log('mint hero', tokenIds)
const { provider, address } = await this.bc.selectAddress() const { provider, address } = await this.bc.selectAddress({})
const preDatas = { const preDatas = {
net_id: import.meta.env.VUE_APP_NET_ID,
to: address, to: address,
contract_address: nft, hero_uniids: tokenIds,
tokens: tokenIds.map(tokenId => {return { tokenId }}),
} }
const passportToken = await this.bc.passportToken() const passportToken = await this.bc.passportToken()
const { errcode, errmsg, trans_req } = await apiUnlockOrMint(preDatas, passportToken) const { errcode, errmsg, trans_req } = await apiMintNft(preDatas, passportToken)
if (errcode) { if (errcode) {
throw new Error(errmsg) throw new Error(errmsg)
} }

View File

@ -129,3 +129,9 @@ export const apiUnlockOrMint = async (data, token) => {
const url = `${API_BASE}/api/nft/stacking/unlock` const url = `${API_BASE}/api/nft/stacking/unlock`
return httpPost(url, data, token) return httpPost(url, data, token)
} }
export const apiMintNft = async (data, token) => {
const url = `${API_BASE}/api/ingame/asset/hero/mint`
return httpPost(url, data, token)
}