Skip to content

Commit

Permalink
Merge branch 'main' into feature/init/swapLanding
Browse files Browse the repository at this point in the history
# Conflicts:
#	utils/config/permission.config.ts
  • Loading branch information
hassnian committed Dec 8, 2024
2 parents 27d3923 + 40fe6f3 commit ee70ff5
Show file tree
Hide file tree
Showing 26 changed files with 562 additions and 480 deletions.
46 changes: 31 additions & 15 deletions components/collection/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
required
:error="!name"
>
<NeoInput
v-model="name"
required
:placeholder="$t('mint.collection.name.placeholder')"
/>
<NonRecommendFieldNotification
:show="name && nameChanged"
@undo="name = props.collection.name"
>
<NeoInput
v-model="name"
required
:placeholder="$t('mint.collection.name.placeholder')"
/>
</NonRecommendFieldNotification>
</NeoField>

<!-- collection description -->
Expand All @@ -36,11 +41,16 @@
/>
</NeoField>
<CollectionEditSection :title="$t('edit.collection.image.label')">
<FormLogoField
v-model:file="image"
v-model:url="imageUrl"
:title="$t('edit.collection.image.message')"
/>
<NonRecommendFieldNotification
:show="hasImageChanged"
@undo="initLogoImage"
>
<FormLogoField
v-model:file="image"
v-model:url="imageUrl"
:title="$t('edit.collection.image.message')"
/>
</NonRecommendFieldNotification>
</CollectionEditSection>

