From 1103eb52d522866f26f745a575a433b1af1dd17b Mon Sep 17 00:00:00 2001 From: Matej yangwao <5887929+yangwao@users.noreply.github.com> Date: Sat, 16 Dec 2023 14:57:55 +0100 Subject: [PATCH] Revert "feat: Drops requiring funds to enable auto-teleport" --- components/collection/drop/AddFundsModal.vue | 167 +++++++++--------- components/collection/drop/Generative.vue | 99 ++++++----- .../collection/drop/HolderOfGenerative.vue | 43 +++-- components/collection/unlockable/const.ts | 3 + .../autoTeleport/AutoTeleportActionButton.vue | 28 ++- .../common/autoTeleport/AutoTeleportModal.vue | 53 +++--- components/common/autoTeleport/utils.ts | 77 -------- components/drops/useDrops.ts | 39 ---- components/shared/format/Money.vue | 12 +- .../useAutoTeleportTransitionDetails.ts | 15 +- composables/useAmount.ts | 13 +- composables/useMultipleBalance.ts | 2 +- locales/en.json | 52 +++--- stores/identity.ts | 20 ++- utils/format/balance.ts | 12 -- utils/teleport.ts | 6 +- 16 files changed, 262 insertions(+), 379 deletions(-) delete mode 100644 components/common/autoTeleport/utils.ts diff --git a/components/collection/drop/AddFundsModal.vue b/components/collection/drop/AddFundsModal.vue index e765128a35..37a2c03664 100644 --- a/components/collection/drop/AddFundsModal.vue +++ b/components/collection/drop/AddFundsModal.vue @@ -8,114 +8,117 @@ - - +
+ +

- - +

{{ $t('mint.unlockable.addFundsModal.textP2') }}

+ +
+ +

+ {{ $t('mint.unlockable.addFundsModal.howToAddFunds') }} +

