Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Massburn #11208

Merged
merged 19 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e1c2281
ref: init `UserCartModal` component
hassnian Dec 3, 2024
2004e2a
fix(UserCartModal.vue): missing `exectTransaction` function
hassnian Dec 3, 2024
894f666
fix(ItemTransferModal.vue): `isYourAddress` invalid not working
hassnian Dec 3, 2024
d902547
ref(UserCartModal.vue): `submit` function
hassnian Dec 3, 2024
f8790a4
ref(UserCartModal.vue): add `title` and `signingTitle` props
hassnian Dec 3, 2024
c5d5839
ref(UserCartModal.vue): add `mode` prop`
hassnian Dec 3, 2024
1d91b2b
add: 🔥 mass burn modal
hassnian Dec 4, 2024
aa99edf
ref(transactions): remove `NFTs.BURN_MULTIPLE` action and added `Item…
hassnian Dec 4, 2024
3e79ec0
Merge branch 'main' into issue-11201
hassnian Dec 4, 2024
3b2f086
fix(ListingCartMini.vue): disable `burn` if it's not available
hassnian Dec 5, 2024
75026f8
ref(ItemBurnModal.vue): add `acknowledge` checkbox
hassnian Dec 5, 2024
c2dbba7
fix(transactions): `burn nft` on `evm` missing `abi`
hassnian Dec 5, 2024
f2cba01
Merge branch 'main' into issue-11201
hassnian Dec 5, 2024
63f898e
fix: deepscan local variable not used.
hassnian Dec 6, 2024
cbc7748
Merge branch 'issue-11201' of https://github.com/hassnian/nft-gallery…
hassnian Dec 6, 2024
d78ae74
ref(codeclimate): Similar blocks of code found in multiple locations
hassnian Dec 6, 2024
892381a
ref(UserCartModal.vue): removed duplicate notification by adding `sho…
hassnian Dec 6, 2024
c57f661
ref(ItemBurnModal.vue): use `checkbox` label prop
hassnian Dec 6, 2024
f30179d
fix(AddressInput.vue): `strict` prop as `optional`
hassnian Dec 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
hassnian marked this conversation as resolved.
Show resolved Hide resolved
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
Loading