Skip to content

Commit

Permalink
Merge pull request #1812 from /issues/1741
Browse files Browse the repository at this point in the history
validation added for custom contract
  • Loading branch information
Raj6939 authored Nov 29, 2022
2 parents 870bbc7 + d1b1f8e commit ffa8ef0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ import {
isEmpty,
isValidURL,
truncate,
isContractValid
} from "../../../../mixins/fieldValidationMixin";
import Messages from "../../../../utils/messages/admin/en";
import config from "../../../../config"
Expand Down Expand Up @@ -330,7 +331,7 @@ export default {
return {
appName: config.appName,
allCondition: [
{ text: "None", value: null },
{ text: "Operator", value: null },
{ text: "=", value: "===" },
{ text: ">", value: ">" },
{ text: "<", value: "<" },
Expand Down Expand Up @@ -364,7 +365,7 @@ export default {
contractABI: "",
methods: null,
operand: null,
operator: "",
operator: null,
returnType: "",
},
selected: {
Expand Down Expand Up @@ -441,7 +442,7 @@ export default {
contractABI: "",
methods: null,
operand: null,
operator: "",
operator: null,
returnType: "",
};
this.selected = clearData;
Expand All @@ -464,25 +465,40 @@ export default {
this.notifyErr(
Messages.EVENTS.ACTIONS.SMARTCONTRACT.CHOOSE_CONTRACT_TYPE
);
}else if (this.contract.methods===null || isEmpty(this.contract.methods)) {
} else if (isEmpty(this.contract.contractAddress)) {
isvalid = false;
this.notifyErr(
Messages.EVENTS.ACTIONS.SMARTCONTRACT.METHODS_EMPTY
Messages.EVENTS.ACTIONS.SMARTCONTRACT.ADDRESS_NOT_EMPTY
);
} else if (isEmpty(this.contract.contractAddress)) {
} else if (!isContractValid(this.contract.contractAddress)) {
isvalid = false;
this.notifyErr(
Messages.EVENTS.ACTIONS.SMARTCONTRACT.ADDRESS_NOT_EMPTY
);
Messages.EVENTS.ACTIONS.SMARTCONTRACT.VALID_CONTRACT_ADDRESS
)
} else if (isEmpty(this.contract.contractABI)) {
isvalid = false;
this.notifyErr(
Messages.EVENTS.ACTIONS.SMARTCONTRACT.ABI_NOT_EMPTY
)
}else if (isValidURL(this.selected.title)) {
} else if (this.contract.methods===null || isEmpty(this.contract.methods)) {
isvalid = false;
this.notifyErr(
Messages.EVENTS.ACTIONS.SMARTCONTRACT.METHODS_EMPTY
);
} else if (this.contract.operator === null) {
isvalid = false;
this.notifyErr(
Messages.EVENTS.ACTIONS.CUSTOM_CONTRACT.SELECT_OPERATOR
);
} else if (isEmpty(this.contract.operand)) {
isvalid = false;
this.notifyErr(
Messages.EVENTS.ACTIONS.CUSTOM_CONTRACT.ENTER_CONDITION_VALUE
)
} else if (isValidURL(this.selected.title)) {
isvalid = false;
this.notifyErr(Messages.EVENTS.ACTIONS.TITLE_URL);
}else if (isEmpty(this.selected.title)) {
} else if (isEmpty(this.selected.title)) {
isvalid = false;
this.notifyErr(Messages.EVENTS.ACTIONS.EMPTY_TITLE);
} else if (isNaN(parseInt(this.selected.score))) {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/messages/admin/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const EVENTS = {
THBALANCE_NOT_NEGATIVE: "Enter the Threshold balance that should be a Positive Number",
VALID_CONTRACT_ADDRESS: "Please enter valid Contract address"
},
CUSTOM_CONTRACT: {
SELECT_OPERATOR: "Select operator",
ENTER_CONDITION_VALUE: "Enter condition value"

},

PRIZECARD: {
PRIZE_TYPE: "Please select prize type",
Expand Down

0 comments on commit ffa8ef0

Please sign in to comment.