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

🎉 STATEMINE v0 #5935

Merged
merged 55 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3a24993
:truck: rename statemine to stmn
vikiival May 8, 2023
9150737
:truck: rename statemine to stmn
vikiival May 8, 2023
420e9b5
:tada: stmn in the house
vikiival May 8, 2023
6f1f374
:bug: statemine not properly defined
vikiival May 8, 2023
c133881
:coffin: old code
vikiival May 8, 2023
65f0a6c
:zap: nicer organization of landing page
vikiival May 8, 2023
2ee59d9
:tada: statemine
vikiival May 8, 2023
483e964
:zap: enable create on stmn
vikiival May 8, 2023
cdaf239
:wrench: apollo endpoints
vikiival May 8, 2023
79b9b2a
:wastebasket: deduped code via static
vikiival May 8, 2023
5e5a03d
:wrench: statemine endpoints
vikiival May 8, 2023
9bed72d
:bug: fixed imports for statick
vikiival May 8, 2023
c3318bd
:bug: stmn was pointing to subqueries
vikiival May 8, 2023
6b5c0e7
:zao: isSnek
vikiival May 8, 2023
2654694
Merge remote-tracking branch 'origin/main' into stmn-version-zero
vikiival May 10, 2023
b6650fa
:bug: fixed value of ksm
vikiival May 10, 2023
80ae98e
:bug: very strange symbols
vikiival May 10, 2023
c883a93
:construction: WIP minting
vikiival May 10, 2023
7f52039
Merge remote-tracking branch 'origin/main' into stmn-version-zero
vikiival May 11, 2023
57e4f57
:zap: enable buy on statemine
vikiival May 11, 2023
3530d99
:bug: nft bought is too soon, close #5622
vikiival May 11, 2023
9ec4c08
:bug: try/catch/finally
vikiival May 11, 2023
bcb6ec8
:zap: buy for statemine
vikiival May 11, 2023
65368c0
:zap: uniqes
vikiival May 11, 2023
b2b2d22
Merge remote-tracking branch 'origin/main' into stmn-version-zero
vikiival May 11, 2023
9e03853
Merge remote-tracking branch 'origin/main' into stmn-version-zero
vikiival May 11, 2023
655ec98
:boom: take url by prefix
vikiival May 11, 2023
9a73871
Merge remote-tracking branch 'origin/main' into stmn-version-zero
vikiival May 11, 2023
0bd2422
:bug: need to pass empty whitelist as undefined
vikiival May 11, 2023
d5eafbf
:sparkles: list
vikiival May 11, 2023
3f488bd
:mute: logs because i had inconsistent connection
vikiival May 11, 2023
b7f1400
:sparkles: send
vikiival May 11, 2023
d8d715b
:broom: organize imports
vikiival May 11, 2023
1ef1cfe
:shrug: may burn works
vikiival May 11, 2023
e57eaba
:zap: disable minting on statemine
vikiival May 11, 2023
c008c46
:sprakles: exec mint Statemine
vikiival May 11, 2023
af5f5aa
:bug: did not set metadata
vikiival May 11, 2023
28b56b0
:bug: expected String got Undefined
vikiival May 11, 2023
5b97959
:sparkles: create collection
vikiival May 11, 2023
5fd6c1b
Merge remote-tracking branch 'origin/main' into stmn-version-zero
vikiival May 11, 2023
baa480b
:technologist: one v-if for whole landing page
vikiival May 11, 2023
060db61
:wastebasket: removed randomly copied components
vikiival May 12, 2023
78a60bc
:zap: statemine will have separated mint pages
vikiival May 12, 2023
80a5040
Apply suggestions from code review
vikiival May 12, 2023
8afabf0
:wastebasket: removed unused
vikiival May 12, 2023
4f6c9ec
:arrow_up: plz build work
vikiival May 12, 2023
79bbf48
Merge branch 'stmn-version-zero' of github.com:kodadot/nft-gallery in…
vikiival May 12, 2023
7f82783
Merge branch 'main' into stmn-version-zero
vikiival May 12, 2023
08c81ac
🔧 build
roiLeo May 12, 2023
cc693b8
:bookmark: static@0.0.2
vikiival May 12, 2023
7f7cad9
:arrow_up: smol hack to build
vikiival May 12, 2023
878a6df
static from workspace
vikiival May 12, 2023
18ea025
❄️ freeeze lockfile
vikiival May 12, 2023
9264554
:ambulance: bad fix
vikiival May 12, 2023
cc8bbb4
Merge branch 'main' into stmn-v-zero
yangwao May 13, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const label = computed(() =>
)

