Skip to content

Commit

Permalink
Merge pull request #173 from ourzora/edit-founders-allocation
Browse files Browse the repository at this point in the history
Edit founders allocation
  • Loading branch information
neokry authored Mar 28, 2023
2 parents fdf5963 + 79fc836 commit 09d2ff0
Show file tree
Hide file tree
Showing 6 changed files with 451 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Yup from 'yup'
import { isValidAddress } from 'src/utils/ens'
import { getProvider } from 'src/utils/provider'

const allocationSchema = Yup.object().shape({
export const allocationSchema = Yup.object().shape({
founderAddress: Yup.string()
.test(
'isValidAddress',
Expand All @@ -14,12 +14,12 @@ const allocationSchema = Yup.object().shape({
allocationPercentage: Yup.number()
.transform((value) => (isNaN(value) ? undefined : value))
.required('*')
.integer('Must be whole number')
.max(100, '< 100')
.when('admin', (admin, schema) => {
if (!admin) return schema.min(1, '> 0') // (condition, errorMessage) - allocation represented as % must be greater than or equal to 0
return schema
})
.max(100, '< 100')
.integer('Must be whole number'),
}),
endDate: Yup.string()
.required('*')
.test('isDateInFuture', 'Must be in future', (value: string | undefined) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Provider } from '@ethersproject/abstract-provider'
import * as Yup from 'yup'

import { auctionSettingsValidationSchema } from 'src/modules/create-dao'
import { TokenAllocation, auctionSettingsValidationSchema } from 'src/modules/create-dao'
import { allocationSchema } from 'src/modules/create-dao/components/AllocationForm/AllocationForm.schema'
import { Duration } from 'src/typings'
import { isValidAddress } from 'src/utils/ens'
import { durationValidationSchema, urlValidationSchema } from 'src/utils/yup'
Expand All @@ -17,6 +18,7 @@ export interface AdminFormValues {
quorumThreshold: number
votingPeriod: Duration
votingDelay: Duration
founderAllocation: TokenAllocation[]
vetoPower: boolean
vetoer: string
}
Expand Down Expand Up @@ -48,6 +50,16 @@ export const adminValidationSchema = (provider: Provider | undefined) =>
{ value: tenMinutes, description: '10 minutes' },
{ value: twentyFourWeeks, description: '24 weeks' }
),
founderAllocation: Yup.array()
.of(allocationSchema)
.test(
'unique',
'Founder allocation addresses should be unique.',
function (values) {
const addresses = values?.map((v) => v.founderAddress)
return values?.length === new Set(addresses)?.size
}
),
vetoPower: Yup.bool().required('*'),
})
)
Loading

2 comments on commit 09d2ff0

@vercel
Copy link

@vercel vercel bot commented on 09d2ff0 Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

testnet-nouns-builder – ./apps/web

testnet.nouns.build
testnet-nouns-builder-ourzora.vercel.app
testnet-nouns-builder-git-main-ourzora.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 09d2ff0 Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.