diff --git a/.env.development b/.env.development index 0f80310d..5a51efcd 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -BASE_ADDRESS=localhost +BASE_ADDRESS=fazabaza NEXT_PUBLIC_API_URL=http://$BASE_ADDRESS:1317 NEXT_PUBLIC_RPC_URL=http://$BASE_ADDRESS:26657 NEXT_PUBLIC_WS_URL=ws://$BASE_ADDRESS:26657/websocket @@ -6,16 +6,16 @@ NEXT_PUBLIC_FAUCET_URL=http://$BASE_ADDRESS:4500 NEXT_PUBLIC_IMAGES_URL=http://localhost:3000 NEXT_PUBLIC_CURRENCY_TOKEN=tlore NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN=utlore -NEXT_PUBLIC_OBJECTS_URL=http://$BASE_ADDRESS:5000 +NEXT_PUBLIC_OBJECTS_URL=http://$BASE_ADDRESS:5001 NEXT_PUBLIC_EXPLORER_URL=http://explorer.$BASE_ADDRESS NEXT_PUBLIC_DOCS_URL=http://docs.$BASE_ADDRESS NEXT_PUBLIC_FORUM_URL=http://forum.$BASE_ADDRESS NEXT_PUBLIC_ROADMAP_URL=http://forum.$BASE_ADDRESS NEXT_PUBLIC_HEADER_MESSAGE=The product is in beta. Any changes you make will not persist and maybe reset. -NEXT_PUBLIC_GITOPIA_ADDRESS= +NEXT_PUBLIC_GITOPIA_ADDRESS=faza1 NEXT_PUBLIC_NETWORK_RELEASE_NOTES= NEXT_PUBLIC_GAS_PRICE=0.001utlore +NEXT_PUBLIC_GIT_SERVER_WALLET_ADDRESS=gitopia1pl822l759d2cqe2ntvuhla29rfthpgs29lmz7x NEXT_PUBLIC_PLAUSIBLE_DOMAIN=$BASE_ADDRESS -NEXT_PUBLIC_GIT_SERVER_WALLET_ADDRESS= NEXT_PUBLIC_GRAPHQL_HTTP_URL=http://$BASE_ADDRESS:8080/v1/graphql -NEXT_PUBLIC_STORAGE_BRIDGE_WALLET_ADDRESS= \ No newline at end of file +NEXT_PUBLIC_STORAGE_BRIDGE_WALLET_ADDRESS=gitopia1uqsv434cjcms08qpznpky3fdwg6f8lzfy9g0hz \ No newline at end of file diff --git a/components/account/daoHeader.js b/components/account/daoHeader.js index 2d2b0557..3978426f 100644 --- a/components/account/daoHeader.js +++ b/components/account/daoHeader.js @@ -26,17 +26,34 @@ function AccountDaoHeader(props) { }, [props.dao.address, props.selectedAddress]); return ( -
+
-
+
-
{props.dao.address}
+
+ + {"@" + props.dao.name.toLowerCase()} + + · + + {props.dao.address} + +
-
+
{ + // const o = await getDao(router.query.userId); + // if (o) { + // setDao(o); + // } + // }, [router.query]); + const hrefBase = "/" + dao.address; + + const validateTitle = async (title) => { + setValidateTitleError(null); + if (title.length < 3) { + setValidateTitleError("Title too short"); + } + }; + + const validateUserAddress = async (address) => { + if (address.trim() !== "" && validAddress.test(address)) { + const res = await getUser(address); + setValidateAddressError(null); + } else { + setValidateAddressError("Enter a valid address"); + } + }; + + function isNaturalNumber(n) { + n = n.toString(); + var n1 = Math.abs(n), + n2 = parseInt(n, 10); + return !isNaN(n1) && n2 === n1 && n1.toString() === n; + } + + const validateAmount = async (amount) => { + setValidateAmountError(null); + let Vamount = Number(amount); + if (amount == "" || amount == 0) { + setValidateAmountError("Enter a valid amount"); + } + + // let balance = props.loreBalance; + if (props.advanceUser === false) { + Vamount = Vamount * 1000000; + } + if (!isNaturalNumber(Vamount)) { + // if (Vamount > balance) { + // setValidateAmountError("Insufficient Balance"); + // } + // } else { + setValidateAmountError("Enter a valid amount"); + } + }; + + const validateInitialAmount = async (amount) => { + setValidateInitialAmountError(null); + let Vamount = Number(amount); + if (amount == "") { + setValidateInitialAmountError("Enter a valid amount"); + } + let balance = props.loreBalance; + if (props.advanceUser === false) { + Vamount = Vamount * 1000000; + } + if (Vamount >= 0 && isNaturalNumber(Vamount)) { + if (Vamount > balance) { + setValidateInitialAmountError("Insufficient balance"); + } + } else { + setValidateInitialAmountError("Enter a valid amount"); + } + }; + + const handleClick = () => { + setCounter(counter + 1); + let array = paramSubspaces.slice(); + array.push(undefined); + setParamSubspaces(array); + + array = paramKeys.slice(); + array.push(undefined); + setParamKeys(array); + + array = paramValues.slice(); + array.push(undefined); + setParamValues(array); + }; + + const handleParamSubspaceOnChange = (subspace, index) => { + const array = paramSubspaces.slice(); + array[index] = subspace; + setParamSubspaces(array); + }; + + const handleParamKeyOnChange = (key, index) => { + const array = paramKeys.slice(); + array[index] = key; + setParamKeys(array); + }; + + const handleParamValueOnChange = (value, index) => { + const array = paramValues.slice(); + array[index] = value; + setParamValues(array); + }; + + const redirectToProposal = async (res) => { + let result = JSON.parse(res.rawLog); + if (res && res.code === 0) { + router.push( + hrefBase + + "?tab=proposals&id=" + + result[0].events[4].attributes[0].value + ); + } + }; + + return ( +
+
+ + + +
+
+

Write your proposal

+

+ Proposals play a vital role in the functioning of decentralised + applications. Any changes or upgrades are done only after proposals + are voted in consensus. But there is no standard category to + distinguish different types of proposals. Having a clear category will + help communities to easily manage different types of proposals. +

+
+
+ + { + await validateTitle(e.target.value); + }} + onChange={(e) => { + setTitle(e.target.value); + }} + /> + {validateTitleError ? ( + + ) : ( + "" + )} +
+
+ + +
+
+ +
+ +
+
+ +
+ { + await validateInitialAmount(e.target.value); + }} + onMouseUp={async (e) => { + await validateInitialAmount(e.target.value); + }} + className="input input-md input-bordered text-xs h-8" + value={initialDeposit} + onChange={(e) => { + setInitialDeposit(e.target.value); + }} + /> + {validateInitialAmountError ? ( + + ) : ( + "" + )} +
+
+ {(menuState == 2 || menuState == 5) && ( +
+
+ +
+ { + await validateAmount(e.target.value); + }} + onMouseUp={async (e) => { + await validateAmount(e.target.value); + }} + className="input input-md input-bordered text-xs h-8" + value={amount} + onChange={(e) => { + setAmount(e.target.value); + }} + /> + {validateAmountError ? ( + + ) : ( + "" + )} +
+
+ +
+ +
+ { + await validateUserAddress(e.target.value); + }} + className="input input-md input-bordered text-xs h-8" + value={address} + onChange={(e) => { + setAddress(e.target.value); + }} + /> + {validateAddressError ? ( + + ) : ( + "" + )} +
+
+
+
+ +
+
+
+ )} + {menuState == 3 && ( +
+
+ +
+ { + setReleaseVersionTag(e.target.value); + }} + /> +
+
+ +
+ +
+ { + setHeight(e.target.value); + }} + /> +
+
+
+
+ +
+
+
+ )} + {menuState == 4 && ( +
+
+ +
+ {Array.from(Array(counter)).map((c, index) => { + return ( +
+
+ { + handleParamSubspaceOnChange(e.target.value, index); + }} + /> +
+
+ { + handleParamKeyOnChange(e.target.value, index); + }} + /> +
+
+ { + handleParamValueOnChange(e.target.value, index); + }} + /> +
+
+ ); + })} +
+
+ +
+
+
+
+ +
+
+
+ )} + {menuState == 1 && ( +
+
+ +
+
+ )} +
+
+ ); +} + +const mapStateToProps = (state) => { + return { + currentDashboard: state.user.currentDashboard, + advanceUser: state.user.advanceUser, + loreBalance: state.wallet.loreBalance, + dashboards: state.user.dashboards, + }; +}; + +export default connect(mapStateToProps, { + submitGovernanceProposal, + chainUpgradeProposal, + communityPoolSpendProposal, + paramChangeProposal, +})(DaoProposalCreate); diff --git a/components/account/daoProposalDetails.js b/components/account/daoProposalDetails.js new file mode 100644 index 00000000..94553f60 --- /dev/null +++ b/components/account/daoProposalDetails.js @@ -0,0 +1,762 @@ +import { useEffect, useState } from "react"; +import { connect } from "react-redux"; +import getProposal from "../../helpers/getProposal"; +import dayjs from "dayjs"; +import { useRouter } from "next/router"; +import { proposalDeposit } from "../../store/actions/proposals"; +import { proposalVote } from "../../store/actions/proposals"; +import { CircularProgressbar, buildStyles } from "react-circular-progressbar"; +import "react-circular-progressbar/dist/styles.css"; +import getTally from "../../helpers/getTally"; +import Link from "next/dist/client/link"; +import getDepositor from "../../helpers/getDepositor"; +import getVoter from "../../helpers/getVoter"; +import ReactMarkdown from "react-markdown"; + +function DaoProposalDetails({ id, ...props }) { + const [amount, setAmount] = useState(""); + const [validateAmountError, setValidateAmountError] = useState(""); + const [depositLoading, setDepositLoading] = useState(false); + const [voteAbstainLoading, setVoteAbstainLoading] = useState(false); + const [voteNoLoading, setVoteNoLoading] = useState(false); + const [voteYesLoading, setVoteYesLoading] = useState(false); + const [voteNoWithVetoLoading, setVoteNoWithVetoLoading] = useState(false); + const [proposal, setProposal] = useState({ content: { description: "" } }); + const [proposer, setProposer] = useState(""); + const [initialDeposit, setInitialDeposit] = useState(""); + const [tally, setTally] = useState({}); + const [depositors, setDepositors] = useState([]); + const [voters, setVoters] = useState([]); + const router = useRouter(); + const hrefBase = "/" + router.query.userId; + const type = "@type"; + var localizedFormat = require("dayjs/plugin/localizedFormat"); + dayjs.extend(localizedFormat); + + const refreshProposal = async () => { + if (id !== undefined) { + await getProposal(id).then((res) => { + if (res !== undefined) { + setProposal(res.msg); + setProposer(res.proposer); + setInitialDeposit(res.initial_deposit); + } else { + router.push(router.query.userId + "?tab=proposals"); + } + }); + } + }; + + const refreshTally = async () => { + if (id !== undefined) { + await getTally(id).then((res) => { + if (res === {}) { + setTally({ + yes: 0, + no: 0, + abstain: 0, + no_with_veto: 0, + }); + } + setTally(res.tally); + }); + } + }; + + const refreshDepositors = async () => { + if (id !== undefined) { + await getDepositor(id).then((res) => { + if (res !== undefined) { + setDepositors(res.slice(1, res.length)); + } + }); + } + }; + + const refreshVoters = async () => { + if (id !== undefined) { + await getVoter(id).then((res) => { + setVoters(res); + }); + } + }; + + useEffect(refreshProposal, [id]); + useEffect(refreshTally, [id]); + useEffect(refreshDepositors, [id]); + useEffect(refreshVoters, [id]); + + function isNaturalNumber(n) { + n = n.toString(); + var n1 = Math.abs(n), + n2 = parseInt(n, 10); + return !isNaN(n1) && n2 === n1 && n1.toString() === n; + } + + const validateAmount = async (amount) => { + setValidateAmountError(null); + let Vamount = Number(amount); + if (amount == "" || amount == 0) { + setValidateAmountError("Enter Valid Amount"); + } + + let balance = props.loreBalance; + if (props.advanceUser === false) { + Vamount = Vamount * 1000000; + } + if (Vamount > 0 && isNaturalNumber(Vamount)) { + if (Vamount > balance) { + setValidateAmountError("Insufficient Balance"); + } + } else { + setValidateAmountError("Enter a Valid Amount"); + } + }; + + function getPercentage(key) { + if (tally !== undefined) { + let total = + parseInt(tally.yes) + + parseInt(tally.no) + + parseInt(tally.abstain) + + parseInt(tally.no_with_veto); + if (total > 0) { + let count; + if (key == "yes") { + count = parseInt(tally.yes); + } else if (key == "no") { + count = parseInt(tally.no); + } else if (key == "abstain") { + count = parseInt(tally.abstain); + } else if (key == "no_with_veto") { + count = parseInt(tally.no_with_veto); + } + let percent = count / total; + return percent * 100; + } + } + return 0; + } + + return ( + <> +
+ + + +
+ {proposal !== undefined ? ( +
+
+ {proposal.status == "PROPOSAL_STATUS_PASSED" ? ( +
+ + + + PASSED +
+ ) : ( + "" + )} + {proposal.status == "PROPOSAL_STATUS_REJECTED" ? ( +
+ + + + REJECTED +
+ ) : ( + "" + )} + {proposal.status == "PROPOSAL_STATUS_DEPOSIT_PERIOD" ? ( +
+ + + + AWAITING DEPOSIT +
+ ) : ( + "" + )} + {proposal.status == "PROPOSAL_STATUS_VOTING_PERIOD" ? ( +
+
+
+
+
+ VOTING IN PROGRESS +
+ ) : ( + "" + )} +
+
+ {proposal.content.title} + + {"#" + proposal.proposal_id} + +
+
+ {typeof proposal.content !== "undefined" ? ( +
+ + {proposal.content.description} + +
+ ) : ( + "" + )} + + {typeof proposal.content !== "undefined" ? ( + proposal.content["@type"] == + "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal" ? ( +
+
{"Plan Name: " + proposal.content.plan.name}
+
{"Upgrade Height: " + proposal.content.plan.height}
+
+ {"Upgraded Client State: " + + (proposal.content.plan.upgraded_client_state == null + ? "--" + : proposal.content.plan.upgraded_client_state)} +
+
+ ) : ( + "" + ) + ) : ( + "" + )} + {typeof proposal.content !== "undefined" ? ( + proposal.content["@type"] == + "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal" ? ( +
+
{"Recipient: " + proposal.content["recipient"]}
+
+ {"Amount: " + + (props.advanceUser === true + ? proposal.content.amount[0].amount + : proposal.content.amount[0].amount / 1000000) + + " " + + (props.advanceUser === true + ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN + : process.env.NEXT_PUBLIC_CURRENCY_TOKEN)} +
+
+ ) : ( + "" + ) + ) : ( + "" + )} + {typeof proposal.content !== "undefined" ? ( + proposal.content["@type"] == + "/cosmos.params.v1beta1.ParameterChangeProposal" ? ( +
+ {proposal.content["changes"].map((change, index) => { + return ( +
+
{"Change " + (index + 1)}
+
+
{"Subspace: " + change.subspace}
+
{"Key: " + change.key}
+
{"Value: " + change.value}
+
+
+ ); + })} +
+ ) : ( + "" + ) + ) : ( + "" + )} +
+ + {proposal.status == "PROPOSAL_STATUS_DEPOSIT_PERIOD" ? ( +
+ +
+ ) : ( +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ )} + +
+
+
+ +
+ { + await validateAmount(e.target.value); + }} + onMouseUp={async (e) => { + await validateAmount(e.target.value); + }} + onChange={(e) => { + setAmount(e.target.value); + }} + className="w-full h-11 input input-xs input-ghost input-bordered " + /> +
+ {validateAmountError ? ( + + ) : ( + "" + )} +
+
+ + +
+
+
+
+
+ +
+
Proposer
+
{proposer}
+
+
+
Type
+
+ {typeof proposal.content !== "undefined" + ? proposal.content["@type"] == + "/cosmos.gov.v1beta1.TextProposal" + ? "TEXT" + : "" + : ""} + {typeof proposal.content !== "undefined" + ? proposal.content["@type"] == + "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal" + ? "SOFTWARE UPGRADE" + : "" + : ""} + {typeof proposal.content !== "undefined" + ? proposal.content["@type"] == + "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal" + ? "COMMUNITY POOL SPEND" + : "" + : ""} + {typeof proposal.content !== "undefined" + ? proposal.content["@type"] == + "/cosmos.params.v1beta1.ParameterChangeProposal" + ? "PARAMETER CHANGE" + : "" + : ""} +
+
+ +
+
Total Deposit
+
+ {typeof proposal.total_deposit !== "undefined" && + proposal.total_deposit.length != 0 + ? (props.advanceUser === true + ? proposal.total_deposit[0].amount + : proposal.total_deposit[0].amount / 1000000) + + " " + + (props.advanceUser === true + ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN + : process.env.NEXT_PUBLIC_CURRENCY_TOKEN) + : "0 " + + (props.advanceUser === true + ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN + : process.env.NEXT_PUBLIC_CURRENCY_TOKEN)} +
+
+
+
+ Initial Deposit +
+
+ {typeof initialDeposit !== "undefined" + ? (props.advanceUser === true + ? initialDeposit + : initialDeposit / 1000000) + + " " + + (props.advanceUser === true + ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN + : process.env.NEXT_PUBLIC_CURRENCY_TOKEN) + : ""} +
+
+
+
Submit Time
+
+ {" " + dayjs(proposal.submit_time).format("LLL")} +
+
+
+
+ Deposit End Time +
+
+ {" " + dayjs(proposal.deposit_end_time).format("LLL")} +
+
+
+
Voting Start
+
+ {dayjs(proposal.submit_time).unix() - + dayjs(proposal.voting_start_time).unix() > + 0 + ? "--" + : " " + dayjs(proposal.voting_start_time).format("LLL")} +
+
+
+
Voting End
+
+ {dayjs(proposal.submit_time).unix() - + dayjs(proposal.voting_end_time).unix() > + 0 + ? "--" + : " " + dayjs(proposal.voting_end_time).format("LLL")} +
+
+ {/* Depositors Section */} + +
+ + + + + + + + + + + + + {depositors !== undefined + ? depositors.map((depositor, i) => { + return ( + + + + + ); + }) + : ""} + +
DepositorsAmount
{proposer} + {props.advanceUser === true + ? initialDeposit + : initialDeposit / 1000000}{" "} + {props.advanceUser === true + ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN.toUpperCase() + : process.env.NEXT_PUBLIC_CURRENCY_TOKEN.toUpperCase()} + + initial deposit + +
{depositor.body.messages[0].depositor} + {props.advanceUser === true + ? depositor.body.messages[0].amount[0].amount + : depositor.body.messages[0].amount[0].amount / + 1000000}{" "} + {props.advanceUser === true + ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN.toUpperCase() + : process.env.NEXT_PUBLIC_CURRENCY_TOKEN.toUpperCase()} +
+
+ +
+ + + + + + + + + {voters !== undefined + ? voters.map((voter, i) => { + let option = voter.body.messages[0].option; + option = option.replace("VOTE_OPTION_", ""); + option = option.replace(/\_/g, " "); + return ( + + + + + ); + }) + : ""} + +
VotersAnswer
{voter.body.messages[0].voter}{option}
+
+
+ ) : ( + "" + )} + + ); +} + +const mapStateToProps = (state) => { + return { advanceUser: state.user.advanceUser }; +}; + +export default connect(mapStateToProps, { proposalDeposit, proposalVote })( + DaoProposalDetails +); diff --git a/components/account/daoProposalList.js b/components/account/daoProposalList.js new file mode 100644 index 00000000..070cdf2f --- /dev/null +++ b/components/account/daoProposalList.js @@ -0,0 +1,69 @@ +import { connect } from "react-redux"; +import { useRouter } from "next/router"; +import Link from "next/link"; +import { useState, useEffect } from "react"; +import getProposals from "../../helpers/getProposals"; +import dayjs from "dayjs"; +import ProposalItem from "../../components/dashboard/proposalItem"; + +function DaoProposalList({ dao, ...props }) { + const router = useRouter(); + // const [dao, setDao] = useState({ + // name: "", + // repositories: [], + // }); + const [proposals, setProposals] = useState([]); + var localizedFormat = require("dayjs/plugin/localizedFormat"); + dayjs.extend(localizedFormat); + + useEffect(async () => { + if (router.query.userId !== process.env.NEXT_PUBLIC_GITOPIA_ADDRESS) { + router.push("/" + router.query.userId); + } + const p = await getProposals(); + setProposals(p); + }, []); + + return ( + <> +
+
Proposal List
+ +
+ + + +
+
+ +
+ {proposals?.length ? ( + proposals.map((p) => { + return ( + + ); + }) + ) : ( +
+

No proposals yet

+
+ )} +
+ + ); +} + +const mapStateToProps = (state) => { + return { + currentDashboard: state.user.currentDashboard, + dashboards: state.user.dashboards, + }; +}; + +export default connect(mapStateToProps, {})(DaoProposalList); diff --git a/components/account/overview.js b/components/account/overview.js index f2c58936..243a2a4f 100644 --- a/components/account/overview.js +++ b/components/account/overview.js @@ -40,15 +40,15 @@ function AccountOverview(props) { return ( <>
Latest repositories
-
+
{allRepos !== null ? allRepos.map((r) => { return (
-
+
{r.name} @@ -63,7 +63,7 @@ function AccountOverview(props) { {r.description || "No Description"}
-
+
diff --git a/components/createUser.js b/components/createUser.js index 69f4d3db..3b219f1c 100644 --- a/components/createUser.js +++ b/components/createUser.js @@ -81,6 +81,25 @@ function CreateUser(props) { }); return false; } + if (props.wallets?.length) { + let foundName = false; + props.wallets.every((w) => { + if (w.name.toLowerCase() === username.toLowerCase()) { + foundName = true; + return false; + } + return true; + }); + if (foundName) { + setUsernameHint({ + shown: true, + type: "error", + message: + "Same named local wallet already present, either delete other wallet or choose a different name", + }); + return false; + } + } return true; }; @@ -171,6 +190,7 @@ const mapStateToProps = (state) => { return { selectedAddress: state.wallet.selectedAddress, user: state.user, + wallets: state.wallet.wallets, }; }; diff --git a/components/dao/description.js b/components/dao/description.js index 8a639ac7..5b3510e3 100644 --- a/components/dao/description.js +++ b/components/dao/description.js @@ -1,4 +1,4 @@ -import { useState, useEffect } from "react"; +import { useState, useRef, useEffect } from "react"; import { connect } from "react-redux"; import { updateDaoDescription } from "../../store/actions/dao"; import { notify } from "reapop"; @@ -13,6 +13,7 @@ function DaoDescription(props = { isEditable: false }) { message: "", }); const [savingDescription, setSavingDescription] = useState(false); + const input = useRef(); const validateDescription = (description) => { setNewDescriptionHint({ @@ -53,6 +54,12 @@ function DaoDescription(props = { isEditable: false }) { setNewDescriptionHint({ shown: false }); }, [props.dao]); + useEffect(() => { + if (isEditing && input?.current) { + input.current.focus(); + } + }, [isEditing]); + return (
{isEditing ? ( @@ -66,6 +73,7 @@ function DaoDescription(props = { isEditable: false }) { setValue={setNewDescription} hint={newDescriptionHint} size="sm" + ref={input} />
); diff --git a/helpers/getNodeInfo.js b/helpers/getNodeInfo.js index 8140cd3e..038738d3 100644 --- a/helpers/getNodeInfo.js +++ b/helpers/getNodeInfo.js @@ -2,7 +2,7 @@ import axios from "../helpers/axiosFetch"; export default async function getNodeInfo() { let networkName = "gitopia"; const baseUrl = - process.env.NEXT_PUBLIC_API_URL + "/node_info" + process.env.NEXT_PUBLIC_API_URL + "/cosmos/base/tendermint/v1beta1/node_info" await axios .get(baseUrl) .then((response) => { diff --git a/helpers/keplr.js b/helpers/keplr.js index 6af818f6..21644d0d 100644 --- a/helpers/keplr.js +++ b/helpers/keplr.js @@ -17,7 +17,7 @@ export default async function initKeplr() { // If the same chain id is already registered, it will resolve and not require the user interactions. const suggestChain = await window.keplr.experimentalSuggestChain({ // Chain-id of the Cosmos SDK chain. - chainId: info.node_info.network, + chainId: info.default_node_info.network, // The name of the chain to be displayed to the user. chainName: info.application_version.name, // RPC endpoint of the chain. @@ -118,7 +118,7 @@ export default async function initKeplr() { // Enabling before using the Keplr is recommended. // This method will ask the user whether or not to allow access if they haven't visited this website. // Also, it will request user to unlock the wallet if the wallet is locked. - await window.keplr.enable(info.node_info.network); + await window.keplr.enable(info.default_node_info.network); // const offlineSigner = window.getOfflineSigner(chainId); // console.log(offlineSigner); diff --git a/package.json b/package.json index 1a7fd986..7ee21179 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@cosmjs/ledger-amino": "^0.27.1", "@cosmjs/proto-signing": "0.27.1", "@cosmjs/stargate": "^0.27.1", - "@gitopia/gitopia-js": "git+https://github.com/gitopia/gitopia-js#078070f1b30467234775c246adf97b14a1c5eedd", + "@gitopia/gitopia-js": "1.0.0", "@gitopia/stargate": "0.27.1", "@ledgerhq/hw-transport-webhid": "^6.20.0", "@ledgerhq/hw-transport-webusb": "^6.20.0", diff --git a/pages/[userId]/index.js b/pages/[userId]/index.js index de7803b2..f686a7a4 100644 --- a/pages/[userId]/index.js +++ b/pages/[userId]/index.js @@ -15,6 +15,9 @@ import AccountRepositories from "../../components/account/repositories"; import AccountTransactions from "../../components/account/transactions"; import AccountPeople from "../../components/account/people"; import AccountDaoHeader from "../../components/account/daoHeader"; +import DaoProposalList from "../../components/account/daoProposalList"; +import DaoProposalCreate from "../../components/account/daoProposalCreate"; +import DaoProposalDetails from "../../components/account/daoProposalDetails"; import validAddress from "../../helpers/validAddress"; export async function getStaticProps() { @@ -141,6 +144,19 @@ function AccountView(props) { ) : ( "" )} + {router.query.tab === "proposals" ? ( + router.query.id ? ( + router.query.id === "new" ? ( + + ) : ( + + ) + ) : ( + + ) + ) : ( + "" + )} {router.query.tab === "people" ? : ""}
diff --git a/pages/[userId]/proposals/[proposalId].js b/pages/[userId]/proposals/[proposalId].js deleted file mode 100644 index c99f1d94..00000000 --- a/pages/[userId]/proposals/[proposalId].js +++ /dev/null @@ -1,792 +0,0 @@ -import Head from "next/head"; -import Header from "../../../components/header"; -import { useEffect, useState } from "react"; -import { connect } from "react-redux"; -import getProposal from "../../../helpers/getProposal"; -import dayjs from "dayjs"; -import { useRouter } from "next/router"; -import { proposalDeposit } from "../../../store/actions/proposals"; -import { proposalVote } from "../../../store/actions/proposals"; -import { CircularProgressbar, buildStyles } from "react-circular-progressbar"; -import "react-circular-progressbar/dist/styles.css"; -import getTally from "../../../helpers/getTally"; -import Link from "next/dist/client/link"; -import getDepositor from "../../../helpers/getDepositor"; -import getVoter from "../../../helpers/getVoter"; -import ReactMarkdown from "react-markdown"; - -function ProposalDetailsView(props) { - const [amount, setAmount] = useState(""); - const [validateAmountError, setValidateAmountError] = useState(""); - const [depositLoading, setDepositLoading] = useState(false); - const [voteAbstainLoading, setVoteAbstainLoading] = useState(false); - const [voteNoLoading, setVoteNoLoading] = useState(false); - const [voteYesLoading, setVoteYesLoading] = useState(false); - const [voteNoWithVetoLoading, setVoteNoWithVetoLoading] = useState(false); - const [proposal, setProposal] = useState({ content: { description: "" } }); - const [proposer, setProposer] = useState(""); - const [initialDeposit, setInitialDeposit] = useState(""); - const [tally, setTally] = useState({}); - const [depositors, setDepositors] = useState([]); - const [voters, setVoters] = useState([]); - const router = useRouter(); - const id = router.query.proposalId; - const hrefBase = "/" + router.query.userId; - const type = "@type"; - var localizedFormat = require("dayjs/plugin/localizedFormat"); - dayjs.extend(localizedFormat); - - const refreshProposal = async () => { - if (id !== undefined) { - await getProposal(id).then((res) => { - if (res !== undefined) { - setProposal(res.msg); - setProposer(res.proposer); - setInitialDeposit(res.initial_deposit); - } else { - router.push(router.query.userId + "/proposals"); - } - }); - } - }; - - const refreshTally = async () => { - if (id !== undefined) { - await getTally(id).then((res) => { - if (res === {}) { - setTally({ - yes: 0, - no: 0, - abstain: 0, - no_with_veto: 0, - }); - } - setTally(res.tally); - }); - } - }; - - const refreshDepositors = async () => { - if (id !== undefined) { - await getDepositor(id).then((res) => { - if (res !== undefined) { - setDepositors(res.slice(1, res.length)); - } - }); - } - }; - - const refreshVoters = async () => { - if (id !== undefined) { - await getVoter(id).then((res) => { - setVoters(res); - }); - } - }; - - useEffect(refreshProposal, [id]); - useEffect(refreshTally, [id]); - useEffect(refreshDepositors, [id]); - useEffect(refreshVoters, [id]); - - function isNaturalNumber(n) { - n = n.toString(); - var n1 = Math.abs(n), - n2 = parseInt(n, 10); - return !isNaN(n1) && n2 === n1 && n1.toString() === n; - } - - const validateAmount = async (amount) => { - setValidateAmountError(null); - let Vamount = Number(amount); - if (amount == "" || amount == 0) { - setValidateAmountError("Enter Valid Amount"); - } - - let balance = props.loreBalance; - if (props.advanceUser === false) { - Vamount = Vamount * 1000000; - } - if (Vamount > 0 && isNaturalNumber(Vamount)) { - if (Vamount > balance) { - setValidateAmountError("Insufficient Balance"); - } - } else { - setValidateAmountError("Enter a Valid Amount"); - } - }; - - function getPercentage(key) { - if (tally !== undefined) { - let total = - parseInt(tally.yes) + - parseInt(tally.no) + - parseInt(tally.abstain) + - parseInt(tally.no_with_veto); - if (total > 0) { - let count; - if (key == "yes") { - count = parseInt(tally.yes); - } else if (key == "no") { - count = parseInt(tally.no); - } else if (key == "abstain") { - count = parseInt(tally.abstain); - } else if (key == "no_with_veto") { - count = parseInt(tally.no_with_veto); - } - let percent = count / total; - return percent * 100; - } - } - return 0; - } - - return ( -
- - Gitopia Proposals - - -
-
-
-
- - - -
- {proposal !== undefined ? ( -
-
- {proposal.status == "PROPOSAL_STATUS_PASSED" ? ( -
- - - - PASSED -
- ) : ( - "" - )} - {proposal.status == "PROPOSAL_STATUS_REJECTED" ? ( -
- - - - REJECTED -
- ) : ( - "" - )} - {proposal.status == "PROPOSAL_STATUS_DEPOSIT_PERIOD" ? ( -
- - - - AWAITING DEPOSIT -
- ) : ( - "" - )} - {proposal.status == "PROPOSAL_STATUS_VOTING_PERIOD" ? ( -
-
-
-
-
- VOTING IN PROGRESS -
- ) : ( - "" - )} -
-
- {proposal.content.title} - - {"#" + proposal.proposal_id} - -
-
- {typeof proposal.content !== "undefined" ? ( -
- - {proposal.content.description} - -
- ) : ( - "" - )} - - {typeof proposal.content !== "undefined" ? ( - proposal.content["@type"] == - "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal" ? ( -
-
{"Plan Name: " + proposal.content.plan.name}
-
- {"Upgrade Height: " + proposal.content.plan.height} -
-
- {"Upgraded Client State: " + - (proposal.content.plan.upgraded_client_state == null - ? "--" - : proposal.content.plan.upgraded_client_state)} -
-
- ) : ( - "" - ) - ) : ( - "" - )} - {typeof proposal.content !== "undefined" ? ( - proposal.content["@type"] == - "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal" ? ( -
-
{"Recipient: " + proposal.content["recipient"]}
-
- {"Amount: " + - (props.advanceUser === true - ? proposal.content.amount[0].amount - : proposal.content.amount[0].amount / 1000000) + - " " + - (props.advanceUser === true - ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN - : process.env.NEXT_PUBLIC_CURRENCY_TOKEN)} -
-
- ) : ( - "" - ) - ) : ( - "" - )} - {typeof proposal.content !== "undefined" ? ( - proposal.content["@type"] == - "/cosmos.params.v1beta1.ParameterChangeProposal" ? ( -
- {proposal.content["changes"].map((change, index) => { - return ( -
-
{"Change " + (index + 1)}
-
-
{"Subspace: " + change.subspace}
-
{"Key: " + change.key}
-
{"Value: " + change.value}
-
-
- ); - })} -
- ) : ( - "" - ) - ) : ( - "" - )} -
- - {proposal.status == "PROPOSAL_STATUS_DEPOSIT_PERIOD" ? ( -
- -
- ) : ( -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- )} - -
-
-
- -
- { - await validateAmount(e.target.value); - }} - onMouseUp={async (e) => { - await validateAmount(e.target.value); - }} - onChange={(e) => { - setAmount(e.target.value); - }} - className="w-full h-11 input input-xs input-ghost input-bordered " - /> -
- {validateAmountError ? ( - - ) : ( - "" - )} -
-
- - -
-
-
-
-
- -
-
Proposer
-
{proposer}
-
-
-
Type
-
- {typeof proposal.content !== "undefined" - ? proposal.content["@type"] == - "/cosmos.gov.v1beta1.TextProposal" - ? "TEXT" - : "" - : ""} - {typeof proposal.content !== "undefined" - ? proposal.content["@type"] == - "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal" - ? "SOFTWARE UPGRADE" - : "" - : ""} - {typeof proposal.content !== "undefined" - ? proposal.content["@type"] == - "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal" - ? "COMMUNITY POOL SPEND" - : "" - : ""} - {typeof proposal.content !== "undefined" - ? proposal.content["@type"] == - "/cosmos.params.v1beta1.ParameterChangeProposal" - ? "PARAMETER CHANGE" - : "" - : ""} -
-
- -
-
- Total Deposit -
-
- {typeof proposal.total_deposit !== "undefined" && - proposal.total_deposit.length != 0 - ? (props.advanceUser === true - ? proposal.total_deposit[0].amount - : proposal.total_deposit[0].amount / 1000000) + - " " + - (props.advanceUser === true - ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN - : process.env.NEXT_PUBLIC_CURRENCY_TOKEN) - : "0 " + - (props.advanceUser === true - ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN - : process.env.NEXT_PUBLIC_CURRENCY_TOKEN)} -
-
-
-
- Initial Deposit -
-
- {typeof initialDeposit !== "undefined" - ? (props.advanceUser === true - ? initialDeposit - : initialDeposit / 1000000) + - " " + - (props.advanceUser === true - ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN - : process.env.NEXT_PUBLIC_CURRENCY_TOKEN) - : ""} -
-
-
-
- Submit Time -
-
- {" " + dayjs(proposal.submit_time).format("LLL")} -
-
-
-
- Deposit End Time -
-
- {" " + dayjs(proposal.deposit_end_time).format("LLL")} -
-
-
-
- Voting Start -
-
- {dayjs(proposal.submit_time).unix() - - dayjs(proposal.voting_start_time).unix() > - 0 - ? "--" - : " " + dayjs(proposal.voting_start_time).format("LLL")} -
-
-
-
Voting End
-
- {dayjs(proposal.submit_time).unix() - - dayjs(proposal.voting_end_time).unix() > - 0 - ? "--" - : " " + dayjs(proposal.voting_end_time).format("LLL")} -
-
- {/* Depositors Section */} - -
- - - - - - - - - - - - - {depositors !== undefined - ? depositors.map((depositor, i) => { - return ( - - - - - ); - }) - : ""} - -
DepositorsAmount
{proposer} - {props.advanceUser === true - ? initialDeposit - : initialDeposit / 1000000}{" "} - {props.advanceUser === true - ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN.toUpperCase() - : process.env.NEXT_PUBLIC_CURRENCY_TOKEN.toUpperCase()} - - initial deposit - -
{depositor.body.messages[0].depositor} - {props.advanceUser === true - ? depositor.body.messages[0].amount[0].amount - : depositor.body.messages[0].amount[0] - .amount / 1000000}{" "} - {props.advanceUser === true - ? process.env.NEXT_PUBLIC_ADVANCE_CURRENCY_TOKEN.toUpperCase() - : process.env.NEXT_PUBLIC_CURRENCY_TOKEN.toUpperCase()} -
-
- -
- - - - - - - - - {voters !== undefined - ? voters.map((voter, i) => { - let option = voter.body.messages[0].option; - option = option.replace("VOTE_OPTION_", ""); - option = option.replace(/\_/g, " "); - return ( - - - - - ); - }) - : ""} - -
VotersAnswer
{voter.body.messages[0].voter}{option}
-
-
- ) : ( - "" - )} -
-
-
- ); -} - -const mapStateToProps = (state) => { - return { advanceUser: state.user.advanceUser }; -}; - -export default connect(mapStateToProps, { proposalDeposit, proposalVote })( - ProposalDetailsView -); diff --git a/pages/[userId]/proposals/index.js b/pages/[userId]/proposals/index.js deleted file mode 100644 index 134f3c54..00000000 --- a/pages/[userId]/proposals/index.js +++ /dev/null @@ -1,144 +0,0 @@ -import Head from "next/head"; -import Header from "../../../components/header"; -import { connect } from "react-redux"; -import { useRouter } from "next/router"; -import Link from "next/link"; -import { useState, useEffect } from "react"; -import PublicTabs from "../../../components/dashboard/publicTabs"; -import getDao from "../../../helpers/getDao"; -import Footer from "../../../components/footer"; -import getProposals from "../../../helpers/getProposals"; -import dayjs from "dayjs"; -import ProposalItem from "../../../components/dashboard/proposalItem"; - -export async function getStaticProps() { - return { props: {} }; -} - -export async function getStaticPaths() { - return { - paths: [], - fallback: "blocking", - }; -} - -function GitopiaProposals(props) { - const router = useRouter(); - const [dao, setDao] = useState({ - name: "", - repositories: [], - }); - const [proposals, setProposals] = useState([]); - var localizedFormat = require("dayjs/plugin/localizedFormat"); - dayjs.extend(localizedFormat); - - useEffect(async () => { - const o = await getDao(router.query.userId); - if (o) { - setDao(o); - } - }, [router.query]); - - const hrefBase = "/" + router.query.userId; - const letter = dao.name.slice(0, 1); - - const avatarLink = - process.env.NEXT_PUBLIC_GITOPIA_ADDRESS === dao.address - ? "/logo-g.svg" - : "https://avatar.oxro.io/avatar.svg?length=1&height=100&width=100&fontSize=52&caps=1&name=" + - letter; - - useEffect(async () => { - if (router.query.userId !== process.env.NEXT_PUBLIC_GITOPIA_ADDRESS) { - router.push("/" + router.query.userId); - } - const p = await getProposals(); - setProposals(p); - }, []); - - return ( -
- - {dao.name} - - -
-
-
-
-
-
- -
-
-
-
{dao.name}
-
- {dao.description} -
-
-
-
- -
-
-
- Proposal List -
- {process.env.NEXT_PUBLIC_GITOPIA_ADDRESS.toString() === - router.query.userId ? ( -
- - - -
- ) : ( - "" - )} -
- -
- {proposals.length > 0 || proposals !== undefined ? ( - proposals.map((p) => { - return ( - - ); - }) - ) : ( -
-

No Proposals to Show

-
- )} -
-
-
-
-
- ); -} - -const mapStateToProps = (state) => { - return { - currentDashboard: state.user.currentDashboard, - dashboards: state.user.dashboards, - }; -}; - -export default connect(mapStateToProps, {})(GitopiaProposals); diff --git a/pages/[userId]/proposals/new.js b/pages/[userId]/proposals/new.js deleted file mode 100644 index cc5c1bdd..00000000 --- a/pages/[userId]/proposals/new.js +++ /dev/null @@ -1,710 +0,0 @@ -import Head from "next/head"; -import Header from "../../../components/header"; -import { useEffect, useState } from "react"; -import { connect } from "react-redux"; -import { useRouter } from "next/router"; -import Link from "next/dist/client/link"; -import { submitGovernanceProposal } from "../../../store/actions/proposals"; -import { chainUpgradeProposal } from "../../../store/actions/proposals"; -import MarkdownEditor from "../../../components/markdownEditor"; -import { communityPoolSpendProposal } from "../../../store/actions/proposals"; -import { paramChangeProposal } from "../../../store/actions/proposals"; -import getDao from "../../../helpers/getDao"; -import getUser from "../../../helpers/getUser"; -import PublicTabs from "../../../components/dashboard/publicTabs"; -import validAddress from "../../../helpers/validAddress"; - -function RepositoryProposalCreateView(props) { - const [validateAddressError, setValidateAddressError] = useState(""); - const [validateAmountError, setValidateAmountError] = useState(""); - const [validateInitialAmountError, setValidateInitialAmountError] = useState( - "" - ); - const [validateTitleError, setValidateTitleError] = useState(""); - const router = useRouter(); - const [loading, setLoading] = useState(false); - const [title, setTitle] = useState(""); - const [description, setDescription] = useState(""); - const [proposalType, setProposalType] = useState("1"); - const [amount, setAmount] = useState(""); - const [address, setAddress] = useState(""); - const [height, setHeight] = useState(""); - const [releaseVersionTag, setReleaseVersionTag] = useState(""); - const [paramSubspaces, setParamSubspaces] = useState([""]); - const [paramKeys, setParamKeys] = useState([""]); - const [paramValues, setParamValues] = useState([""]); - const [menuState, setMenuState] = useState(1); - const [counter, setCounter] = useState(1); - const [initialDeposit, setInitialDeposit] = useState(0); - const [dao, setDao] = useState({ - name: "", - repositories: [], - }); - - useEffect(async () => { - const o = await getDao(router.query.userId); - if (o) { - setDao(o); - } - }, [router.query]); - const hrefBase = "/" + dao.address; - const letter = dao.id ? dao.name.slice(0, 1) : "x"; - const avatarLink = - process.env.NEXT_PUBLIC_GITOPIA_ADDRESS === dao.address - ? "/logo-g.svg" - : "https://avatar.oxro.io/avatar.svg?length=1&height=100&width=100&fontSize=52&caps=1&name=" + - letter; - - const validateTitle = async (title) => { - setValidateTitleError(null); - if (title.length < 3) { - setValidateTitleError("Title too short"); - } - }; - - const validateUserAddress = async (address) => { - if (address.trim() !== "" && validAddress.test(address)) { - const res = await getUser(address); - setValidateAddressError(null); - } else { - setValidateAddressError("Enter a valid address"); - } - }; - - function isNaturalNumber(n) { - n = n.toString(); - var n1 = Math.abs(n), - n2 = parseInt(n, 10); - return !isNaN(n1) && n2 === n1 && n1.toString() === n; - } - - const validateAmount = async (amount) => { - setValidateAmountError(null); - let Vamount = Number(amount); - if (amount == "" || amount == 0) { - setValidateAmountError("Enter a valid amount"); - } - - // let balance = props.loreBalance; - if (props.advanceUser === false) { - Vamount = Vamount * 1000000; - } - if (!isNaturalNumber(Vamount)) { - // if (Vamount > balance) { - // setValidateAmountError("Insufficient Balance"); - // } - // } else { - setValidateAmountError("Enter a valid amount"); - } - }; - - const validateInitialAmount = async (amount) => { - setValidateInitialAmountError(null); - let Vamount = Number(amount); - if (amount == "") { - setValidateInitialAmountError("Enter a valid amount"); - } - let balance = props.loreBalance; - if (props.advanceUser === false) { - Vamount = Vamount * 1000000; - } - if (Vamount >= 0 && isNaturalNumber(Vamount)) { - if (Vamount > balance) { - setValidateInitialAmountError("Insufficient balance"); - } - } else { - setValidateInitialAmountError("Enter a valid amount"); - } - }; - - const handleClick = () => { - setCounter(counter + 1); - let array = paramSubspaces.slice(); - array.push(undefined); - setParamSubspaces(array); - - array = paramKeys.slice(); - array.push(undefined); - setParamKeys(array); - - array = paramValues.slice(); - array.push(undefined); - setParamValues(array); - }; - - const handleParamSubspaceOnChange = (subspace, index) => { - const array = paramSubspaces.slice(); - array[index] = subspace; - setParamSubspaces(array); - }; - - const handleParamKeyOnChange = (key, index) => { - const array = paramKeys.slice(); - array[index] = key; - setParamKeys(array); - }; - - const handleParamValueOnChange = (value, index) => { - const array = paramValues.slice(); - array[index] = value; - setParamValues(array); - }; - - const redirectToProposal = async (res) => { - let result = JSON.parse(res.rawLog); - if (res && res.code === 0) { - router.push( - hrefBase + "/proposals/" + result[0].events[4].attributes[0].value - ); - } - }; - - return ( -
- - Gitopia Proposals - - -
-
-
-
-
-
- -
-
-
-
{dao.name}
-
- {dao.description} -
-
-
-
- -
- -
-
- - - -
-
-

Write your proposal

-

- Proposals play a vital role in the functioning of decentralised - applications. Any changes or upgrades are done only after - proposals are voted in consensus. But there is no standard - category to distinguish different types of proposals. Having a - clear category will help communities to easily manage different - types of proposals. -

-
-
- - { - await validateTitle(e.target.value); - }} - onChange={(e) => { - setTitle(e.target.value); - }} - /> - {validateTitleError ? ( - - ) : ( - "" - )} -
-
- - -
-
- -
- -
-
- -
- { - await validateInitialAmount(e.target.value); - }} - onMouseUp={async (e) => { - await validateInitialAmount(e.target.value); - }} - className="input input-md input-bordered text-xs h-8" - value={initialDeposit} - onChange={(e) => { - setInitialDeposit(e.target.value); - }} - /> - {validateInitialAmountError ? ( - - ) : ( - "" - )} -
-
- {(menuState == 2 || menuState == 5) && ( -
-
- -
- { - await validateAmount(e.target.value); - }} - onMouseUp={async (e) => { - await validateAmount(e.target.value); - }} - className="input input-md input-bordered text-xs h-8" - value={amount} - onChange={(e) => { - setAmount(e.target.value); - }} - /> - {validateAmountError ? ( - - ) : ( - "" - )} -
-
- -
- -
- { - await validateUserAddress(e.target.value); - }} - className="input input-md input-bordered text-xs h-8" - value={address} - onChange={(e) => { - setAddress(e.target.value); - }} - /> - {validateAddressError ? ( - - ) : ( - "" - )} -
-
-
-
- -
-
-
- )} - {menuState == 3 && ( -
-
- -
- { - setReleaseVersionTag(e.target.value); - }} - /> -
-
- -
- -
- { - setHeight(e.target.value); - }} - /> -
-
-
-
- -
-
-
- )} - {menuState == 4 && ( -
-
- -
- {Array.from(Array(counter)).map((c, index) => { - return ( -
-
- { - handleParamSubspaceOnChange( - e.target.value, - index - ); - }} - /> -
-
- { - handleParamKeyOnChange(e.target.value, index); - }} - /> -
-
- { - handleParamValueOnChange(e.target.value, index); - }} - /> -
-
- ); - })} -
-
- -
-
-
-
- -
-
-
- )} - {menuState == 1 && ( -
-
- -
-
- )} -
-
-
-
-
- ); -} - -const mapStateToProps = (state) => { - return { - currentDashboard: state.user.currentDashboard, - advanceUser: state.user.advanceUser, - loreBalance: state.wallet.loreBalance, - dashboards: state.user.dashboards, - }; -}; - -export default connect(mapStateToProps, { - submitGovernanceProposal, - chainUpgradeProposal, - communityPoolSpendProposal, - paramChangeProposal, -})(RepositoryProposalCreateView); diff --git a/pages/daos/[daoId]/dashboard.js b/pages/daos/[daoId]/dashboard.js index 5a94627a..24b54f7c 100644 --- a/pages/daos/[daoId]/dashboard.js +++ b/pages/daos/[daoId]/dashboard.js @@ -91,7 +91,7 @@ function DaoDashboard(props) { href={ "/" + process.env.NEXT_PUBLIC_GITOPIA_ADDRESS + - "/proposals" + "?tab=proposals" } > Proposals @@ -130,19 +130,13 @@ function DaoDashboard(props) { href={ "/" + process.env.NEXT_PUBLIC_GITOPIA_ADDRESS + - "/proposals" + "?tab=proposals" } > Proposals - - Source code - + Source code ) : ( diff --git a/pages/home.js b/pages/home.js index f1232ec4..83f73fc0 100644 --- a/pages/home.js +++ b/pages/home.js @@ -33,18 +33,17 @@ function Home(props) { }); useEffect(async () => { - if (props.selectedAddress !== props.currentDashboard) { - const newUrl = getHomeUrl(props.dashboards, props.currentDashboard); - console.log(newUrl); - router.push(newUrl); - } if (props.selectedAddress) { - const repos = await getAnyRepositoryAll(props.currentDashboard); - if (repos) { - console.log(repos); - setAllRepository(repos); + if (props.selectedAddress !== props.currentDashboard) { + const newUrl = getHomeUrl(props.dashboards, props.currentDashboard); + router.push(newUrl); } else { - setAllRepository([]); + const repos = await getAnyRepositoryAll(props.currentDashboard); + if (repos) { + setAllRepository(repos); + } else { + setAllRepository([]); + } } } else { setAllRepository([]); @@ -110,7 +109,7 @@ function Home(props) { href={ "/" + process.env.NEXT_PUBLIC_GITOPIA_ADDRESS + - "/proposals" + "?tab=proposals" } > Proposals @@ -118,11 +117,7 @@ function Home(props) { - + Source code @@ -164,19 +159,13 @@ function Home(props) { href={ "/" + process.env.NEXT_PUBLIC_GITOPIA_ADDRESS + - "/proposals" + "?tab=proposals" } > Proposals - - Source code - + Source code ) : ( diff --git a/store/actions/dao.js b/store/actions/dao.js index c1e55204..9f88dff2 100644 --- a/store/actions/dao.js +++ b/store/actions/dao.js @@ -32,7 +32,6 @@ export const createDao = ({ try { const message = await env.txClient.msgCreateDao(dao); const result = await sendTransaction({ message })(dispatch, getState); - console.log(result); if (result && result.code === 0) { await getUserDetailsForSelectedAddress()(dispatch, getState); const daos = await getUserDaoAll(wallet.selectedAddress); @@ -45,8 +44,16 @@ export const createDao = ({ }, }); updateUserBalance()(dispatch, getState); - setCurrentDashboard(wallet.selectedAddress)(dispatch, getState); - return { url: "/home" }; + let newDaoAddress; + daos.every((d) => { + if (d.name === name) { + newDaoAddress = d.address; + return false; + } + return true; + }); + setCurrentDashboard(newDaoAddress)(dispatch, getState); + return { url: "/daos/" + name + "/dashboard" }; } else { dispatch(notify(result.rawLog, "error")); return null; diff --git a/store/actions/wallet.js b/store/actions/wallet.js index baa4d5f1..7907d87f 100644 --- a/store/actions/wallet.js +++ b/store/actions/wallet.js @@ -96,7 +96,7 @@ export const unlockKeplrWallet = () => { if (window.keplr && window.getOfflineSigner) { try { const info = await getNodeInfo(); - const chainId = info.node_info.network; + const chainId = info.default_node_info.network; const offlineSigner = await window.getOfflineSignerAuto(chainId); const accounts = await offlineSigner.getAccounts(); const key = await window.keplr.getKey(chainId); diff --git a/store/reducers/user.js b/store/reducers/user.js index ce02c142..625f1962 100644 --- a/store/reducers/user.js +++ b/store/reducers/user.js @@ -41,7 +41,7 @@ const reducer = (state = initialState, action) => { } case userActions.INIT_DASHBOARDS: { - const { name, id, daos } = action.payload; + const { name, id, daos = [] } = action.payload; const dashboards = [ { type: "User", diff --git a/yarn.lock b/yarn.lock index eb2b397d..e11172ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -304,9 +304,10 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@gitopia/gitopia-js@git+https://github.com/gitopia/gitopia-js#078070f1b30467234775c246adf97b14a1c5eedd": - version "0.14.0" - resolved "git+https://github.com/gitopia/gitopia-js#078070f1b30467234775c246adf97b14a1c5eedd" +"@gitopia/gitopia-js@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@gitopia/gitopia-js/-/gitopia-js-1.0.0.tgz#84aa587de3a4b21611195936f2173b06f62a9ee6" + integrity sha512-h42uDkot5kal31YN4fL1XIgdxz1XOJNnucEFpW9qz7rDPAPQpXnlSdLjDAo/rsBz/PJq+h1YTRFBznVMCp1Peg== "@gitopia/stargate@0.27.1": version "0.27.1"