diff --git a/apps/astraplusplus/widget/DAO/Proposal/Create/FunctionCall.jsx b/apps/astraplusplus/widget/DAO/Proposal/Create/FunctionCall.jsx index 2c7bd75..ee0862e 100644 --- a/apps/astraplusplus/widget/DAO/Proposal/Create/FunctionCall.jsx +++ b/apps/astraplusplus/widget/DAO/Proposal/Create/FunctionCall.jsx @@ -107,9 +107,9 @@ const handleFunctionCall = () => { }); return; } - if (state.gas > 300) { + if (state.gas > 270) { State.update({ - error: "Maximum gas allowed is 300Tgas" + error: "Maximum gas allowed is 270Tgas" }); return; } diff --git a/apps/astraplusplus/widget/DAO/Proposals/Card/index.jsx b/apps/astraplusplus/widget/DAO/Proposals/Card/index.jsx index 2eea96f..a755e0d 100644 --- a/apps/astraplusplus/widget/DAO/Proposals/Card/index.jsx +++ b/apps/astraplusplus/widget/DAO/Proposals/Card/index.jsx @@ -291,19 +291,6 @@ const expensiveWork = () => { : isAllowedTo(proposalKinds[kindName], actions.VoteRemove) ]; - // --- end check user permissions - // --- Votes required: - // TODO: Needs to be reviewed - - // Fixes pikespeak API for single proposal - Object.keys(my_proposal.vote_counts).forEach((k) => { - if (typeof my_proposal.vote_counts[k] !== "string") return; - my_proposal.vote_counts[k] = my_proposal.vote_counts[k] - .match(/.{1,2}/g) - .slice(0, 3) - .map((a) => parseInt(a)); - }); - let totalVotesNeeded = 0; if (policy?.roles) { @@ -357,11 +344,14 @@ const expensiveWork = () => { total: 0 }; - Object.keys(my_proposal.vote_counts).forEach((key) => { - if (key === "all") return; - totalVotes.yes += my_proposal.vote_counts[key][0]; - totalVotes.no += my_proposal.vote_counts[key][1]; - totalVotes.spam += my_proposal.vote_counts[key][2]; + Object.values(my_proposal.votes).forEach((vote) => { + if (vote === "Approve") { + totalVotes.yes++; + } else if (vote === "Reject") { + totalVotes.no++; + } else if (vote === "Remove") { + totalVotes.spam++; + } }); if (isVotingBodyDao) { @@ -493,7 +483,7 @@ const handleVote = ({ contractName: daoId, methodName: isCongressDaoID ? "vote" : "act_proposal", args: args, - gas: 270000000000000 + gas: 300000000000000 } ]; if (showNotification) { diff --git a/apps/astraplusplus/widget/DAO/Proposals/CardsList.jsx b/apps/astraplusplus/widget/DAO/Proposals/CardsList.jsx index 9e5ff14..6a5236a 100644 --- a/apps/astraplusplus/widget/DAO/Proposals/CardsList.jsx +++ b/apps/astraplusplus/widget/DAO/Proposals/CardsList.jsx @@ -29,13 +29,6 @@ return ( proposal.id = proposal_id; if (proposal.status === "Removed") return <>; - Object.keys(proposal.vote_counts).forEach((k) => { - if (typeof proposal.vote_counts[k] == "string") { - proposal.vote_counts[k] = proposal.vote_counts[k] - .match(/.{1,2}/g) - .map((x) => parseInt(x)); - } - }); return ( - asyncFetch( - `https://api.pikespeak.ai/sbt/sbt-by-owner?holder=${accountId}®istry=registry.i-am-human.near`, - { - method: "GET", - headers: { - "Content-Type": "application/json", - "x-api-key": "/*__@replace:pikespeakApiKey__*/" - } - } - ).then((res) => res?.body?.length > 0), - daoId + "-is-human-pikespeak-api", - { subscribe: false } + () => + asyncFetch( + `https://api.pikespeak.ai/sbt/sbt-by-owner?holder=${accountId}®istry=registry.i-am-human.near`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + "x-api-key": "/*__@replace:pikespeakApiKey__*/" + } + } + ).then((res) => res?.body?.length > 0), + daoId + "-is-human-pikespeak-api", + { subscribe: false } ); if (isHuman === null) { - return ; + return ; } const Table = styled.div` - font-size: 14px; - max-width: 100%; - overflow-x: auto; - height: 100%; - min-height: 100%; + font-size: 14px; + max-width: 100%; + overflow-x: auto; + height: 100%; + min-height: 100%; - td, - th { - vertical-align: middle; - padding-block: 5px; - } + td, + th { + vertical-align: middle; + padding-block: 5px; + } - tr { - height: 65px; - } + tr { + height: 65px; + } - .id-value { - border: 1px solid #4498e0; - color: #4498e0; - padding: 4px 8px; - background: rgba(68, 152, 224, 0.1); - border-radius: 100px; - font-size: 12px; - font-weight: 500; - } + .id-value { + border: 1px solid #4498e0; + color: #4498e0; + padding: 4px 8px; + background: rgba(68, 152, 224, 0.1); + border-radius: 100px; + font-size: 12px; + font-weight: 500; + } `; const roles = isCongressDaoID - ? Near.view(daoId, "get_members") - : isVotingBodyDao - ? null - : Near.view(daoId, "get_policy"); + ? Near.view(daoId, "get_members") + : isVotingBodyDao + ? null + : Near.view(daoId, "get_policy"); roles = roles === null ? [] : roles?.roles ?? roles; // -- Filter the user roles const userRoles = []; if (Array.isArray(roles)) { - for (const role of roles) { - if (role.kind === "Everyone") { - userRoles.push(role); - continue; - } - if (!role.kind.Group) continue; - if ( - accountId && - role.kind.Group && - role.kind.Group.includes(accountId) - ) { - userRoles.push(role); - } + for (const role of roles) { + if (role.kind === "Everyone") { + userRoles.push(role); + continue; } + if (!role.kind.Group) continue; + if (accountId && role.kind.Group && role.kind.Group.includes(accountId)) { + userRoles.push(role); + } + } } if (isCongressDaoID) { - userRoles = [ - { - name: "all", - kind: "Everyone", - permissions: roles?.permissions, - vote_policy: {} - } - ]; + userRoles = [ + { + name: "all", + kind: "Everyone", + permissions: roles?.permissions, + vote_policy: {} + } + ]; } if (isVotingBodyDao) { - userRoles = [ - { - name: "all", - kind: "Everyone", - permissions: {}, - vote_policy: {} - } - ]; + userRoles = [ + { + name: "all", + kind: "Everyone", + permissions: {}, + vote_policy: {} + } + ]; } const isAllowedTo = (kind, action) => { - // -- Check if the user is allowed to perform the action - let allowed = false; - userRoles - .filter(({ permissions }) => { - if (isCongressDaoID) { - const allowedRole = - permissions.includes(`${kind.toString()}`) && - roles?.members?.includes(accountId); - allowed = allowed || allowedRole; - return allowedRole; - } else { - const allowedRole = - permissions.includes( - `${kind.toString()}:${action.toString()}` - ) || - permissions.includes(`${kind.toString()}:*`) || - permissions.includes(`*:${action.toString()}`) || - permissions.includes("*:*"); - allowed = allowed || allowedRole; - return allowedRole; - } - }) - .map((role) => role.name); - return allowed; + // -- Check if the user is allowed to perform the action + let allowed = false; + userRoles + .filter(({ permissions }) => { + if (isCongressDaoID) { + const allowedRole = + permissions.includes(`${kind.toString()}`) && + roles?.members?.includes(accountId); + allowed = allowed || allowedRole; + return allowedRole; + } else { + const allowedRole = + permissions.includes(`${kind.toString()}:${action.toString()}`) || + permissions.includes(`${kind.toString()}:*`) || + permissions.includes(`*:${action.toString()}`) || + permissions.includes("*:*"); + allowed = allowed || allowedRole; + return allowedRole; + } + }) + .map((role) => role.name); + return allowed; }; return ( - - {proposals === null ? ( - <> - - - ) : ( -
- - - - - - - - - - - - - - {proposals !== null && - proposals.map( - ({ proposal, proposal_type, proposal_id }, i) => { - if (!isCongressDaoID && !isVotingBodyDao) { - proposal.kind = { - [proposal_type]: { - ...proposal.kind - } - }; - } - proposal.id = proposal_id; - if (proposal.status === "Removed") return <>; - Object.keys(proposal.vote_counts).forEach( - (k) => { - if ( - typeof proposal.vote_counts[k] == - "string" - ) { - proposal.vote_counts[k] = - proposal.vote_counts[k] - .match(/.{1,2}/g) - .map((x) => parseInt(x)); - } - } - ); - return ( - - ); - } - )} - -
IDDateProposer - Type - DescriptionVotes - Status -
- )} - + + {proposals === null ? ( + <> + + + ) : ( +
+ + + + + + + + + + + + + + {proposals !== null && + proposals.map(({ proposal, proposal_type, proposal_id }, i) => { + if (!isCongressDaoID && !isVotingBodyDao) { + proposal.kind = { + [proposal_type]: { + ...proposal.kind + } + }; + } + proposal.id = proposal_id; + if (proposal.status === "Removed") return <>; + return ( + + ); + })} + +
IDDateProposer + Type + DescriptionVotes + Status +
+ )} + );