Merge branch 'new-CounterFire' of http://git.kingsome.cn/huangjinming/CounterFireGames into new-CounterFire
This commit is contained in:
commit
0faffa2863
@ -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',
|
||||||
@ -47,7 +47,7 @@ export class Locker {
|
|||||||
|
|
||||||
async sendUnlockOrMint(provider, {to, data}) {
|
async sendUnlockOrMint(provider, {to, data}) {
|
||||||
|
|
||||||
const txHash = await web3Provider.request({
|
const txHash = await provider.request({
|
||||||
method: 'eth_sendTransaction',
|
method: 'eth_sendTransaction',
|
||||||
params: [{
|
params: [{
|
||||||
to,
|
to,
|
||||||
@ -80,17 +80,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)
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="metaMask-login" v-if="!localWalletStore.address" @click="immuTableLogin">Login</div>
|
<div class="metaMask-login" v-if="!localWalletStore.address" @click="immuTableLogin">Login</div>
|
||||||
<div class="metaMask-login-active" v-else @click="showMenu = !showMenu">
|
<div class="metaMask-login-active" v-else @click="showMenu = !showMenu">
|
||||||
<div class="matamask">
|
<div class="metamask">
|
||||||
<div class="title">{{ localWalletStore.showAddress }}</div>
|
<div class="title">{{ localWalletStore.showAddress }}</div>
|
||||||
|
<svg @click="handleCopy" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0 1 18 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3 1.5 1.5 3-3.75" />
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu" v-show="showMenu">
|
<div class="menu" v-show="showMenu">
|
||||||
<div class="menu-item" @click="immuTableLogout">Logout</div>
|
<div class="menu-item" @click="immuTableLogout">Logout</div>
|
||||||
@ -62,7 +65,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted, computed, watchEffect, getCurrentInstance, watch } from "vue";
|
import { ref, reactive, onMounted, computed, watchEffect, getCurrentInstance, watch, inject } from "vue";
|
||||||
|
const message = inject('$message')
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
import { useAppStore } from "@/store/app";
|
import { useAppStore } from "@/store/app";
|
||||||
import { hasMetamask } from "@/utils/chain.util";
|
import { hasMetamask } from "@/utils/chain.util";
|
||||||
@ -155,9 +159,9 @@ function click(event) {
|
|||||||
//const { copied, copyToClipboard } = useCopyToClipboard(AppModule.accountId);
|
//const { copied, copyToClipboard } = useCopyToClipboard(AppModule.accountId);
|
||||||
const { copied, error, reset, copyToClipboard } = useCopyToClipboard();
|
const { copied, error, reset, copyToClipboard } = useCopyToClipboard();
|
||||||
|
|
||||||
const message = copied.value
|
// const message = copied.value
|
||||||
? "Text copied!"
|
// ? "Text copied!"
|
||||||
: "Click the button to copy text.";
|
// : "Click the button to copy text.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -190,13 +194,14 @@ function handNavCurent(nav) {
|
|||||||
function openThirdPartyLink(url) {
|
function openThirdPartyLink(url) {
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
}
|
}
|
||||||
const handleCopy = () => {
|
const handleCopy = (e) => {
|
||||||
const accountId = AppModule.accountId;
|
e.stopPropagation();
|
||||||
|
const accountId = localWalletStore.address;
|
||||||
reset();
|
reset();
|
||||||
copyToClipboard(accountId).then(() => {
|
copyToClipboard(accountId).then(() => {
|
||||||
// if (copied.value) {
|
if (copied.value) {
|
||||||
// message.success("Copy successful!");
|
message.success("address copied");
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
@ -594,6 +599,14 @@ onMounted( async () => {
|
|||||||
a:hover {
|
a:hover {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
.metamask{
|
||||||
|
display: flex;
|
||||||
|
svg {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.immutable-cart {
|
.immutable-cart {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
@ -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)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user