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

Post-Mint Text: #SwapOnTeia #367

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
24 changes: 16 additions & 8 deletions src/context/mintStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ interface SelectField {
value: string
}

type OperationReturn = Promise<string | undefined>

interface MintState {
title?: string
description?: string
Expand All @@ -48,6 +50,12 @@ interface MintState {
isValid: boolean

reset: () => void
mint: (
tz: string,
amount: number,
cid: string,
royalties: number
) => OperationReturn
}

const defaultValuesStored = {
Expand All @@ -67,7 +75,7 @@ const defaultValues = {
artifact: undefined,
cover: undefined,
thumbnail: undefined,
getValuesStored: () => {},
getValuesStored: () => { },
}

export const useMintStore = create<MintState>()(
Expand Down Expand Up @@ -160,8 +168,8 @@ export const useMintStore = create<MintState>()(
// Metadata accessibility
const accessibility = photosensitive
? {
hazards: [METADATA_ACCESSIBILITY_HAZARDS_PHOTOSENS],
}
hazards: [METADATA_ACCESSIBILITY_HAZARDS_PHOTOSENS],
}
: null

const contentRating = nsfw ? METADATA_CONTENT_RATING_MATURE : null
Expand Down Expand Up @@ -219,11 +227,10 @@ export const useMintStore = create<MintState>()(
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',
Expand Down Expand Up @@ -304,6 +311,7 @@ export const useMintStore = create<MintState>()(
royalties as number
)
console.debug('success', success)

if (success) {
reset()
}
Expand Down
14 changes: 14 additions & 0 deletions src/context/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -166,6 +167,19 @@ export const useUserStore = create<UserState>()(
// 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})`
Expand Down
Loading