-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
🎉 STATEMINE v0 #5935
Changes from 53 commits
3a24993
9150737
420e9b5
6f1f374
c133881
65f0a6c
2ee59d9
483e964
cdaf239
79b9b2a
5e5a03d
9bed72d
c3318bd
6b5c0e7
2654694
b6650fa
80ae98e
c883a93
7f52039
57e4f57
3530d99
9ec4c08
bcb6ec8
65368c0
b2b2d22
9e03853
655ec98
9a73871
0bd2422
d5eafbf
3f488bd
b7f1400
d8d715b
1ef1cfe
e57eaba
c008c46
af5f5aa
28b56b0
5b97959
5fd6c1b
baa480b
060db61
78a60bc
80a5040
8afabf0
4f6c9ec
79bbf48
7f82783
08c81ac
cc693b8
7f7cad9
878a6df
18ea025
9264554
cc8bbb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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( | ||
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({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }), | ||
}) | ||
} | ||
}) | ||
} |
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function |
||
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({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }), | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -50,4 +54,13 @@ export function execListTx(item: ActionList, api, executeTransaction) { | |
errorMessage: item.errorMessage, | ||
}) | ||
} | ||
|
||
if (item.urlPrefix === 'stmn') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
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.