new contracts + visual improvements + cyle end

This commit is contained in:
EmberSpirit
2023-07-20 20:28:21 +02:00
parent cb85a47a94
commit 994c440e2f
13 changed files with 398 additions and 128 deletions
-1
View File
@@ -41,7 +41,6 @@ provide("isMobile", isMobile);
onMounted(async () => { onMounted(async () => {
window.addEventListener("resize", handleWindowSizeChange); window.addEventListener("resize", handleWindowSizeChange);
handleWindowSizeChange(); handleWindowSizeChange();
// initContracts // initContracts
await walletStore.init(); await walletStore.init();
await tokenStore.init(); await tokenStore.init();
+30 -1
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "LiquidityOwner", "contractName": "LiquidityOwner",
"contractAddress": "0xa162bb56eD85f1BEb6f9AdB1DFFecBa01eA51d50", "contractAddress": "0x88E69D5CE691644F7cE151a2b085798194DAFEa1",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
@@ -440,6 +440,35 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint256",
"name": "payForGas",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "memeAltarGasPrice",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "consumedGasByMemeAltar",
"type": "uint256"
}
],
"name": "triggeredByMemeAltar",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "uniV3Pool", "name": "uniV3Pool",
+224 -23
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "MemeBurner", "contractName": "MemeBurner",
"contractAddress": "0xf6e6ffAb831eCC42aBDD1c068DC83b89b9CF8386", "contractAddress": "0xc9cC73C414f122f85EfE20382EB753d29C5a0351",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
@@ -43,11 +43,6 @@
"internalType": "uint256[]", "internalType": "uint256[]",
"name": "roundGoals", "name": "roundGoals",
"type": "uint256[]" "type": "uint256[]"
},
{
"internalType": "uint256",
"name": "_liquidityAmountLimit",
"type": "uint256"
} }
], ],
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
@@ -68,16 +63,36 @@
"name": "LiquidityOwnerAlreadyInitialized", "name": "LiquidityOwnerAlreadyInitialized",
"type": "error" "type": "error"
}, },
{
"inputs": [],
"name": "LiquidityOwnerTriggerFailed",
"type": "error"
},
{ {
"inputs": [], "inputs": [],
"name": "MemeIsNotInAList", "name": "MemeIsNotInAList",
"type": "error" "type": "error"
}, },
{
"inputs": [],
"name": "NextRoundRegistrationFailed",
"type": "error"
},
{ {
"inputs": [], "inputs": [],
"name": "NothingToSacrifice", "name": "NothingToSacrifice",
"type": "error" "type": "error"
}, },
{
"inputs": [],
"name": "RewardRegistrationFailed",
"type": "error"
},
{
"inputs": [],
"name": "RoundCompletedRegistrationFailed",
"type": "error"
},
{ {
"inputs": [], "inputs": [],
"name": "TokenIsNotInSacrificableList", "name": "TokenIsNotInSacrificableList",
@@ -176,6 +191,51 @@
"name": "NewAdmin", "name": "NewAdmin",
"type": "event" "type": "event"
}, },
{
"anonymous": false,
"inputs": [
{
"components": [
{
"internalType": "uint8",
"name": "b1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b3",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m4",
"type": "uint8"
}
],
"indexed": true,
"internalType": "struct MemeBurner.BM",
"name": "_bm",
"type": "tuple"
}
],
"name": "NewBM",
"type": "event"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
@@ -189,6 +249,19 @@
"name": "NewDefaultRoundGoal", "name": "NewDefaultRoundGoal",
"type": "event" "type": "event"
}, },
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "newDurationLimit",
"type": "uint256"
}
],
"name": "NewRoundDurationLimit",
"type": "event"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -213,6 +286,57 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"components": [
{
"internalType": "uint8",
"name": "b1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b3",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m4",
"type": "uint8"
}
],
"internalType": "struct MemeBurner.BM",
"name": "newBM",
"type": "tuple"
}
],
"name": "adjustBM",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -232,6 +356,25 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint256",
"name": "newDurationLimit",
"type": "uint256"
}
],
"name": "adjustRoundDurationLimit",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "admin", "name": "admin",
@@ -245,6 +388,44 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "bm",
"outputs": [
{
"internalType": "uint8",
"name": "b1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b3",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m4",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "currentRound", "name": "currentRound",
@@ -290,6 +471,25 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint256",
"name": "roundNumber",
"type": "uint256"
}
],
"name": "getGoalInBLD",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -343,19 +543,6 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "liquidityAmountLimit",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "liquidityOwner", "name": "liquidityOwner",
@@ -439,6 +626,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "roundDurationLimit",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -453,6 +653,11 @@
"internalType": "uint256", "internalType": "uint256",
"name": "goal", "name": "goal",
"type": "uint256" "type": "uint256"
},
{
"internalType": "uint256",
"name": "expirationTimestamp",
"type": "uint256"
} }
], ],
"stateMutability": "view", "stateMutability": "view",
@@ -526,10 +731,6 @@
], ],
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
} }
] ]
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "MemeToken", "contractName": "MemeToken",
"contractAddress": "0x2052cCA2b50f5F609a450f2C055E53e969E56587", "contractAddress": "0x9dcD7Cd83ED0Fe69DDfE3c2A265a1207F2Bc3219",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "RewardLocker", "contractName": "RewardLocker",
"contractAddress": "0xb2f281CDa06E17Eefc4cf0A485C43a8310012d8B", "contractAddress": "0x7C3D5a19878d550D0c6c2b0BFC884ef410F6e440",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
@@ -580,9 +580,9 @@
"name": "rounds", "name": "rounds",
"outputs": [ "outputs": [
{ {
"internalType": "bool", "internalType": "uint256",
"name": "roundCompleted", "name": "roundCompletedTimestamp",
"type": "bool" "type": "uint256"
}, },
{ {
"internalType": "uint256", "internalType": "uint256",
+4
View File
@@ -14,3 +14,7 @@
background-color: lighten($button-background-color, 10%), background-color: lighten($button-background-color, 10%),
color: darken($button-color, 10%), color: darken($button-color, 10%),
cursor: pointer cursor: pointer
&.btn--disabled
background-color: #151515
color: #808080
cursor: not-allowed
+33 -13
View File
@@ -8,7 +8,13 @@
<div class="sacrifice-tokens"> <div class="sacrifice-tokens">
<div <div
class="sacrifice-token" class="sacrifice-token"
:class="[{ 'sacrifice-token--active': token.contractAddress === activeToken.contractAddress }]" :class="[
{
'sacrifice-token--active': token.contractAddress === activeToken.contractAddress,
'bloodline-border': token.contractAddress === activeToken.contractAddress,
'bloodline-border--variant1': token.contractAddress === activeToken.contractAddress,
},
]"
v-for="token in props.data" v-for="token in props.data"
:key="token.contractAddress" :key="token.contractAddress"
@click="tokenStore.changeActiveToken(token)" @click="tokenStore.changeActiveToken(token)"
@@ -22,7 +28,14 @@
</div> </div>
</div> </div>
<div class="sacrifice-from-to-wrapper" v-if="activeToken.contractAddress"> <div class="sacrifice-from-to-wrapper" v-if="activeToken.contractAddress">
<div class="sacrifice-from-wrapper bloodline-border bloodline-border--variant1"> <div
:class="{
'sacrifice-from-wrapper': true,
'bloodline-border': true,
'bloodline-border--variant1': true,
purple: isMobile,
}"
>
<div class="sarcrifice-from-input"> <div class="sarcrifice-from-input">
<input @input="processChange" v-model="tokenNumber" :placeholder="0" /> <input @input="processChange" v-model="tokenNumber" :placeholder="0" />
<div class="sacrifice-logo"> <div class="sacrifice-logo">
@@ -42,7 +55,14 @@
<div class="sacrifice-divider bloodline-devider"> <div class="sacrifice-divider bloodline-devider">
<font-awesome-icon :icon="['fas', 'arrow-down']" /> <font-awesome-icon :icon="['fas', 'arrow-down']" />
</div> </div>
<div class="sacrifice-to-wrapper bloodline-border bloodline-border--variant1"> <div
:class="{
'sacrifice-from-wrapper': true,
'bloodline-border': true,
'bloodline-border--variant1': true,
purple: isMobile && output && output > 0,
}"
>
<div class="sarcrifice-from-input"> <div class="sarcrifice-from-input">
<div class="sacrifice-to-output"> <div class="sacrifice-to-output">
<div class="sacrifice-to-output-coin">$BLOOD</div> <div class="sacrifice-to-output-coin">$BLOOD</div>
@@ -94,7 +114,7 @@
</template> </template>
<script setup> <script setup>
import { ref, defineProps, watch, inject } from "vue"; import { ref, defineProps, watch, inject, computed } from "vue";
import { useWalletStore } from "@/stores/wallet"; import { useWalletStore } from "@/stores/wallet";
import { useTokenStore } from "@/stores/tokens"; import { useTokenStore } from "@/stores/tokens";
import { useMemeburnerStore } from "@/stores/memeBurner"; import { useMemeburnerStore } from "@/stores/memeBurner";
@@ -129,7 +149,7 @@ const approvalData = ref(null);
const processChange = Helper.debounce((e) => getRewardsFor(e)); const processChange = Helper.debounce((e) => getRewardsFor(e));
async function getRewardsFor(e) { async function getRewardsFor(e) {
if (!e.target.value) { if (!e.target.value || isNaN(e.target.value)) {
output.value = 0; output.value = 0;
return; return;
} }
@@ -186,15 +206,15 @@ async function addTokens(value) {
cursor: pointer cursor: pointer
background-color: #0F0F0F background-color: #0F0F0F
text-align: center text-align: center
@media (min-width: 992px) // @media (min-width: 992px)
padding: 0 // padding: 0
background-color: unset // background-color: unset
&:hover,
&:active,
&:focus
background-color: var(--tertiary-dark)
&.sacrifice-token--active &.sacrifice-token--active
background-color: var(--tertiary-dark) padding: 10px
border-color: var(--purple)
@media (min-width: 992px)
border-color: var(--blood-color)
.sacrifice-token-name .sacrifice-token-name
padding: 5px 26px padding: 5px 26px
font-size: 16px font-size: 16px
+6 -2
View File
@@ -35,7 +35,11 @@
<rewards-wrapper title="Total Reward" coin="$BLOOD" amount="0" image="/src/assets/img/vampir.png" /> <rewards-wrapper title="Total Reward" coin="$BLOOD" amount="0" image="/src/assets/img/vampir.png" />
</div> </div>
<div class="claim-button"> <div class="claim-button">
<div class="btn btn-immortal" @click="claimRewards">Claim</div> <div v-if="activeRound === currentRound" class="btn btn-immortal btn--disabled">Cycle Active</div>
<div v-else-if="getCurrentRoundData?.rewards_total > 0" class="btn btn-immortal" @click="claimRewards">
Claim
</div>
<div v-else class="btn btn-immortal btn--disabled">Nothing to claim</div>
</div> </div>
</div> </div>
</template> </template>
@@ -54,7 +58,7 @@ const rewardLockerStore = useRewardLockerStore();
const walletStore = useWalletStore(); const walletStore = useWalletStore();
const roundStore = useRoundsStore(); const roundStore = useRoundsStore();
const { address } = storeToRefs(walletStore); const { address } = storeToRefs(walletStore);
const { activeRound, getCurrentRoundData } = storeToRefs(roundStore); const { activeRound, currentRound, getCurrentRoundData } = storeToRefs(roundStore);
onMounted(async () => {}); onMounted(async () => {});
+6 -2
View File
@@ -67,7 +67,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
console.log("token.contractAddress", token.contractAddress); console.log("token.contractAddress", token.contractAddress);
console.log("roundnumber", roundnumber); console.log("roundnumber", roundnumber);
var test = await this.getSacrificedMeme(roundnumber, token.contractAddress); var test = await this.getSacrificedMeme(roundnumber, token.contractAddress);
console.log("test", test); console.log(token.name, test);
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress)); calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
// calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress)); // calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress));
} }
@@ -96,6 +96,10 @@ export const useMemeburnerStore = defineStore("memeburner", {
} finally { } finally {
this.loading = false; this.loading = false;
} }
}, },
async getGoalInBLD(roundNumber) {
return await this.contract.methods.getGoalInBLD(roundNumber).call();
}
}, },
}); });
-2
View File
@@ -34,8 +34,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
const calls = []; const calls = [];
for (let index = 0; index < tokenStore.token.length; index++) { for (let index = 0; index < tokenStore.token.length; index++) {
const token = tokenStore.token[index]; const token = tokenStore.token[index];
var test = this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress);
console.log("test123", test);
calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress)); calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
} }
const multicallStore = useMultiCallStore(); const multicallStore = useMultiCallStore();
+29 -32
View File
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import { useMemeburnerStore } from "./memeburner"; import { useMemeburnerStore } from "./memeburner";
import { useTokenStore } from "./tokens"; import { useTokenStore } from "./tokens";
import { useRewardLockerStore } from "./rewardlocker"; import { useRewardLockerStore } from "./rewardlocker";
import { useWalletStore } from "./wallet";
export const useRoundsStore = defineStore("rounds", { export const useRoundsStore = defineStore("rounds", {
@@ -33,6 +34,7 @@ export const useRoundsStore = defineStore("rounds", {
console.log("fillRound"); console.log("fillRound");
const memeBurnerStore = useMemeburnerStore(); const memeBurnerStore = useMemeburnerStore();
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
const walletStore = useWalletStore();
const rewardLockerStore = useRewardLockerStore(); const rewardLockerStore = useRewardLockerStore();
// if (this.activeRound === this.currentRound) { // if (this.activeRound === this.currentRound) {
@@ -42,13 +44,12 @@ export const useRoundsStore = defineStore("rounds", {
console.log("round not filled --> fill round"); console.log("round not filled --> fill round");
console.log("vor error"); console.log("vor error");
var data = await memeBurnerStore.getSacrificedRound(this.activeRound) var data = await memeBurnerStore.getSacrificedRound(this.activeRound)
var rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound); let rewardData = null;
if (await walletStore.isConnected()) {
rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
}
var goal = await memeBurnerStore.getGoal(this.activeRound); var goal = await memeBurnerStore.getGoal(this.activeRound);
console.log("goal", goal);
console.log("this.activeRound", this.activeRound);
console.log("dataabc", data);
console.log("rewardData", rewardData);
console.log("pepecoin-rewards", rewardData[0]);
var tokenArray = [] var tokenArray = []
var rewards_clan = BigInt(0); var rewards_clan = BigInt(0);
@@ -56,43 +57,39 @@ export const useRoundsStore = defineStore("rounds", {
for (let index = 0; index < data.length; index++) { for (let index = 0; index < data.length; index++) {
var tokenData = {}; var tokenData = {};
const token = tokenStore.token[index]; const token = tokenStore.token[index];
console.log("testabcv", token);
console.log("123abc", token.contractAddress);
var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient(this.activeRound, token.contractAddress); var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient(this.activeRound, token.contractAddress);
console.log("testcoef",);
console.log(`rewards ${token.name}`, BigInt(rewardData[index]));
console.log(`clanwin multiplier ${token.name}`, (testcoef / 10000));
const clanwin = BigInt((testcoef / 10000 -1) * rewardData[index]);
console.log(`clanwin ${token.name}`, clanwin);
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
console.log(`sacrifice rewards`, sacrificeRewards);
console.log("token", token);
tokenData.name = token.name; tokenData.name = token.name;
tokenData.contractAddress = token.contractAddress; tokenData.contractAddress = token.contractAddress;
tokenData.vamplogo = token.vamp.logo; tokenData.vamplogo = token.vamp.logo;
tokenData.vampname = token.vamp.name; tokenData.vampname = token.vamp.name;
tokenData.amount = data[index][1]; tokenData.amount = data[index][1];
tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress); tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
tokenData.rewards_ges = rewardData[index]; if (this.currentRound !== this.activeRound && await walletStore.isConnected()) {
if (this.currentRound !== this.activeRound) { const clanwin = BigInt((testcoef / 10000 - 1) * rewardData[index]);
tokenData.rewards_clan = clanwin; const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
console.log("clanwin", clanwin); tokenData.rewards_ges = rewardData[index];
tokenData.rewards_sacrifice = sacrificeRewards; tokenData.rewards_clan = clanwin;
rewards_clan = rewards_clan + BigInt(clanwin / BigInt(Math.pow(10, token.decimals))); tokenData.rewards_sacrifice = sacrificeRewards;
rewards_sacrifice = rewards_clan = rewards_clan + BigInt(clanwin / BigInt(Math.pow(10, token.decimals)));
rewards_sacrifice + BigInt(sacrificeRewards / BigInt(Math.pow(10, token.decimals)));; rewards_sacrifice =
} rewards_sacrifice + BigInt(sacrificeRewards / BigInt(Math.pow(10, token.decimals)));
}
tokenArray.push(tokenData); tokenArray.push(tokenData);
} }
console.log("Math.pow(10, tokenStore.memeToken.decimals)", Math.pow(10, tokenStore.memeToken.decimals)); const goalInBLD = await memeBurnerStore.getGoalInBLD(this.activeRound);
console.log("goal", goal);
this.rounds[this.activeRound] = { this.rounds[this.activeRound] = {
goal: goal, goal: goal.goal,
rewards_clan: rewards_clan, goalInBLD: goalInBLD /Math.pow(10, tokenStore.memeToken.decimals),
expirationTimestamp: goal.expirationTimestamp,
rewards_clan: rewards_clan,
rewards_sacrifice: rewards_sacrifice, rewards_sacrifice: rewards_sacrifice,
token: tokenArray, rewards_total: rewards_clan + rewards_sacrifice,
}; token: tokenArray,
};
} else { } else {
console.log("round already filled"); console.log("round already filled");
} }
+18 -4
View File
@@ -15,10 +15,26 @@ export const useWalletStore = defineStore("wallet", {
}, },
actions: { actions: {
async init() { async init() {
console.log("wallet init");
await this.isConnected();
const goerliKey = import.meta.env.VITE_GOERLI_KEY; const goerliKey = import.meta.env.VITE_GOERLI_KEY;
if (this.connected) { if (this.connected) {
const web3 = new Web3(window.ethereum); const web3 = new Web3(window.ethereum);
this.web3 = markRaw(web3); this.web3 = markRaw(web3);
console.log("hierabc");
window.ethereum.on("accountsChanged", async (data) => {
console.log("accountsChanged", data);
console.log("data", data);
if (data.length > 0) {
this.address = data[0]
this.connected = true;
} else {
this.address = null;
this.connected = false;
}
});
// provider = new ethers.BrowserProvider(window.ethereum); // provider = new ethers.BrowserProvider(window.ethereum);
} else { } else {
const url = `https://eth-goerli.g.alchemy.com/v2/${goerliKey}`; const url = `https://eth-goerli.g.alchemy.com/v2/${goerliKey}`;
@@ -31,9 +47,6 @@ export const useWalletStore = defineStore("wallet", {
new Web3.providers.WebsocketProvider(`wss://eth-goerli.g.alchemy.com/v2/${goerliKey}`) new Web3.providers.WebsocketProvider(`wss://eth-goerli.g.alchemy.com/v2/${goerliKey}`)
); );
}, },
increment() {
this.count++;
},
connectWallet() { connectWallet() {
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
// if (window.ethereum) { // if (window.ethereum) {
@@ -43,6 +56,7 @@ export const useWalletStore = defineStore("wallet", {
console.log("data", data); console.log("data", data);
this.address = data[0]; this.address = data[0];
this.connected = true; this.connected = true;
this.init();
}) })
.catch((error) => { .catch((error) => {
if (error.code === 4001) { if (error.code === 4001) {
+42 -42
View File
@@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed, inject, onMounted } from "vue"; import { ref, computed, inject, onMounted, onBeforeUnmount } from "vue";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import SacrificeToken from "@/components/SacrificeToken.vue"; import SacrificeToken from "@/components/SacrificeToken.vue";
import BloodChart from "@/components/BloodChart.vue"; import BloodChart from "@/components/BloodChart.vue";
@@ -15,17 +15,13 @@ const { getCurrentRoundData } = storeToRefs(roundsStore);
const { currentRound, activeRound, rounds } = storeToRefs(roundsStore); const { currentRound, activeRound, rounds } = storeToRefs(roundsStore);
// Import Swiper Vue.js components const days = ref(null);
const swiperInstance = ref(); const hours = ref(null);
import { Navigation } from "swiper"; const minutes = ref(null);
import { Swiper, SwiperSlide } from "swiper/vue"; const seconds = ref(null);
import "swiper/css"; const timer = ref(null);
import "swiper/css/navigation";
const modules = [Navigation]; const modules = [Navigation];
const isMobile = inject("isMobile"); const isMobile = inject("isMobile");
function onSwiper(swiper) {
swiperInstance.value = swiper;
}
async function prevSlide() { async function prevSlide() {
if (activeRound.value > 1) { if (activeRound.value > 1) {
@@ -43,16 +39,40 @@ async function nextSlide() {
onMounted(() => { onMounted(() => {
console.log("getCurrentRoundData", getCurrentRoundData); console.log("getCurrentRoundData", getCurrentRoundData);
timer.value = setInterval(function () {
timeBetweenDates();
}, 1000);
}); });
// const computedRounds = computed(() => { onBeforeUnmount(() => {
// if() clearInterval(timer.value);
// return "" });
// })
// let web3 = new Web3( function timeBetweenDates() {
// "https://eth-goerli.g.alchemy.com/v2/0-W9tOm6v_QP1PfRV8RuBCpWr-qoEbkN" const dateEntered = new Date(getCurrentRoundData.value?.expirationTimestamp * 1000);
// );
if (dateEntered) {
var now = new Date();
var difference = dateEntered.getTime() - now.getTime();
if (difference <= 0) {
clearInterval(timer.value);
} else {
var _seconds = Math.floor(difference / 1000);
var _minutes = Math.floor(_seconds / 60);
var _hours = Math.floor(_minutes / 60);
var _days = Math.floor(_hours / 24);
days.value = _days;
hours.value = _hours % 24;
minutes.value = _minutes % 60;
seconds.value = _seconds % 60;
days.value = ("0" + days.value).slice(-2) + "d";
hours.value = ("0" + hours.value).slice(-2) + "h";
minutes.value = ("0" + minutes.value).slice(-2) + "m";
}
}
}
</script> </script>
<template> <template>
@@ -74,20 +94,6 @@ onMounted(() => {
each cycle's end. each cycle's end.
</div> </div>
<section id="cycle-section" class="container"> <section id="cycle-section" class="container">
<swiper
:slides-per-view="1"
:navigation="true"
:space-between="50"
@swiper="onSwiper"
:modules="modules"
class="cycle-slider"
>
<swiper-slide>Cycle 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
<swiper-slide>Slide 4</swiper-slide>
<swiper-slide>Slide 5</swiper-slide>
</swiper>
<div class="slider-wrapper"> <div class="slider-wrapper">
<font-awesome-icon <font-awesome-icon
:class="{ 'slider-prev': true, disabled: roundsStore.activeRound <= 1 }" :class="{ 'slider-prev': true, disabled: roundsStore.activeRound <= 1 }"
@@ -142,18 +148,18 @@ onMounted(() => {
<div class="cycle-end-text">A cycle ends when only one of these goals is reached.</div> <div class="cycle-end-text">A cycle ends when only one of these goals is reached.</div>
<div class="bloodline-border"> <div class="bloodline-border">
<table> <table>
{{
getCurrentRoundData?.goal
}}
<tr> <tr>
<td>Sacrifice:</td> <td>Sacrifice:</td>
<td class="divider"></td> <td class="divider"></td>
<td>200b $BLOOD</td> <td>{{ getCurrentRoundData?.goalInBLD?.toFixed(2) }} $BDL</td>
</tr> </tr>
<tr> <tr>
<td>Time left:</td> <td>Time left:</td>
<td class="divider"></td> <td class="divider"></td>
<td>23h 59m</td> <td v-if="currentRound === roundsStore.activeRound">
{{ days }} {{ hours }} {{ minutes }}
</td>
<td v-else>0</td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -249,12 +255,6 @@ onMounted(() => {
text-align: center text-align: center
padding-top: 10px padding-top: 10px
.cycle-slider
text-align: center
.swiper-button-next
right: 30%
.swiper-button-prev
left: 30%
.slider-wrapper .slider-wrapper
display: flex display: flex