Skip to content

Commit

Permalink
Merge pull request #1868 from /issues/1866
Browse files Browse the repository at this point in the history
Issues/1866
  • Loading branch information
Raj6939 authored Jan 13, 2023
2 parents 1346623 + e10b62f commit abcffb8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ export default {
},
handleEventActionDelete() {
// Code to delete an Action
const data = {...this.prizeDetails}
if(data.hasOwnProperty('isDistributed') && data.isDistributed=== true) {
return this.notifyErr('Reward has been distributed for this prize you cannot delete it!')
}
const actionToDelete = this.eventActionList[this.currentSelectedId];
this.eventActionList.splice(this.currentSelectedId, 1);
this.$emit("updateEventActions", {
Expand Down
61 changes: 26 additions & 35 deletions src/components/admin/marketPlaceSlider/marketPlaceSlide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,12 @@ export default {
this.depositTokenAddress = "";
this.selectedChain = null
this.files = null
this.showDismissibleAlert.status = false
this.simpleData=""
},
getFriendlyValue(str) {
const toEthStd = utils.fromWei(str.toString(), "ether").toString();
const rounded = Number(toEthStd).toFixed(4)
const convertToDecimal = Number(str)/Number(10 ** this.feeStructure.decimals)
const rounded = Number(convertToDecimal).toFixed(4)
return rounded
},
getRoundOffValue(num) {
Expand All @@ -493,7 +495,7 @@ export default {
async onSelectChain(e) {
if(e===null) {
return this.notifyErr('Select Chain')
} if(this.depositTokenAddress!=="" && this.simpleData!=="") {
} if(this.depositTokenAddress!=="" && this.simpleData!=="") {
await this.calculateFee()
}
},
Expand All @@ -504,14 +506,14 @@ export default {
if (this.depositTokenAddress === "") {
return(this.notifyErr('Enter token Address'))
} if(!checkWalletAddress.validate(this.depositTokenAddress,'Ethereum','eth')){
return(this.notifyErr('Enter valid contract address'))
return(this.notifyErr('Enter valid token address'))
}
if(this.simpleData!=='') {
await this.calculateFee()
}
},
async calculateFee() {
try{
this.proceed = false
this.feeStructure = {
fyrePlatformCommision: '',
Expand All @@ -520,28 +522,17 @@ export default {
symbol: "",
decimal:0
}
this.isCheckEveryThing=false
// this.onSelectChain(this.selectedChain)
// this.checkContractAddress()
if (this.selectedChain === null) {
// this.showDismissibleAlert.status = true
// this.showDismissibleAlert.text = 'Select Chain'
throw new Error(this.notifyErr('Select Chain'))
this.isCheckEveryThing=false
if (this.selectedChain === null) {
return (this.notifyErr('Select Chain'))
} if (this.depositTokenAddress === "") {
// this.showDismissibleAlert.status = true
// this.showDismissibleAlert.text = 'Enter Contract Address'
throw new Error(this.notifyErr('Enter token Address'))
return (this.notifyErr('Enter token Address'))
}
if (this.simpleData === "") {
this.showDismissibleAlert.status = true
this.showDismissibleAlert.text = 'Enter Wallet addresses and respective token value'
}
try{
const web3 = await loadweb3(this.selectedChain)
const contract = new web3.eth.Contract(erc20ABI, this.depositTokenAddress);
this.feeStructure.symbol = await contract.methods.symbol().call();
this.feeStructure.decimal = await contract.methods.decimals().call();
var allTextLines = this.simpleData.split(/\r\n|\n/);
//Split per line on tabs and commas
this.locations = [];
Expand All @@ -556,14 +547,8 @@ export default {
this.showDismissibleAlert.status = true
return this.showDismissibleAlert.text = `Distribution list contains invalid address at line ${i+1}`
}
// if(data[1]==="") {
// this.showDismissibleAlert.status = true
// return this.showDismissibleAlert.text = 'Enter token value'
// }
if(Number(data[1]) && Number(data[1])>0) {
const inwei = BigInt((data[1] * 10 ** this.feeStructure.decimal)).toString();
let location = { "destination": data[0], "value": inwei.toString(), };
if(Number(data[1]) && Number(data[1])>0) {
let location = { "destination": data[0], "value": data[1].toString() };
this.locations.push(location);
}else{
this.showDismissibleAlert.status = true
Expand All @@ -573,12 +558,10 @@ export default {
//Final Data
if (this.locations.length < JSON.parse(this.flash.value).winners) {
this.showDismissibleAlert.status = true
return this.showDismissibleAlert.text = 'Number of winners entered are less than you mentioned in Prize'
// throw new Error(this.notifyErr('Number of winners entered are less than you mentioned in Prize'))
return this.showDismissibleAlert.text = 'Number of winners entered are less than you mentioned in Prize'
} else if (this.locations.length > JSON.parse(this.flash.value).winners) {
this.showDismissibleAlert.status = true
return this.showDismissibleAlert.text = 'Number of winners entered are more than you mentioned in Prize'
// throw new Error(this.notifyErr('Number of winners entered are more than you mentioned in Prize'))
return this.showDismissibleAlert.text = 'Number of winners entered are more than you mentioned in Prize'
} else {
this.showDismissibleAlert.status=false
const chainIdd = parseInt(this.selectedChain)
Expand Down Expand Up @@ -608,16 +591,21 @@ export default {
this.feeStructure.totalAmountToDistribute = res.totalAmountToPay.toString()
this.feeStructure.fyrePlatformCommision = res.serviceFee.toString()
this.feeStructure.serviceFeePercente = res.serviceFeePercent
this.feeStructure.decimals = res.decimals
this.feeStructure.symbol = res.symbol
delete res.serviceFee
delete res.serviceFeePercent
delete res.totalAmountToPay
delete res.decimals
delete res.eventId
delete res.symbol
const dataToUploadToBlockchain = res
this.newData = { ...dataToUploadToBlockchain }
this.proceed = true
this.isCheckEveryThing = true
}
}catch(e) {
this.notifyErr(e.message);
this.notifyErr(e);
}
},
async createDistribution() {
Expand Down Expand Up @@ -677,7 +665,9 @@ export default {
parsedValue["externalRecordId"] = dbTreeId.toString()
parsedValue["contractAddress"] = this.depositTokenAddress.toString()
parsedValue["appBaseUrl"] = this.selectedTool.meta.appBaseUrl.toString()
parsedValue["chainId"] = this.selectedChain
parsedValue["chainId"] = this.selectedChain
parsedValue["decimals"] = this.feeStructure.decimals.toString()
parsedValue["symbol"] = this.feeStructure.symbol
this.flash.value = JSON.stringify(parsedValue)
const index = this.eventToAirdrop.actions.findIndex((x) => {
return x._id === this.flash._id
Expand Down Expand Up @@ -722,6 +712,7 @@ export default {
eventId: this.eventToAirdrop._id,
actionId: this.flash._id,
whiteListedAddress: [...this.newData.inputData],
decimals:this.feeStructure.decimals,
externalAppId: dbTreeId,
totalAmountToDistribute: this.feeStructure.totalAmountToDistribute.toString()
}
Expand Down
33 changes: 14 additions & 19 deletions src/components/participant/ActionInputs/RewardClaimAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ import notificationMixins from "../../../mixins/notificationMixins";
import axios from "axios";
import { utils } from "web3";
import profileIconMixins from "../../../mixins/profileIconMixins";
import { erc20ABI } from "../../../mixins/ERC20ContractAbi";
// import HfNotes from "../../elements/HfNotes.vue";
import config from "../../../config";
import { truncate } from "../../../mixins/fieldValidationMixin";
export default {
Expand Down Expand Up @@ -171,28 +169,22 @@ export default {
}
ele.forEach((x)=>{
groupName = el.title
swal_html = swal_html + `<strong class="grpName pt-3" style="text-align: left;">`+ groupName +`</strong>`
let objectToRemove = x.whiteListedAddress.findIndex((x)=>{
return x.destination === config.marketPlace.fyre_wallet_address
})
x.whiteListedAddress.splice(objectToRemove,1)
x.whiteListedAddress.forEach((y, index) => {
let img1 = this.getTokenIcon(index+1);
swal_html = swal_html + `<strong class="grpName pt-3" style="text-align: left;">`+ groupName +`</strong>`
x.whiteListedAddress.forEach((y, index) => {
let rank = index+1
swal_html =
swal_html +
`<div class="list-group-item d-flex align-items-center">
<span class="b-avatar mr-3 badge-info rounded-circle">
<span class="b-avatar mr-3 badge-success rounded-circle">
<span class="b-avatar-img">
<img src="` +
img1 +
`" alt="avatar">
<span class="badge circle circle-md bg-success">`+ rank +`</span>
</span><!---->
</span>
<span class="mr-auto">` +
y.destination +
`</span>
<span class="badge badge-primary">` +
this.friendlyValue(y.value) +
this.friendlyValue(y.value,x.decimals) +
`</span>
</div> `;
});
Expand All @@ -213,8 +205,12 @@ export default {
});
this.isLoading = false;
},
friendlyValue(str) {
const toEthStd = utils.fromWei(str.toString(), "ether").toString();
friendlyValue(str,decimal) {
let decimalCount = 18
if(!(isNaN(decimal) || decimal === undefined)){
decimalCount = decimal
}
const toEthStd = Number(str)/Number(10 ** decimalCount)
return toEthStd;
},
async importToken(data) {
Expand All @@ -223,9 +219,8 @@ export default {
const chainIdFromData = JSON.parse(data.value).chainId
const web3 = await loadweb3(chainIdFromData);
const tokenAddress = JSON.parse(data.value).contractAddress;
const contract = new web3.eth.Contract(erc20ABI, tokenAddress);
const tokenSymbol = await contract.methods.symbol().call();
const tokenDecimals = await contract.methods.decimals().call();
const tokenDecimals = JSON.parse(data.value).decimals;
const tokenSymbol = JSON.parse(data.value).symbol;
const tokenImage = this.getTokenIcon(tokenSymbol);
// wasAdded is a boolean. Like any RPC method, an error may be thrown.
const wasAdded = await web3.currentProvider.request({
Expand Down
5 changes: 0 additions & 5 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ const config = {
moopay:{
payment_url:process.env.VUE_APP_MOOPAY_PAYMENT_URL,
},
marketPlace:{
// create_merkel_tree_finance_vote:process.env.VUE_APP_FINANCE_VOTE || 'https://bank.influencebackend.xyz',
fyre_wallet_address:process.env.VUE_APP_FYRE_WALLET_ADDRESS

}
}

export default config
6 changes: 3 additions & 3 deletions src/views/participant/Event.vue
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,11 @@ export default {
var swal_html = `<div class="list-group list-group-flush" style="max-height:500px;overflow-y: scroll;">`;
data.forEach((element, index) => {
let img1 = this.getTokenIcon(index+1)
let userRank = index+1
swal_html=swal_html+`<div class="list-group-item d-flex align-items-center">
<span class="b-avatar mr-3 badge-info rounded-circle">
<span class="b-avatar mr-3 badge-success rounded-circle">
<span class="b-avatar-img">
<img src="`+img1+`" alt="avatar">
<span class="badge circle circle-md bg-success">`+ userRank +`</span>
</span><!---->
</span>
<span class="mr-auto">`+element.name+`</span>
Expand Down

0 comments on commit abcffb8

Please sign in to comment.