diff --git a/src/Components/Sprite/Sprite.tsx b/src/Components/Sprite/Sprite.tsx index 70115627..9ff31aee 100644 --- a/src/Components/Sprite/Sprite.tsx +++ b/src/Components/Sprite/Sprite.tsx @@ -24,8 +24,8 @@ const Svg = styled.svg` --secondaryColor: ${({ secondaryColor }) => secondaryColor}; width: ${({ size, width }) => width || size}; height: ${({ size, height }) => height || size}; - transform: ${({ flipX }) => flipX && `scaleX(-1)`} ${({ flipY }) => flipY && `scaleY(-1)`}; - ${({ spin }) => Boolean(spin) && `rotate(${spin}deg)`}; + transform: ${({ flipX }) => flipX && `scaleX(-1)`} ${({ flipY }) => flipY && `scaleY(-1)`} + ${({ spin }) => Boolean(spin) && `rotate(${spin}deg)`}; transition: ${({ animate }) => animate && 'transform 150ms linear'}; `; diff --git a/src/Pages/Proposal/Components/ManageVotingModal/ManageVotingModal.tsx b/src/Pages/Proposal/Components/ManageVotingModal/ManageVotingModal.tsx index 55f5d17d..f3716e3f 100644 --- a/src/Pages/Proposal/Components/ManageVotingModal/ManageVotingModal.tsx +++ b/src/Pages/Proposal/Components/ManageVotingModal/ManageVotingModal.tsx @@ -1,8 +1,9 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Formik, FormikProps } from 'formik'; import styled, { useTheme } from 'styled-components'; import { Button, Modal, Forms } from 'Components'; import { isEmpty, votingData as data, votingValidations as validations } from 'utils'; +import { useWalletConnect } from '@provenanceio/walletconnect-js'; import { useGovernance, useAccounts } from 'redux/hooks'; import { VotingChart, Countdown } from './Components'; @@ -138,6 +139,7 @@ const ManageVotingModal = ({ const hasDelegations = parseInt(accountDelegationsTotal.amount) > 0; const [voteAnyway, setVoteAnyway] = useState(false); const [error, setError] = useState(''); + const { walletConnectService: wcs } = useWalletConnect(); useEffect(() => { setIsOpen(isLoggedIn && modalOpen); @@ -236,12 +238,14 @@ const ManageVotingModal = ({ } // Submit proposal message if (!voted) { - await submitVotes({ + const { data } = await submitVotes({ proposalId, voter: voterId, votes, - }).catch((error) => { - setError(error); + }); + wcs.customAction({ + description: 'Submit Proposal', + message: data.base64, }); } // Clear the form diff --git a/src/Pages/Proposal/Proposal.tsx b/src/Pages/Proposal/Proposal.tsx index 29b17c6a..80347e97 100644 --- a/src/Pages/Proposal/Proposal.tsx +++ b/src/Pages/Proposal/Proposal.tsx @@ -45,7 +45,8 @@ const Proposal = () => { useEffect(() => { if (address) { - getAccountAssets({ address }); + // TODO: Need an endpoint that only returns a users hash value + getAccountAssets({ address, count: 100 }); } }, [getAccountAssets, address]); diff --git a/src/Pages/Proposals/Components/ManageProposalModal.tsx b/src/Pages/Proposals/Components/ManageProposalModal.tsx index d5919dbc..459d3f3d 100644 --- a/src/Pages/Proposals/Components/ManageProposalModal.tsx +++ b/src/Pages/Proposals/Components/ManageProposalModal.tsx @@ -11,7 +11,7 @@ import { ContentProps, } from 'utils'; import { PROPOSAL_TYPES } from 'consts'; -import { useBlocks, useGovernance } from '../../../redux/hooks'; +import { useApp, useBlocks, useGovernance } from 'redux/hooks'; import { Countdown } from '../../Proposal/Components/ManageVotingModal/Components'; const Title = styled.div` @@ -103,6 +103,7 @@ const ManageProposalModal = ({ const [proposalType, setProposalType] = useState('text'); const { submitProposal } = useGovernance(); const { walletConnectService: wcs } = useWalletConnect(); + const { authToken } = useApp(); useEffect(() => { setIsOpen(isLoggedIn && modalOpen); @@ -168,8 +169,8 @@ const ManageProposalModal = ({ validationSchema={proposalValidations(proposalType, blockNumber)} onSubmit={async (values: ProposalProps, { resetForm }) => { // Remove the file from values to send separately - const file = values.file; - delete values.file; + const file = values?.file; + if (file) delete values.file; // Format values as needed const { data } = await submitProposal({ // Format the type string to match the query @@ -177,6 +178,7 @@ const ManageProposalModal = ({ // Get the proposal content as a string data: proposalContent(values as unknown as ContentProps), file: (file as unknown as File) || undefined, + token: authToken, }); // Submit via walletconnect-js diff --git a/src/redux/features/api.ts b/src/redux/features/api.ts index c14e33f6..e2a0949a 100644 --- a/src/redux/features/api.ts +++ b/src/redux/features/api.ts @@ -18,8 +18,9 @@ export const axios = _axios.create({ withCredentials: true, }); -export const xhrSetToken = (value: string) => - (axios.defaults.headers.Authorization = `Bearer ${value}`); +export const xhrSetToken = (value: string) => { + axios.defaults.headers.Authorization = `Bearer ${value}`; +}; function errorHandling(error: any) { if (error.response) { diff --git a/src/redux/features/governance/governanceSlice.ts b/src/redux/features/governance/governanceSlice.ts index 9016d02f..6fd7fcce 100644 --- a/src/redux/features/governance/governanceSlice.ts +++ b/src/redux/features/governance/governanceSlice.ts @@ -516,10 +516,12 @@ export const submitProposal = ({ type, data, file, + token, }: { type: string; data: SubmitProposalProps; file?: File; + token: string; }) => { // Create a new FormData object const formData = new FormData(); diff --git a/src/utils/proposals/proposalContent.tsx b/src/utils/proposals/proposalContent.tsx index 0e302a2f..debfa215 100644 --- a/src/utils/proposals/proposalContent.tsx +++ b/src/utils/proposals/proposalContent.tsx @@ -50,19 +50,33 @@ export const proposalContent = ({ funds, submitter, }: ContentProps) => ({ - content: JSON.stringify({ - changes, - name, - height, - info, - runAs, - accessConfig, - admin, - codeId, - label, - msg, - funds, - }), + // If there is content, stringify. Otherwise, return an empty string + content: + changes || + name || + height || + info || + runAs || + accessConfig || + admin || + codeId || + label || + msg || + funds + ? JSON.stringify({ + changes, + name, + height, + info, + runAs, + accessConfig, + admin, + codeId, + label, + msg, + funds, + }) + : '', title, description, initialDeposit: initialDeposit