From d5bf85984dccbf4c7451078d85dc39b0b58ffaae Mon Sep 17 00:00:00 2001 From: yuetloo Date: Wed, 24 Apr 2024 22:47:34 -0400 Subject: [PATCH 1/3] do not show verify page if using semaphore user registry --- vue-app/src/api/core.ts | 7 ++++++- vue-app/src/components/CallToActionCard.vue | 4 ++-- vue-app/src/components/Cart.vue | 6 ++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/vue-app/src/api/core.ts b/vue-app/src/api/core.ts index 5caa704c6..6d79b2785 100644 --- a/vue-app/src/api/core.ts +++ b/vue-app/src/api/core.ts @@ -45,6 +45,7 @@ export enum UserRegistryType { SIMPLE = 'simple', SNAPSHOT = 'snapshot', MERKLE = 'merkle', + SEMAPHORE = 'semaphore', } if (!Object.values(UserRegistryType).includes(userRegistryType as UserRegistryType)) { @@ -92,7 +93,11 @@ export const showComplianceRequirement = /^yes$/i.test(import.meta.env.VITE_SHOW export const isBrightIdRequired = userRegistryType === 'brightid' export const isOptimisticRecipientRegistry = recipientRegistryType === 'optimistic' -export const isUserRegistrationRequired = userRegistryType !== UserRegistryType.SIMPLE +export const isUserRegistrationRequired = [ + UserRegistryType.BRIGHT_ID, + UserRegistryType.MERKLE, + UserRegistryType.SNAPSHOT, +].includes(userRegistryType) // Try to get the next scheduled start date const nextStartDate = import.meta.env.VITE_NEXT_ROUND_START_DATE diff --git a/vue-app/src/components/CallToActionCard.vue b/vue-app/src/components/CallToActionCard.vue index 7d094a1a6..2d29121d7 100644 --- a/vue-app/src/components/CallToActionCard.vue +++ b/vue-app/src/components/CallToActionCard.vue @@ -55,7 +55,7 @@ import { computed } from 'vue' import BrightIdWidget from '@/components/BrightIdWidget.vue' import Links from '@/components/Links.vue' -import { userRegistryType, UserRegistryType, isBrightIdRequired } from '@/api/core' +import { isUserRegistrationRequired, isBrightIdRequired } from '@/api/core' import { useAppStore, useUserStore } from '@/stores' import { storeToRefs } from 'pinia' @@ -69,7 +69,7 @@ const hasStartedVerification = computed( ) const showUserVerification = computed(() => { return ( - userRegistryType !== UserRegistryType.SIMPLE && + isUserRegistrationRequired && currentRound.value && currentUser.value?.isRegistered !== undefined && !currentUser.value.isRegistered diff --git a/vue-app/src/components/Cart.vue b/vue-app/src/components/Cart.vue index cb10c454a..605a766fc 100644 --- a/vue-app/src/components/Cart.vue +++ b/vue-app/src/components/Cart.vue @@ -237,7 +237,7 @@ import CartItems from '@/components/CartItems.vue' import Links from '@/components/Links.vue' import TimeLeft from '@/components/TimeLeft.vue' import { MAX_CONTRIBUTION_AMOUNT, MAX_CART_SIZE, type CartItem, isContributionAmountValid } from '@/api/contributions' -import { userRegistryType, UserRegistryType, operator } from '@/api/core' +import { userRegistryType, UserRegistryType, operator, isUserRegistrationRequired } from '@/api/core' import { RoundStatus } from '@/api/round' import { formatAmount as _formatAmount } from '@/utils/amounts' import FundsNeededWarning from '@/components/FundsNeededWarning.vue' @@ -477,9 +477,7 @@ const isBrightIdRequired = computed( () => userRegistryType === UserRegistryType.BRIGHT_ID && !currentUser.value?.isRegistered, ) -const isRegistrationRequired = computed( - () => userRegistryType !== UserRegistryType.SIMPLE && !currentUser.value?.isRegistered, -) +const isRegistrationRequired = computed(() => isUserRegistrationRequired && !currentUser.value?.isRegistered) const errorMessage = computed(() => { if (isMessageLimitReached.value) return t('dynamic.cart.error.reached_contribution_limit') From 5102e77acd377c82ba7d73bbc1ae0f4f0aba21ec Mon Sep 17 00:00:00 2001 From: yuetloo Date: Wed, 24 Apr 2024 23:17:38 -0400 Subject: [PATCH 2/3] handle user not registered case for semaphore user registry --- vue-app/src/components/Cart.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vue-app/src/components/Cart.vue b/vue-app/src/components/Cart.vue index 605a766fc..1e0301d38 100644 --- a/vue-app/src/components/Cart.vue +++ b/vue-app/src/components/Cart.vue @@ -484,9 +484,9 @@ const errorMessage = computed(() => { if (!currentUser.value) return t('dynamic.cart.error.connect_wallet') if (isBrightIdRequired.value) return t('dynamic.cart.error.need_to_setup_brightid') if (!currentUser.value.isRegistered) { - return userRegistryType === UserRegistryType.SIMPLE - ? t('dynamic.cart.error.user_not_registered', { operator }) - : t('dynamic.cart.error.need_to_register') + return isUserRegistrationRequired + ? t('dynamic.cart.error.need_to_register') + : t('dynamic.cart.error.user_not_registered', { operator }) } if (!isFormValid()) return t('dynamic.cart.error.invalid_contribution_amount') if (cart.value.length > MAX_CART_SIZE) From 08dc551507cc95fc57f38a03433f399822794f90 Mon Sep 17 00:00:00 2001 From: yuetloo Date: Wed, 24 Apr 2024 23:21:05 -0400 Subject: [PATCH 3/3] add semaphore user registry --- vue-app/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vue-app/.env.example b/vue-app/.env.example index b7a9357e4..26689edf3 100644 --- a/vue-app/.env.example +++ b/vue-app/.env.example @@ -21,7 +21,7 @@ VITE_SUBGRAPH_URL=http://localhost:8000/subgraphs/name/clrfund/clrfund VITE_CLRFUND_ADDRESS=0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 -# Supported values: simple, brightid, snapshot, merkle +# Supported values: simple, brightid, snapshot, merkle, semaphore VITE_USER_REGISTRY_TYPE=simple # clr.fund (prod) or CLRFundTest (testing) # Learn more about BrightID and context in /docs/brightid.md