cec claim

This commit is contained in:
yuyongdong 2024-09-06 10:47:05 +08:00
parent eb9595ecbc
commit e68464adec
11 changed files with 252 additions and 138 deletions

View File

@ -22,4 +22,5 @@ VUE_APP_PRODUCTION=sandbox
VUE_APP_LOGIN_API='https://login-test.kingsome.cn'
VUE_APP_NET_ID_MAIN='11155111'
VUE_APP_LOCKER_ADDRESS_MAIN='0x7F2b4DB626d878778e178B4F0C7bA3a2870C6dd0'
VUE_APP_LOCKER_ADDRESS_MAIN='0x7F2b4DB626d878778e178B4F0C7bA3a2870C6dd0'
VUE_APP_NET_ID_CLAIM='97'

View File

@ -22,4 +22,5 @@ VUE_APP_PRODUCTION=sandbox
VUE_APP_LOGIN_API='https://login-test.kingsome.cn'
VUE_APP_NET_ID_MAIN='11155111'
VUE_APP_LOCKER_ADDRESS_MAIN='0x7F2b4DB626d878778e178B4F0C7bA3a2870C6dd0'
VUE_APP_LOCKER_ADDRESS_MAIN='0x7F2b4DB626d878778e178B4F0C7bA3a2870C6dd0'
VUE_APP_NET_ID_CLAIM='97'

View File

@ -22,4 +22,5 @@ VUE_APP_PRODUCTION=production
VUE_APP_LOGIN_API='https://login-test.cebggame.com'
VUE_APP_NET_ID_MAIN='1'
VUE_APP_LOCKER_ADDRESS_MAIN='0x5c16AC8322E5cac8ad235F7e0Dc5d23bffe3ed50'
VUE_APP_LOCKER_ADDRESS_MAIN='0x5c16AC8322E5cac8ad235F7e0Dc5d23bffe3ed50'
VUE_APP_NET_ID_CLAIM='56'

View File

