Skip to content

Commit

Permalink
AP claim
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Oct 3, 2023
1 parent a8f3625 commit 0ccee7e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div>
<p class="text-center">
Claim {{ airdropPostMinting }} {{ $config.chatTokenSymbol }} airdrop for doing post minting in the past.
Claim {{ airdropAp }} {{ $config.chatTokenSymbol }} airdrop for past activity points.
</p>

<!-- Input field -->
<div class="input-group mt-5">
<input
v-model="airdropPostMinting"
v-model="airdropAp"
type="text"
class="form-control"
disabled
Expand All @@ -21,7 +21,7 @@
<!-- Claim button -->
<div class="d-flex justify-content-center mt-4 mb-4">
<button
:disabled="waiting || loadingData || airdropPostMinting == 0"
:disabled="waiting || loadingData || airdropAp == 0"
class="btn btn-outline-primary"
type="button"
@click="claim"
Expand Down Expand Up @@ -49,8 +49,8 @@ import WaitingToast from "~/components/WaitingToast";
import { useUserStore } from '~/store/user';
export default {
name: 'AirdropPostMinters',
props: [ "airdropPostMintingWei", "loadingData" ],
name: 'AirdropActivityPoints',
props: [ "airdropApWei", "loadingData" ],
emits: [ "setDomainChatRewardWeiToZero" ],
data() {
Expand All @@ -60,27 +60,27 @@ export default {
},
computed: {
airdropPostMinting() {
return Math.floor(Number(ethers.utils.formatEther(this.airdropPostMintingWei)));
airdropAp() {
return Math.round(Number(ethers.utils.formatEther(this.airdropApWei)));
}
},
methods: {
async claim() {
this.waiting = true;
const claimPostMintersInterface = new ethers.utils.Interface([
const claimApInterface = new ethers.utils.Interface([
"function claim() external"
]);
const claimPostMintersContract = new ethers.Contract(
this.$config.airdropPostMintersAddress,
claimPostMintersInterface,
const claimApContract = new ethers.Contract(
this.$config.airdropApAddress,
claimApInterface,
this.signer
);
try {
const tx = await claimPostMintersContract.claim();
const tx = await claimApContract.claim();
const toastWait = this.toast(
{
Expand All @@ -100,11 +100,11 @@ export default {
if (receipt.status === 1) {
this.toast.dismiss(toastWait);
this.userStore.addToChatTokenBalanceWei(this.airdropPostMintingWei);
this.userStore.addToChatTokenBalanceWei(this.airdropApWei);
this.$emit("setDomainChatRewardWeiToZero");
this.toast("Airdrop for minting posts in the past has been successfully claimed!", {
this.toast("Airdrop for past APs has been successfully claimed!", {
type: "success",
onClick: () => window.open(this.$config.blockExplorerBaseUrl+"/tx/"+tx.hash, '_blank').focus()
});
Expand All @@ -128,7 +128,7 @@ export default {
extractMessage = extractMessage.replace('"', "");
extractMessage = extractMessage.replace('"', "");
extractMessage = extractMessage.replace('execution reverted:', "Error:");
extractMessage = extractMessage.replace('ChatTokenClaimDomains: ', "");
extractMessage = extractMessage.replace('ChatTokenClaimActivityPoints: ', "");
console.log(extractMessage);
Expand Down
4 changes: 2 additions & 2 deletions components/sidebars/SidebarLeft.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
</li>

<!-- Airdrop -->
<li class="nav-item p-1" @click="closeLeftSidebar" v-if="($config.airdropClaimDomainsAddress || $config.airdropPostMintersAddress) && $config.showFeatures.airdrop">
<li class="nav-item p-1" @click="closeLeftSidebar" v-if="($config.airdropClaimDomainsAddress || $config.airdropApAddress) && $config.showFeatures.airdrop">
<NuxtLink class="nav-link" :class="$route.path.startsWith('/airdrop') ? 'active' : ''" aria-current="page" to="/airdrop">
<i class="bi bi-gift"></i> Airdrop
</NuxtLink>
Expand Down Expand Up @@ -157,7 +157,7 @@
<ul class="dropdown-menu">
<li class="pt-1 pb-1" @click="closeLeftSidebar" v-if="$config.airdropClaimDomainsAddress || $config.airdropPostMintersAddress">
<li class="pt-1 pb-1" @click="closeLeftSidebar" v-if="$config.airdropClaimDomainsAddress || $config.airdropApAddress">
<NuxtLink class="dropdown-item" :class="$route.path.startsWith('/airdrop') ? 'active' : ''" aria-current="page" to="/airdrop">
<i class="bi bi-gift"></i> Airdrop
</NuxtLink>
Expand Down
6 changes: 3 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default defineNuxtConfig({
public: {
activityPointsAddress: "0x7d20A0E75B1ac519f500a51351bcb01A07fE3D7d",
activityPointsRatio: 1_000_000,
airdropClaimDomainsAddress: "0x3ebDBc1D47d4bFe7D08A58123Ab3c85fC7358831", // chat token claim for domain holders contract address
airdropPostMintersAddress: "0x11608f93Ec226E173754262c04F98Df3Bfaad7Db", // chat token claim for post minters contract address
airdropApAddress: "0x9Fc55DbA8978406FE212B9C8b4672B4B7a110401", // chat token claim for APs
airdropClaimDomainsAddress: "0x3ebDBc1D47d4bFe7D08A58123Ab3c85fC7358831", // chat token claim for domain holders
blockExplorerBaseUrl: "https://mumbai.polygonscan.com",
chatTokenAddress: "0x83C0E6655Ea65363F8B85954afa29F05e257231b", // chat token address
chatTokenImage: "https://bafkreigih3jk3d4fffzml27e7kqyn636t7v646ohxvhv3nzhkzfcmh4prq.ipfs.w3s.link", // chat token image
Expand Down Expand Up @@ -118,7 +118,7 @@ export default defineNuxtConfig({
rpcCustom: process.env.RPC_CUSTOM || "", // Custom RPC URL
showFeatures: { // show/hide features in sidebars (if you have too many "true", make the sidebar scrollable --> sidebarLeftSticky: false)
"activityPoints": true,
"airdrop": false,
"airdrop": true,
"friendKeys": true,
"governance": false,
"newsletter": false,
Expand Down
3 changes: 0 additions & 3 deletions pages/activity-points.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ export default {
async fetchActivityPoints() {
if (this.$config.activityPointsAddress && this.address) {
this.toast.info("Refreshing activity points...", { timeout: 2000 });
const activityPoints = await this.getActivityPoints(this.address);
this.userStore.setCurrentUserActivityPoints(activityPoints);
}
}
Expand Down
30 changes: 15 additions & 15 deletions pages/airdrop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<li class="nav-item">
<button
class="nav-link"
:class="currentTab === 'post' ? 'active' : ''"
@click="changeCurrentTab('post')"
>Post Minters</button>
:class="currentTab === 'ap' ? 'active' : ''"
@click="changeCurrentTab('ap')"
>Activity Points</button>
</li>

</ul>
Expand All @@ -56,11 +56,11 @@
</div>

<!-- Second Tab -->
<div v-if="currentTab === 'post'">
<div v-if="currentTab === 'ap'">
<div class="d-flex justify-content-center mt-5">
<div class="col-12 col-lg-8">
<AirdropPostMinters
:airdropPostMintingWei="airdropPostMintingWei"
<AirdropActivityPoints
:airdropApWei="airdropApWei"
:loadingData="fetchingData"
@setDomainChatRewardWeiToZero="setDomainChatRewardWeiToZero"
/>
Expand All @@ -78,14 +78,14 @@
import { ethers } from 'ethers';
import { useEthers } from 'vue-dapp';
import AirdropDomainHolders from '~/components/airdrop/AirdropDomainHolders.vue';
import AirdropPostMinters from '~/components/airdrop/AirdropPostMinters.vue';
import AirdropActivityPoints from '~/components/airdrop/AirdropActivityPoints.vue';
export default {
name: 'Airdrop',
data() {
return {
airdropPostMintingWei: 0, // the amount of CHAT tokens that user will get for past post minting (unclaimed only)
airdropApWei: 0, // the amount of CHAT tokens that user will get for past APs
currentTab: "domain",
domainChatRewardWei: 100000000000000,
fetchingData: false,
Expand All @@ -94,7 +94,7 @@ export default {
components: {
AirdropDomainHolders,
AirdropPostMinters
AirdropActivityPoints
},
mounted() {
Expand Down Expand Up @@ -133,18 +133,18 @@ export default {
this.domainChatRewardWei = await chatTokenClaimDomainsContract.chatReward();
// preview airdrop claim for minting posts
const claimPostMintersInterface = new ethers.utils.Interface([
// preview airdrop claim for past APs
const claimApInterface = new ethers.utils.Interface([
"function claimPreview(address _address) public view returns (uint256)"
]);
const claimPostMintersContract = new ethers.Contract(
this.$config.airdropPostMintersAddress,
claimPostMintersInterface,
const claimApContract = new ethers.Contract(
this.$config.airdropApAddress,
claimApInterface,
this.signer
);
this.airdropPostMintingWei = await claimPostMintersContract.claimPreview(this.address);
this.airdropApWei = await claimApContract.claimPreview(this.address);
this.fetchingData = false;
},
Expand Down
3 changes: 0 additions & 3 deletions pages/keys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ export default {
this.buyKeyPriceWei = await keysContract.getBuyPriceAfterFee(this.cleanDomainName, 1); // buy only 1 key at a time
console.log("buyKeyPriceWei", this.buyKeyPriceWei);
console.log("buyKeyPrice", ethers.utils.formatEther(this.buyKeyPriceWei));
this.waitingBuy = false;
},
Expand Down

1 comment on commit 0ccee7e

@vercel
Copy link

@vercel vercel bot commented on 0ccee7e Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.