质押cec 测试ing

This commit is contained in:
yuyongdong 2024-09-13 19:45:16 +08:00
parent 6d073b7b62
commit a8d8730c04
8 changed files with 204 additions and 111 deletions

View File

@ -88,16 +88,16 @@ function hideModal(result = null) {
.cf-overlay {
z-index: 1000;
width: 1140px;
min-height: 500px;
width: 700px;
min-height: 300px;
background: #1a1821;
color: #fff;
position: fixed;
top: 20%;
top: 50%;
left: 50%;
transform: translateX(-50%);
transform: translate(-50%, -50%);
border: 1px solid #b966ff;
padding: 50px;
padding: 30px;
box-sizing: border-box;
box-shadow: 0px 15px 28px 3px rgba(22, 22, 22, 0.13);
border-radius: 100px;
@ -107,18 +107,18 @@ function hideModal(result = null) {
height: 60px;
font-family: 'Anton';
font-weight: 400;
font-size: 48px;
font-size: 36px;
}
}
.cf-content-text {
width: 78%;
width: 90%;
margin: 0 auto;
margin-top: 10px;
text-align: left;
text-align: center;
.cf-text {
font-family: 'Poppins';
font-weight: 500;
font-size: 28px;
font-size: 22px;
}
}
.cf-btn-grid {
@ -130,13 +130,13 @@ function hideModal(result = null) {
display: flex;
justify-content: space-evenly;
button {
width: 289px;
height: 60px;
width: 180px;
height: 40px;
background: #fec25d;
border: 0px;
font-family: 'Poppins';
font-weight: 700;
font-size: 18px;
font-size: 16px;
color: #2D2738;
border-radius:30px;
}

View File

@ -22,10 +22,10 @@
<div class="left">
<span>{{ props.dialogText.typeLabel }}</span>
<p>
<input type="number" placeholder="0" min="0" :max="modelAmount" v-model="modelAmount">
<input type="number" :placeholder="placeholderAmount" v-model="modelAmount" @input="handleInput">
</p>
</div>
<div class="left" @click="cecAmount">
<div class="right" @click="cecAmount">
<span>MAX: {{ priceCalculated(props.dialogText.amount) }}</span>
<p>{{ props.dialogText.typeName }}</p>
</div>
@ -35,7 +35,7 @@
<span>{{ props.dialogText.conversion }}</span>
<p class="padding-left-20">{{ modelAmount }}</p>
</div>
<div class="left">
<div class="right">
<span>&nbsp;</span>
<p>{{ props.dialogText.conversionName }}</p>
</div>
@ -69,14 +69,16 @@ const props = defineProps({
// },
});
const placeholderAmount = ref(0)
const emit = defineEmits(["handleClose", "eventBtn"]);
const handleCancel = (e) => {
modelAmount.value = 0
emit("handleClose");
};
const eventBtn = () => {
if(modelAmount.value == 0) {
message.error('Please enter the corresponding number')
message.error('Please enter the amount')
} else {
emit("eventBtn",{title:props.dialogText.title, amount: modelAmount.value});
}
@ -87,19 +89,27 @@ const cecAmount = () => {
modelAmount.value = priceCalculated(props.dialogText.amount)
}
const handleInput = (e) => {
if(Number(modelAmount.value) > Number(priceCalculated(props.dialogText.amount))) {
modelAmount.value = priceCalculated(props.dialogText.amount)
} else if(Number(modelAmount.value) == 0 || Number(modelAmount.value) < 0) {
modelAmount.value= 0
}
}
</script>
<style lang="scss" scoped>
:deep(.cecDialog) {
width: 800px !important;
// height: 468px;
width: 600px !important;
min-height: 330px;
.ant-modal-content {
height: 100%;
padding: 0px;
background: #1a1821;
border: 1px solid #b966ff;
box-shadow: 0px 15px 28px 3px rgba(22, 22, 22, 0.13);
border-radius: 100px;
border-radius: 50px;
}
}
.cec-dialog {
@ -107,8 +117,8 @@ const cecAmount = () => {
position: absolute;
top: -23px;
right: -23px;
width: 106px;
height: 106px;
width: 80px;
height: 80px;
cursor: pointer;
img {
width: 100%;
@ -117,26 +127,26 @@ const cecAmount = () => {
}
.cec-dialog-content {
color: #fff;
margin-top: 40px;
margin-top: 20px;
.content-title {
width: 700px;
width: 500px;
margin: 0 auto;
padding: 0 40px;
padding: 0 20px;
border-bottom: 1px solid #3d4057;
h1 {
font-family: "Anton";
font-weight: 400;
font-size: 48px;
font-size: 28px;
}
p {
color: #FF7C7C;
}
}
.content-amount {
width: 700px;
width: 500px;
margin: 0 auto;
margin-top: 20px;
padding: 0 40px;
margin-top: 10px;
padding: 0 20px;
li {
display: flex;
align-items: center;
@ -144,15 +154,16 @@ const cecAmount = () => {
>div {
span {
display: inline-block;
margin-bottom: 20px;
margin-bottom: 10px;
color: #b966ff;
font-size: 16px;
cursor: pointer;
}
p {
font-size: 28px;
font-family: 'Poppins';
input {
width: 397px;
width: 200px;
border: 0;
background: #2d2738;
padding-left: 20px;
@ -191,12 +202,18 @@ const cecAmount = () => {
padding-left: 20px;
}
}
.right {
p {
text-align: right;
}
}
}
}
.content-btn {
width: 300px;
height: 60px;
line-height: 60px;
width: 180px;
height: 40px;
line-height: 40px;
margin: 0 auto;
text-align: center;
color: #000;
@ -204,8 +221,8 @@ const cecAmount = () => {
background: #fec25d;
cursor: pointer;
border-radius: 20px;
margin-top: 120px;
margin-bottom: 40px;
margin-top: 30px;
margin-bottom: 20px;
}
}
}

View File

@ -102,11 +102,11 @@ const dialogUnstakeText = ref({
const conversionModal = () => {
cecDialogVisible.value = true
dialogUnstakeText.value = {
title: "Reverse conversion esCEC",
typeLabel: "Unstake",
tips: "withdrawing the transformed ESCEC unlocks a certain number of cecs",
title: "Vest esCEC",
typeLabel: "Vest",
tips: "Vest esCEC needs to lock amount of CEC",
typeName: "es CEC",
conversion: "Reveres conversion esCEC",
conversion: "CEC Locked",
conversionName: "CEC",
amount: stakingStore.cecInfoData.esCecBalance
}
@ -137,7 +137,7 @@ const collectionModal = () => {
}
const eventBtnName = (val) => {
if(val.title == 'Reverse conversion esCEC') {
if(val.title == 'Vest esCEC') {
cecDeposit(val.amount)
// } else if(val.title == 'Claim esCEC') {
// claimCec()
@ -268,7 +268,7 @@ onMounted(() => {
<style lang="scss" scoped>
.content {
width: 1120px;
width: 1348px;
margin: 0 auto;
display: flex;
justify-content: center;

View File

@ -85,7 +85,7 @@
</div>
</div>
<div class="right">
<div>esCEC Conversion</div>
<div>Vesting esCEC</div>
<p>{{ priceCalculated(stakingStore.cecInfoData.esCecConversion) }}</p>
</div>
</li>
@ -254,7 +254,7 @@ onMounted(() => {
align-items: center;
padding-left: 54px;
line-height: 22px;
margin-bottom: 16px;
margin-bottom: 5px;
h1 {
font-family: "Poppins";
font-weight: bold;

View File

@ -202,8 +202,8 @@ const eventBtnName = (val) => {
const cecStakingText = async () => {
if(!stakingStore.bindPassportAddress) {
const confirmResult = await createModal(ConfirmDialog, {
title: 'Need login to Passport',
message: 'Are you sure you want to login with Passport?'
title: 'Link your Passport.',
message: 'Please note, once linked, it cannot be unlinked. Ensure youre connecting the correct Passport.'
}).show()
if(confirmResult.errcode == 0) {
await new BlockChain().appendPassport()
@ -212,8 +212,14 @@ const cecStakingText = async () => {
message.success('Bind Successful')
refreshCecInfo()
} else if(res.errcode == 1) {
message.error('account or passport bound')
new PassportWallet().logout();
const confirmResult1 = await createModal(ConfirmDialog, {
title: '',
noBtnTitle: '',
message: 'This Immutable Passport is already connected to another wallet. Please use a different Immutable Passport.'
}).show()
if(confirmResult1.errcode == 0) {
new PassportWallet().logout();
}
}
} else {
message.error('User denied transaction signature')
@ -453,7 +459,7 @@ onMounted(() => {
box-sizing: border-box;
background: #2D2738;
border-radius: 20px;
padding: 0 20px;
// padding: 0 20px;
box-sizing: border-box;
.top {
display: flex;
@ -463,7 +469,7 @@ onMounted(() => {
border-bottom: 2px solid #4C425F;
padding: 20px 0px 10px 0px;
// margin: 0 41px 0 54px;
margin-left: 34px;
margin-left: 54px;
margin-right: 21px;
box-sizing: border-box;
.top-left {
@ -532,7 +538,7 @@ onMounted(() => {
flex-direction: column;
justify-content: space-evenly;
// padding: 10px 0;
margin: 0 21px 0 34px;
margin: 0 21px 0 54px;
box-sizing: border-box;
border-bottom: 2px solid #4C425F;
li {

View File

@ -4,15 +4,20 @@ import { ethers } from "ethers"
// 计算价格精度
export const priceCalculated = (price, decimals=18) => {
if (!price) {
return '0.000000'
return '0.00000'
}
let str = Number(ethers.utils.formatUnits(price, decimals)).toFixed(6)
if(str == '0.000000') {
str = '<0.000010'
let str = Number(ethers.utils.formatUnits(price, decimals))
str = (Math.floor(str * 100000)/100000).toFixed(5)
// let numStr = String(str)
// const regex = new RegExp(`(\\.\\d{${6}})[1-9]+`, 'g')
// str = numStr.replace(regex, (match) => match.slice(0, 6 + 5))
// console.log(str)
if(str == '0.00000') {
str = '<0.00001'
} else {
return str.slice(0, -1)
return str
}
return str.slice(0, -1)
return str
}
// 计算购买总价格

View File

@ -15,6 +15,7 @@ export const useStakingStore = defineStore('staking', () => {
esCecCollection: BigInt('0'),
totalCollection: BigInt('0'),
CecClaimable: BigInt("0"),
lastDepositTime: BigInt("0"),
})
const bindPassportAddress = ref([])
const bindPassportEmail = ref([])

View File

@ -43,40 +43,69 @@
<div class="con">
<Header />
<div class="staking-label">
<li :class="labelListIndex == index ? 'active' : ''" v-for="(item, index) in labelList" :key="index" @click="labelListIndex = index">{{ item.text }}</li>
<li
:class="labelListIndex == index ? 'active' : ''"
v-for="(item, index) in labelList"
:key="index"
@click="labelListIndex = index"
>{{ item.text }}</li>
</div>
<Staking v-if="labelListIndex == 0" @refreshCecInfo="userCecInfo" />
<Conversion v-else-if="labelListIndex == 1" @refreshCecInfo="userCecInfo" />
</div>
<div class="footer">
<div class="footer-left">
<div>
<img src="@/assets/img/cec_activity/game_logo02.png" alt />
</div>
<p>© Candy Bubble Global Limited.ALL RIGHTS RESERVED.</p>
</div>
<div class="footer-right">
<!-- <li>
<a href="https://discord.com/invite/counterfire" target="_blank">
<img src="./../assets/home/com_Discord_icon.png" alt="">
</a>
</li>
<li>
<a href="https://twitter.com/@playCounterFire" target="_blank">
<img src="./../assets/home/com_X_icon.png" alt="">
</a>
</li>
<li>
<a href="https://www.youtube.com/@playCounterFire" target="_blank">
<img src="./../assets/home/com_Youtube_icon.png" alt="">
</a>
</li>-->
</div>
</div>
</div>
</template>
<script setup>
import { ref, toRaw, onMounted } from "vue";
import {ref, toRaw, onMounted} from "vue";
import Header from "@/components/staking/header.vue";
import Staking from "@/components/staking/index.vue";
import Conversion from "@/components/staking/conversion.vue";
import { BlockChain } from "@/components/chain/BlockChain"
import {BlockChain} from "@/components/chain/BlockChain";
// import { switchEthereumChain } from "@/components/chain/utils"
import { apiVipInfo } from "@/utils/marketplace"
import {apiVipInfo} from "@/utils/marketplace";
import {walletStore} from "@/store/wallet";
import { useStakingStore } from "@/store/staking"
import { PassportWallet } from "@/components/chain/wallet/PassportWallet";
import {useStakingStore} from "@/store/staking";
import {PassportWallet} from "@/components/chain/wallet/PassportWallet";
const localWalletStore = walletStore();
const stakingStore = useStakingStore()
const labelListIndex = ref(0)
const stakingStore = useStakingStore();
const labelListIndex = ref(0);
const labelList = ref([
{
text: 'Staking',
text: "Staking",
},
{
text: 'Vest',
}
])
text: "Vest",
},
]);
const isLogout = ref(false);
const cecInfoData = ref({
cecBalance: BigInt("0"),
CecStaked: BigInt("0"),
@ -135,11 +164,12 @@ const getCecData = async () => {
cecInfoData.value.esCecCollection = BigInt(await bc.staking.queryClaimableByEsCEC());
cecInfoData.value.CecClaim = BigInt(await bc.staking.queryCumulativeByCEC());
cecInfoData.value.esCecClaim = BigInt(await bc.staking.queryCumulativeByEsCEC());
cecInfoData.value.CecClaimable = BigInt(await bc.vester.queryClaimable())
cecInfoData.value.cecClaimAll = BigInt(await bc.vester.queryClaimabledAll())
cecInfoData.value.lastDepositTime = BigInt(await bc.vester.queryLastDepositTime())
cecInfoData.value.CecClaimable = BigInt(await bc.vester.queryClaimable());
cecInfoData.value.cecClaimAll = BigInt(await bc.vester.queryClaimabledAll());
cecInfoData.value.lastDepositTime = BigInt(await bc.vester.queryLastDepositTime());
cecInfoData.value.totalCollection = cecInfoData.value.CecCollection + cecInfoData.value.esCecCollection;
stakingStore.cecInfoData = cecInfoData.value;
console.log(cecInfoData.value);
// getCode()
} catch (e) {
// console.log("query claimable error", e);
@ -148,76 +178,75 @@ const getCecData = async () => {
}, 2000);
};
const getCode = () =>{
const getCode = () => {
const TIME_COUNT = 3;
if (!timer.value) {
count.value = TIME_COUNT;
// this.show = false;
timer.value = setInterval(() => {
if (count.value > 0 && count.value <= TIME_COUNT) {
count.value--;
if (count.value > 0 && count.value <= TIME_COUNT) {
count.value--;
} else {
// getCecData()
TIME_COUNT = 3;
clearInterval(timer.value);
timer.value = null;
clearInterval(timer.value);
timer.value = null;
}
}, 2000)
}, 2000);
}
}
};
const getLinkWallet = async () => {
let disabled = [5,3]
await new BlockChain().cecLogin({disabled})
location.reload()
let disabled = [5, 3];
await new BlockChain().cecLogin({disabled});
location.reload();
};
const logOut = async () => {
stakingStore.cecInfoData = {}
stakingStore.bindPassportAddress = ''
stakingStore.bindPassportEmail = ''
stakingStore.cecInfoData = {};
new PassportWallet().logout();
await new BlockChain().logout()
await new BlockChain().logout();
// location.reload()
};
// ID
const getNetId = async () => {
await new BlockChain().checkNetId(localWalletStore.walletType)
}
await new BlockChain().checkNetId(localWalletStore.walletType);
};
// passport
const getVipInfo = async () => {
const { errcode, info } = await apiVipInfo()
console.log('bind_passport_address',info.bind_passport_address)
if(errcode == 0) {
stakingStore.bindPassportAddress = info.bind_passport_address
stakingStore.bindPassportEmail = info.bind_email
const {errcode, info} = await apiVipInfo();
console.log("bind_passport_address", info.bind_passport_address);
if (errcode == 0) {
stakingStore.bindPassportAddress = info.bind_passport_address;
stakingStore.bindPassportEmail = info.bind_email;
}
}
};
//
const toTwitter = () => {
const url = "https://twitter.com/intent/tweet?text=";
const hashtags = encodeURIComponent("500,000 $CEC Awaits - Earn Your Share!");
const imageUrl = encodeURIComponent(`https://counterfire.games/cecActivity`);
const imageUrl = encodeURIComponent(`https://market.kingsome.cn`);
const params = `${hashtags}&url=${imageUrl}`;
// const params = `${hashtags}`;
window.open(`${url}${params}`, "_blank");
};
const userCecInfo = () => {
getNetId()
getVipInfo()
getNetId();
getVipInfo();
getCecData();
}
};
onMounted(() => {
if(localWalletStore.address) {
userCecInfo()
if (localWalletStore.address) {
userCecInfo();
}
})
});
</script>
<style lang="scss" scoped>
@ -234,8 +263,8 @@ onMounted(() => {
background-size: 100% 100%;
.header-left {
div {
width: 263px;
height: 163px;
width: 283px;
height: 133px;
img {
width: 100%;
height: 100%;
@ -246,7 +275,7 @@ onMounted(() => {
display: flex;
// align-items: center;
color: #fff;
margin-top: 58px;
margin-top: 43px;
.left {
width: 106px;
height: 47px;
@ -377,32 +406,67 @@ onMounted(() => {
}
}
.con {
margin-top: -133px;
margin-top: -240px;
padding-bottom: 80px;
.staking-label {
display: flex;
width: 1348px;
margin: 0 auto;
margin-top: 33px;
margin-bottom: 11px;
margin-bottom: 5px;
li {
width: 281px;
height: 57px;
line-height: 57px;
background: #363142;
border-radius: 40px 40px 0px 0px;
font-family: 'Poppins';
font-family: "Poppins";
font-weight: bold;
font-size: 30px;
color: #C7BCE8;
color: #c7bce8;
text-align: center;
margin-right: 16px;
cursor: pointer;
}
.active {
background: #FFC35B;
background: #ffc35b;
color: #000;
}
}
}
.footer {
width: 100%;
height: 98px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 45px;
box-sizing: border-box;
border-top: 2px solid #2c2635;
background: #1a1821;
.footer-left {
width: 1348px;
margin: 0 auto;
display: flex;
align-items: center;
div {
width: 235px;
height: 51px;
margin-right: 40px;
img {
width: 100%;
height: 100%;
}
}
p {
font-family: 'Poppins-Regular';
font-weight: 400;
color: #877e98;
font-size: 18px;
margin-top: 8px;
}
}
}
}
</style>