Skip to content

Commit

Permalink
Merge pull request #1010 from hypersign-protocol/nft-frontend
Browse files Browse the repository at this point in the history
Nft frontend
  • Loading branch information
Pratap2018 authored Mar 8, 2022
2 parents 647a8fc + ffe8f97 commit 4846332
Show file tree
Hide file tree
Showing 12 changed files with 3,479 additions and 942 deletions.
225 changes: 225 additions & 0 deletions MaticErc20.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
<template>
<b-card no-body class="action-wrap">
<b-card-header
:class="visible ? null : 'collapsed'"
:aria-expanded="visible ? 'true' : 'false'"
:aria-controls="`collapse-${idValue}`"
@click="visible = !visible"
>
<b-row>
<b-col cols="1" sm="1" md="1">
<img src="../../../assets/matic-logo.svg" height="25px" />
</b-col>
<b-col cols="9" sm="9" class="text-left" md="9">
<div class="text text-capitalize">{{ data.title }}</div>
</b-col>

<b-col cols="2" sm="2" md="2">
<b-badge class="btn-score" @click="update()" v-if="!done">
<img src="../../../assets/plus.svg" />
{{ data.score }}
</b-badge>
<img
class="check-mark"
src="../../../assets/check-circle-fill.svg"
height="25px"
v-if="done"
/>
</b-col>
</b-row>
</b-card-header>
<b-collapse :id="`collapse-${idValue}`" v-model="visible">
<b-card-body class="user-details">
<b-row v-if="!showerror">
<b-col cols="12" sm="12" md="12">
<div class="metamask">
<b-form-input
type="text"
:placeholder="data.placeHolder"
v-model="value.userWalletAddress"
:disabled="true"
:required="data.isManadatory"
></b-form-input>
<button class="btn text-black" @click="invokeMetamask()" v-if="!done" >
<img
src="../../../assets/metamask.svg"
height="25px"
width="25px"
/>
</button>
</div>
</b-col>
</b-row>
<b-row v-else>
<b-col cols="12" sm="12" md="12">
<ErrorMessage errorMessage="Install Metamask browser extension" />
</b-col>
</b-row>
<b-row v-if="!done">
<b-col cols="12" sm="12" md="12" >
<button class="btn btn-link center" @click="update()">Continue</button>
</b-col>
</b-row>
</b-card-body>
</b-collapse>
</b-card>
</template>
<style scoped>
.center{
display: block; margin-left: auto;margin-right: auto
}
</style>

