-
Notifications
You must be signed in to change notification settings - Fork 4
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
Interact with dao contract functions #104
Merged
Merged
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
dd2ed5b
chore: separate connected key and kit service
0xExp-po 9946702
chore: check empty descriptions before submit
0xExp-po 92c3af1
chore: add proposal name input
0xExp-po 9ba0fca
chore: add create proposal function to new proposal page
0xExp-po 8b7474c
fix: create proposal error
0xExp-po 7886484
chore: add voting dates input
0xExp-po 740f421
chore: update proposal data interface
0xExp-po 2356f07
feat: fetch proposals from contract
0xExp-po 677e55d
feat: fetch proposal data from contract
0xExp-po c37fc13
feat: implement vote function
0xExp-po e1cf39c
chore: define the response type, create contract error messages
0xExp-po c16daee
chore: add error handler to voting function
0xExp-po da95617
chore: change the response data type
0xExp-po e80c248
chore: add error handler to submit proposal function
0xExp-po 820d203
chore: add error handler to commit hash function
0xExp-po bcac3df
chore: add error handler to register project function
0xExp-po ee71b0f
feat: add error handler to read contract functions
0xExp-po 9713448
chore: remove demo proposal data
0xExp-po bd30995
fix: update check condition for proposal submit
0xExp-po 773f2f5
chore: update contract response data type
0xExp-po d8a4955
chore: add process checker in submit proposal function
0xExp-po 8a385b9
update stellar wallet kit version
0xExp-po 473de08
chore: update submit proposal function
0xExp-po 3b66ef1
fix: linting error
0xExp-po 7258ee0
chore: add console log to check delegation
0xExp-po 0bd0e37
Fix signing and sending
tupui 08dd2f4
Merge branch 'main' of https://github.com/0xExp-po/soroban-versioning…
0xExp-po f13f3f3
Merge branch 'main' of https://github.com/0xExp-po/soroban-versioning…
0xExp-po 970016c
feat: create challenge to submit proposal
0xExp-po 3e8e2a6
fix: regular expression for markdown image
0xExp-po 5e020db
chore: set delegation expire time as 1 min
0xExp-po 3c1b4ab
chore: divide proof env data into two parts
0xExp-po 0588b41
fix: linter error
0xExp-po File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ const ProposalForm: React.FC = () => { | |
const connectedAddress = useStore(connectedPublicKey); | ||
const projectName = useStore(projectNameForGovernance); | ||
const [projectMaintainers, setProjectMaintainers] = useState<string[]>([]); | ||
const [proposalName, setProposalName] = useState(""); | ||
|
||
useEffect(() => { | ||
setIsClient(true); | ||
|
@@ -112,7 +113,31 @@ const ProposalForm: React.FC = () => { | |
}, | ||
}; | ||
|
||
const isDescriptionValid = (description: string) => { | ||
return description.trim().split(/\s+/).length >= 3; | ||
}; | ||
|
||
const submitProposal = async () => { | ||
if (!proposalName) { | ||
alert("Proposal name is required"); | ||
return; | ||
} | ||
|
||
if (!isDescriptionValid(approveDescription)) { | ||
alert("Approved description must contain at least 3 words."); | ||
return; | ||
} | ||
|
||
if (!isDescriptionValid(rejectDescription)) { | ||
alert("Rejected description must contain at least 3 words."); | ||
return; | ||
} | ||
|
||
if (!isDescriptionValid(cancelledDescription)) { | ||
alert("Cancelled description must contain at least 3 words."); | ||
return; | ||
} | ||
|
||
if (!connectedAddress) { | ||
alert("Please connect your wallet first"); | ||
return; | ||
|
@@ -181,12 +206,25 @@ const ProposalForm: React.FC = () => { | |
|
||
const directoryCid = await client.uploadDirectory(files); | ||
|
||
setIsLoading(false); | ||
alert( | ||
`Proposal submitted successfully! CID: ${getIpfsBasicLink(directoryCid.toString())}`, | ||
const { createProposal } = await import("@service/WriteContractService"); | ||
|
||
const proposalId = await createProposal( | ||
projectName, | ||
proposalName, | ||
directoryCid.toString(), | ||
Date.now() + 86400000 * import.meta.env.PUBLIC_VOTING_PERIOD, | ||
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. This needs to be configurable from the user side 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. got it |
||
); | ||
|
||
window.location.href = `/governance?name=${projectName}`; | ||
setIsLoading(false); | ||
if (proposalId === -1) { | ||
alert("Error submitting proposal"); | ||
} else { | ||
alert( | ||
`Proposal submitted successfully! Proposal ID: ${proposalId}, CID: ${getIpfsBasicLink(directoryCid.toString())}`, | ||
); | ||
|
||
window.location.href = `/governance?name=${projectName}`; | ||
} | ||
} catch (error) { | ||
throw new Error("Error submitting proposal", { | ||
cause: error, | ||
|
@@ -196,6 +234,16 @@ const ProposalForm: React.FC = () => { | |
|
||
return ( | ||
<div> | ||
<h3 className="text-base sm:text-lg md:text-2xl font-semibold py-2"> | ||
Proposal Name | ||
</h3> | ||
<input | ||
type="text" | ||
value={proposalName} | ||
onChange={(e) => setProposalName(e.target.value)} | ||
className="w-full p-2 border border-zinc-700 rounded-md focus:outline-none" | ||
placeholder="Enter your proposal name here..." | ||
/> | ||
<h3 className="text-base sm:text-lg md:text-2xl font-semibold py-2"> | ||
Proposal Description | ||
</h3> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { connectedPublicKey } from "utils/store"; | ||
|
||
const connectionState: { publicKey: string | undefined } = { | ||
publicKey: undefined, | ||
}; | ||
|
||
function loadedPublicKey(): string | undefined { | ||
return connectionState.publicKey; | ||
} | ||
|
||
function setPublicKey(data: string): void { | ||
connectionState.publicKey = data; | ||
localStorage.setItem("publicKey", data); | ||
connectedPublicKey.set(data); | ||
} | ||
|
||
function initializeConnection(): void { | ||
const storedPublicKey = localStorage.getItem("publicKey"); | ||
if (storedPublicKey) { | ||
setPublicKey(storedPublicKey); | ||
} | ||
} | ||
|
||
export { loadedPublicKey, setPublicKey, initializeConnection }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's more complicated. Only for approval it's a must to have a description. For reject and cancelled, description is only required if there is a XDR.
While we are here, if no XDR is provided or no description, then in the UI we don't need to show this specific outcome. I expect that a lot of proposals will just have an approve outcome and the rest will be empty. So we don't need to show empty outcomes.