diff --git a/src/components/assets/cenCard.vue b/src/components/assets/cenCard.vue
index fca242b..69315d4 100644
--- a/src/components/assets/cenCard.vue
+++ b/src/components/assets/cenCard.vue
@@ -25,7 +25,7 @@
-
+
@@ -140,45 +140,57 @@ const sellNft = async (val) => {
const loadingDialogVisible = ref(false)
// 下链使用
-// const lockToGame = async(type) => {
-// if(type == 'redeem') {
-// const confirmResult = await createModal(ConfirmDialog, {
-// title: '',
-// message: `Redeem ${props.nftData.detail.gold_coins} Gold to your game account. Do you wish to proceed?`
-// }).show()
-// if (confirmResult.errcode == 0) {
-// loadingDialogVisible.value = true
-// lockToGameConfirm()
-// }
-// } else if(type == 'convert') {
-// const confirmResult = await createModal(ConfirmDialog, {
-// 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?'
-// }).show()
-// if (confirmResult.errcode == 0) {
-// loadingDialogVisible.value = true
-// lockToGameConfirm()
-// }
-// }
-// }
-// const lockToGameConfirm = async () => {
-// try {
-// const bc = new BlockChain()
-// 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
-// }
-// }
+const lockToGame = async(type) => {
+ if(type == 'redeem') {
+ const confirmResult = await createModal(ConfirmDialog, {
+ title: '',
+ message: `Redeem ${props.nftData.detail.gold_coins} Gold to your game account. Do you wish to proceed?`
+ }).show()
+ if (confirmResult.errcode == 0) {
+ loadingDialogVisible.value = true
+ lockToGameConfirm()
+ }
+ } else if(type == 'convert') {
+ const confirmResult = await createModal(ConfirmDialog, {
+ 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?'
+ }).show()
+ if (confirmResult.errcode == 0) {
+ loadingDialogVisible.value = true
+ lockToGameConfirm()
+ }
+ }
+}
+// mint一个英雄
+const mintHero = async () => {
+ const confirmResult = await createModal(ConfirmDialog, {
+ 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?'
+ }).show()
+ if (confirmResult.errcode == 0) {
+ // loadingDialogVisible.value = true
+ const res = await new BlockChain().locker.mintNft([toRaw(props.nftData).uniid])
+ console.log(res)
+ }
+}
+const lockToGameConfirm = async () => {
+ try {
+ const bc = new BlockChain()
+ 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
+ }
+}
// 获取出售中价格价格
diff --git a/src/components/chain/BlockChain.js b/src/components/chain/BlockChain.js
index 174442a..844dcda 100644
--- a/src/components/chain/BlockChain.js
+++ b/src/components/chain/BlockChain.js
@@ -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 { OkxWallet } from '@/components/chain/wallet/OkxWallet';
import {walletStore} from "@/store/wallet";
@@ -9,6 +9,7 @@ import {ImtblMarket} from "@/components/chain/Market";
import { ALL_PROVIDERS } from "@/configs/configchain";
import {Locker} from "@/components/chain/contract/Locker";
import ConfirmDialog from "@/components/Dialogs/confirmDialog.vue";
+import { checkout } from '@imtbl/sdk';
export const allProviders = {
@@ -72,6 +73,7 @@ export class BlockChain {
}
this.store.$persist();
this.market.updateProvider(provider);
+ // this.initWidget(provider);
return provider;
}
@@ -138,7 +140,7 @@ export class BlockChain {
*/
async passportToken() {
if (this.store.walletType == 3) {
- return this.store.token
+ return this.token()
}
if (!this.passportProvider) {
return ''
@@ -212,4 +214,28 @@ export class BlockChain {
}
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');
+ }
}
diff --git a/src/components/chain/contract/Locker.js b/src/components/chain/contract/Locker.js
index adaadd6..75f418f 100644
--- a/src/components/chain/contract/Locker.js
+++ b/src/components/chain/contract/Locker.js
@@ -44,16 +44,18 @@ export class Locker {
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',
params: [{
+ from,
to,
data
}]
})
console.log(txHash)
+ await provider.waitForTransaction(txHash)
return txHash
}
@@ -97,6 +99,7 @@ export class Locker {
if (errcode) {
throw new Error(errmsg)
}
- return this.sendUnlockOrMint(provider, trans_req)
+ trans_req.from = address
+ return this.sendUnlockOrMint(this.bc.web3Provider, trans_req)
}
}
diff --git a/src/components/chain/wallet/PassportWallet.js b/src/components/chain/wallet/PassportWallet.js
index f014941..e32f23a 100644
--- a/src/components/chain/wallet/PassportWallet.js
+++ b/src/components/chain/wallet/PassportWallet.js
@@ -32,7 +32,7 @@ export class PassportWallet {
this.passportInstance.loginCallback().then(()=>{}).catch(err=>{});
this.client = new orderbook.Orderbook({ baseConfig });
}
- async initWidget() {
+ async initWidget(provider) {
const checkoutSDK = new checkout.Checkout({
baseConfig,
passport: this.passportInstance,
@@ -48,13 +48,12 @@ export class PassportWallet {
// 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); // 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 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
- connect.mount('wallet');
+ wallet.mount('wallet');
}
get nativeProvider() {
return this.passportInstance.connectEvm();
@@ -65,6 +64,7 @@ export class PassportWallet {
const accounts = await passportProvider.request({ method: "eth_requestAccounts" });
const provider = new providers.Web3Provider(passportProvider);
const token = await this.passportInstance.getIdToken()
+ // this.initWidget(provider);
return { provider, accounts, token };
}
diff --git a/src/components/layout/NavBar.vue b/src/components/layout/NavBar.vue
index 08043d6..9f46b4c 100644
--- a/src/components/layout/NavBar.vue
+++ b/src/components/layout/NavBar.vue
@@ -59,7 +59,7 @@
-