Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions backend/main/server/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,22 @@ func (a *App) createCommunity(w http.ResponseWriter, r *http.Request) {
return
}

//Validate Contract Thresholds
//Validate Strategies & Proposal Thresholds
if payload.Strategies != nil {
err = validateContractThreshold(*payload.Strategies)
if err != nil {
respondWithError(w, http.StatusBadRequest, err.Error())
return
}
}
propThreshold, err := strconv.ParseFloat(*payload.Proposal_threshold, 64)
if err != nil {
respondWithError(w, http.StatusBadRequest, "Error Converting Proposal Threshold to Float.")
}
if propThreshold < 1 {
respondWithError(w, http.StatusBadRequest, "Proposal Threshold cannot be less than 1.")
return
}

c, httpStatus, err := helpers.createCommunity(payload)
if err != nil {
Expand All @@ -383,14 +391,22 @@ func (a *App) updateCommunity(w http.ResponseWriter, r *http.Request) {
return
}

//Validate Contract Thresholds
//Validate Strategies & Proposal Thresholds
if payload.Strategies != nil {
err = validateContractThreshold(*payload.Strategies)
if err != nil {
respondWithError(w, http.StatusBadRequest, err.Error())
return
}
}
propThreshold, err := strconv.ParseFloat(*payload.Proposal_threshold, 64)
if err != nil {
respondWithError(w, http.StatusBadRequest, "Error Converting Proposal Threshold to Float.")
}
if propThreshold < 1 {
respondWithError(w, http.StatusBadRequest, "Proposal Threshold cannot be less than 1.")
return
}

c, httpStatus, err := helpers.updateCommunity(id, payload)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion backend/main/server/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ func validateContractThreshold(s []models.Strategy) error {
for _, s := range s {
if s.Threshold != nil {
if *s.Threshold < 1 {
return errors.New("Contract Threshold Cannot Be < 1.")
return errors.New("Contract Threshold cannot be less than 1.")
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/client/src/App.sass
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ code
background: transparent
.divider
border-bottom: 1px solid $grey-light
.rounded
border-radius: 16px
.rounded-sm
border-radius: 8px
.rounded-sm-tl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ yup.addMethod(yup.string, 'makeOtherFieldsRequired', function (message) {
});
});

yup.addMethod(yup.string, 'validateThreshold', function (message) {
return this.test('checkLessThanOne', message, function (value, context) {
const { path } = context;
if (parseFloat(value) < 1) {
return this.createError({
path: `${path}`,
message,
});
}
return true;
});
});

const Schema = (isValidFlowAddress) =>
yup.object().shape({
onlyAuthorsToSubmitProposals: yup.boolean(),
Expand Down Expand Up @@ -75,6 +88,7 @@ const Schema = (isValidFlowAddress) =>
'Please enter a proposal threshold if other fields are not empty'
)
.matches(/(^[0-9]+$|^$)/, 'Proposal threshold must be a number')
.validateThreshold('Threshold cannot be less than 1.')
.when('onlyAuthorsToSubmitProposals', {
is: false,
then: yup.string().required('Please enter a proposal threshold'),
Expand Down
15 changes: 6 additions & 9 deletions frontend/packages/client/src/components/WalletConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ const SignInOutButton = ({
);
const addressStyle = classnames('', { 'smaller-text': !notMobile });

const containerAddressStyle = classnames('is-flex', { 'pl-2': !notMobile });

const containerButtonStyle = classnames('is-flex is-align-items-center', {
'flex-1 is-justify-content-space-between': notMobile,
});

return (
<>
<div className={dropdownBackground} />
Expand All @@ -101,14 +95,14 @@ const SignInOutButton = ({
}
>
{loggedIn ? (
<div className={containerButtonStyle}>
<div className="is-flex is-align-items-center flex-1 is-justify-content-space-around">
<Blockies
seed={addr}
size={notMobile ? 6.5 : 5}
scale={4}
className="blockies"
/>
<div className={containerAddressStyle}>
<div className="is-flex">
<p className={addressStyle}>{truncateAddress(addr, 4, 4)}</p>
</div>
</div>
Expand All @@ -128,7 +122,10 @@ const SignInOutButton = ({
ref={dropdownRef}
style={!notMobile ? { left: '-160px' } : { left: '-130px' }}
>
<div className="dropdown-content p-0" style={{ width: '277px' }}>
<div
className="dropdown-content p-0 rounded"
style={{ width: '277px' }}
>
<div className="px-4 pt-4 pb-2">
<Tooltip
classNames="is-flex is-flex-grow-1 is-align-items-center transition-all"
Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/client/src/hooks/useJoinCommunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function useJoinCommunity() {
compositeSignatures,
voucher,
userType: 'member',
signingAddr: addr,
});
},
{
Expand Down Expand Up @@ -74,6 +75,7 @@ export default function useJoinCommunity() {
hexTime,
compositeSignatures,
voucher,
signingAddr: addr,
});
},
{
Expand Down