Merge branch 'new-CounterFire' of http://git.kingsome.cn/huangjinming/CounterFireGames into new-CounterFire
This commit is contained in:
commit
6610f054c0
@ -25,7 +25,7 @@
|
|||||||
<img :src="icon" alt="">
|
<img :src="icon" alt="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="link-below" @click="lockToGame('convert')">
|
<div class="link-below" @click="mintHero('convert')">
|
||||||
<!-- Convert -->
|
<!-- Convert -->
|
||||||
<img src="@/assets/img/marketplace/Off-Chain.png" alt="">
|
<img src="@/assets/img/marketplace/Off-Chain.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
@ -140,45 +140,57 @@ const sellNft = async (val) => {
|
|||||||
|
|
||||||
const loadingDialogVisible = ref(false)
|
const loadingDialogVisible = ref(false)
|
||||||
// 下链使用
|
// 下链使用
|
||||||
// const lockToGame = async(type) => {
|
const lockToGame = async(type) => {
|
||||||
// if(type == 'redeem') {
|
if(type == 'redeem') {
|
||||||
// const confirmResult = await createModal(ConfirmDialog, {
|
const confirmResult = await createModal(ConfirmDialog, {
|
||||||
// title: '',
|
title: '',
|
||||||
// message: `Redeem ${props.nftData.detail.gold_coins} Gold to your game account. Do you wish to proceed?`
|
message: `Redeem ${props.nftData.detail.gold_coins} Gold to your game account. Do you wish to proceed?`
|
||||||
// }).show()
|
}).show()
|
||||||
// if (confirmResult.errcode == 0) {
|
if (confirmResult.errcode == 0) {
|
||||||
// loadingDialogVisible.value = true
|
loadingDialogVisible.value = true
|
||||||
// lockToGameConfirm()
|
lockToGameConfirm()
|
||||||
// }
|
}
|
||||||
// } else if(type == 'convert') {
|
} else if(type == 'convert') {
|
||||||
// const confirmResult = await createModal(ConfirmDialog, {
|
const confirmResult = await createModal(ConfirmDialog, {
|
||||||
// title: '',
|
title: '',
|
||||||
// message: 'After converting, you will be able to use the hero in the game. At the end of Season 1, the hero will automatically be returned to your wallet or Immutable Passport. Do you want to proceed?'
|
message: 'After converting, you will be able to use the hero in the game. At the end of Season 1, the hero will automatically be returned to your wallet or Immutable Passport. Do you want to proceed?'
|
||||||
// }).show()
|
}).show()
|
||||||
// if (confirmResult.errcode == 0) {
|
if (confirmResult.errcode == 0) {
|
||||||
// loadingDialogVisible.value = true
|
loadingDialogVisible.value = true
|
||||||
// lockToGameConfirm()
|
lockToGameConfirm()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// const lockToGameConfirm = async () => {
|
// mint一个英雄
|
||||||
// try {
|
const mintHero = async () => {
|
||||||
// const bc = new BlockChain()
|
const confirmResult = await createModal(ConfirmDialog, {
|
||||||
// let res = await bc.locker.lock(toRaw(props.nftData).contract_address, [toRaw(props.nftData).token_id])
|
title: '',
|
||||||
// message.success('lockToGame success')
|
message: 'After converting, you will be able to use the hero in the game. At the end of Season 1, the hero will automatically be returned to your wallet or Immutable Passport. Do you want to proceed?'
|
||||||
// // router.go(-1)
|
}).show()
|
||||||
// emit('renewMyNft')
|
if (confirmResult.errcode == 0) {
|
||||||
// loadingDialogVisible.value = false
|
// loadingDialogVisible.value = true
|
||||||
// // router.push('/assets')
|
const res = await new BlockChain().locker.mintNft([toRaw(props.nftData).uniid])
|
||||||
// } catch (e) {
|
console.log(res)
|
||||||
// if(e.message.indexOf('rejected') > -1) {
|
}
|
||||||
// message.error('User rejected the request')
|
}
|
||||||
// } else {
|
const lockToGameConfirm = async () => {
|
||||||
// message.error('lockToGame fail.')
|
try {
|
||||||
// }
|
const bc = new BlockChain()
|
||||||
// loadingDialogVisible.value = false
|
let res = await bc.locker.lock(toRaw(props.nftData).contract_address, [toRaw(props.nftData).token_id])
|
||||||
// }
|
message.success('lockToGame success')
|
||||||
// }
|
// router.go(-1)
|
||||||
|
emit('renewMyNft')
|
||||||
|
loadingDialogVisible.value = false
|
||||||
|
// router.push('/assets')
|
||||||
|
} catch (e) {
|
||||||
|
if(e.message.indexOf('rejected') > -1) {
|
||||||
|
message.error('User rejected the request')
|
||||||
|
} else {
|
||||||
|
message.error('lockToGame fail.')
|
||||||
|
}
|
||||||
|
loadingDialogVisible.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取出售中价格价格
|
// 获取出售中价格价格
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {PassportWallet} from "@/components/chain/wallet/PassportWallet";
|
import {PassportWallet, baseConfig} from "@/components/chain/wallet/PassportWallet";
|
||||||
import { MetaMaskWallet } from '@/components/chain/wallet/MetaMaskWallet';
|
import { MetaMaskWallet } from '@/components/chain/wallet/MetaMaskWallet';
|
||||||
import { OkxWallet } from '@/components/chain/wallet/OkxWallet';
|
import { OkxWallet } from '@/components/chain/wallet/OkxWallet';
|
||||||
import {walletStore} from "@/store/wallet";
|
import {walletStore} from "@/store/wallet";
|
||||||
@ -9,6 +9,7 @@ import {ImtblMarket} from "@/components/chain/Market";
|
|||||||
import { ALL_PROVIDERS } from "@/configs/configchain";
|
import { ALL_PROVIDERS } from "@/configs/configchain";
|
||||||
import {Locker} from "@/components/chain/contract/Locker";
|
import {Locker} from "@/components/chain/contract/Locker";
|
||||||
import ConfirmDialog from "@/components/Dialogs/confirmDialog.vue";
|
import ConfirmDialog from "@/components/Dialogs/confirmDialog.vue";
|
||||||
|
import { checkout } from '@imtbl/sdk';
|
||||||
|
|
||||||
|
|
||||||
export const allProviders = {
|
export const allProviders = {
|
||||||
@ -72,6 +73,7 @@ export class BlockChain {
|
|||||||
}
|
}
|
||||||
this.store.$persist();
|
this.store.$persist();
|
||||||
this.market.updateProvider(provider);
|
this.market.updateProvider(provider);
|
||||||
|
// this.initWidget(provider);
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +140,7 @@ export class BlockChain {
|
|||||||
*/
|
*/
|
||||||
async passportToken() {
|
async passportToken() {
|
||||||
if (this.store.walletType == 3) {
|
if (this.store.walletType == 3) {
|
||||||
return this.store.token
|
return this.token()
|
||||||
}
|
}
|
||||||
if (!this.passportProvider) {
|
if (!this.passportProvider) {
|
||||||
return ''
|
return ''
|
||||||
@ -212,4 +214,28 @@ export class BlockChain {
|
|||||||
}
|
}
|
||||||
return { provider, address: accounts[0] };
|
return { provider, address: accounts[0] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async initWidget(provider) {
|
||||||
|
const checkoutSDK = new checkout.Checkout({
|
||||||
|
baseConfig,
|
||||||
|
passport: this.passportInstance,
|
||||||
|
bridge: { enable: true },
|
||||||
|
swap: { enable: true },
|
||||||
|
onRamp: { enable: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
const widgets = await checkoutSDK.widgets({
|
||||||
|
config: { theme: checkout.WidgetTheme.DARK },
|
||||||
|
});
|
||||||
|
|
||||||
|
// RECOMMENDED - create all of the widgets once at the start of your application
|
||||||
|
// use the created widgets throughout your application to mount and unmount in specific parts of your application
|
||||||
|
const connect = widgets.create(checkout.WidgetType.CONNECT);
|
||||||
|
const wallet = widgets.create(checkout.WidgetType.WALLET, {provider}); // you can optionally pass in additional config per widget
|
||||||
|
const swap = widgets.create(checkout.WidgetType.SWAP);
|
||||||
|
const bridge = widgets.create(checkout.WidgetType.BRIDGE);
|
||||||
|
const onramp = widgets.create(checkout.WidgetType.ONRAMP);
|
||||||
|
// Mount the wallet widget passing the element id of where to mount the widget
|
||||||
|
wallet.mount('wallet');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,16 +44,18 @@ export class Locker {
|
|||||||
return res.hash
|
return res.hash
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendUnlockOrMint(provider, {to, data}) {
|
async sendUnlockOrMint(provider, {from, to, data}) {
|
||||||
|
|
||||||
const txHash = await provider.request({
|
const txHash = await provider.provider.request({
|
||||||
method: 'eth_sendTransaction',
|
method: 'eth_sendTransaction',
|
||||||
params: [{
|
params: [{
|
||||||
|
from,
|
||||||
to,
|
to,
|
||||||
data
|
data
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
console.log(txHash)
|
console.log(txHash)
|
||||||
|
await provider.waitForTransaction(txHash)
|
||||||
return txHash
|
return txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +99,7 @@ export class Locker {
|
|||||||
if (errcode) {
|
if (errcode) {
|
||||||
throw new Error(errmsg)
|
throw new Error(errmsg)
|
||||||
}
|
}
|
||||||
return this.sendUnlockOrMint(provider, trans_req)
|
trans_req.from = address
|
||||||
|
return this.sendUnlockOrMint(this.bc.web3Provider, trans_req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export class PassportWallet {
|
|||||||
this.passportInstance.loginCallback().then(()=>{}).catch(err=>{});
|
this.passportInstance.loginCallback().then(()=>{}).catch(err=>{});
|
||||||
this.client = new orderbook.Orderbook({ baseConfig });
|
this.client = new orderbook.Orderbook({ baseConfig });
|
||||||
}
|
}
|
||||||
async initWidget() {
|
async initWidget(provider) {
|
||||||
const checkoutSDK = new checkout.Checkout({
|
const checkoutSDK = new checkout.Checkout({
|
||||||
baseConfig,
|
baseConfig,
|
||||||
passport: this.passportInstance,
|
passport: this.passportInstance,
|
||||||
@ -48,13 +48,12 @@ export class PassportWallet {
|
|||||||
// RECOMMENDED - create all of the widgets once at the start of your application
|
// RECOMMENDED - create all of the widgets once at the start of your application
|
||||||
// use the created widgets throughout your application to mount and unmount in specific parts of your application
|
// use the created widgets throughout your application to mount and unmount in specific parts of your application
|
||||||
const connect = widgets.create(checkout.WidgetType.CONNECT);
|
const connect = widgets.create(checkout.WidgetType.CONNECT);
|
||||||
const wallet = widgets.create(checkout.WidgetType.WALLET); // you can optionally pass in additional config per widget
|
const wallet = widgets.create(checkout.WidgetType.WALLET, {provider}); // you can optionally pass in additional config per widget
|
||||||
const swap = widgets.create(checkout.WidgetType.SWAP);
|
const swap = widgets.create(checkout.WidgetType.SWAP);
|
||||||
const bridge = widgets.create(checkout.WidgetType.BRIDGE);
|
const bridge = widgets.create(checkout.WidgetType.BRIDGE);
|
||||||
const onramp = widgets.create(checkout.WidgetType.ONRAMP);
|
const onramp = widgets.create(checkout.WidgetType.ONRAMP);
|
||||||
|
|
||||||
// Mount the wallet widget passing the element id of where to mount the widget
|
// Mount the wallet widget passing the element id of where to mount the widget
|
||||||
connect.mount('wallet');
|
wallet.mount('wallet');
|
||||||
}
|
}
|
||||||
get nativeProvider() {
|
get nativeProvider() {
|
||||||
return this.passportInstance.connectEvm();
|
return this.passportInstance.connectEvm();
|
||||||
@ -65,6 +64,7 @@ export class PassportWallet {
|
|||||||
const accounts = await passportProvider.request({ method: "eth_requestAccounts" });
|
const accounts = await passportProvider.request({ method: "eth_requestAccounts" });
|
||||||
const provider = new providers.Web3Provider(passportProvider);
|
const provider = new providers.Web3Provider(passportProvider);
|
||||||
const token = await this.passportInstance.getIdToken()
|
const token = await this.passportInstance.getIdToken()
|
||||||
|
// this.initWidget(provider);
|
||||||
return { provider, accounts, token };
|
return { provider, accounts, token };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="wallet"></div>
|
<div id="wallet" class="wallet-widget"></div>
|
||||||
<Cart v-if="cartShow" @closeCart="closeCartBox" class="cart-con" />
|
<Cart v-if="cartShow" @closeCart="closeCartBox" class="cart-con" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -660,4 +660,10 @@ onMounted( async () => {
|
|||||||
background: #1e1b23;
|
background: #1e1b23;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
.wallet-widget {
|
||||||
|
position: fixed;
|
||||||
|
top: 84px;
|
||||||
|
right: 0;
|
||||||
|
z-index: 10000;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user