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

Colection required amount #6849

Closed
wants to merge 18 commits into from
Closed
8 changes: 7 additions & 1 deletion components/base/SubmitButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<NeoButton
:size="size"
:type="type"
:icon-left="icon"
:icon="disabledIcon ? '' : icon"
:disabled="disabled"
:loading="loading"
:expanded="expanded"
:variant="variant"
icon-pack="far"
outlined
@click.native="$emit('click')">
Expand All @@ -19,22 +20,27 @@

<script setup lang="ts">
import { NeoButton, NeoField } from '@kodadot1/brick'
import { NeoButtonVariant } from '@kodadot1/brick'

export interface Props {
disabled?: boolean
expanded?: boolean
disabledIcon?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you just check if there is icon prop behing passed?
something like:

const hasIcon = computed(() => +props.icon)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't work because it has a default value (paper-plane). Should I remove the default value, but that might break functionality on other pages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we'll keep this icon on all submit button in app, might be time to remove it.

icon?: string
label: string
loading?: boolean
type?: string
size?: 'small' | 'medium' | 'large'
variant?: NeoButtonVariant
}

withDefaults(defineProps<Props>(), {
loading: false,
disabled: false,
disabledIcon: false,
roiLeo marked this conversation as resolved.
Show resolved Hide resolved
type: 'is-primary',
icon: 'paper-plane',
size: 'medium',
variant: 'k-accent',
})
</script>
40 changes: 31 additions & 9 deletions components/rmrk/Create/CreateCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,26 @@
</template>

<template #footer>
<NeoField
v-if="isLogIn"
variant="danger"
:message="balanceNotEnoughMessage">
<NeoField v-if="isLogIn">
<SubmitButton
expanded
label="create collection"
:label="balanceNotEnough ? 'not enough funds' : 'create collection'"
Jarsen136 marked this conversation as resolved.
Show resolved Hide resolved
:loading="isLoading"
disabled-icon
variant="k-accent"
:disabled="balanceNotEnough"
@click="submit" />
<template #message>
{{ $t('tooltip.deposit1') }}
<strong>{{ COLLECTION_DEPOSIT }} KSM</strong>
pbkompasz marked this conversation as resolved.
Show resolved Hide resolved
{{ $t('tooltip.deposit2') }}
<a
v-safe-href="
'https://hello.kodadot.xyz/multi-chain/fees/assethub-fees#polkadot-asset-hub-fees-prev.-statemint'
"
>Learn more</a
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<a
v-safe-href="
'https://hello.kodadot.xyz/multi-chain/fees/assethub-fees#polkadot-asset-hub-fees-prev.-statemint'
"
>Learn more</a
>
<a
v-safe-href="
https://hello.kodadot.xyz/multi-chain/fees/assethub-fees#polkadot-asset-hub-fees-prev.-statemint
"
>Learn more</a
>

missing translation helper.learnMore

Copy link
Contributor Author

@pbkompasz pbkompasz Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where should the 'Learn more' link to for /bsx?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the chain (urlPrefix) you're on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urlPrefix has the following type Prefix = 'bsx' | 'glmr' | 'rmrk' | 'movr' | 'ksm' | 'snek' | 'ahk' | 'dot' | 'ahp';
Each one has a different deposit value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each one has a different deposit value?

Yes, maybe bsx & snek has the same, I think it can be fetched through polkadot api package

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values should be fetched from the API or kept in the constants.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I use this?

export function getclassDeposit(api: ApiPromise): bigint {

</template>
</NeoField>
</template>
</BaseCollectionForm>
Expand All @@ -65,6 +76,7 @@ import SubmitButton from '@/components/base/SubmitButton.vue'
import { NeoField, NeoInput } from '@kodadot1/brick'
import { BaseCollectionType } from '@/composables/transaction/types'
import useLoader from '@/composables/useLoader'
import { COLLECTION_DEPOSIT } from '@/utils/constants'

interface ComponentWithCheckValidity extends Vue {
checkValidity(): boolean
Expand All @@ -83,7 +95,6 @@ const symbolInput = ref<ComponentWithCheckValidity>()
const { accountId, balance, isLogIn } = useAuth()
const { isLoading, status } = useLoader()
const emit = defineEmits(['created'])
const { $i18n } = useNuxtApp()

const checkValidity = () => {
return (
Expand All @@ -93,9 +104,8 @@ const checkValidity = () => {

const rmrkId = computed(() => generateId(accountId.value, symbol.value))

const balanceNotEnough = computed(() => Number(balance.value) <= 2)
const balanceNotEnoughMessage = computed(() =>
balanceNotEnough.value ? $i18n.t('tooltip.notEnoughBalance') : ''
const balanceNotEnough = computed(
() => Number(balance.value) <= COLLECTION_DEPOSIT
)
const isMintDisabled = computed(() => balanceNotEnough.value)

Expand Down Expand Up @@ -154,3 +164,15 @@ const submit = async () => {
}
}
</script>

<style lang="scss" scoped>
@import '@/styles/abstracts/variables';

a {
@include ktheme() {
color: theme('k-blue') !important;
}
text-decoration: underline;
white-space: nowrap;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... even on scoped component this can be smelly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is styling directly the a tag?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there could be side effects If we'll use another a tag on this component

</style>
5 changes: 4 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"facts": "Facts",
"computed id": "Computed id",
"create collection": "Create Collection",
"not enough funds": "Not Enough Funds",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate of confirmPurchase.notEnoughFuns

"Select collection where do you want mint your token": "Select collection where do you want mint your token",
"Maximum NFTs in collection": "Maximum NFTs in collection",
"name": "Name",
Expand Down Expand Up @@ -538,7 +539,9 @@
"smallDisplay": "Small Display",
"largeDisplay": "Large Display",
"emptyAddress": "Receiver address cannot be empty",
"emptyListAmount": "Amount should be greater than 0"
"emptyListAmount": "Amount should be greater than 0",
"deposit1": "A deposit of",
"deposit2": "is required to create a collection. Please note, this initial deposit is refundable."
pbkompasz marked this conversation as resolved.
Show resolved Hide resolved
},
"nft": {
"carbonless": "This NFT is carbonless",
Expand Down
2 changes: 2 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ export const NFT_SQUID_SORT_COLLECTIONS: string[] = [
export const MIN_OFFER_PRICE = 0.01

export const EXTERNAL_LINK_WHITELIST = ['*.kodadot.xyz']

export const COLLECTION_DEPOSIT = 0.1