const balance = computed<string>(() => {
if (['rmrk', 'ksm'].includes(urlPrefix.value)) {
if (['rmrk', 'ksm', 'stmn'].includes(urlPrefix.value)) {
return $store.getters.getAuthBalance
}
return $store.getters.getTokenBalanceOf(getKusamaAssetId(urlPrefix.value))
Expand Down Expand Up @@ -188,7 +188,7 @@ const handleBuy = async () => {
}

try {
transaction({
await transaction({
interaction: ShoppingActions.BUY,
currentOwner: props.currentOwner,
price: props.nftPrice,
Expand All @@ -200,11 +200,11 @@ const handleBuy = async () => {
successMessage: $i18n.t('mint.successNewNfts'),
errorMessage: $i18n.t('transaction.buy.error'),
})
} catch (error) {
warningMessage(error)
} finally {

showNotification(`[${actionLabel}] ${itemId}`, notificationTypes.success)
emit('buy-success')
} catch (error) {
warningMessage(error)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const { transaction, isLoading, status } = useTransaction()
const { urlPrefix } = usePrefix()

const props = defineProps<{
mimeType: string
mimeType?: string
name?: string
ipfsImage?: string
currentOwner?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
:label="$t('tabs.offers')"
:disabled-tooltip="$t('tabs.offersDisabled')">
<GalleryItemOffers
v-if="
!['rmrk', 'ksm'].includes(urlPrefix) &&
nft?.collection.id &&
nft?.id &&
nft.currentOwner
"
v-if="isSnek && nft?.collection.id && nft?.id && nft.currentOwner"
:collection-id="nft?.collection.id"
:nft-id="nft?.id"
:account="nft?.currentOwner" />
Expand Down Expand Up @@ -59,6 +54,8 @@ const { offersDisabled } = useChain()
const activeTab = ref('0')
const collectionId = ref('')

const isSnek = computed(() => ['bsx', 'snek'].includes(urlPrefix.value))

watchEffect(() => {
if (props.activeTab) {
activeTab.value = props.activeTab
Expand Down
56 changes: 28 additions & 28 deletions components/landing/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,33 @@
<LazySearchLanding />
</section>

<!-- spotlight -->
<section v-if="showCarousel" class="py-8 instance">
<div class="container is-fluid">
<LazyCarouselTypeSpotlight />
</div>
</section>
<template v-if="showCarousel">
<!-- spotlight -->
<section class="py-8 instance">
<div class="container is-fluid">
<LazyCarouselTypeSpotlight />
</div>
</section>

<!-- top collections -->
<section v-if="showCarousel && urlPrefix !== 'ksm'" class="py-8 instance">
<div class="container is-fluid">
<LazyTopCollections class="my-5" />
</div>
</section>
<!-- top collections -->
<section
v-if="urlPrefix !== 'ksm' && urlPrefix !== 'stmn'"
class="py-8 instance">
<div class="container is-fluid">
<LazyTopCollections class="my-5" />
</div>
</section>

<section v-if="showCarousel" class="py-8 instance">
<div class="container is-fluid">
<!-- new listings -->
<LazyCarouselTypeNewestList />
<section class="py-8 instance">
<div class="container is-fluid">
<!-- new listings -->
<LazyCarouselTypeNewestList />

<!-- latest sales -->
<LazyCarouselTypeLatestSales class="mt-8" />
</div>
</section>
<!-- latest sales -->
<LazyCarouselTypeLatestSales class="mt-8" />
</div>
</section>
</template>

<section class="py-8 instance instance-accent">
<div class="container is-fluid footer-landing-container">
Expand All @@ -37,15 +41,11 @@
</template>

<script lang="ts" setup>
import type { Prefix } from '@kodadot1/static'

const prefixes: Prefix[] = ['rmrk', 'ksm', 'snek', 'bsx', 'stmn']
const { urlPrefix } = usePrefix()

// currently only supported on rmrk and snek
const showCarousel = computed(() => {
return (
urlPrefix.value === 'rmrk' ||
urlPrefix.value === 'ksm' ||
urlPrefix.value === 'snek' ||
urlPrefix.value === 'bsx'
)
})
const showCarousel = computed(() => prefixes.includes(urlPrefix.value))
</script>
61 changes: 61 additions & 0 deletions components/stmn/Create/CreateCollection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<div>
<h2 class="title is-size-3">
{{ $t('mint.collection.create') }}
</h2>
<form class="w-full">
<NeoField :label="$t('mint.collection.logo.label')" class="w-full mb-4">
<MetadataUpload
ref="collectionImage"
v-model="logo"
required
:label="$t('mint.collection.logo.message')"
expanded
preview
accept="image/png, image/jpeg, image/gif, image/svg+xml, image/svg" />
</NeoField>
<NeoField :label="$t('mint.collection.banner.label')" class="w-full mb-4">
<MetadataUpload
ref="collectionImage"
v-model="image"
required
:label="$t('mint.collection.drop')"
expanded
preview
accept="image/png, image/jpeg, image/gif, image/svg+xml, image/svg" />
</NeoField>
<NeoField
:label="$t('mint.collection.name.label')"
class="w-full mb-4 placholder-color"
:error="!name">
<NeoInput
v-model="name"
required
:placeholder="'*' + $t('massmint.required')" />
</NeoField>
<NeoField
:label="$t('mint.collection.description.label')"
class="w-full mb-4">
<NeoInput
v-model="description"
type="textarea"
has-counter
maxlength="500"
height="10rem" />
</NeoField>
</form>
</div>
</template>

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

const MetadataUpload = defineAsyncComponent(
() => import('@/components/rmrk/Create/DropUpload.vue')
)

const name = ref('')
const description = ref('')
const logo = ref<File | null>(null)
const image = ref<File | null>(null)
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ExecuteTransactionParams } from '@/composables/useTransaction'
import type { ActionMintCollection } from '../types'
import { constructMeta } from './constructMeta'
import { useNewCollectionId } from './useNewCollectionId'

export async function execMintCollectionStatemine(
Copy link

Choose a reason for hiding this comment

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

Function execMintCollectionStatemine has 29 lines of code (exceeds 25 allowed). Consider refactoring.

item: ActionMintCollection,
api,
executeTransaction: (p: ExecuteTransactionParams) => void
) {
const { $i18n } = useNuxtApp()
const metadata = await constructMeta(item)
const { accountId } = useAuth()

const cb = api.tx.utility.batchAll

const { newCollectionId } = useNewCollectionId()

const arg = [
[
api.tx.uniques.create(newCollectionId, accountId.value),
api.tx.uniques.setCollectionMetadata(newCollectionId, metadata, false),
],
]

watch(newCollectionId, (id) => {
if (id) {
executeTransaction({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

cb,
arg,
successMessage:
item.successMessage ||
((blockNumber) =>
$i18n.t('mint.mintCollectionSuccess', {
name: item.collection.name,
block: blockNumber,
})),
errorMessage:
item.errorMessage ||
$i18n.t('mint.ErrorCreateNewNft', { name: item.collection.name }),
})
}
})
}
50 changes: 50 additions & 0 deletions composables/transaction/mintToken/transactionMintStatemine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ExecuteTransactionParams } from '@/composables/useTransaction'
import type { ActionMintToken, MintedCollectionBasilisk } from '../types'
import { constructMeta } from './constructMeta'

export async function execMintStatemine(
Copy link

Choose a reason for hiding this comment

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

Function execMintStatemine has 31 lines of code (exceeds 25 allowed). Consider refactoring.

item: ActionMintToken,
api,
executeTransaction: (p: ExecuteTransactionParams) => void
) {
const { $i18n } = useNuxtApp()

const {
id: collectionId,
alreadyMinted: collectionAlreadyMinted,
lastIndexUsed,
} = item.token.selectedCollection as MintedCollectionBasilisk
const { price } = item.token

const metadata = await constructMeta(item)

const cb = api.tx.utility.batchAll

const nextId = Math.max(lastIndexUsed + 1, collectionAlreadyMinted + 1)

const create = api.tx.uniques.mint(collectionId, nextId, metadata)

const meta = api.tx.uniques.setMetadata(collectionId, nextId, metadata, false)

const list =
Number(price) > 0
? [api.tx.uniques.setPrice(collectionId, nextId, price)]
: []

const args = [[create, meta, ...list]]

executeTransaction({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

cb,
arg: args,
successMessage:
item.successMessage ||
((blockNumber) =>
$i18n.t('mint.mintNFTSuccess', {
name: item.token.name,
block: blockNumber,
})),
errorMessage:
item.errorMessage ||
$i18n.t('mint.ErrorCreateNewNft', { name: item.token.name }),
})
}
15 changes: 14 additions & 1 deletion composables/transaction/transactionBurn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
createInteraction as createNewInteraction,
} from '@kodadot1/minimark/v2'

import { bsxParamResolver, getApiCall } from '@/utils/gallery/abstractCalls'
import {
bsxParamResolver,
getApiCall,
uniqueParamResolver,
} from '@/utils/gallery/abstractCalls'
import type { ActionConsume } from './types'

export function execBurnTx(item: ActionConsume, api, executeTransaction) {
Expand Down Expand Up @@ -72,4 +76,13 @@ export function execBurnTx(item: ActionConsume, api, executeTransaction) {
})
})
}

if (item.urlPrefix === 'stmn') {
executeTransaction({
cb: getApiCall(api, item.urlPrefix, Interaction.CONSUME),
arg: uniqueParamResolver(item.nftId, Interaction.CONSUME, ''),
successMessage: item.successMessage,
errorMessage: item.errorMessage,
})
}
}
16 changes: 16 additions & 0 deletions composables/transaction/transactionBuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ function execBuyBasilisk(item: ActionBuy, api, executeTransaction) {
})
}

function execBuyStatemine(item: ActionBuy, api, executeTransaction) {
const { id, item: token } = tokenIdToRoute(item.nftId)

// TODO: implement tx fees #5130
executeTransaction({
cb: getApiCall(api, item.urlPrefix, item.interaction),
arg: [id, token, item.price],
successMessage: item.successMessage,
errorMessage: item.errorMessage,
})
}

export function execBuyTx(item: ActionBuy, api, executeTransaction) {
if (item.urlPrefix === 'rmrk' || item.urlPrefix === 'ksm') {
execBuyRmrk(item, api, executeTransaction)
Expand All @@ -62,4 +74,8 @@ export function execBuyTx(item: ActionBuy, api, executeTransaction) {
if (item.urlPrefix === 'snek' || item.urlPrefix === 'bsx') {
execBuyBasilisk(item, api, executeTransaction)
}

if (item.urlPrefix === 'stmn') {
execBuyStatemine(item, api, executeTransaction)
}
}
15 changes: 14 additions & 1 deletion composables/transaction/transactionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
createInteraction as createNewInteraction,
} from '@kodadot1/minimark/v2'

import { bsxParamResolver, getApiCall } from '@/utils/gallery/abstractCalls'
import {
bsxParamResolver,
getApiCall,
uniqueParamResolver,
} from '@/utils/gallery/abstractCalls'
import { warningMessage } from '@/utils/notification'

import type { ActionList } from './types'
Expand Down Expand Up @@ -50,4 +54,13 @@ export function execListTx(item: ActionList, api, executeTransaction) {
errorMessage: item.errorMessage,
})
}

if (item.urlPrefix === 'stmn') {
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

executeTransaction({
cb: getApiCall(api, item.urlPrefix, Interaction.LIST),
arg: uniqueParamResolver(item.nftId, Interaction.LIST, meta),
successMessage: item.successMessage,
errorMessage: item.errorMessage,
})
}
}
Loading