<script>
import eventBus from "../../../eventBus.js";
import apiClient from "../../../mixins/apiClientMixin.js";
import {
isValidURL,
isValidText,
isEmpty,
} from "../../../mixins/fieldValidationMixin";
import notificationMixins from "../../../mixins/notificationMixins";
import Messages from "../../../utils/messages/participants/en";
import ErrorMessage from "../ErrorMessage.vue";
import Web3 from "web3";
export default {
name: "MaticErc20",
props: {
idValue: {
required: true,
},
data: {
required: true,
},
},
components: {
ErrorMessage,
},
data() {
return {
visible: false,
done: this.data.isDone,
authToken: localStorage.getItem("authToken"),
showerror: false,
signature: "",
message_sign: "",
value: {
contractAddress: "",
userWalletAddress: "",
thresholdBalance: 0
}
};
},
mounted() {
if(this.data.value){
Object.assign(this.value, {...JSON.parse(this.data.value) })
}
eventBus.$on(`disableInput${this.data._id}`, this.disableInput);
this.checkWeb3Injection();
},
methods: {
checkWeb3Injection() {
try {
if (ethereum && ethereum.isMetaMask) {
this.web3 = new Web3(window.ethereum);
}
} catch (error) {
console.log(error);
this.showerror = true;
}
},
async signMessage() {
const message =
"You are Signing this message to ensure your participation in this event";
this.message_sign = message;
return await this.web3.eth.personal.sign(
message,
ethereum.selectedAddress
);
},
async invokeMetamask() {
try {
if (ethereum.isMetaMask) {
const wallet = await ethereum.request({
method: "eth_requestAccounts",
});
this.signature = await this.signMessage();
const generatedWalletAddr = await this.web3.eth.personal.ecRecover(this.message_sign, this.signature)
if(generatedWalletAddr === wallet[0]){
this.value.userWalletAddress = wallet[0];
} else{
return this.notifyErr(Messages.EVENT_ACTIONS.ETH.INVALID_SIG)
}
}
} catch (error) {
return this.notifyErr(error.message)
}
},
async update() {
if (!this.isFieldValid() || this.value.userWalletAddress === "") {
return this.notifyErr(Messages.EVENT_ACTIONS.ETH.CONNECT_METAMASK);
} else {
try {
let balance = await this.fetchBalance();
if (balance !== undefined) {
if (balance >= Number.parseFloat(this.value.thresholdBalance)) {
this.$emit("input", JSON.stringify({
...this.value,
}));
} else {
throw new Error(Messages.EVENT_ACTIONS.ETH.INSUFFICIENT_BALANCE);
}
}
} catch (error) {
this.data.value = ""
return this.notifyErr(error);
}
}
},
isFieldValid() {
if (isEmpty(this.value.userWalletAddress)) {
return false;
}
if (isValidURL(this.value.userWalletAddress)) {
return false;
}
if (!isValidText(this.value.userWalletAddress)) {
return false;
}
return true;
},
async fetchBalance() {
const body = {
actionType: this.data.type,
data: this.value.userWalletAddress,
contractAddress: this.value.contractAddress,
signature: this.signature,
message: this.message_sign,
};
let url = `${this.$config.studioServer.BASE_URL}api/v1/action/contract/call`;
let headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${this.authToken}`,
};
const res = await apiClient.makeCall({
method: "POST",
url: url,
body: body,
header: headers,
});
const result = res.data;
return result;
},
disableInput(data) {
this.done = data;
},
},
mixins: [notificationMixins],
};
</script>
45 changes: 25 additions & 20 deletions src/components/admin/createProjectSlider/CreateProjectSlide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
block
v-b-toggle.accordion-1
class="bg-transparent border-0 text-left text-primary"
title="Create General configuration for your event"
title="Create General configuration for your event"
><i class="fas fa-cog"></i> General Configurations</b-button
>
</b-card-header>
Expand Down Expand Up @@ -81,7 +81,7 @@
v-b-toggle.accordion-2
variant="info"
class="bg-transparent border-0 text-left text-primary"
title="Create Referral configuration for your event"
title="Create Referral configuration for your event"
><i class="fa fa-user-plus"></i> Referral Configurations
</b-button>
</b-card-header>
Expand Down Expand Up @@ -112,7 +112,7 @@
block
v-b-toggle.accordion-3
class="bg-transparent border-0 text-left text-primary"
title="Create Prize configuration for your event"
title="Create Prize configuration for your event"
><i class="fas fa-gift"></i> Prize Configurations
</b-button>
</b-card-header>
Expand Down Expand Up @@ -144,7 +144,7 @@
v-b-toggle.accordion-4
variant="info"
class="bg-transparent border-0 text-left text-primary"
title="Create Custom Inputs configuration for your event"
title="Create Custom Inputs configuration for your event"
><i class="fab fa-intercom"></i> Custom Inputs Configurations
</b-button>
</b-card-header>
Expand Down Expand Up @@ -206,7 +206,7 @@
v-b-toggle.accordion-6
variant="info"
class="bg-transparent border-0 text-left text-primary"
title="Create Wallet configuration for your event"
title="Create Wallet configuration for your event"
><i class="fab fa-bitcoin"></i> Wallet Configurations
</b-button>
</b-card-header>
Expand Down Expand Up @@ -238,7 +238,7 @@
v-b-toggle.accordion-7
variant="info"
class="bg-transparent border-0 text-left text-primary"
title="Create Smart contract configuration for your event"
title="Create Smart contract configuration for your event"
><i class="fas fa-file-contract"></i> Smart Contract
Configurations
</b-button>
Expand Down Expand Up @@ -356,26 +356,27 @@ export default {
isProjectEditing: {
type: Boolean,
},
tagList:{
tagList: {
type: Array,
},
tagFdb:{
tagFdb: {
type: Array,
}
},
},
computed: {
// a computed getter
getTagDb: function () {
if(this.tagFdb && this.tagFdb.length >0){
for(let index = 0; index < this.tagFdb.length; index++){
if (this.tagFdb && this.tagFdb.length > 0) {
for (let index = 0; index < this.tagFdb.length; index++) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.options.tagDetails.push({
text:this.tagFdb[index].tagName, value:this.tagFdb[index].type
})
text: this.tagFdb[index].tagName,
value: this.tagFdb[index].type,
});
}
return this.options.tagDetails
}
else{
return this.options.tagDetails;
} else {
return [];
}
},
Expand Down Expand Up @@ -461,7 +462,6 @@ export default {
{ text: "LINK", value: "INPUT_HYPERLINK" },
{ text: "HYPERLINK", value: "HYPERLINK_URL" },
{ text: "INFO", value: "INFO_TEXT" },
],
socialAction: [
{ text: "Select Social Action type", value: null },
Expand All @@ -483,20 +483,25 @@ export default {
smartContractAction: [
{ text: "Select Contract Type", value: null },
{ text: "Ethereum ERC20", value: "ETHEREUM_ERC20" },
{ text: "Ethereum ERC721", value: "ETHEREUM_ERC721" },
{ text: "Polygon ERC20", value: "MATIC_ERC20" },
{ text: "Polygon ERC721", value: "MATIC_ERC721" },
{ text: "Binance ERC20", value: "BINANCE_ERC20" },
{ text: "Binance ERC721", value: "BINANCE_ERC721" },
{ text: "Moon Beam ERC20", value: "MOONBEAM_ERC20" },
{ text: "Moon Beam ERC721", value: "MOONBEAM_ERC721" },
{ text: "Moon River ERC20", value: "MOONRIVER_ERC20" },
{ text: "Moon River ERC721", value: "MOONRIVER_ERC721" },
{ text: "Moon Alpha(testnet) ERC20", value: "MOON_ERC20" },
{ text: "Moon Alpha(testnet) ERC721", value: "MOON_ERC721" },
{ text: "Reef ERC20", value: "REEF_ERC20" },
{ text: "Reef ERC721", value: "REEF_ERC721" },
],
prizeDetails: [
{ text: "Select Prize Type", value: null },
{ text: "Prize Card", value: "PRIZE_CARD" },
],
tagDetails: [
{ text: "Select Tag Type", value: null },
],
tagDetails: [{ text: "Select Tag Type", value: null }],
},
};
},
Expand Down
Loading

0 comments on commit 4846332

Please sign in to comment.