@visualizevalue/mint-app-base 0.1.88 → 0.1.89

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.
@@ -46,7 +46,7 @@ const collections = computed(() => isMe.value
46
46
  // Force update collections with no mints
47
47
  if (store.forArtist(id.value).length !== collections.length) {
48
48
  store.forArtist(id.value)
49
- .filter(c => c.latestTokenId === 0n)
49
+ .filter(c => c?.latestTokenId === 0n)
50
50
  .forEach(c => store.fetchCollection(c.address))
51
51
  }
52
52
  </script>
@@ -44,6 +44,7 @@ export const useOnchainStore = () => {
44
44
  return this.artist(address).collections
45
45
  .map(c => state.collections[c])
46
46
  .sort((a, b) => a.initBlock > b.initBlock ? -1 : 1)
47
+ .filter(c => !!c)
47
48
  }
48
49
  },
49
50
  forArtistOnlyMinted () {
@@ -204,24 +205,29 @@ export const useOnchainStore = () => {
204
205
  }) as Promise<GetBalanceReturnType>,
205
206
  ])
206
207
 
208
+ const artist = owner.toLowerCase() as `0x${string}`
207
209
  const json = Buffer.from(data.substring(29), `base64`).toString()
208
- const metadata = JSON.parse(json)
209
210
 
210
- const artist = owner.toLowerCase() as `0x${string}`
211
+ try {
212
+ const metadata = JSON.parse(json)
211
213
 
212
- return await this.addCollection({
213
- image: metadata.image,
214
- name: metadata.name,
215
- symbol: metadata.symbol,
216
- description: metadata.description,
217
- address,
218
- initBlock,
219
- latestTokenId,
220
- owner: artist,
221
- tokens: {},
222
- balance: balance.value,
223
- renderers: [],
224
- })
214
+ return await this.addCollection({
215
+ image: metadata.image,
216
+ name: metadata.name,
217
+ symbol: metadata.symbol,
218
+ description: metadata.description,
219
+ address,
220
+ initBlock,
221
+ latestTokenId,
222
+ owner: artist,
223
+ tokens: {},
224
+ balance: balance.value,
225
+ renderers: [],
226
+ })
227
+ } catch (e) {
228
+ console.warn(`Error parsing collection`, e)
229
+ this.artists[artist].collections = this.artists[artist].collections.filter(c => c !== address)
230
+ }
225
231
  },
226
232
 
227
233
  async fetchCollectionBalance (address: `0x${string}`) {
@@ -327,8 +333,16 @@ export const useOnchainStore = () => {
327
333
 
328
334
  const [ name, description, _artifact, _renderer, mintedBlock, _closeAt, _extraData ] = data
329
335
 
330
- const json = Buffer.from(dataUri.substring(29), `base64`).toString()
331
- const metadata = JSON.parse(json)
336
+ let metadata
337
+ try {
338
+ const json = Buffer.from(dataUri.substring(29), `base64`).toString()
339
+ metadata = JSON.parse(json)
340
+ } catch (e) {
341
+ metadata = {
342
+ image: '',
343
+ animationUrl: '',
344
+ }
345
+ }
332
346
 
333
347
  const token: Token = {
334
348
  tokenId,
@@ -116,8 +116,8 @@ export const useCreateMintFlow = (collection: Collection, txFlow: Ref) => {
116
116
  address: collection.address,
117
117
  functionName: 'create',
118
118
  args: [
119
- name.value,
120
- description.value,
119
+ sanitizeForJson(name.value),
120
+ sanitizeForJson(description.value),
121
121
  multiTransactionPrepare ? [] : artifactByteArray,
122
122
  renderer.value,
123
123
  0n, // Additional Data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visualizevalue/mint-app-base",
3
- "version": "0.1.88",
3
+ "version": "0.1.89",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {
@@ -129,9 +129,9 @@ const deployRequest = computed(() => async () => {
129
129
  address: config.public.factoryAddress,
130
130
  functionName: creationType.value,
131
131
  args: [
132
- title.value,
133
- symbol.value,
134
- description.value,
132
+ sanitizeForJson(title.value),
133
+ sanitizeForJson(symbol.value),
134
+ sanitizeForJson(description.value),
135
135
  toByteArray(image.value),
136
136
  ],
137
137
  })
package/utils/strings.ts CHANGED
@@ -28,3 +28,6 @@ export const extractURLs = (str: string) => {
28
28
  urls: str.match(urlPattern),
29
29
  }
30
30
  }
31
+
32
+ // Replace special characters with their escaped counterparts
33
+ export const sanitizeForJson = (input: string): string => JSON.stringify(input).slice(1, -1)