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

Refactor: CreateCollection #6968

Closed
Closed
Changes from all commits
Commits
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
41 changes: 19 additions & 22 deletions components/bsx/Create/CreateCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ import { BaseCollectionType } from '@/composables/transaction/types'
import shouldUpdate from '@/utils/shouldUpdate'
import { Token, getBalance, getDeposit, getFeesToken } from './utils'
import { NeoField } from '@kodadot1/brick'
import Loader from '@/components/shared/Loader.vue'
import BaseCollectionForm from '@/components/base/BaseCollectionForm.vue'
import SubmitButton from '@/components/base/SubmitButton.vue'
import Money from '@/components/bsx/format/TokenMoney.vue'
import AccountBalance from '@/components/shared/AccountBalance.vue'
import MultiPaymentFeeButton from '@/components/bsx/specific/MultiPaymentFeeButton.vue'

const emit = defineEmits(['created'])

Expand All @@ -60,15 +66,6 @@ const { urlPrefix, tokenId } = usePrefix()
const { status: transactionStatus, isLoading: isTransactionLoading } =
useTransactionStatus()

const Loader = () => import('@/components/shared/Loader.vue')
const BaseCollectionForm = () =>
import('@/components/base/BaseCollectionForm.vue')
const SubmitButton = () => import('@/components/base/SubmitButton.vue')
const Money = () => import('@/components/bsx/format/TokenMoney.vue')
const AccountBalance = () => import('@/components/shared/AccountBalance.vue')
const MultiPaymentFeeButton = () =>
import('@/components/bsx/specific/MultiPaymentFeeButton.vue')

const base = ref<BaseCollectionType>({
name: '',
file: null,
Expand Down Expand Up @@ -102,6 +99,19 @@ const depositOfToken = computed(() =>
getDeposit(feesToken.value, parseFloat(collectionDeposit.value))
)

const { transaction, status, isLoading, blockNumber } = useTransaction()
watch([isLoading, status], () => {
isTransactionLoading.value = isLoading.value
if (Boolean(status.value)) {
transactionStatus.value = status.value
}
})
watch(blockNumber, (block) => {
if (block) {
emit('created')
}
})

async function submit(): Promise<void> {
// check fields
if (!checkValidity()) {
Expand All @@ -118,19 +128,6 @@ async function submit(): Promise<void> {
isTransactionLoading.value = true
transactionStatus.value = 'loader.checkBalance'

const { transaction, status, isLoading, blockNumber } = useTransaction()
watch([isLoading, status], () => {
isTransactionLoading.value = isLoading.value
if (Boolean(status.value)) {
transactionStatus.value = status.value
}
})
watch(blockNumber, (block) => {
if (block) {
emit('created')
}
})

try {
showNotification(
$i18n.t('mint.creatingCollection', { name: base.value.name }),
Expand Down