Skip to content

Commit 09d2ff0

Browse files
authored
Merge pull request #173 from ourzora/edit-founders-allocation
Edit founders allocation
2 parents fdf5963 + 79fc836 commit 09d2ff0

File tree

6 files changed

+451
-179
lines changed

6 files changed

+451
-179
lines changed

apps/web/src/modules/create-dao/components/AllocationForm/AllocationForm.schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as Yup from 'yup'
33
import { isValidAddress } from 'src/utils/ens'
44
import { getProvider } from 'src/utils/provider'
55

6-
const allocationSchema = Yup.object().shape({
6+
export const allocationSchema = Yup.object().shape({
77
founderAddress: Yup.string()
88
.test(
99
'isValidAddress',
@@ -14,12 +14,12 @@ const allocationSchema = Yup.object().shape({
1414
allocationPercentage: Yup.number()
1515
.transform((value) => (isNaN(value) ? undefined : value))
1616
.required('*')
17+
.integer('Must be whole number')
18+
.max(100, '< 100')
1719
.when('admin', (admin, schema) => {
1820
if (!admin) return schema.min(1, '> 0') // (condition, errorMessage) - allocation represented as % must be greater than or equal to 0
1921
return schema
20-
})
21-
.max(100, '< 100')
22-
.integer('Must be whole number'),
22+
}),
2323
endDate: Yup.string()
2424
.required('*')
2525
.test('isDateInFuture', 'Must be in future', (value: string | undefined) => {

apps/web/src/modules/dao/components/AdminForm/AdminForm.schema.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Provider } from '@ethersproject/abstract-provider'
22
import * as Yup from 'yup'
33

4-
import { auctionSettingsValidationSchema } from 'src/modules/create-dao'
4+
import { TokenAllocation, auctionSettingsValidationSchema } from 'src/modules/create-dao'
5+
import { allocationSchema } from 'src/modules/create-dao/components/AllocationForm/AllocationForm.schema'
56
import { Duration } from 'src/typings'
67
import { isValidAddress } from 'src/utils/ens'
78
import { durationValidationSchema, urlValidationSchema } from 'src/utils/yup'
@@ -17,6 +18,7 @@ export interface AdminFormValues {
1718
quorumThreshold: number
1819
votingPeriod: Duration
1920
votingDelay: Duration
21+
founderAllocation: TokenAllocation[]
2022
vetoPower: boolean
2123
vetoer: string
2224
}
@@ -48,6 +50,16 @@ export const adminValidationSchema = (provider: Provider | undefined) =>
4850
{ value: tenMinutes, description: '10 minutes' },
4951
{ value: twentyFourWeeks, description: '24 weeks' }
5052
),
53+
founderAllocation: Yup.array()
54+
.of(allocationSchema)
55+
.test(
56+
'unique',
57+
'Founder allocation addresses should be unique.',
58+
function (values) {
59+
const addresses = values?.map((v) => v.founderAddress)
60+
return values?.length === new Set(addresses)?.size
61+
}
62+
),
5163
vetoPower: Yup.bool().required('*'),
5264
})
5365
)

0 commit comments

Comments
 (0)