-
Notifications
You must be signed in to change notification settings - Fork 180
Feature/chatbot integration #215
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
4da995e
619f550
0edf12d
5cbe811
5b803c2
636644c
4e92493
e7af19c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,8 +5,8 @@ import styles from './CreateProcessPage.module.css'; | |||||||||||||||||||||||
| import {ethers} from 'ethers'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| //web3 imports | ||||||||||||||||||||||||
| import { deployVotingProcess, deployTestContract, getTestContract } from '../web3/contracts' | ||||||||||||||||||||||||
| import { useState, useEffect, useRef } from 'react'; | ||||||||||||||||||||||||
| import { deployVotingProcess} from '../web3/contracts' | ||||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||
| import { useNavigate } from 'react-router-dom'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -27,35 +27,44 @@ const CreateProcess = () => { | |||||||||||||||||||||||
| const [open, setOpen] = useState(false); | ||||||||||||||||||||||||
| const [transactionResult, setTransactionResult] = useState(null); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const refValue = useRef(false); | ||||||||||||||||||||||||
| // const refValue = useRef(false); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const createProcess = async (e) => { | ||||||||||||||||||||||||
| e.preventDefault(); | ||||||||||||||||||||||||
| console.log("name: ", name); | ||||||||||||||||||||||||
| //format proposals | ||||||||||||||||||||||||
| let proposalArray = formatProposals(proposals); | ||||||||||||||||||||||||
| //check form inputs | ||||||||||||||||||||||||
| if(!isFormValid()){ | ||||||||||||||||||||||||
| window.alert("Form is not valid"); | ||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| const createProcess = async (e) => { | ||||||||||||||||||||||||
| e.preventDefault(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (!isFormValid()) { | ||||||||||||||||||||||||
| window.alert("Form is not valid"); | ||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| setPending(true); | ||||||||||||||||||||||||
| refValue.current = true; | ||||||||||||||||||||||||
| //deploy new process contract | ||||||||||||||||||||||||
| const result = await deployVotingProcess(name, description, proposalArray,1000000,1000000); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const proposalArray = formatProposals(proposals); | ||||||||||||||||||||||||
| const result = await deployVotingProcess( | ||||||||||||||||||||||||
| name, | ||||||||||||||||||||||||
| description, | ||||||||||||||||||||||||
| proposalArray, | ||||||||||||||||||||||||
| 1000000, | ||||||||||||||||||||||||
| 1000000 | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| setTransactionResult(result); | ||||||||||||||||||||||||
| setShow(true); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| refValue.current = false; | ||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||
| console.error(err); | ||||||||||||||||||||||||
| window.alert("Transaction failed"); | ||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||
| setPending(false); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| setShow(true); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const isFormValid = () => { | ||||||||||||||||||||||||
| if(proposals < 2) | ||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| return proposals.split(',').length >= 2; | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
Comment on lines
64
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validation doesn't reject empty proposals after trimming. The validation only counts commas but doesn't verify that trimmed proposals are non-empty. Input like Filter and validate trimmed proposals. 🔎 Proposed fix const isFormValid = () => {
- return proposals.split(',').length >= 2;
+ const trimmedProposals = proposals.split(',').map(p => p.trim()).filter(p => p.length > 0);
+ return trimmedProposals.length >= 2;
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const formatProposals = (input) => { | ||||||||||||||||||||||||
| let proposals = input.split(','); | ||||||||||||||||||||||||
|
|
@@ -67,9 +76,6 @@ const CreateProcess = () => { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||
| // setPending(!pending); | ||||||||||||||||||||||||
| }, [pending]) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||
| <div > | ||||||||||||||||||||||||
|
|
@@ -105,11 +111,27 @@ const CreateProcess = () => { | |||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||
| <button className="baseButton">Create new process</button> | ||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||
| className="baseButton" | ||||||||||||||||||||||||
| type="submit" | ||||||||||||||||||||||||
| disabled={pending} | ||||||||||||||||||||||||
| > | ||||||||||||||||||||||||
| {pending ? ( | ||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||
| <Spinner | ||||||||||||||||||||||||
| animation="border" | ||||||||||||||||||||||||
| size="sm" | ||||||||||||||||||||||||
| style={{ marginRight: "8px" }} | ||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| Creating... | ||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||
| "Create new process" | ||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||
| {refValue.current == true && <div style={{marginTop: "2em"}}> | ||||||||||||||||||||||||
| <Spinner animation="border" /> | ||||||||||||||||||||||||
| </div>} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| </form> | ||||||||||||||||||||||||
| <Modal show={show} onHide={handleClose}> | ||||||||||||||||||||||||
| <Modal.Header closeButton> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| function Explorer() { | ||
| return ( | ||
| <div style={{ padding: "20px" }}> | ||
| <h2>Explorer</h2> | ||
| <p>Blockchain explorer coming soon.</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default Explorer; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,4 +87,4 @@ def chat(): | |
| return jsonify({"error": str(e)}) | ||
|
|
||
| if __name__ == '__main__': | ||
| app.run(host="0.0.0.0", port=5000,debug=True) | ||
| app.run(host="0.0.0.0", port=5000,debug=True) | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| { | ||
| "intents": [ | ||
| { | ||
| "tag": "greeting", | ||
|
|
@@ -454,4 +454,4 @@ | |
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.