+
+ +
- + + {{ $t('autoTeleport.addFundsViaOnramp') }} +
+ diff --git a/components/collection/drop/Generative.vue b/components/collection/drop/Generative.vue index be948edb08..48ca7903ca 100644 --- a/components/collection/drop/Generative.vue +++ b/components/collection/drop/Generative.vue @@ -60,8 +60,8 @@
+ @close="isAddFundModalActive = false" /> @@ -135,12 +131,18 @@ import { createUnlockableMetadata } from '../unlockable/utils' import GenerativePreview from '@/components/collection/drop/GenerativePreview.vue' import { DropItem } from '@/params/types' import { DoResult, doWaifu } from '@/services/waifu' -import { useDropMinimumFunds, useDropStatus } from '@/components/drops/useDrops' +import { useDropStatus } from '@/components/drops/useDrops' import { makeScreenshot } from '@/services/capture' import { pinFileToIPFS } from '@/services/nftStorage' import { sanitizeIpfsUrl } from '@/utils/ipfs' import newsletterApi from '@/utils/newsletter' +import { formatBsxBalanceToNumber } from '@/utils/format/balance' import { prefixToToken } from '@/components/common/shoppingCart/utils' +import { useIdentityStore } from '@/stores/identity' +import { + DOT_EXISTENTIAL_DEPOSIT, + KSM_EXISTENTIAL_DEPOSIT, +} from '@/components/collection/unlockable/const' import DropConfirmModal from './modal/DropConfirmModal.vue' import ListingCartModal from '@/components/common/listingCart/ListingCartModal.vue' import { nftToListingCartItem } from '@/components/common/shoppingCart/utils' @@ -149,12 +151,6 @@ import { fetchNft } from '@/components/items/ItemsGrid/useNftActions' const NuxtLink = resolveComponent('NuxtLink') const MINTING_SECOND = 120 -export type DropMintedNft = DoResult & { - id: string - collectionName: string - name: string -} - const props = defineProps({ drop: { type: Object, @@ -164,39 +160,55 @@ const props = defineProps({ }, }) +useMultipleBalance(true) + +const minimumFunds = computed( + () => (props.drop.meta && formatBsxBalanceToNumber(props.drop.meta)) || 0, +) +const store = useIdentityStore() + +const isWalletConnecting = ref(false) +const collectionId = computed(() => props.drop?.collection) +const disabledByBackend = computed(() => props.drop?.disabled) +const defaultImage = computed(() => props.drop?.image) +const defaultName = computed(() => props.drop?.name) +const defaultMax = computed(() => props.drop?.max || 255) +const { currentAccountMintedToken, mintedDropCount, fetchDropStatus } = + useDropStatus(props.drop.alias) const instance = getCurrentInstance() const listingCartStore = useListingCartStore() const preferencesStore = usePreferencesStore() +const { doAfterLogin } = useDoAfterlogin(instance) const { $i18n } = useNuxtApp() +const root = ref() + const { toast } = useToast() const { accountId, isLogIn } = useAuth() -const { urlPrefix } = usePrefix() -const { currentAccountMintedToken, mintedDropCount, fetchDropStatus } = - useDropStatus(props.drop.alias) -const { doAfterLogin } = useDoAfterlogin(instance) -const { fetchMultipleBalance } = useMultipleBalance() -const { hasMinimumFunds, formattedMinimumFunds, minimumFunds } = - useDropMinimumFunds(props.drop) -const isWalletConnecting = ref(false) -const root = ref() +const { urlPrefix } = usePrefix() const selectedImage = ref('') const isLoading = ref(false) const isImageFetching = ref(false) const isConfirmModalActive = ref(false) const isAddFundModalActive = ref(false) -const mintedNft = ref() -const mintedNftWithMetadata = ref() -const collectionId = computed(() => props.drop?.collection) -const disabledByBackend = computed(() => props.drop?.disabled) -const defaultImage = computed(() => props.drop?.image) -const defaultName = computed(() => props.drop?.name) -const defaultMax = computed(() => props.drop?.max || 255) const chainName = computed(() => getChainName(props.drop.chain)) const token = computed(() => prefixToToken[props.drop.chain]) +export type DropMintedNft = DoResult & { + id: string + collectionName: string + name: string +} + +const mintedNft = ref() +const mintedNftWithMetadata = ref() + +const handleSelectImage = (image: string) => { + selectedImage.value = image +} + const { data: collectionData } = useGraphql({ queryName: 'unlockableCollectionById', variables: { @@ -244,10 +256,6 @@ const collectionName = computed( () => collectionData.value?.collectionEntity?.name, ) -const handleSelectImage = (image: string) => { - selectedImage.value = image -} - const tryCapture = async () => { try { const imgFile = await makeScreenshot(sanitizeIpfsUrl(selectedImage.value)) @@ -273,12 +281,21 @@ const handleSubmitMint = async () => { return } - if (isLoading.value || isImageFetching.value) { return false } - if (hasMinimumFunds.value) { + const dropChainBalance = Number(store.getAuthBalanceByChain(props.drop.chain)) + const relayChainBalance = Number( + store.getAuthBalanceByRelayChain(props.drop.chain), + ) + const existentialDeposit = + token.value === 'KSM' ? KSM_EXISTENTIAL_DEPOSIT : DOT_EXISTENTIAL_DEPOSIT + + if ( + dropChainBalance >= minimumFunds.value || + relayChainBalance >= existentialDeposit + minimumFunds.value + ) { openConfirmModal() } else { openAddFundModal() @@ -297,10 +314,6 @@ const openAddFundModal = () => { isAddFundModalActive.value = true } -const closeAddFundModal = () => { - isAddFundModalActive.value = false -} - const subscribe = async (email: string) => { try { await newsletterApi.subscribe(email) @@ -405,12 +418,6 @@ const clear = () => { listingCartStore.removeItem(mintedNftWithMetadata.value?.id) } -const handleDropAddModalConfirm = () => { - closeAddFundModal() - openConfirmModal() - fetchMultipleBalance([urlPrefix.value]) -} - onBeforeUnmount(clear) diff --git a/components/collection/drop/HolderOfGenerative.vue b/components/collection/drop/HolderOfGenerative.vue index 101c9b2b5b..011bd94eda 100644 --- a/components/collection/drop/HolderOfGenerative.vue +++ b/components/collection/drop/HolderOfGenerative.vue @@ -68,7 +68,7 @@
+ @close="isAddFundModalActive = false" />