Skip to content

Commit

Permalink
Merge branch 'main' into feat-art-kind
Browse files Browse the repository at this point in the history
  • Loading branch information
hassnian authored Nov 20, 2024
2 parents e06ef27 + 0439e14 commit a339e09
Show file tree
Hide file tree
Showing 80 changed files with 824 additions and 608 deletions.
2 changes: 2 additions & 0 deletions components/base/MediaItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
:preview="preview"
:autoplay="autoplay"
:lazy-loading="lazyLoading"
:inner-class="innerClass"
/>
<div
v-if="isLewd && isLewdBlurredLayer"
Expand Down Expand Up @@ -101,6 +102,7 @@ const props = withDefaults(
lazyLoading?: boolean
enableNormalTag?: boolean
sizes?: string
innerClass?: string
imageComponent?:
| string
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
Expand Down
9 changes: 7 additions & 2 deletions components/codeChecker/CodeChecker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ const onFileSelected = async (file: File) => {
clear()
startClock()
selectedFile.value = file
const { indexFile, sketchFile, entries }
= await extractAssetsFromZip(file)
const { indexFile, sketchFile, p5File, entries } = await extractAssetsFromZip(file)
if (!indexFile) {
errorMessage.value = `Index file not found: Please make sure that “index.html” is in the root directory`
Expand All @@ -291,6 +290,12 @@ const onFileSelected = async (file: File) => {
errorMessage.value = `Sketch file not found: ${config.sketchFile}`
return
}
if (!p5File) {
errorMessage.value = `p5 file not found: Please make sure that “p5.min.js” is in the root directory`
return
}
const valid = validate(indexFile.content, sketchFile.content)
if (!valid.isSuccess) {
errorMessage.value = valid.error ?? 'Unknown error'
Expand Down
1 change: 1 addition & 0 deletions components/codeChecker/codechecker.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
iframeId: 'sketch-iframe',
sketchFile: 'sketch.js',
p5File: 'p5.min.js',
p5: 'p5',
maxAllowedLoadTime: 3000, // in ms
varaitionsOptions: [1, 3, 5, 10, 15, 20],
Expand Down
22 changes: 15 additions & 7 deletions components/codeChecker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,29 @@ const calculateCommonPrefix = (filePaths: string[]): string => {
const categorizeFiles = async (
entries: { [key: string]: ZipEntry },
commonPrefix: string,
): Promise<{ htmlFiles: FileEntry[], jsFiles: FileEntry[] }> => {
): Promise<{ htmlFiles: FileEntry[], jsFiles: FileEntry[], p5Files: FileEntry[] }> => {
const htmlFiles: FileEntry[] = []
const jsFiles: FileEntry[] = []
const p5Files: FileEntry[] = []

for (const [path, file] of Object.entries(entries)) {
const adjustedPath = path.replace(commonPrefix, '')
const content = await file.text()
const isJsFile = path.endsWith('.js')

if (path === 'index.html') {
htmlFiles.push({ path: adjustedPath, content })
}
else if (path.endsWith('.js') && !path.includes(config.p5)) {
// allows p5 libraries
else if (path.includes(config.p5) && isJsFile) {
p5Files.push({ path: adjustedPath, content })
}
else if (isJsFile) {
jsFiles.push({ path: adjustedPath, content })
}
}

return { htmlFiles, jsFiles }
return { htmlFiles, jsFiles, p5Files }
}

// exported functions
Expand Down Expand Up @@ -130,6 +136,7 @@ export const extractAssetsFromZip = async (
): Promise<{
indexFile: FileEntry
sketchFile: FileEntry
p5File: FileEntry
entries: { [key: string]: ZipEntry }
jsFiles: FileEntry[]
}> => {
Expand All @@ -138,14 +145,15 @@ export const extractAssetsFromZip = async (

const commonPrefix = calculateCommonPrefix(filePaths)

const { htmlFiles, jsFiles } = await categorizeFiles(entries, commonPrefix)
const sketchFile = jsFiles.find(file =>
file.path.includes(config.sketchFile),
) as FileEntry
const { htmlFiles, jsFiles, p5Files } = await categorizeFiles(entries, commonPrefix)

const sketchFile = jsFiles.find(file => file.path.includes(config.sketchFile)) as FileEntry
const p5File = p5Files.find(file => file.path.includes(config.p5File)) as FileEntry

return {
indexFile: htmlFiles[0],
sketchFile,
p5File,
entries,
jsFiles,
}
Expand Down
6 changes: 4 additions & 2 deletions components/codeChecker/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ const constants = {
localP5JsRegex: /<script.*src="(?!http)([^"]*p5[^"]*\.js)"/,
titleTagRegex: /<title>(.*?)<\/title>/,
kodaRendererRegex: /kodahash\/render\/completed/,
kodaRendererCalledRegex: /(?<!function\s)postMessageKoda\s*\(/,
resizerRegex: /resizeCanvas\(/,
disallowedTitle: 'KodaHash',
}

const validateCanvasCreation = (
sketchFileContent: string,
): Result<RegExpExecArray> => {
const canvasMatch = constants.canvasRegex.exec(sketchFileContent)
// Create a new regex instance to avoid issues with lastIndex when using the global flag.
const canvasMatch = new RegExp(constants.canvasRegex).exec(sketchFileContent)
if (!canvasMatch) {
return { isSuccess: false, error: 'createCanvas function not found.' }
}
Expand Down Expand Up @@ -141,7 +143,7 @@ const validateSketchContent = (
canvasSize,
localP5jsUsed: false, // This will be set based on HTML content checks
validTitle: false, // This will be updated after HTML content checks
kodaRendererUsed: constants.kodaRendererRegex.test(sketchFileContent),
kodaRendererUsed: constants.kodaRendererRegex.test(sketchFileContent) && constants.kodaRendererCalledRegex.test(sketchFileContent),
resizerUsed: constants.resizerRegex.test(sketchFileContent),
usesHashParam: validateURLParamsUsage(sketchFileContent).isSuccess,
}
Expand Down
17 changes: 11 additions & 6 deletions components/collection/CollectionHeader/CollectionBanner.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
class="collection-banner relative md:h-[560px] h-72 bg-no-repeat bg-cover bg-center border-b"
:style="{ backgroundImage: `url(${bannerImageUrl})` }"
:style="{ backgroundImage: `url(${collectionBanner})` }"
>
<div class="collection-banner-shadow absolute inset-0" />

Expand Down Expand Up @@ -55,38 +55,43 @@ const props = defineProps<{
const route = useRoute()
const collectionAvatar = ref('')
const collectionBanner = ref('')
const collectionName = ref('--')
const bannerImageUrl = computed(
() => collectionAvatar.value && toOriginalContentUrl(collectionAvatar.value),
)
watch(() => props.collectionId, () => {
collectionAvatar.value = ''
collectionBanner.value = ''
collectionName.value = '--'
})
watchEffect(async () => {
const collection = props.collection
const metadata = collection?.metadata
const image = collection?.meta?.image
const banner = collection?.meta?.banner || image
const name = collection?.name
if (image && name) {
if (image && name && banner) {
collectionAvatar.value = sanitizeIpfsUrl(image)
collectionBanner.value = toOriginalContentUrl(sanitizeIpfsUrl(banner))
collectionName.value = name
}
else {
const meta = (await processSingleMetadata(
metadata as string,
)) as NFTMetadata
const metaImage = sanitizeIpfsUrl(meta?.image)
const metaBanner = meta?.banner ? sanitizeIpfsUrl(meta?.banner) : metaImage
const metaName = meta?.name
if (metaName) {
collectionName.value = metaName
}
if (metaBanner) {
collectionBanner.value = toOriginalContentUrl(metaBanner)
}
if (metaImage) {
collectionAvatar.value = metaImage
}
Expand Down
2 changes: 1 addition & 1 deletion components/collection/drop/GenerativePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const { formatted: formattedPrice } = useAmount(
)
const emit = defineEmits(['generation:start', 'generation:end', 'mint'])
const isUnlimited = computed(() => drop.value.max !== undefined && drop.value.max > Number.MAX_SAFE_INTEGER)
const isUnlimited = computed(() => drop.value.max !== undefined && drop.value.max >= Number.MAX_SAFE_INTEGER)
const { start: startTimer } = useTimeoutFn(() => {
// quick fix: ensure that even if the completed event is not received, the loading state of the drop can be cleared
Expand Down
2 changes: 1 addition & 1 deletion components/collection/drop/HolderOfGenerative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const handleSubmitMint = async () => {
// use paid modal if it's holder of + price
if (isHolderOfWithPaidMint.value) {
isMintModalActive.value = true
return await massGenerate()
return await massGenerate().catch(closeMintModal)
}
if (hasMinimumFunds.value) {
Expand Down
2 changes: 1 addition & 1 deletion components/collection/drop/PaidGenerative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const handleSubmitMint = async () => {
doAfterCheckCurrentChainVM(() => {
isMintModalActive.value = true
massGenerate()
massGenerate().catch(handleMintModalClose)
})
}
Expand Down
17 changes: 2 additions & 15 deletions components/collection/drop/modal/PaidMint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,11 @@ const { isTransactionSuccessful } = useTransactionSuccessful({
isLoading,
})
const isSingleMintNotReady = computed(
() => amountToMint.value === 1 && !canMint.value,
)
const mintButton = computed(() => {
if (!canMint.value) {
return {
label: $i18n.t('drops.mintDropError'),
disabled: true,
}
}
return { label: $i18n.t('drops.proceedToSigning'), disabled: false }
})
const mintButton = { label: $i18n.t('drops.proceedToSigning'), disabled: false }
const loading = computed(
() =>
isSingleMintNotReady.value
!canMint.value
|| mintOverview.value?.loading
|| (autoteleportCompleted.value && !moveSuccessfulDrop.value)
|| false,
Expand Down
1 change: 1 addition & 0 deletions components/collection/utils/useCollectionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const useCollectionMinimal = ({

collection.value = collectionData
},
{ immediate: true },
)

watchEffect(async () => {
Expand Down
2 changes: 1 addition & 1 deletion components/common/ChooseCollectionDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const props = defineProps({
const { isLogIn, accountId } = useAuth()
const { collectionsEntites, isLoading } = useCollectionForMint()
const { collections: collectionsEntites, isLoading } = useCollectionForMint()
const selectedCollection = ref<MintedCollection>()
const disabled = computed(() => !isLogIn.value || isLoading.value)
Expand Down
14 changes: 5 additions & 9 deletions components/common/ConnectWallet/ConnectEvm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { useAccount, useDisconnect, useConnections } from '@wagmi/vue'
const emits = defineEmits(['select'])
const { address, isConnected, isConnecting, chainId } = useAccount()
const { urlPrefix, setUrlPrefix } = usePrefix()
const { modal } = useWeb3Modal()
const { disconnectAsync: disconnect } = useDisconnect()
const connections = useConnections()
Expand All @@ -47,15 +46,12 @@ watch([address, isConnected, chainId], ([address, isConnected, chainId]) => {
const chainPrefix = CHAIN_ID_TO_PREFIX?.[chainId ?? '']
if (address && isConnected && chainId && chainPrefix) {
const isCorrectChainConnected = chainPrefix === urlPrefix.value
if (!isCorrectChainConnected) {
setUrlPrefix(chainPrefix)
}
emits('select', {
address: address as string,
vm: 'EVM',
account: {
address: address as string,
vm: 'EVM',
},
prefix: chainPrefix,
})
}
})
Expand Down
12 changes: 7 additions & 5 deletions components/common/ConnectWallet/ConnectSubstrate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ const installedWallet = computed(() => {
const setAccount = (account: SubstrateWalletAccount) => {
forceWalletSelect.value = false
emits('select', {
address: account.address,
extension: account.source,
name: account.name,
vm: 'SUB',
} as WalletAccount)
account: {
address: account.address,
extension: account.source,
name: account.name,
vm: 'SUB',
} as WalletAccount,
})
}
const refreshWallets = () => {
Expand Down
15 changes: 9 additions & 6 deletions components/common/ConnectWallet/ConnectWalletModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@

<script setup lang="ts">
import { NeoModalHead } from '@kodadot1/brick'
import { type ChainVM, DEFAULT_VM_PREFIX } from '@kodadot1/static'
import { type ChainVM, type Prefix } from '@kodadot1/static'
import { DEFAULT_VM_PREFIX } from '@kodadot1/static'
import WalletAsset from '@/components/common/ConnectWallet/WalletAsset.vue'
import { ModalCloseType } from '@/components/navbar/types'
import { arePrefixesOfSameVm } from '@/utils/config/chain.config'
const emit = defineEmits(['close', 'connect'])
const props = defineProps<{ preselected?: ChainVM }>()
Expand All @@ -68,14 +70,15 @@ const selectedTab = ref<ChainVM>(props.preselected ?? 'SUB')
const showAccount = computed(() => Boolean(account.value))
const setAccount = (account: WalletAccount) => {
const setAccount = ({ account, prefix }: { account: WalletAccount, prefix?: Prefix }) => {
prefix ??= DEFAULT_VM_PREFIX[account.vm]
walletStore.setWallet(account)
identityStore.setAuth({ address: account.address })
if (!isPrefixVmOf(urlPrefix.value, account.vm)) {
const newChain = DEFAULT_VM_PREFIX[account.vm]
setUrlPrefix(newChain)
redirectAfterChainChange(newChain)
if (!arePrefixesOfSameVm(prefix, urlPrefix.value)) {
setUrlPrefix(prefix)
redirectAfterChainChange(urlPrefix.value)
}
emit('connect', account)
Expand Down
2 changes: 0 additions & 2 deletions components/common/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ import {
NeoMessage,
} from '@kodadot1/brick'
type NotificationAction = { label: string, url: string, icon?: string }
const emit = defineEmits(['close'])
const props = withDefaults(
defineProps<{
Expand Down
2 changes: 2 additions & 0 deletions components/common/autoTeleport/AutoTeleportActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
:disabled="isDisabled"
:loading="loading"
:loading-with-label="loading"
with-shortcut
class="flex flex-grow btn-height capitalize"
@click="handleSubmit"
/>
Expand Down Expand Up @@ -90,6 +91,7 @@

<OnRampModal
v-model="onRampActive"
no-overlap
@close="onRampActive = false"
/>
</div>
Expand Down
Loading

0 comments on commit a339e09

Please sign in to comment.