@ -23,4 +23,5 @@ VUE_APP_LOGIN_API='https://login-test.cebggame.com'
VUE_APP_NET_ID_MAIN='1'
VUE_APP_LOCKER_ADDRESS_MAIN='0x5c16AC8322E5cac8ad235F7e0Dc5d23bffe3ed50'
VUE_APP_LOCKER_ADDRESS_MAIN='0x5c16AC8322E5cac8ad235F7e0Dc5d23bffe3ed50'
VUE_APP_NET_ID_CLAIM='56'

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -12,6 +12,7 @@ import {ImtblMarket} from "@/components/chain/Market";
import { ALL_PROVIDERS } from "@/configs/configchain";
import {Locker} from "@/components/chain/contract/Locker";
import {GameItemMall} from "@/components/chain/contract/GameItemMall";
import { CecClaim } from "@/components/chain/contract/cecClaim"
import ConfirmDialog from "@/components/Dialogs/confirmDialog.vue";
import { Widgets } from "./Widgets";
@ -34,6 +35,7 @@ export class BlockChain {
this.market = new ImtblMarket(this)
this.locker = new Locker(this)
this.mall = new GameItemMall(this)
this.claim = new CecClaim(this)
this.widgets = new Widgets(this)
BlockChain.instance = this;
@ -340,6 +342,8 @@ export class BlockChain {
}
async claimAddress({title, subTitle, targetChainId}) {
console.log(targetChainId)
// return
const initData = {}
initData[this.store.walletType] = this.store.address
const rewardModal = createModal(WalletSelectModel, {
@ -354,7 +358,7 @@ export class BlockChain {
console.log(`select address result : ${errmsg}`);
throw new Error(errmsg);
}
targetChainId = targetChainId || cfgChainId;
targetChainId = targetChainId;
let chainId = await walletInstance.getChainId();
if (chainId !== targetChainId) {
console.log(`current chain: ${chainId}, want: ${targetChainId}`)

View File

@ -90,7 +90,7 @@ async function selectWallet(id) {
const Provider = allProviders[id];
const walletInstance = new Provider()
const { provider, accounts } = await walletInstance.web3Provider();
console.log(accounts)
// console.log(accounts)
hideModal({errcode: 0, provider, wallet: id, walletInstance, accounts});
}

View File

@ -0,0 +1,48 @@
import { apiCecClaim } from '@/utils/marketplace'
export class CecClaim {
constructor(_chainInstance) {
this.bc = _chainInstance
}
async sendTransaction(provider, {from, to, data}) {
const txHash = await provider.provider.request({
method: 'eth_sendTransaction',
params: [{
from,
to,
data
}]
})
const res = await provider.waitForTransaction(txHash)
if (res.status == 0) {
throw new Error('transaction failed')
}
return txHash
}
async cecClaim(token) {
const chainId = parseInt(import.meta.env.VUE_APP_NET_ID_CLAIM);
const subTitle = 'Select the payment address.'
const { provider, address } = await this.bc.claimAddress({subTitle: subTitle,targetChainId: chainId})
// const preDatas = {
// address: address,
// }
const { errocode, errmsg, calls } = await apiCecClaim(address,token)
if (errocode) {
throw new Error(errmsg)
}
if (!calls || calls.length == 0) {
throw new Error('no calls')
}
let resutls = []
for (let i = 0; i < calls.length; i++) {
const { to, data } = calls[i].trans_req
let hash = await this.sendTransaction(provider, {from: address, to, data})
resutls.push(hash)
}
return resutls
}
}

View File

@ -80,6 +80,15 @@ export const AllChains = [
symbol: 'BNB',
explorerurl: 'https://bscscan.com'
},
{
name: 'Binance Smart Chain Testnet RPC',
type: 'Testnet',
rpc: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
id: 97,
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTAwIiBoZWlnaHQ9IjI1MDAiIHZpZXdCb3g9IjAgMCAyMDAwIDIwMDAiPjxnIGZpbGw9IiNmM2JhMmYiPjxwYXRoIGQ9Ik02MTEuNTkgODQwLjQybDM4OC40LTM4OC4zOSAzODguNiAzODguNTkgMjI2LTIyNkw5OTkuOTkgMCAzODUuNiA2MTQuNDJsMjI1Ljk5IDIyNk0uMDA2IDk5OS45NjlsMjI2LjAwNy0yMjYuMDA3IDIyNS45OTIgMjI1Ljk5M0wyMjYgMTIyNS45NnpNNjExLjU5IDExNTkuNThsMzg4LjQgMzg4LjM5IDM4OC41OS0zODguNTggMjI2LjEyIDIyNS44OC0uMTEuMTJMOTk5Ljk5IDIwMDBsLTYxNC40MS02MTQuNC0uMzItLjMyIDIyNi4zMy0yMjUuN00xNTQ4LjAxMyAxMDAwLjA5M2wyMjYuMDA3LTIyNi4wMDYgMjI1Ljk5MiAyMjUuOTkyLTIyNi4wMDYgMjI2LjAwN3oiLz48cGF0aCBkPSJNMTIyOS4yMiA5OTkuODhoLjFMOTk5Ljk5IDc3MC41NSA4MzAuNTEgOTQwLjAzaC0uMDFsLTE5LjQ3IDE5LjQ4LTQwLjE2IDQwLjE3LS4zMi4zMS4zMi4zMyAyMjkuMTIgMjI5LjEzIDIyOS4zMy0yMjkuMzMuMTEtLjEzLS4yMS0uMTEiLz48L2c+PC9zdmc+',
symbol: 'BNB',
explorerurl: 'https://testnet.bscscan.com'
},
{
name: 'OKExChain Mainnet RPC',
type: 'Mainnet',

View File

@ -47,12 +47,22 @@
</div>
<div class="content-tips-link">
<div>
<file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a>
<!-- <file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a> -->
</div>
</div>
<div class="content-times">
<div class="content-time-top" @click="connectLogin">
<div class="content-time-top">
<li>
<div class="left">
<span>Claim to your wallet</span>
</div>
<div class="right">
<span>Sep 9, 00:00 UTC</span>
</div>
</li>
</div>
<div class="content-time-btm">
<li>
<div class="left left-hover">
<div>
@ -62,7 +72,7 @@
<span>0 gas</span>
</div>
<div class="right">
<span>Aug 30, 06:00 - Sep 5, 06:00 UTC </span>
<span>Closed</span>
</div>
</li>
<li>
@ -71,21 +81,9 @@
</div>
</li>
</div>
<!-- <div class="content-time-line"></div> -->
<div class="content-time-btm">
<li>
<div class="left">
<div></div>
<span>Claim to your wallet</span>
</div>
<div class="right">
<span>Coming soon</span>
</div>
</li>
</div>
</div>
</div>
<div class="content" v-else-if="address && cecUserStatus == -2">
<div class="content" v-else-if="address && cecInfo.available == '0'">
<div class="content-tips">
You have no CEC available to claim.
</div>
@ -94,61 +92,24 @@
</div>
<div class="content-tips-link">
<div class="padding-right-15">
<file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a>
</div>
</div>
<div class="content-time">
<div class="content-time-top">
<li>
<div class="left">
<div>
<img src="@/assets/img/cec_claim/Bitgetlogo.png" alt="">
</div>
<h3>Deposit to Bitget</h3>
<span>0 gas</span>
</div>
<div class="right">
<span>Aug 30, 06:00 - Sep 5, 06:00 UTC </span>
</div>
</li>
<li>
<div class="left">
<p>Grab a share of 1,000,000 $CEC</p>
</div>
</li>
</div>
<div class="content-time-line"></div>
<div class="content-time-btm">
<li>
<div class="left">
<div></div>
<span>Claim to your wallet</span>
</div>
<div class="right">
<span>Coming soon</span>
</div>
</li>
</div>
</div>
</div>
<div class="content" v-else-if="cecUserStatus == -1">
<div class="content-tips content-tips-login">
<span>Address:</span> {{address}}
</div>
<div class="content-tips content-tips-login">
<span>You can currently pre-deposit to Bitget</span>
</div>
<div class="content-tips-link">
<div>
<file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a>
<!-- <file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a> -->
</div>
</div>
<div class="content-times">
<div class="content-time-top " @click="isBindAccount">
<div class="content-time-top">
<li>
<div class="left">
<span>Claim to your wallet</span>
</div>
<div class="right">
<span>Sep 9, 00:00 UTC</span>
</div>
</li>
</div>
<div class="content-time-btm">
<li>
<div class="left left-hover">
<div>
<img src="@/assets/img/cec_claim/Bitgetlogo.png" alt="">
</div>
@ -156,7 +117,7 @@
<span>0 gas</span>
</div>
<div class="right">
<span>Aug 30, 06:00 - Sep 5, 06:00 UTC </span>
<span>Closed</span>
</div>
</li>
<li>
@ -165,22 +126,59 @@
</div>
</li>
</div>
<!-- <div class="content-time-line"></div> -->
<div class="content-time-btm">
<li>
<div class="left">
<div></div>
<span>Claim to your wallet</span>
</div>
<div class="right">
<!-- <div class="right claim-btn" @click="cecClaim"> -->
<span>Coming soon</span>
</div>
</li>
</div>
</div>
</div>
<div class="content" v-else>
<div class="content-tips content-tips-login">
<span>Address:</span> {{address}}
</div>
<!-- <div class="content-tips content-tips-login" v-if="cecInfo.bindUid">
<span>You'll receive your $CEC airdrop in Bitget spot account before the listing time.</span>
</div> -->
<div class="content-tips-link">
<div>
<!-- <file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a> -->
</div>
</div>
<div class="content-times">
<!-- @click="isBindAccount" -->
<div class="content-time-top" @click="cecUserStatus = 0">
<li>
<div class="left">
<div></div>
<span>Claim to your wallet</span>
</div>
<div class="right">
<!-- <div class="right claim-btn" @click="cecClaim">Claim</div> -->
<span class="claim-btn" @click="cecClaim">Claim</span>
</div>
</li>
</div>
<!-- <div class="content-time-line"></div> -->
<div class="content-time-btm">
<li>
<div class="left">
<div>
<img src="@/assets/img/cec_claim/Bitgetlogo.png" alt="">
</div>
<h3>Deposit to Bitget</h3>
<span>0 gas</span>
</div>
<div class="right">
<span>Closed</span>
</div>
</li>
<li>
<div class="left">
<p>Grab a share of 1,000,000 $CEC</p>
</div>
</li>
</div>
</div>
</div>
<div class="content" v-if="false">
<div class="content-title">
<div class="content-title-left">
<div class="content-title-logo">
@ -192,8 +190,8 @@
<div class="content-title-right">
<div class="content-tips-link">
<div>
<file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a>
<!-- <file-text-outlined />
<a :href="instructionLink" target="_blank">Instruction</a> -->
</div>
</div>
</div>
@ -227,7 +225,7 @@
<p class="center">Jump to<a href="https://www.bitget.com/support/articles/12560603814979?utmSource=Twitter_CEC" target="_blank"> Bitget Launchpool</a> and grab your share of 11M $CEC now!</p>
</div>
<div class="body-box-btn">
<p><a @click="cecUserStatus = 4">Cancel the Pre-Deposit to Bitget</a></p>
<!-- <p><a @click="cecUserStatus = 4">Cancel the Pre-Deposit to Bitget</a></p> -->
</div>
</div>
<!-- 4 是否取消绑定交易所 -->
@ -329,7 +327,7 @@
</div>
<!-- ------------------------------------------------------------------------ -->
</div>
<LoadingDialog :loadingDialogVisible="loadingDialogVisible" />
<div ref="claimLogModal">
<a-modal :class="'claimLogModal'" :getContainer="() => $refs.claimLogModal" v-model:open="claimLogDialogVisible" :closable="false" :footer="null" :maskClosable="false">
<div class="log-title">Cec claim</div>
@ -346,14 +344,17 @@
import { ref, toRefs, toRaw, onMounted, computed, watch, inject} from "vue"
const message = inject('$message')
import { FileTextOutlined } from '@ant-design/icons-vue';
import LoadingDialog from "@/components/Dialogs/loadingDialog.vue";
import { priceCalculated } from "@/configs/priceCalculate"
import {walletStore} from "@/store/wallet";
import { useMarketplaceStore } from "@/store/marketplace"
import { BlockChain } from "@/components/chain/BlockChain"
import { apiCecInfoAll, apiBindAccount, apiCecClaim } from "@/utils/marketplace"
import ConfirmDialog from "@/components/Dialogs/confirmDialog.vue";
import {createModal} from "@/utils/model.util";
const loadingDialogVisible = ref(false)
const localWalletStore = walletStore()
const marketplaceStore = useMarketplaceStore()
const instructionLink = ref('https://medium.com/@CounterFire/pre-deposit-instruction-a30d6ce62f80')
@ -361,7 +362,7 @@ const claimLogDialogVisible = ref(false)
const address = ref()
const tradeId = ref()
const tradeAddress = ref()
const cecUserStatus = ref(0) // -2 cec -1 0 1 2 3 4 5
const cecUserStatus = ref(-1) // -2 cec -1 0 1 2 3 4 5
const cecInfo = ref({
available: 0,
bindAddress: '',
@ -378,17 +379,22 @@ const getCecTotal = async () => {
let token = marketplaceStore.fireToken || localWalletStore.token
let data = await apiCecInfoAll(address.value, token)
cecInfo.value = data.data
if(data.data.available == 0 || data.data.available == '0') {
cecUserStatus.value = -2
} else {
if(data.data.bindUid) {
// cecUserStatus.value = -2
// } else {
cecUserStatus.value = -1
} else {
if(data.data.available == 0 || data.data.available == '0') {
cecUserStatus.value = -2
} else {
cecUserStatus.value = -1
}
}
}
}
const isBindAccount = () => {
console.log(cecInfo.value.bindUid)
if(cecInfo.value.bindUid) {
cecUserStatus.value = 3
} else {
@ -474,12 +480,36 @@ const reqGetInfo = async () => {
//
const cecClaim = async () => {
let res = await new BlockChain().claimAddress({})
console.log(res.address)
let walletToken = await new BlockChain().token()
let token = marketplaceStore.fireToken || walletToken
let res1 = await apiCecClaim(res.address, token)
console.log(res1)
try {
loadingDialogVisible.value = true
let res = await new BlockChain().claim.cecClaim(token)
if(res) {
loadingDialogVisible.value = false
getCecTotal()
const confirmResult = await createModal(ConfirmDialog, {
title: '',
noBtnTitle: '',
message: 'Claim Successful'
}).show()
}
} catch(e) {
if(e.message.indexOf("User denied transaction signature") > -1) {
message.error("User rejected the request");
} else if(e.message.indexOf("reject") > -1){
message.error("User rejected the request");
} else if(e.message.indexOf("User denied request signature") > -1){
message.error("User rejected the request");
} else {
message.error("Claim fail.");
}
loadingDialogVisible.value = false
}
// let walletToken = await new BlockChain().token()
// let token = marketplaceStore.fireToken || walletToken
// let res1 = await apiCecClaim(res.address, token)
}
onMounted(() => {
@ -844,16 +874,69 @@ onMounted(() => {
.content-time-top {
background: url('@/assets/img/cec_claim/Counterfire_mbg02.png') no-repeat;
background-size: 100% 100%;
height: 100px;
padding: 10px 20px 0 20px;
cursor: pointer;
li {
display: flex;
justify-content: space-between;
margin-top: 20px;
font-size: 18px;
font-family: 'Poppins';
// color: #8d8598;
.left {
margin-left: 60px;
width: 390px;
font-family: "Poppins";
font-size: 24px;
font-weight: 700;
}
.right {
width: 283px;
text-align: right;
span {
padding-right: 40px;
}
.claim-btn {
padding: 5px 20px;
border-radius: 20px;
color: #000;
background: #fec25d;
margin-right: 40px;
}
}
.claim-btn {
span {
color: #fff;
padding: 10px;
border: 1px solid #31FFF3;
border-radius: 20px;
cursor: pointer;
}
}
}
&:hover {
background: url('@/assets/img/cec_claim/Counterfire_mbg01.png') no-repeat;
background-size: 100% 100%;
}
}
.content-time-line {
width: 100%;
height: 2px;
background: #44375c;
}
.content-time-btm {
padding-top: 10px;
li {
display: flex;
align-items: center;
justify-content: space-between;
color: #8e8497;
.left {
display: flex;
align-items: center;
width: 380px;
padding-left: 40px;
div {
width: 30px;
height: 30px;
@ -873,7 +956,7 @@ onMounted(() => {
span {
display: inline-block;
color: #000;
background: #31FFF3;
background: #8e8497;
font-size: 12px;
font-family: "Poppins";
padding: 0 5px;
@ -892,6 +975,7 @@ onMounted(() => {
span {
font-weight: 700;
font-size: 16px;
padding-right: 60px;
}
.tips {
position: relative;
@ -929,42 +1013,7 @@ onMounted(() => {
}
}
}
&:hover {
background: url('@/assets/img/cec_claim/Counterfire_mbg01.png') no-repeat;
background-size: 100% 100%;
}
}
.content-time-line {
width: 100%;
height: 2px;
background: #44375c;
}
.content-time-btm {
li {
display: flex;
justify-content: space-between;
margin-top: 20px;
font-size: 18px;
font-family: 'Poppins';
color: #8d8598;
.left {
margin-left: 60px;
width: 390px;
}
.right {
width: 283px;
text-align: left;
}
.claim-btn {
span {
color: #fff;
padding: 10px;
border: 1px solid #31FFF3;
border-radius: 20px;
cursor: pointer;
}
}
}
}
}
.content-title {