<CollectionEditSection :title="$t('edit.collection.banner.label')">
Expand Down Expand Up @@ -165,19 +175,26 @@ const unlimited = ref(true)
const min = computed(() => props.min || 1)
const max = ref<number | null>(null)
const nameChanged = computed(() => props.collection.name !== name.value)
const hasImageChanged = computed(() => (!imageUrl.value && Boolean(props.collection.image)) || Boolean(image.value))
const originalLogoImageUrl = computed(() => sanitizeIpfsUrl(props.collection.image))
const disabled = computed(() => {
const hasImage = imageUrl.value
const isNameFilled = Boolean(name.value)
const nameChanged = props.collection.name !== name.value
const descriptionChanged = props.collection.description !== description.value
const hasImageChanged = (!imageUrl.value && Boolean(props.collection.image)) || Boolean(image.value)
const hasBannerChanged = (!bannerUrl.value && Boolean(props.collection.banner)) || Boolean(banner.value)
const hasMaxChanged = max.value !== props.collection.max
return !hasImage || !isNameFilled || (!nameChanged && !descriptionChanged && !hasImageChanged && !hasBannerChanged && !hasMaxChanged)
return !hasImage || !isNameFilled || (!nameChanged.value && !descriptionChanged && !hasImageChanged.value && !hasBannerChanged && !hasMaxChanged)
})
const initLogoImage = () => {
imageUrl.value = originalLogoImageUrl.value
image.value = undefined
}
const editCollection = async () => {
emit('submit', {
name: name.value,
Expand All @@ -193,10 +210,9 @@ watch(isModalActive, (value) => {
if (value && props.collection) {
name.value = props.collection.name
description.value = props.collection.description
imageUrl.value = sanitizeIpfsUrl(props.collection.image)
bannerUrl.value = props.collection.banner && sanitizeIpfsUrl(props.collection.banner)
image.value = undefined
banner.value = undefined
initLogoImage()
unlimited.value = !props.collection.max
max.value = props.collection.max
}
Expand Down
4 changes: 2 additions & 2 deletions components/collection/HeroButtonDeleteNfts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</template>

<script setup lang="ts">
import { Interaction } from '@kodadot1/minimark/v1'
import { NeoDropdownItem } from '@kodadot1/brick'
import { NFTs } from '@/composables/transaction/types'
type NftIds = {
nfts?: {
Expand Down Expand Up @@ -53,7 +53,7 @@ const deleteNfts = async () => {
isLoading.value = true
await transaction({
interaction: NFTs.BURN_MULTIPLE,
interaction: Interaction.CONSUME,
nftIds: ids,
urlPrefix: urlPrefix.value,
})
Expand Down
57 changes: 57 additions & 0 deletions components/common/ItemBurnModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<UserCartModal
ref="userCartModal"
mode="burn"
:title="$t('transaction.burnNft', items.length)"
:signing-title="$t('mint.nft.burning', items.length)"
:get-action="getAction"
:label="label"
:disabled="!acknowledged"
@reset="acknowledged = false"
>
<template #body>
<hr class="!mt-4 !mb-5">
</template>

<template #action-button-top>
<div class="mb-4">
<NeoCheckbox
v-model="acknowledged"
class="!flex items-center"
label-class="!pl-3 text-sm capitalize"
:label="$t('burning.agree')"
/>
</div>
</template>
</UserCartModal>
</template>

<script setup lang="ts">
import { Interaction } from '@kodadot1/minimark/v1'
import { NeoCheckbox } from '@kodadot1/brick'
import { type ActionConsume } from '@/composables/transaction/types'
import { type UserCartModalExpose } from '@/components/common/userCart/UserCartModal.vue'
const { $i18n } = useNuxtApp()
const { urlPrefix } = usePrefix()
const acknowledged = ref(false)
const userCartModal = ref<UserCartModalExpose>()
const items = computed(() => userCartModal.value?.items || [])
const abi = computed(() => userCartModal.value?.abi)
const label = computed(() => {
if (!acknowledged.value) {
return $i18n.t('helper.acknowledgeToContinue')
}
return $i18n.t('transaction.burnNft', items.value.length)
})
const getAction = (): ActionConsume => ({
interaction: Interaction.CONSUME,
nftIds: items.value.map(item => item.id),
urlPrefix: urlPrefix.value,
abi: abi.value,
})
</script>
114 changes: 114 additions & 0 deletions components/common/ItemTransferModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<template>
<UserCartModal
ref="userCartModal"
mode="transfer"
:title="$t('transaction.transferNft', items.length)"
:signing-title="$t('transaction.transferingNft', items.length)"
:get-action="getAction"
:label="label"
:disabled="disabled"
:loading="loading"
@reset="reset"
>
<template #body>
<hr class="my-4">

<h2 class="mb-2 font-bold text-text-color capitalize">
{{ $t('transaction.transferTo') }}
</h2>

<AddressInput
v-model="address"
:is-invalid="isYourAddress"
label=""
class="flex-1 !pb-12"
placeholder="Enter wallet address"
with-address-check
@check="isValid => isAddressValid = isValid"
/>
</template>

<template #footer>
<div class="mt-3 flex justify-between text-k-grey">
<NeoIcon
icon="circle-info"
size="small"
class="mr-4"
/>

<p class="text-xs">
{{ $t('transaction.wrongAddressCannotRecoveredWarning') }}
</p>
</div>
</template>
</UserCartModal>
</template>

<script setup lang="ts">
import { NeoIcon } from '@kodadot1/brick'
import { Interaction } from '@kodadot1/minimark/v1'
import { toSubstrateAddress } from '@/services/profile'
import AddressInput from '@/components/shared/AddressInput.vue'
import type { ActionSend } from '@/composables/transaction/types'
import { type UserCartModalExpose } from '@/components/common/userCart/UserCartModal.vue'
const { $i18n } = useNuxtApp()
const { urlPrefix } = usePrefix()
const { accountId } = useAuth()
const userCartModal = ref<UserCartModalExpose>()
const address = ref('')
const isAddressValid = ref(false)
const items = computed(() => userCartModal.value?.items || [])
const abi = computed(() => userCartModal.value?.abi)
const label = computed(() => {
if (!address.value) {
return $i18n.t('transaction.inputAddressFirst')
}
if (!isAddressValid.value) {
return $i18n.t('transaction.addressIncorrect')
}
if (isYourAddress.value) {
return $i18n.t('transaction.selfTransfer')
}
return $i18n.t('transaction.transferNft')
})
const isYourAddress = computed(() => getChainAddress(accountId.value) === getChainAddress(address.value))
const loading = computed(() => (isEvm(urlPrefix.value) ? !abi.value : false))
const disabled = computed(
() =>
!address.value
|| !isAddressValid.value
|| isYourAddress.value,
)
const getAction = (): ActionSend => ({
interaction: Interaction.SEND,
urlPrefix: urlPrefix.value,
address: address.value,
abi: abi.value,
nfts: items.value.map(item => ({
id: item.id,
sn: item.sn,
collectionId: item.collection.id,
})),
})
const reset = () => {
address.value = ''
isAddressValid.value = false
}
const getChainAddress = (value: string) => {
try {
return toSubstrateAddress(value)
}
catch (error) {
return null
}
}
</script>
Loading

0 comments on commit ee70ff5

Please sign in to comment.