From 6e4a3eb5035f85c004da74cc6a23f4fd00d9cb8b Mon Sep 17 00:00:00 2001 From: raj6939 Date: Fri, 13 Jan 2023 21:15:54 +0530 Subject: [PATCH 1/2] fixed bugs in issues/1866 --- .../components/PrizeEventActionConfig.vue | 4 ++ .../marketPlaceSlider/marketPlaceSlide.vue | 61 ++++++++----------- .../ActionInputs/RewardClaimAction.vue | 33 +++++----- src/views/participant/Event.vue | 6 +- 4 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/components/admin/createProjectSlider/components/PrizeEventActionConfig.vue b/src/components/admin/createProjectSlider/components/PrizeEventActionConfig.vue index 99aa0179..28518537 100644 --- a/src/components/admin/createProjectSlider/components/PrizeEventActionConfig.vue +++ b/src/components/admin/createProjectSlider/components/PrizeEventActionConfig.vue @@ -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", { diff --git a/src/components/admin/marketPlaceSlider/marketPlaceSlide.vue b/src/components/admin/marketPlaceSlider/marketPlaceSlide.vue index afe357d1..1d232975 100644 --- a/src/components/admin/marketPlaceSlider/marketPlaceSlide.vue +++ b/src/components/admin/marketPlaceSlider/marketPlaceSlide.vue @@ -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) { @@ -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() } }, @@ -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: '', @@ -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 = []; @@ -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 @@ -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) @@ -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() { @@ -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 @@ -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() } diff --git a/src/components/participant/ActionInputs/RewardClaimAction.vue b/src/components/participant/ActionInputs/RewardClaimAction.vue index 01ee1cc7..65535551 100644 --- a/src/components/participant/ActionInputs/RewardClaimAction.vue +++ b/src/components/participant/ActionInputs/RewardClaimAction.vue @@ -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 { @@ -171,28 +169,22 @@ export default { } ele.forEach((x)=>{ groupName = el.title - swal_html = swal_html + ``+ groupName +`` - 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 + ``+ groupName +`` + x.whiteListedAddress.forEach((y, index) => { + let rank = index+1 swal_html = swal_html + `
- + - avatar + `+ rank +` ` + y.destination + ` ` + - this.friendlyValue(y.value) + + this.friendlyValue(y.value,x.decimals) + `
`; }); @@ -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) { @@ -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({ diff --git a/src/views/participant/Event.vue b/src/views/participant/Event.vue index 2d311385..cb691c67 100644 --- a/src/views/participant/Event.vue +++ b/src/views/participant/Event.vue @@ -500,11 +500,11 @@ export default { var swal_html = `
`; data.forEach((element, index) => { - let img1 = this.getTokenIcon(index+1) + let userRank = index+1 swal_html=swal_html+`
- + - avatar + `+ userRank +` `+element.name+` From e10b62fb01c1e41a1add457ff3a374b89e68cbc0 Mon Sep 17 00:00:00 2001 From: raj6939 Date: Fri, 13 Jan 2023 21:18:59 +0530 Subject: [PATCH 2/2] removed config for finance.vote --- src/config.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/config.js b/src/config.js index 6a4acae3..920c87bc 100644 --- a/src/config.js +++ b/src/config.js @@ -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 \ No newline at end of file