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

Fix/copies-on-basilisk #6996

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions components/bsx/Create/CreateToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<template #footer>
<NeoField key="advanced">
<CollapseWrapper
v-if="base.edition > 1"
v-if="base.copies > 1"
visible="mint.expert.show"
hidden="mint.expert.hide"
class="mt-3">
Expand Down Expand Up @@ -147,7 +147,7 @@ const base = ref<BaseTokenType>({
file: null,
description: '',
selectedCollection: null,
edition: 1,
copies: 1,
secondFile: null,
})
const collections = ref<MintedCollection[]>([])
Expand All @@ -161,7 +161,7 @@ const hasRoyalty = ref(true)
const feesToken = ref<Token>('BSX')
const royalty = ref<Royalty>({
amount: 0.15,
address: '',
address: accountId.value,
})
const balanceNotEnough = ref(false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ActionMintToken, MintedCollection, TokenToMint } from '../types'
import { isRoyaltyValid } from '@/utils/royalty'
import { constructMeta } from './constructMeta'
import { BaseMintedCollection } from '@/components/base/types'
import { transactionFactory } from './utils'
import { expandCopies, transactionFactory } from './utils'

const prepareTokenMintArgs = async (
token: TokenToMint,
Expand Down Expand Up @@ -38,8 +38,9 @@ const prepareTokenMintArgs = async (
const getArgs = async (item: ActionMintToken, api) => {
const { $consola } = useNuxtApp()

const tokens = Array.isArray(item.token) ? item.token : [item.token]

const tokens = expandCopies(
Array.isArray(item.token) ? item.token : [item.token]
)
const arg = (
await Promise.all(
tokens.map((token, i) => {
Expand Down
20 changes: 1 addition & 19 deletions composables/transaction/mintToken/transactionMintStatemine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BaseMintedCollection } from '@/components/base/types'
import type { ActionMintToken, MintedCollection } from '../types'
import { TokenToMint } from '../types'
import { constructMeta } from './constructMeta'
import { calculateFees, copiesToMint, transactionFactory } from './utils'
import { calculateFees, expandCopies, transactionFactory } from './utils'
import { canSupport } from '@/utils/support'

type id = { id: number }
Expand All @@ -23,24 +23,6 @@ export const assignIds = <T extends TokenToMint>(tokens: T[]): (T & id)[] => {
})
}

export const expandCopies = <T extends TokenToMint>(tokens: T[]): T[] => {
return tokens.flatMap((token) => {
const copies = copiesToMint(token)
if (copies === 1) {
return token
}

return Array(copies)
.fill(null)
.map((_, index) => {
return {
...token,
name: token.postfix ? `${token.name} #${index + 1}` : token.name,
}
})
})
}

export const prepareTokenMintArgs = async (token: TokenToMint & id, api) => {
const { id: collectionId } = token.selectedCollection as BaseMintedCollection
const { price, id: nextId } = token
Expand Down
18 changes: 18 additions & 0 deletions composables/transaction/mintToken/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,21 @@ export const transactionFactory = (getArgs) => {
})
}
}

export const expandCopies = <T extends TokenToMint>(tokens: T[]): T[] => {
return tokens.flatMap((token) => {
const copies = copiesToMint(token)
if (copies === 1) {
return token
}

return Array(copies)
.fill(null)
.map((_, index) => {
return {
...token,
name: token.postfix ? `${token.name} #${index + 1}` : token.name,
}
})
})
}