diff --git a/packages/concordia-app/src/components/PollCreate/index.jsx b/packages/concordia-app/src/components/PollCreate/index.jsx index f631cdc..1b0219e 100644 --- a/packages/concordia-app/src/components/PollCreate/index.jsx +++ b/packages/concordia-app/src/components/PollCreate/index.jsx @@ -15,7 +15,7 @@ import { breeze, drizzle } from '../../redux/store'; import { TRANSACTION_ERROR, TRANSACTION_SUCCESS } from '../../constants/TransactionStatus'; import './styles.css'; import { POLL_OPTIONS, POLL_QUESTION } from '../../constants/orbit/PollsDatabaseKeys'; -import generateHash from '../../utils/hashUtils'; +import generatePollHash from '../../utils/hashUtils'; const { contracts: { [VOTING_CONTRACT]: { methods: { createPoll } } } } = drizzle; const { orbit: { stores } } = breeze; @@ -96,7 +96,7 @@ const PollCreate = forwardRef((props, ref) => { useImperativeHandle(ref, () => ({ createPoll(topicId) { setCreating(true); - const dataHash = generateHash(JSON.stringify({ question, optionValues })); + const dataHash = generatePollHash(question, optionValues); setCreatePollCacheSendStackId(createPoll.cacheSend( ...[topicId, options.length, dataHash, allowVoteChanges], { from: account }, )); diff --git a/packages/concordia-app/src/utils/hashUtils.js b/packages/concordia-app/src/utils/hashUtils.js index 3a6d269..a4d31d1 100644 --- a/packages/concordia-app/src/utils/hashUtils.js +++ b/packages/concordia-app/src/utils/hashUtils.js @@ -1,7 +1,8 @@ import sha256 from 'crypto-js/sha256'; -function generateHash(message) { - return sha256(message).toString().substring(0, 16); -} +const generateHash = (message) => sha256(message).toString().substring(0, 16); -export default generateHash; +const generatePollHash = (pollQuestion, pollOptions) => generateHash(JSON + .stringify({ question: pollQuestion, optionValues: pollOptions })); + +export default generatePollHash;