质押cec 测试完成

This commit is contained in:
yuyongdong 2024-09-14 14:35:41 +08:00
parent a8d8730c04
commit c14cdd4737
5 changed files with 122 additions and 101 deletions

View File

@ -2,12 +2,12 @@
<div class="cec-dialog" ref="cecModal"> <div class="cec-dialog" ref="cecModal">
<a-modal <a-modal
:class="'cecDialog'" :class="'cecDialog'"
v-model:open="props.cecDialogVisible" :open="props.cecDialogVisible"
:closable="false" :closable="false"
:footer="null" :footer="null"
:getContainer="() => $refs.cecModal" :getContainer="() => $refs.cecModal"
:maskClosable="false" :maskClosable="false"
destroyOnClose :destroyOnClose="true"
> >
<div class="top-close" @click="handleCancel"> <div class="top-close" @click="handleCancel">
<img src="@/assets/img/marketplace/Close_counter.png" alt /> <img src="@/assets/img/marketplace/Close_counter.png" alt />
@ -22,7 +22,7 @@
<div class="left"> <div class="left">
<span>{{ props.dialogText.typeLabel }}</span> <span>{{ props.dialogText.typeLabel }}</span>
<p> <p>
<input type="number" :placeholder="placeholderAmount" v-model="modelAmount" @input="handleInput"> <input type="number" placeholder="Please enter the amount" v-model="modelAmount" @input="handleInput">
</p> </p>
</div> </div>
<div class="right" @click="cecAmount"> <div class="right" @click="cecAmount">
@ -42,7 +42,7 @@
</li> </li>
</div> </div>
<div class="content-btn" @click="eventBtn"> <div class="content-btn" @click="eventBtn">
Approve {{ props.dialogText.btnText }}
</div> </div>
</div> </div>
</a-modal> </a-modal>
@ -50,7 +50,7 @@
</template> </template>
<script setup> <script setup>
import { ref, inject } from "vue"; import { ref, toRaw, watch, onUnmounted, inject } from "vue";
const message = inject("$message"); const message = inject("$message");
import { priceCalculated } from "@/configs/priceCalculate" import { priceCalculated } from "@/configs/priceCalculate"
@ -61,18 +61,12 @@ const props = defineProps({
}, },
dialogText: { dialogText: {
type: Object, type: Object,
required: true, required: false,
}, },
// buyDataArr: {
// type: Array,
// required: true,
// },
}); });
const placeholderAmount = ref(0)
const emit = defineEmits(["handleClose", "eventBtn"]); const emit = defineEmits(["handleClose", "eventBtn"]);
const handleCancel = (e) => { const handleCancel = (e) => {
modelAmount.value = 0 modelAmount.value = ''
emit("handleClose"); emit("handleClose");
}; };
@ -84,19 +78,25 @@ const eventBtn = () => {
} }
} }
const modelAmount = ref(0) const modelAmount = ref()
const cecAmount = () => { const cecAmount = () => {
modelAmount.value = priceCalculated(props.dialogText.amount) modelAmount.value = priceCalculated(props.dialogText.amount)
} }
const handleInput = (e) => { const handleInput = (e) => {
if(Number(modelAmount.value) > Number(priceCalculated(props.dialogText.amount))) { if(Number(modelAmount.value) == 0 || Number(modelAmount.value) < 0) {
modelAmount.value= ''
} else if(Number(modelAmount.value) > Number(priceCalculated(props.dialogText.amount))) {
modelAmount.value = priceCalculated(props.dialogText.amount) modelAmount.value = priceCalculated(props.dialogText.amount)
} else if(Number(modelAmount.value) == 0 || Number(modelAmount.value) < 0) {
modelAmount.value= 0
} }
} }
watch(props,(preTest1, oldTest1) => {
if(!toRaw(preTest1).cecDialogVisible) {
modelAmount.value= ''
}
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -163,8 +163,9 @@ const handleInput = (e) => {
font-size: 28px; font-size: 28px;
font-family: 'Poppins'; font-family: 'Poppins';
input { input {
width: 200px; width: 260px;
border: 0; border: 0;
font-size: 28px;
background: #2d2738; background: #2d2738;
padding-left: 20px; padding-left: 20px;
box-sizing: border-box; box-sizing: border-box;
@ -179,11 +180,13 @@ const handleInput = (e) => {
margin: 0; margin: 0;
} }
input::input-placeholder { input::input-placeholder {
color: #fff; font-size: 18px;
color: #B3B5DA;
} }
input::-webkit-input-placeholder { input::-webkit-input-placeholder {
//WebKit browsersChrome //WebKit browsersChrome
color: #fff; font-size: 18px;
color: #B3B5DA;
} }
input::-moz-placeholder { input::-moz-placeholder {
//Mozilla Firefox 4 to 18 //Mozilla Firefox 4 to 18

View File

@ -108,7 +108,8 @@ const conversionModal = () => {
typeName: "es CEC", typeName: "es CEC",
conversion: "CEC Locked", conversion: "CEC Locked",
conversionName: "CEC", conversionName: "CEC",
amount: stakingStore.cecInfoData.esCecBalance amount: stakingStore.cecInfoData.esCecBalance,
btnText: 'Confirm'
} }
} }
@ -146,19 +147,27 @@ const eventBtnName = (val) => {
// //
const cecDeposit = async (_amount) => { const cecDeposit = async (_amount) => {
if(Number(priceCalculated(stakingStore.cecInfoData.CecStaked)) < Number(_amount)) {
cecDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, {
title: "",
noBtnTitle: '',
message: 'Please stake a sufficient amount of CEC, which will be used to lock the corresponding amount of CEC when the esCEC is vested.'
}).show();
} else {
let amount = BigInt(_amount * 1e18) let amount = BigInt(_amount * 1e18)
loadingDialogVisible.value = true loadingDialogVisible.value = true
try { try {
let res = await bc.vester.deposit(amount) let res = await bc.vester.deposit(amount)
if(res.hash != '') { if(res.hash != '') {
refreshCecInfo() refreshCecInfo()
cecDialogVisible.value = false handleClose()
loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: "", title: "",
noBtnTitle: '', noBtnTitle: '',
message: 'Conversion Successful' message: 'Conversion Successful'
}).show(); }).show();
loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
if(e.message.indexOf('User denied transaction signature') == -1) { if(e.message.indexOf('User denied transaction signature') == -1) {
@ -166,6 +175,7 @@ const cecDeposit = async (_amount) => {
} }
loadingDialogVisible.value = false loadingDialogVisible.value = false
} }
}
} }
// //
@ -175,13 +185,12 @@ const cecWithdraw = async () => {
let res = await bc.vester.withdraw() let res = await bc.vester.withdraw()
if(res.hash != '') { if(res.hash != '') {
refreshCecInfo() refreshCecInfo()
cecDialogVisible.value = false loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: "", title: "",
noBtnTitle: '', noBtnTitle: '',
message: 'Withdraw Successful' message: 'Withdraw Successful'
}).show(); }).show();
loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
if(e.message.indexOf('User denied transaction signature') == -1) { if(e.message.indexOf('User denied transaction signature') == -1) {
@ -210,13 +219,12 @@ const claimCec = async () => {
let res = await bc.vester.claim() let res = await bc.vester.claim()
if(res.hash != '') { if(res.hash != '') {
refreshCecInfo() refreshCecInfo()
cecDialogVisible.value = false loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: "", title: "",
noBtnTitle: '', noBtnTitle: '',
message: 'Claim Successful' message: 'Claim Successful'
}).show(); }).show();
loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
loadingDialogVisible.value = false loadingDialogVisible.value = false

View File

@ -3,8 +3,8 @@
<div class="staking-header-tit"> <div class="staking-header-tit">
<h1>STAKING OVERVIEW</h1> <h1>STAKING OVERVIEW</h1>
<div> <div>
<p><span><img :src="icon_pass" alt=""></span> {{ stakingStore.bindPassportAddress ? sliceAddress(stakingStore.bindPassportAddress) : '-' }}</p> <!-- <p><span><img :src="icon_pass" alt=""></span> {{ stakingStore.bindPassportAddress ? sliceAddress(stakingStore.bindPassportAddress) : '-' }}</p> -->
<p><span>Email:</span> {{ stakingStore.bindPassportEmail ? stakingStore.bindPassportEmail : '-' }}</p> <!-- <p><span>Email:</span> {{ stakingStore.bindPassportEmail ? stakingStore.bindPassportEmail : '-' }}</p> -->
</div> </div>
</div> </div>
<div class="content"> <div class="content">
@ -266,6 +266,7 @@ onMounted(() => {
p { p {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 18px;
span { span {
width: 40px; width: 40px;
display: flex; display: flex;

View File

@ -61,7 +61,8 @@
<span v-else class="no">Stake</span> <span v-else class="no">Stake</span>
</div> </div>
<div class="btn"> <div class="btn">
<span v-if="stakingStore.cecInfoData.CecStaked" @click="closeCecStakedText">Unstake</span> <span v-if="Number(stakingStore.cecInfoData.CecStaked) - Number(stakingStore.cecInfoData.CecDisarm) == 0" class="no">Unstake</span>
<span v-else-if="Number(stakingStore.cecInfoData.CecStaked) != 0" @click="closeCecStakedText">Unstake</span>
<span v-else class="no">Unstake</span> <span v-else class="no">Unstake</span>
</div> </div>
<div class="btn"> <div class="btn">
@ -184,7 +185,7 @@ const toLogin = async () => {
const handleClose = () => { const handleClose = () => {
cecDialogVisible.value = false cecDialogVisible.value = false
} }
console.log(stakingStore.cecInfoData.CecStaked, stakingStore.cecInfoData.CecDisarm)
// //
const eventBtnName = (val) => { const eventBtnName = (val) => {
if(val.title == 'Stake CEC') { if(val.title == 'Stake CEC') {
@ -200,39 +201,40 @@ const eventBtnName = (val) => {
// cec stake // cec stake
const cecStakingText = async () => { const cecStakingText = async () => {
if(!stakingStore.bindPassportAddress) { // if(!stakingStore.bindPassportAddress) {
const confirmResult = await createModal(ConfirmDialog, { // const confirmResult = await createModal(ConfirmDialog, {
title: 'Link your Passport.', // title: 'Link your Passport.',
message: 'Please note, once linked, it cannot be unlinked. Ensure youre connecting the correct Passport.' // message: 'Please note, once linked, it cannot be unlinked. Ensure youre connecting the correct Passport.'
}).show() // }).show()
if(confirmResult.errcode == 0) { // if(confirmResult.errcode == 0) {
await new BlockChain().appendPassport() // await new BlockChain().appendPassport()
let res = await apiBindPassport({passport_jwt: 'Bearer ' + await new BlockChain().passportToken()}) // let res = await apiBindPassport({passport_jwt: 'Bearer ' + await new BlockChain().passportToken()})
if(res.errcode == 0) { // if(res.errcode == 0) {
message.success('Bind Successful') // message.success('Bind Successful')
refreshCecInfo() // refreshCecInfo()
} else if(res.errcode == 1) { // } else if(res.errcode == 1) {
const confirmResult1 = await createModal(ConfirmDialog, { // const confirmResult1 = await createModal(ConfirmDialog, {
title: '', // title: '',
noBtnTitle: '', // noBtnTitle: '',
message: 'This Immutable Passport is already connected to another wallet. Please use a different Immutable Passport.' // message: 'This Immutable Passport is already connected to another wallet. Please use a different Immutable Passport.'
}).show() // }).show()
if(confirmResult1.errcode == 0) { // if(confirmResult1.errcode == 0) {
new PassportWallet().logout(); // new PassportWallet().logout();
} // }
} // }
} else { // } else {
message.error('User denied transaction signature') // message.error('User denied transaction signature')
} // }
} else { // } else {
cecDialogVisible.value = true cecDialogVisible.value = true
dialogUnstakeText.value = { dialogUnstakeText.value = {
title: "Stake CEC", title: "Stake CEC",
typeLabel: "Stake", typeLabel: "Stake",
typeName: "CEC", typeName: "CEC",
amount: stakingStore.cecInfoData.cecBalance amount: stakingStore.cecInfoData.cecBalance,
} btnText: 'Confirm'
} }
// }
} }
const closeCecStakedText = () => { const closeCecStakedText = () => {
@ -241,7 +243,8 @@ const closeCecStakedText = () => {
title: "Unstake CEC", title: "Unstake CEC",
typeLabel: "Unstake", typeLabel: "Unstake",
typeName: "CEC", typeName: "CEC",
amount: stakingStore.cecInfoData.CecStaked - stakingStore.cecInfoData.CecDisarm amount: stakingStore.cecInfoData.CecStaked - stakingStore.cecInfoData.CecDisarm,
btnText: 'Unstake'
} }
} }
@ -265,7 +268,8 @@ const esCecStakingText = () => {
title: "Stake esCEC", title: "Stake esCEC",
typeLabel: "Stake", typeLabel: "Stake",
typeName: "esCEC", typeName: "esCEC",
amount: stakingStore.cecInfoData.esCecBalance amount: stakingStore.cecInfoData.esCecBalance,
btnText: 'Confirm',
} }
} }
@ -275,7 +279,8 @@ const closeEsCecStakedText = () => {
title: "Unstake esCEC", title: "Unstake esCEC",
typeLabel: "Unstake", typeLabel: "Unstake",
typeName: "esCEC", typeName: "esCEC",
amount: stakingStore.cecInfoData.esCecStaked amount: stakingStore.cecInfoData.esCecStaked,
btnText: 'Unstake'
} }
} }
// esCec end // esCec end
@ -294,7 +299,7 @@ const cecStaked = async (_amount) => {
let res2 = await bc.staking.stakeCec(amount) let res2 = await bc.staking.stakeCec(amount)
if(res2.hash != '') { if(res2.hash != '') {
refreshCecInfo() refreshCecInfo()
cecDialogVisible.value = false handleClose()
loadingDialogVisible.value = false loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: '', title: '',
@ -319,13 +324,13 @@ const closeStaked = async (type, _amount) => {
let res = await bc.staking.unstakeCec(amount) let res = await bc.staking.unstakeCec(amount)
if(res.hash != '') { if(res.hash != '') {
refreshCecInfo() refreshCecInfo()
handleClose()
loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: "", title: "",
noBtnTitle: '', noBtnTitle: '',
message: 'Unstake Successful' message: 'Unstake Successful'
}).show(); }).show();
cecDialogVisible.value = false
loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
if(e.message.indexOf('User denied transaction signature') == -1) { if(e.message.indexOf('User denied transaction signature') == -1) {
@ -338,13 +343,13 @@ const closeStaked = async (type, _amount) => {
let res = await bc.staking.unstakeEsCec(amount) let res = await bc.staking.unstakeEsCec(amount)
if(res.hash != '') { if(res.hash != '') {
refreshCecInfo() refreshCecInfo()
handleClose()
loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: "", title: "",
noBtnTitle: '', noBtnTitle: '',
message: 'Unstake Successful' message: 'Unstake Successful'
}).show(); }).show();
cecDialogVisible.value = false
loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
if(e.message.indexOf('User denied transaction signature') == -1) { if(e.message.indexOf('User denied transaction signature') == -1) {
@ -368,7 +373,6 @@ const getCecCollection = async (type) => {
noBtnTitle: '', noBtnTitle: '',
message: 'Claim Successful' message: 'Claim Successful'
}).show(); }).show();
cecDialogVisible.value = false
loadingDialogVisible.value = false loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
@ -387,7 +391,6 @@ const getCecCollection = async (type) => {
noBtnTitle: '', noBtnTitle: '',
message: 'Claim Successful' message: 'Claim Successful'
}).show(); }).show();
cecDialogVisible.value = false
loadingDialogVisible.value = false loadingDialogVisible.value = false
} }
} catch (e) { } catch (e) {
@ -408,7 +411,7 @@ const esCecStaked = async (_amount) => {
let res = await bc.staking.stakeEsCec(amount) let res = await bc.staking.stakeEsCec(amount)
if(res.hash != '') { if(res.hash != '') {
refreshCecInfo() refreshCecInfo()
cecDialogVisible.value = false handleClose()
loadingDialogVisible.value = false loadingDialogVisible.value = false
const confirmResult = await createModal(ConfirmDialog, { const confirmResult = await createModal(ConfirmDialog, {
title: '', title: '',

View File

@ -13,9 +13,14 @@
<img src="@/assets/img/cec_activity/Icon_Disc.png" alt /> <img src="@/assets/img/cec_activity/Icon_Disc.png" alt />
</a> </a>
</div> </div>
<div @click="toTwitter"> <div>
<a href="https://x.com/playCounterFire" target="_blank" rel="noopener noreferrer">
<img src="@/assets/img/cec_activity/Icon_X.png" alt /> <img src="@/assets/img/cec_activity/Icon_X.png" alt />
</a>
</div> </div>
<!-- <div @click="toTwitter">
<img src="@/assets/img/cec_activity/Icon_X.png" alt />
</div> -->
</div> </div>
<div class="right"> <div class="right">
<div <div
@ -218,12 +223,12 @@ const getNetId = async () => {
// passport // passport
const getVipInfo = async () => { const getVipInfo = async () => {
const {errcode, info} = await apiVipInfo(); // const {errcode, info} = await apiVipInfo();
console.log("bind_passport_address", info.bind_passport_address); // console.log("bind_passport_address", info.bind_passport_address);
if (errcode == 0) { // if (errcode == 0) {
stakingStore.bindPassportAddress = info.bind_passport_address; // stakingStore.bindPassportAddress = info.bind_passport_address;
stakingStore.bindPassportEmail = info.bind_email; // stakingStore.bindPassportEmail = info.bind_email;
} // }
}; };
// //
@ -238,7 +243,7 @@ const toTwitter = () => {
const userCecInfo = () => { const userCecInfo = () => {
getNetId(); getNetId();
getVipInfo(); // getVipInfo();
getCecData(); getCecData();
}; };
@ -254,7 +259,7 @@ onMounted(() => {
background: #16141b; background: #16141b;
color: #fff; color: #fff;
.header { .header {
width: 1506px; width: 1420px;
height: 316px; height: 316px;
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;
@ -276,6 +281,7 @@ onMounted(() => {
// align-items: center; // align-items: center;
color: #fff; color: #fff;
margin-top: 43px; margin-top: 43px;
margin-right: -24px;
.left { .left {
width: 106px; width: 106px;
height: 47px; height: 47px;