diff --git a/src/context/mintStore.ts b/src/context/mintStore.ts index 5a83f296f..108190c70 100644 --- a/src/context/mintStore.ts +++ b/src/context/mintStore.ts @@ -31,6 +31,8 @@ interface SelectField { value: string } +type OperationReturn = Promise + interface MintState { title?: string description?: string @@ -48,6 +50,12 @@ interface MintState { isValid: boolean reset: () => void + mint: ( + tz: string, + amount: number, + cid: string, + royalties: number + ) => OperationReturn } const defaultValuesStored = { @@ -67,7 +75,7 @@ const defaultValues = { artifact: undefined, cover: undefined, thumbnail: undefined, - getValuesStored: () => {}, + getValuesStored: () => { }, } export const useMintStore = create()( @@ -160,8 +168,8 @@ export const useMintStore = create()( // Metadata accessibility const accessibility = photosensitive ? { - hazards: [METADATA_ACCESSIBILITY_HAZARDS_PHOTOSENS], - } + hazards: [METADATA_ACCESSIBILITY_HAZARDS_PHOTOSENS], + } : null const contentRating = nsfw ? METADATA_CONTENT_RATING_MATURE : null @@ -219,11 +227,10 @@ export const useMintStore = create()( used_cover.format = { mimeType: used_cover.mimeType, fileSize: used_cover.buffer.byteLength, - fileName: `${removeExtension(artifact.file.name)}.${ - coverIsGif - ? 'gif' - : extensionFromMimetype(used_cover.mimeType) - }`, + fileName: `${removeExtension(artifact.file.name)}.${coverIsGif + ? 'gif' + : extensionFromMimetype(used_cover.mimeType) + }`, dimensions: { value: `${imageWidth}x${imageHeight}`, unit: 'px', @@ -304,6 +311,7 @@ export const useMintStore = create()( royalties as number ) console.debug('success', success) + if (success) { reset() } diff --git a/src/context/userStore.ts b/src/context/userStore.ts index 20bdb92dd..f47d3055a 100644 --- a/src/context/userStore.ts +++ b/src/context/userStore.ts @@ -20,6 +20,7 @@ import { useLocalSettings } from './localSettingsStore' import { NetworkType } from '@airgap/beacon-types' import { getUser } from '@data/api' import type { RPC_NODES } from './localSettingsStore' +import { getTzktData } from '@data/api' import { BURN_ADDRESS, HEN_CONTRACT_FA2, @@ -166,6 +167,19 @@ export const useUserStore = create()( // skippable useModalStore.setState({ confirm: true }) const confirm = await op.confirmation() + if(title === 'Mint' && confirm?.completed) { + const tokendata = await getTzktData(`/v1/operations/transactions/${op.opHash}`) + const id = tokendata[0].storage.objkt_id - 1 // this is really strange, the objkt_id returned by the tzkt api is off by 1 :/ + const url = `/objkt/${id}/swap` + show( + "**Minting sucessful**", + `Please consider [swapping/listing](https://github.com/teia-community/teia-docs/wiki/How-to-swap-%F0%9F%94%83) your OBJKT on teia.art. + By doing this you're supporting Teia via the [platform fees](https://github.com/teia-community/teia-docs/wiki/Marketplace-Fees). + Swaps done on teia.art will also be visible on objkt.com. + [Click here to proceed to the swap page](${url})` + ) + return op.opHash + } show( confirm.completed ? `${title} Successful` : `${title} Error`, `[see on tzkt.io](https://tzkt.io/${op.opHash})`