Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validation added for custom contract #1812

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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