@visualizevalue/mint-app-base 0.1.93 → 0.1.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -17,6 +17,8 @@ NUXT_PUBLIC_CREATOR_ADDRESS=0xc8f8e2f59dd95ff67c3d39109eca2e2a017d4c8a
17
17
  # SERVICES
18
18
  # =========================
19
19
  NUXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
20
+ NUXT_PUBLIC_IPFS_GATEWAY=
21
+ NUXT_PUBLIC_ARWEAVE_GATEWAY=
20
22
 
21
23
  # =========================
22
24
  # MAINNET
@@ -42,12 +42,13 @@ async function fetchMediaType(url: string): Promise<string | null> {
42
42
  }
43
43
  }
44
44
 
45
+ const config = useRuntimeConfig()
45
46
  const props = defineProps({
46
47
  src: String,
47
48
  })
48
49
 
49
50
  // Update on input change
50
- const src = ref(props.src)
51
+ const src = ref()
51
52
  const mediaType = ref()
52
53
  const isPlayable = computed(() => {
53
54
  if (! mediaType.value) return false
@@ -55,7 +56,7 @@ const isPlayable = computed(() => {
55
56
  })
56
57
 
57
58
  watchEffect(async () => {
58
- src.value = props.src
59
+ src.value = validateURI(props.src, config.public)
59
60
  mediaType.value = await fetchMediaType(src.value)
60
61
  })
61
62
 
@@ -20,6 +20,7 @@
20
20
  <script setup>
21
21
  import { vIntersectionObserver } from '@vueuse/components'
22
22
 
23
+ const config = useRuntimeConfig()
23
24
  const props = defineProps({
24
25
  src: String,
25
26
  alt: String,
@@ -46,7 +47,7 @@ const loadImage = ([{ isIntersecting }]) => {
46
47
 
47
48
  if (! props.src) return
48
49
 
49
- uri.value = props.src
50
+ uri.value = validateURI(props.src, config.public)
50
51
  }
51
52
  watch(() => props.src, () => loadImage([{ isIntersecting: true }]))
52
53
 
@@ -50,6 +50,7 @@
50
50
  </template>
51
51
 
52
52
  <script setup>
53
+ const config = useRuntimeConfig()
53
54
  const {
54
55
  artifact,
55
56
  image,
@@ -92,28 +93,18 @@ const setAnimationArtifact = async (file) => {
92
93
  }
93
94
 
94
95
  watch(imageIpfsCid, () => {
95
- const validated = validateCID(imageIpfsCid.value)
96
- if (! validated) {
97
- image.value = ''
98
- } else {
99
- image.value = ipfsToHttpURI(`ipfs://${validated}`)
100
- }
96
+ image.value = getValidIpfsURI(imageIpfsCid.value)
101
97
  })
102
98
  watch(imageArTxId, () => {
103
- image.value = `https://arweave.net/${imageArTxId.value}`
99
+ image.value = getValidArweaveURI(imageArTxId.value)
104
100
  })
105
101
  watch(mode, () => image.value = '')
106
102
 
107
103
  watch(animationIpfsCid, () => {
108
- const validated = validateCID(animationIpfsCid.value)
109
- if (! validated) {
110
- animationUrl.value = ''
111
- } else {
112
- animationUrl.value = ipfsToHttpURI(`ipfs://${validated}`)
113
- }
104
+ animationUrl.value = getValidIpfsURI(animationIpfsCid.value)
114
105
  })
115
106
  watch(animationArTxId, () => {
116
- animationUrl.value = `https://arweave.net/${animationArTxId.value}`
107
+ animationUrl.value = getValidArweaveURI(animationArTxId.value)
117
108
  })
118
109
  watch(mode, () => {
119
110
  image.value = ''
@@ -36,6 +36,7 @@ const props = defineProps({
36
36
  },
37
37
  })
38
38
 
39
+ const config = useRuntimeConfig()
39
40
  const {
40
41
  artifact,
41
42
  image,
@@ -60,15 +61,10 @@ const setArtifact = async (file) => {
60
61
  }
61
62
  }
62
63
  watch(ipfsCid, () => {
63
- const validated = validateCID(ipfsCid.value)
64
- if (! validated) {
65
- image.value = ''
66
- } else {
67
- image.value = ipfsToHttpURI(`ipfs://${validated}`)
68
- }
64
+ image.value = getValidIpfsURI(ipfsCid.value)
69
65
  })
70
66
  watch(arTxId, () => {
71
- image.value = `https://arweave.net/${arTxId.value}`
67
+ image.value = getValidArweaveURI(arTxId.value)
72
68
  })
73
69
  watch(mode, () => image.value = '')
74
70
 
@@ -67,7 +67,7 @@ const { price, displayPrice } = useMintPrice(mintCount)
67
67
  const mintRequest = computed(() => async () => {
68
68
  const count = BigInt(props.mintCount)
69
69
 
70
- const priceWithBlockBuffer = price.value * 105n / 100n
70
+ const priceWithBlockBuffer = price.value * 110n / 100n
71
71
 
72
72
  return writeContract($wagmi, {
73
73
  abi: MINT_ABI,
package/nuxt.config.ts CHANGED
@@ -25,6 +25,8 @@ export default defineNuxtConfig({
25
25
  rpc1: 'https://eth.llamarpc.com',
26
26
  rpc2: 'https://ethereum-rpc.publicnode.com',
27
27
  rpc3: 'https://eth.drpc.org',
28
+ ipfsGateway: 'https://ipfs.io/ipfs/',
29
+ arweaveGateway: 'https://arweave.net/',
28
30
  title: 'Mint',
29
31
  walletConnectProjectId: '',
30
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visualizevalue/mint-app-base",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {
@@ -0,0 +1,12 @@
1
+ export const validateArweaveTx = (tx: string): string|false => {
2
+ return tx
3
+ }
4
+
5
+ export const getValidArweaveURI = (tx: string): string => {
6
+ const validated = validateArweaveTx(tx)
7
+
8
+ return validated ? `ipfs://${validated}` : ''
9
+ }
10
+
11
+ export const arweaveToHttpURI = (url: string, gateway: string = 'https://arweave.net/') => url.replace('ar://', gateway)
12
+
package/utils/ipfs.ts CHANGED
@@ -11,3 +11,17 @@ export const validateCID = (cid: string): string|false => {
11
11
  return false
12
12
  }
13
13
  }
14
+
15
+ export const getValidIpfsURI = (cid: string): string => {
16
+ const validated = validateCID(cid)
17
+
18
+ return validated ? `ipfs://${validated}` : ''
19
+ }
20
+
21
+ export const ipfsToHttpURI = (
22
+ url: string,
23
+ gateway: string = 'https://ipfs.io/ipfs/'
24
+ ) => url
25
+ .replace('https://ipfs.io/ipfs/', gateway)
26
+ .replace('ipfs://', gateway)
27
+
package/utils/urls.ts CHANGED
@@ -1,13 +1,24 @@
1
- export const ipfsToHttpURI = (url: string, gateway: string = 'https://ipfs.io/ipfs/') => url.replace('ipfs://', gateway)
1
+ type UrlValidationConfig = {
2
+ ipfsGateway?: string,
3
+ arweaveGateway?: string,
4
+ }
2
5
 
3
- export const validateURI = (url: string) => {
6
+ export const validateURI = (url: string, config: UrlValidationConfig = {}) => {
4
7
  if (! url || ! url.length) return false
5
8
 
6
9
  let validated = url.trim()
7
10
 
8
11
  // Normalize protocol
9
- if (! validated.startsWith('https://')) validated = `https://${validated}`
10
- if (! validated.startsWith('http')) validated = `http://${validated}`
12
+ // if (validated.startsWith('ipfs://') || validated.contains('ipfs')) {
13
+ if (validated.indexOf('ipfs') > -1) {
14
+ validated = ipfsToHttpURI(validated, config.ipfsGateway)
15
+ }
16
+ if (validated.startsWith('ar://')) {
17
+ validated = arweaveToHttpURI(validated, config.arweaveGateway)
18
+ }
19
+ if (! validated.startsWith('data:') && ! validated.startsWith('http')) {
20
+ validated = `https://${validated}`
21
+ }
11
22
 
12
23
  // Check url validity
13
24
  try {
package/utils/images.ts DELETED
@@ -1,27 +0,0 @@
1
- export type ImageVersions = {
2
- xs?: boolean, // 215
3
- sm?: boolean, // 512
4
- md?: boolean, // 1024
5
- lg?: boolean, // 2048
6
- }
7
-
8
- export type Image = {
9
- id: string,
10
- versions: ImageVersions,
11
- cdn: string,
12
- path: string,
13
- type: string,
14
- aspectRatio?: number,
15
- }
16
-
17
- const CDN_BASE = `cdn.evverydays.com`
18
-
19
- export const imageURI = (image: Image, version?: keyof ImageVersions) => {
20
- if (! image) return null
21
-
22
- const name = (version && image.versions[version])
23
- ? `${image.id}@${version}.webp`
24
- : `${image.id}.${image.type}`
25
-
26
- return `https://${image.cdn}.${CDN_BASE}/${image.path}/${name}`
27
- }