-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support offchain space creation
- Loading branch information
Showing
16 changed files
with
1,360 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<script lang="ts" setup> | ||
import { clone } from '@/helpers/utils'; | ||
import { getValidator } from '@/helpers/validation'; | ||
const VALID_EXTENSIONS = [ | ||
'eth', | ||
'xyz', | ||
'com', | ||
'org', | ||
'io', | ||
'app', | ||
'art', | ||
'id' | ||
] as const; | ||
const DOMAIN_DEFINITION = { | ||
type: 'string', | ||
pattern: `^[a-zA-Z0-9\-\.]+\.(${VALID_EXTENSIONS.join('|')})$`, | ||
title: 'ENS name', | ||
examples: ['dao-name.eth'], | ||
errorMessage: { | ||
pattern: `Must be a valid domain ending with ${VALID_EXTENSIONS.join(', ')}` | ||
} | ||
} as const; | ||
const definition = { | ||
type: 'object', | ||
additionalProperties: false, | ||
required: [], | ||
properties: { | ||
domain: DOMAIN_DEFINITION | ||
} | ||
}; | ||
const emit = defineEmits<{ | ||
(e: 'submit'); | ||
}>(); | ||
const form = ref(clone({ domain: '' })); | ||
const formErrors = computed(() => { | ||
const validator = getValidator(definition); | ||
return validator.validate(form.value, { skipEmptyOptionalFields: true }); | ||
}); | ||
const formValid = computed(() => { | ||
return form.value.domain && Object.keys(formErrors.value).length === 0; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="s-box"> | ||
<UiForm :model-value="form" :error="formErrors" :definition="definition" /> | ||
<UiButton | ||
class="w-full" | ||
:disabled="!formValid" | ||
:to=" | ||
formValid | ||
? `https://app.ens.domains/name/${form.domain}/register` | ||
: undefined | ||
" | ||
@click="emit('submit')" | ||
> | ||
Register ENS name | ||
</UiButton> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts" setup> | ||
import { TokenStandard } from '@/components/SetupStrategiesOffchain.vue'; | ||
const ITEMS: Record<TokenStandard, { label: string; description: string }> = { | ||
ERC20: { | ||
label: 'ERC-20', | ||
description: 'For tokens e.g. ETH, USDC, UNI, etc...' | ||
}, | ||
ERC721: { | ||
label: 'ERC-721', | ||
description: 'For non-fungible tokens e.g. CryptoKitties, Doodle, etc...' | ||
}, | ||
ERC1155: { | ||
label: 'ERC-1155', | ||
description: | ||
'For both fungibles and non-fungibles tokens, e.g. MANA, Decentraland, etc...' | ||
} | ||
} as const; | ||
defineProps<{ | ||
open: boolean; | ||
initialState?: string; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'close'); | ||
(e: 'save', value: TokenStandard); | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<UiModal :open="open" @close="emit('close')"> | ||
<template #header> | ||
<h3>Select token standard</h3> | ||
</template> | ||
<div class="p-4 flex flex-col gap-2.5"> | ||
<UiSelector | ||
v-for="(standard, id) in ITEMS" | ||
:key="id" | ||
:is-active="initialState === id" | ||
class="w-full" | ||
@click="emit('save', id)" | ||
> | ||
<div> | ||
<h4 class="text-skin-link" v-text="standard.label" /> | ||
<div v-text="standard.description" /> | ||
</div> | ||
</UiSelector> | ||
</div> | ||
</UiModal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<script lang="ts" setup> | ||
import UiSelector from '@/components/Ui/Selector.vue'; | ||
import { VALIDATION_TYPES_INFO } from '@/helpers/constants'; | ||
import { NetworkID, Validation } from '@/types'; | ||
type ValidationDetailId = keyof typeof VALIDATION_TYPES_INFO; | ||
type ValidationDetails = typeof VALIDATION_TYPES_INFO & { | ||
key: ValidationDetailId; | ||
tag?: string; | ||
}; | ||
type ValidationRecords = Partial<Record<ValidationDetailId, ValidationDetails>>; | ||
const PROPOSAL_VALIDATION_TYPES_ID: ValidationDetailId[] = [ | ||
'only-members', | ||
'basic', | ||
'passport-gated', | ||
'arbitrum', | ||
'karma-eas-attestation' | ||
] as const; | ||
const VALIDATIONS_WITHOUT_PARAMS: ValidationDetailId[] = [ | ||
'only-members' | ||
] as const; | ||
const PROPOSAL_VALIDATION_TAGS = { | ||
'passport-gated': 'Beta' | ||
} as const; | ||
const validation = defineModel<Validation | null>({ required: true }); | ||
defineProps<{ | ||
networkId: NetworkID; | ||
snapshotChainId: number; | ||
}>(); | ||
const isSelectValidationModalOpen = ref(false); | ||
const initialValidation = ref<Validation | undefined>(); | ||
const availableValidations = computed<ValidationRecords>(() => { | ||
return PROPOSAL_VALIDATION_TYPES_ID.reduce((acc, id) => { | ||
acc[id] = { | ||
...VALIDATION_TYPES_INFO[id], | ||
key: id, | ||
tag: PROPOSAL_VALIDATION_TAGS[id] | ||
}; | ||
return acc; | ||
}, {}); | ||
}); | ||
function handleClick(validationId: ValidationDetailId) { | ||
const selectedValidation = { | ||
name: validationId, | ||
params: {} | ||
}; | ||
if (VALIDATIONS_WITHOUT_PARAMS.includes(validationId)) { | ||
validation.value = selectedValidation; | ||
return; | ||
} | ||
initialValidation.value = | ||
validation.value?.name === validationId | ||
? validation.value | ||
: selectedValidation; | ||
isSelectValidationModalOpen.value = true; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div class="space-y-3"> | ||
<UiSelectorCard | ||
:is="UiSelector" | ||
v-for="(type, id) in availableValidations" | ||
:key="id" | ||
:item="type" | ||
:selected="validation?.name === id" | ||
:is-active="validation?.name === id" | ||
@click="handleClick(id)" | ||
/> | ||
</div> | ||
<teleport to="#modal"> | ||
<ModalSelectValidation | ||
type="proposal" | ||
:open="isSelectValidationModalOpen" | ||
:network-id="networkId" | ||
:default-chain-id="snapshotChainId" | ||
:current="initialValidation" | ||
:skip-menu="true" | ||
@close="isSelectValidationModalOpen = false" | ||
@save="value => (validation = value)" | ||
/> | ||
</teleport> | ||
</div> | ||
</template> |
Oops, something went wrong.