diff --git a/src/components/Dialogs/confirmDialog.vue b/src/components/Dialogs/confirmDialog.vue index 1718278..082f7ce 100644 --- a/src/components/Dialogs/confirmDialog.vue +++ b/src/components/Dialogs/confirmDialog.vue @@ -111,14 +111,14 @@ function hideModal(result = null) { } } .cf-content-text { - width: 75%; + width: 78%; margin: 0 auto; margin-top: 10px; text-align: left; .cf-text { font-family: 'Poppins'; font-weight: 500; - font-size: 30px; + font-size: 28px; } } .cf-btn-grid { diff --git a/src/components/assets/activity.vue b/src/components/assets/activity.vue index 4aaf43c..e99ae97 100644 --- a/src/components/assets/activity.vue +++ b/src/components/assets/activity.vue @@ -36,7 +36,7 @@ import Hero from "@/components/common/searchView/hero.vue" import Gold from "@/components/common/searchView/gold.vue" import Card from "@/components/common/convertCard.vue"; import NftId from "@/configs/item.json" -import { apiLockState } from "@/utils/marketplace" +import { apiLockState, apiActivity } from "@/utils/marketplace" import {useMarketplaceStore} from "@/store/marketplace"; import {walletStore} from "@/store/wallet"; const marketplaceStore = useMarketplaceStore() @@ -114,13 +114,34 @@ const getMyAssets = async () => { // nftList.value = [] const myADdress = localWalletStore.address // console.log(data) + const data = { + page_size: 20, + cursor: '', + search: { + name: '', + }, + filter: { + item_ids: [] + }, + sort: { + fields: [ + { + name: '', + type: 0 + } + ] + } + } // return + // const address = import.meta.env.VUE_APP_EXPLORER_URL if(myADdress) { try { reqData.value.cursor = next_cursor.value.next_cursor - let res = await apiLockState(myADdress, reqData.value) - // return - nftList.value = [...nftList.value, ...res.rows] + // let res = await apiLockState(myADdress, reqData.value) + let res = await apiActivity(data, myADdress) + console.log(res,'--------------------------------') + return + // nftList.value = [...nftList.value, ...res.rows] // nftListBox = nftList.value.reduce((acc, obj) => { // const existingObj = acc.find(item => item.token_id == obj.token_id) // if(!existingObj) { diff --git a/src/components/assets/assetsHeader.vue b/src/components/assets/assetsHeader.vue index 41f79e3..3a99df1 100644 --- a/src/components/assets/assetsHeader.vue +++ b/src/components/assets/assetsHeader.vue @@ -10,6 +10,7 @@

Total Contribution Credits:  {{ contributionPointTotal }}

+

Daily Expected:   +{{ contributionPoint }}/d

@@ -222,20 +223,20 @@
  • Founder’s Tag

    - Tier + Rarity Daily contribution points
    - Tier 1 + Common 20
    - Tier 2 + Rare 40
    - Tier 3 + Legendary 100
    @@ -291,7 +292,6 @@ const imageUrl = computed(() => { // 打开历史记录弹窗 const receiveLog = () => { - console.log('----') logDialogVisible.value = true } diff --git a/src/components/assets/myCard.vue b/src/components/assets/myCard.vue index cc354dd..2c8d5d8 100644 --- a/src/components/assets/myCard.vue +++ b/src/components/assets/myCard.vue @@ -31,21 +31,32 @@
    -
    -
    List
    +
    + loading + List +
    Cancel listing
    -
    Unstake
    -
    Stake
    +
    + loading + Unstake +
    +
    + loading + Stake +
    @@ -56,7 +67,7 @@ import { ref, toRaw, onMounted, getCurrentInstance, inject } from "vue" const message = inject('$message') import SellDialog from "@/components/Dialogs/sellDialog.vue" -import { apiGetPrice, nftDetail } from "@/utils/marketplace" +import { apiGetPrice, nftDetail, apiTxHash } from "@/utils/marketplace" import ImgCard from "@/components/common/imgCard.vue" import LoadingDialog from "@/components/Dialogs/loadingDialog.vue" import { priceCalculated } from "@/configs/priceCalculate" @@ -173,14 +184,28 @@ const lockToGameConfirm = async () => { const bc = new BlockChain() let res = await bc.locker.lock(toRaw(props.nftData).contract_address, [toRaw(props.nftData).token_id]) // message.success('lockToGame success') + toRaw(props.nftData)['status'] = 1 const confirmResult = await createModal(ConfirmDialog, { title: '', noBtnTitle: '', message: 'Staking is complete. This process may take 3-4 minutes.' }).show() - // router.go(-1) - emit('renewMyNft') loadingDialogVisible.value = false + if(res) { + try { + const {errcode, errmsg, confirmed} = await apiTxHash([toRaw(props.nftData).net_id], res) + let timer = setInterval(() => { + if(confirmed == 1) { + toRaw(props.nftData)['status'] = '' + emit('renewMyNft') + clearInterval(timer); + } + }, 2000); + } catch (e) { + console.log(e) + } + } + // // router.go(-1) // router.push('/assets') } catch (e) { if(e.message.indexOf('rejected') > -1) { @@ -197,16 +222,29 @@ const unlockMainConfirm = async () => { const bc = new BlockChain() let res = await bc.locker.lockMain(toRaw(props.nftData).contract_address, [toRaw(props.nftData).token_id]) // message.success('lockToGame success') + toRaw(props.nftData)['status'] = 1 const confirmResult = await createModal(ConfirmDialog, { title: '', noBtnTitle: '', message: 'Staking is complete. This process may take 3-4 minutes.' }).show() - // router.go(-1) - emit('renewMyNft') loadingDialogVisible.value = false - // router.push('/assets') + if(res) { + try { + const {errcode, errmsg, confirmed} = await apiTxHash([toRaw(props.nftData).net_id], res) + let timer = setInterval(() => { + if(confirmed == 1) { + toRaw(props.nftData)['status'] = '' + emit('renewMyNft') + clearInterval(timer); + } + }, 2000); + } catch (e) { + console.log(e) + } + } } catch (e) { + console.log(e) if(e.message.indexOf('rejected') > -1) { message.error('User rejected the request') } else { @@ -251,18 +289,26 @@ const heroLock = async (data) => { try { const bc = new BlockChain() let res = await bc.locker.unlockOrMintGameNft(toRaw(data).contract_address,[toRaw(data).token_id]) + toRaw(props.nftData)['status'] = 1 + const confirmResult = await createModal(ConfirmDialog, { + title: '', + noBtnTitle: '', + message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' + }).show() + loadingDialogVisible.value = false if(res) { - let timer = setTimeout( async () => { - // message.success('Unstake success.') - const confirmResult = await createModal(ConfirmDialog, { - title: '', - noBtnTitle: '', - message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' - }).show() - loadingDialogVisible.value = false - emit('renewMyNft') - clearTimeout(timer); + try { + const {errcode, errmsg, confirmed} = await apiTxHash(toRaw(props.nftData).net_id, res) + let timer = setInterval( async () => { + if(confirmed == 1) { + toRaw(props.nftData)['status'] = '' + emit('renewMyNft') + clearInterval(timer); + } }, 2000); + } catch (e) { + console.log(e) + } } } catch (e) { console.log(e) @@ -281,28 +327,39 @@ const founderLock = async (data) => { try { const bc = new BlockChain() let res = await bc.locker.unlockMain(data.contract_address,[data.token_id]) + toRaw(props.nftData)['status'] = 1 + const confirmResult = await createModal(ConfirmDialog, { + title: '', + noBtnTitle: '', + message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' + }).show() + loadingDialogVisible.value = false if(res) { - let timer = setTimeout( async () => { - // message.success('Unstake success.') - const confirmResult = await createModal(ConfirmDialog, { - title: '', - noBtnTitle: '', - message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' - }).show() - loadingDialogVisible.value = false - emit('renewMyNft') - clearTimeout(timer); + try { + const {errcode, errmsg, confirmed} = await apiTxHash(toRaw(props.nftData).net_id, res) + let timer = setInterval( async () => { + if(confirmed == 1) { + toRaw(props.nftData)['status'] = '' + emit('renewMyNft') + clearInterval(timer); + } }, 2000); + } catch (e) { + console.log(e) + } } } catch (e) { - console.log(e); loadingDialogVisible.value = false if(e.message.indexOf('rejected') > -1) { message.error('User rejected the request') } else if (e.message.indexOf('select wallet') > -1) { message.error('user cancel select wallet') } else if (e.message.indexOf('eoa address changed') > -1) { - message.error("It looks like there's an issue with your MetaMask or OKX wallet address. Please check your wallet address and try again") + const confirmResult = await createModal(ConfirmDialog, { + title: '', + noBtnTitle: '', + message: "It looks like there's an issue with your MetaMask or OKX wallet address. Please check your wallet address and try again." + }).show() } else { message.error('Unstake fail') } @@ -475,6 +532,11 @@ onMounted(() => { background: #1778f1; border-radius: 12px; text-align: center; + span { + display: inline-block; + width: 100%; + height: 100%; + } } .card-sell, .card-cancel { width: 100%; diff --git a/src/components/chain/utils.js b/src/components/chain/utils.js index d0196fc..d79ec9d 100644 --- a/src/components/chain/utils.js +++ b/src/components/chain/utils.js @@ -199,6 +199,10 @@ export const switchEthereumChain = async (provider, targetChainId) => { provider.removeListener('chainChanged', onChainChange) deferred.reject(addError) } + } else { + console.error('error add chain: ', e.message) + provider.removeListener('chainChanged', onChainChange) + deferred.reject(e) } } return deferred.promise diff --git a/src/utils/marketplace.js b/src/utils/marketplace.js index ed0382c..63b41b8 100644 --- a/src/utils/marketplace.js +++ b/src/utils/marketplace.js @@ -147,3 +147,15 @@ export const apiUserData = async (account_address) => { const url = `${API_BASE}/api/user/${account_address}` return httpGet(url, {}) } + +// 轮询状态 +export const apiTxHash = async (net_id, account_address) => { + const url = `${API_BASE}/api/chain/txhash/${net_id}/${account_address}` + return httpGet(url, {}) +} + +// 活动交易记录 +export const apiActivity = async (data, account_address) => { + const url = `${API_BASE}/api/chain/activity/${account_address}` + return httpPost(url, data) +} diff --git a/src/views/DetailView.vue b/src/views/DetailView.vue index a778c8e..1c67c50 100644 --- a/src/views/DetailView.vue +++ b/src/views/DetailView.vue @@ -49,7 +49,12 @@
  • -
    Unstake
    +
    + Loading +
    +
    + Unstake +
    Mint
    @@ -77,11 +82,18 @@ 2、下架 3、使用 --> -
    +
    List
    Cancel listing
    -
    Stake
    -
    Stake
    +
    + Loading +
    +
    + Stake +
    +
    + Stake +
    @@ -197,7 +209,7 @@ import ImgCard from "@/components/common/imgCard.vue" import StarTimer from "@/components/common/starTimer.vue" import SellDialog from "@/components/Dialogs/sellDialog.vue" import Footer from "@/components/common/footer.vue" -import { nftDetail, apiGetPrice } from "@/utils/marketplace" +import { nftDetail, apiGetPrice, apiTxHash } from "@/utils/marketplace" import {priceCalculated} from "@/configs/priceCalculate.js" import { BlockChain } from "@/components/chain/BlockChain" import {walletStore} from "@/store/wallet"; @@ -336,13 +348,28 @@ const lockToGameConfirm = async () => { try { await new BlockChain().locker.lock(detailData.value.nft.contract_address, [detailData.value.nft.token_id]) // message.success('lockToGame success') + detailData.value.nft['status'] = 1 const confirmResult = await createModal(ConfirmDialog, { title: '', noBtnTitle: '', message: 'Staking is complete. This process may take 3-4 minutes.' }).show() loadingDialogVisible.value = false - router.go(-1) + if(res) { + try { + const { confirmed } = await apiTxHash(detailData.value.nft.net_id, res) + let timer = setInterval( async () => { + // message.success('Unstake success.') + if(confirmed == 1) { + detailData.value.nft['status'] = '' + router.go(-1) + clearInterval(timer); + } + }, 2000); + } catch (e) { + console.log(e) + } + } } catch (e) { if(e.message.indexOf('rejected') > -1) { message.error('User rejected the request') @@ -356,16 +383,28 @@ const unlockMainConfirm = async () => { try { const bc = new BlockChain() let res = await bc.locker.lockMain(detailData.value.nft.contract_address, [detailData.value.nft.token_id]) - // message.success('lockToGame success') + detailData.value.nft['status'] = 1 const confirmResult = await createModal(ConfirmDialog, { title: '', noBtnTitle: '', message: 'Staking is complete. This process may take 3-4 minutes.' }).show() - // router.go(-1) - emit('renewMyNft') loadingDialogVisible.value = false - // router.push('/assets') + if(res) { + try { + const { confirmed } = await apiTxHash(detailData.value.nft.net_id, res) + let timer = setInterval( async () => { + // message.success('Unstake success.') + if(confirmed == 1) { + detailData.value.nft['status'] = '' + router.go(-1) + clearInterval(timer); + } + }, 2000); + } catch (e) { + console.log(e) + } + } } catch (e) { if(e.message.indexOf('rejected') > -1) { message.error('User rejected the request') @@ -397,18 +436,27 @@ const heroLock = async () => { try { const bc = new BlockChain() let res = await bc.locker.unlockOrMintGameNft(detailData.value.nft.contract_address,[detailData.value.nft.token_id]) + detailData.value.nft['status'] = 1 + const confirmResult = await createModal(ConfirmDialog, { + title: '', + noBtnTitle: '', + message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' + }).show() + loadingDialogVisible.value = false if(res) { - let timer = setTimeout( async () => { + try { + const { confirmed } = await apiTxHash(detailData.value.nft.net_id, res) + let timer = setInterval( async () => { // message.success('Unstake success.') - const confirmResult = await createModal(ConfirmDialog, { - title: '', - noBtnTitle: '', - message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' - }).show() - loadingDialogVisible.value = false - router.go(-1) - clearTimeout(timer); + if( confirmed) { + detailData.value.nft['status'] = '' + router.go(-1) + clearInterval(timer); + } }, 2000); + } catch (e) { + console.log(e) + } } } catch (e) { loadingDialogVisible.value = false @@ -426,18 +474,27 @@ const founderLock = async () => { try { const bc = new BlockChain() let res = await bc.locker.unlockMain(detailData.value.nft.contract_address,[detailData.value.nft.token_id]) + detailData.value.nft['status'] = 1 + const confirmResult = await createModal(ConfirmDialog, { + title: '', + noBtnTitle: '', + message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' + }).show() + loadingDialogVisible.value = false if(res) { - let timer = setTimeout( async () => { + try { + const { confirmed } = await apiTxHash(detailData.value.nft.net_id, res) + let timer = setInterval( async () => { // message.success('Unstake success.') - const confirmResult = await createModal(ConfirmDialog, { - title: '', - noBtnTitle: '', - message: 'Unstake success. It is expected to take 3-4 minutes. Please log in to the original wallet address to check later.' - }).show() - loadingDialogVisible.value = false - router.go(-1) - clearTimeout(timer); + if( confirmed) { + detailData.value.nft['status'] = '' + router.go(-1) + clearInterval(timer); + } }, 2000); + } catch (e) { + console.log(e) + } } } catch (e) { loadingDialogVisible.value = false @@ -446,7 +503,11 @@ const founderLock = async () => { } else if (e.message.indexOf('select wallet') > -1) { message.error('user cancel select wallet') } else if (e.message.indexOf('eoa address changed') > -1) { - message.error("It looks like there's an issue with your MetaMask or OKX wallet address. Please check your wallet address and try again") + const confirmResult = await createModal(ConfirmDialog, { + title: '', + noBtnTitle: '', + message: "It looks like there's an issue with your MetaMask or OKX wallet address. Please check your wallet address and try again." + }).show() } else { message.error('Unstake fail') }