diff --git a/.env.dev b/.env.dev index f585ce0..0e4be69 100644 --- a/.env.dev +++ b/.env.dev @@ -24,4 +24,5 @@ VUE_APP_LOGIN_API='https://login-test.kingsome.cn' VUE_APP_NET_ID_MAIN='11155111' VUE_APP_LOCKER_ADDRESS_MAIN='0x7F2b4DB626d878778e178B4F0C7bA3a2870C6dd0' -VUE_APP_STAKING_CHAIN='97' \ No newline at end of file +VUE_APP_STAKING_CHAIN='97' +VUE_APP_NET_ID_CLAIM='97' diff --git a/.env.development b/.env.development index 9e9986e..9814aaf 100644 --- a/.env.development +++ b/.env.development @@ -24,4 +24,5 @@ VUE_APP_LOGIN_API='https://login-test.kingsome.cn' VUE_APP_NET_ID_MAIN='11155111' VUE_APP_LOCKER_ADDRESS_MAIN='0x7F2b4DB626d878778e178B4F0C7bA3a2870C6dd0' -VUE_APP_STAKING_CHAIN='97' \ No newline at end of file +VUE_APP_STAKING_CHAIN='97' +VUE_APP_NET_ID_CLAIM='97' diff --git a/.env.production b/.env.production index 7721b2d..aac6571 100644 --- a/.env.production +++ b/.env.production @@ -24,4 +24,5 @@ VUE_APP_LOGIN_API='https://login-test.cebggame.com' VUE_APP_NET_ID_MAIN='1' VUE_APP_LOCKER_ADDRESS_MAIN='0x5c16AC8322E5cac8ad235F7e0Dc5d23bffe3ed50' -VUE_APP_STAKING_CHAIN='56' \ No newline at end of file +VUE_APP_STAKING_CHAIN='56' +VUE_APP_NET_ID_CLAIM='56' diff --git a/.env.test b/.env.test index 3498501..c2f681e 100644 --- a/.env.test +++ b/.env.test @@ -25,4 +25,5 @@ VUE_APP_LOGIN_API='https://login-test.cebggame.com' VUE_APP_NET_ID_MAIN='1' VUE_APP_LOCKER_ADDRESS_MAIN='0x5c16AC8322E5cac8ad235F7e0Dc5d23bffe3ed50' -VUE_APP_STAKING_CHAIN='56' \ No newline at end of file +VUE_APP_STAKING_CHAIN='56' +VUE_APP_NET_ID_CLAIM='56' diff --git a/marketplace-test.zip b/marketplace-test.zip deleted file mode 100644 index 7899ee1..0000000 Binary files a/marketplace-test.zip and /dev/null differ diff --git a/src/assets/img/cec_claim/Bitgetlogo.png b/src/assets/img/cec_claim/Bitgetlogo.png index 3f11209..2088070 100644 Binary files a/src/assets/img/cec_claim/Bitgetlogo.png and b/src/assets/img/cec_claim/Bitgetlogo.png differ diff --git a/src/assets/img/home/investor_DWFlabs.png b/src/assets/img/home/investor_DWFlabs.png deleted file mode 100644 index 0e3931f..0000000 Binary files a/src/assets/img/home/investor_DWFlabs.png and /dev/null differ diff --git a/src/assets/img/home/investor_Foresight.png b/src/assets/img/home/investor_Foresight.png new file mode 100644 index 0000000..490b6ed Binary files /dev/null and b/src/assets/img/home/investor_Foresight.png differ diff --git a/src/components/about/AboutFooter.vue b/src/components/about/AboutFooter.vue index 50ed91b..10719ec 100644 --- a/src/components/about/AboutFooter.vue +++ b/src/components/about/AboutFooter.vue @@ -97,7 +97,7 @@ const logos = ref([ .href, }, { - imgeSrc: new URL("@/assets/img/home/investor_DWFlabs.png", import.meta.url) + imgeSrc: new URL("@/assets/img/home/investor_Foresight.png", import.meta.url) .href, } ]); diff --git a/src/components/chain/BlockChain.js b/src/components/chain/BlockChain.js index a7c63a0..f01eeff 100644 --- a/src/components/chain/BlockChain.js +++ b/src/components/chain/BlockChain.js @@ -6,12 +6,14 @@ import { FireWallet } from '@/components/chain/wallet/FireWallet'; import { walletStore } from "@/store/wallet"; import WalletSelectModel from "@/components/chain/WalletSelectModel.vue"; import ClaimSelectModel from "@/components/chain/ClaimSelectModel.vue"; +import ClaimAddressModel from "@/components/chain/ClaimAddressModel.vue" import {createModal} from "@/utils/model.util"; import {isTokenExpired, genRefreshToken, cfgChainId, switchEthereumChain} from "@/components/chain/utils" 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"; import { Vester } from "./contract/Vester"; @@ -40,6 +42,7 @@ export class BlockChain { this.vester = new Vester(this) this.staking = new Staking(this) this.erc20 = new ERC20(this) + this.claim = new CecClaim(this) this.widgets = new Widgets(this) BlockChain.instance = this; @@ -346,9 +349,11 @@ 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, { + const rewardModal = createModal(ClaimAddressModel, { title: title || 'Select Address', message: subTitle || 'Please select the address you want to use', subTitle: subTitle, @@ -360,7 +365,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}`) @@ -369,9 +374,41 @@ export class BlockChain { return { provider, address: accounts[0] }; } +/** + * CEC 选择钱包地址 + */ + async ClaimSelectAddress({title, subTitle, disabled, targetChainId}) { + // console.log(targetChainId) + // return + const initData = {} + initData[this.store.walletType] = this.store.address + const rewardModal = createModal(ClaimAddressModel, { + title: title || 'Connect your reciveing wallet', + message: subTitle || 'Use this wallet to reciveing $CEC and pay gas', + subTitle: subTitle, + initData: { 1: 'MetaMask', 2: 'OKX Wallet', 3: 'Passport' }, + disabled: disabled || [5,3] + }); + const { errcode, errmsg, walletInstance, provider, accounts } = await rewardModal.show(); + if (errcode) { + console.log(`select address result : ${errmsg}`); + throw new Error(errmsg); + } + targetChainId = targetChainId; + let chainId = await walletInstance.getChainId(); + if (chainId !== targetChainId) { + console.log(`current chain: ${chainId}, want: ${targetChainId}`) + chainId = await switchEthereumChain(provider.provider, targetChainId); + location.reload() + } + return { provider, address: accounts[0] }; + } + /** * CEC Claim登录 */ - async ClaimLogin() {} + async ClaimChangLogout() { + await this.wallet.logout() + } } diff --git a/src/components/chain/ClaimAddressModel.vue b/src/components/chain/ClaimAddressModel.vue new file mode 100644 index 0000000..949ffee --- /dev/null +++ b/src/components/chain/ClaimAddressModel.vue @@ -0,0 +1,342 @@ + + + diff --git a/src/components/chain/ClaimSelectModel.vue b/src/components/chain/ClaimSelectModel.vue index 9211e4a..67f5af9 100644 --- a/src/components/chain/ClaimSelectModel.vue +++ b/src/components/chain/ClaimSelectModel.vue @@ -76,7 +76,7 @@ const currentDatas = computed(() => { if (initData) { current = initData[item.id]; } - const tip = installed ? current?.tip || item.tip || '' : "Click to Install"; + const tip = installed ? current?.tip || item.tip || '' : "Install"; return { id: item.id, name: item.name, @@ -247,7 +247,7 @@ function hideModal(result = null) { } } .name { - width: 55%; + width: 65%; font-family: 'Poppins-Regular'; font-weight: 400; font-size: 18px; @@ -257,10 +257,10 @@ function hideModal(result = null) { } .tip { text-align: right; - color: red; + color: #a39caa; } .tip a{ - color: red; + color: #a39caa; } .fire-wallet { position: absolute; @@ -318,6 +318,12 @@ function hideModal(result = null) { .name { color: #0A090A; } + .tip { + color: #845c91; + a { + color: #845c91; + } + } } } diff --git a/src/components/chain/WalletSelectModel.vue b/src/components/chain/WalletSelectModel.vue index a5fa84c..1482c20 100644 --- a/src/components/chain/WalletSelectModel.vue +++ b/src/components/chain/WalletSelectModel.vue @@ -71,7 +71,7 @@ const currentDatas = computed(() => { if (initData) { current = initData[item.id]; } - const tip = installed ? current?.tip || item.tip || '' : "Click to Install"; + const tip = installed ? current?.tip || item.tip || '' : "Install"; return { id: item.id, name: item.name, @@ -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}); } @@ -220,7 +220,7 @@ function hideModal(result = null) { } } .name { - width: 55%; + width: 65%; font-family: 'Poppins-Regular'; font-weight: 400; font-size: 18px; @@ -230,10 +230,10 @@ function hideModal(result = null) { } .tip { text-align: right; - color: red; + color: #a39caa; } .tip a{ - color: red; + color: #a39caa; } .fire-wallet { position: absolute; @@ -267,6 +267,12 @@ function hideModal(result = null) { .name { color: #0A090A; } + .tip { + color: #845c91; + a { + color: #845c91; + } + } } } diff --git a/src/components/chain/contract/cecClaim.js b/src/components/chain/contract/cecClaim.js new file mode 100644 index 0000000..534787c --- /dev/null +++ b/src/components/chain/contract/cecClaim.js @@ -0,0 +1,74 @@ +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(provider,address,token) { + // console.log(provider) + const chainId = parseInt(import.meta.env.VUE_APP_NET_ID_CLAIM); + const subTitle = 'Use this wallet to reciveing $CEC and pay gas.' + // const { provider, address } = await this.bc.ClaimSelectAddress({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 + } + + async eaoCecClaim(token,disabled) { + // console.log(provider) + const chainId = parseInt(import.meta.env.VUE_APP_NET_ID_CLAIM); + const subTitle = 'Use this wallet to reciveing $CEC and pay gas.' + const { provider, address } = await this.bc.ClaimSelectAddress({subTitle: subTitle,targetChainId: chainId, disabled: disabled}) + // 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 + } + +} \ No newline at end of file diff --git a/src/components/common/footer.vue b/src/components/common/footer.vue index 104baca..11c3216 100644 --- a/src/components/common/footer.vue +++ b/src/components/common/footer.vue @@ -82,7 +82,7 @@ const logos = ref([ .href, }, { - imgeSrc: new URL("@/assets/img/home/investor_DWFlabs.png", import.meta.url) + imgeSrc: new URL("@/assets/img/home/investor_Foresight.png", import.meta.url) .href, } ]); diff --git a/src/components/home/HomeFooter.vue b/src/components/home/HomeFooter.vue index ae006f4..02fb572 100644 --- a/src/components/home/HomeFooter.vue +++ b/src/components/home/HomeFooter.vue @@ -141,7 +141,7 @@ const logos = ref([ .href, }, { - imgeSrc: new URL("@/assets/img/home/investor_DWFlabs.png", import.meta.url) + imgeSrc: new URL("@/assets/img/home/investor_Foresight.png", import.meta.url) .href, } ]); diff --git a/src/configs/allchain.ts b/src/configs/allchain.ts index 5303e0c..91ecbdf 100644 --- a/src/configs/allchain.ts +++ b/src/configs/allchain.ts @@ -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', diff --git a/src/views/ClaimView copy.vue b/src/views/ClaimView copy.vue index ba1c986..9ec74f0 100644 --- a/src/views/ClaimView copy.vue +++ b/src/views/ClaimView copy.vue @@ -1,4 +1,4 @@ -a