fix: mscz ipfs

This commit is contained in:
Xmader 2020-11-14 13:37:46 -05:00
parent 5003e6572f
commit 59c4e62912
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
2 changed files with 6 additions and 4 deletions

View File

@ -6,9 +6,11 @@ let msczBufferP: Promise<ArrayBuffer> | undefined
export const fetchMscz = async (): Promise<ArrayBuffer> => { export const fetchMscz = async (): Promise<ArrayBuffer> => {
if (!msczBufferP) { if (!msczBufferP) {
const url = scoreinfo.msczUrl const url = scoreinfo.msczCidUrl
msczBufferP = (async (): Promise<ArrayBuffer> => { msczBufferP = (async (): Promise<ArrayBuffer> => {
const r = await fetch(url) const r0 = await fetch(url)
const { Cid: { '/': cid } } = await r0.json()
const r = await fetch(`https://ipfs.infura.io/ipfs/${cid as string}`)
const data = await r.arrayBuffer() const data = await r.arrayBuffer()
return data return data
})() })()

View File

@ -71,8 +71,8 @@ export const scoreinfo = {
return `/ipns/${IPNS_KEY}/${this.id}.mscz` return `/ipns/${IPNS_KEY}/${this.id}.mscz`
}, },
get msczUrl (this: typeof scoreinfo): string { get msczCidUrl (this: typeof scoreinfo): string {
return `https://ipfs.infura.io:5001/api/v0/cat?arg=${this.msczIpfsRef}` return `https://ipfs.infura.io:5001/api/v0/dag/resolve?arg=${this.msczIpfsRef}`
}, },
get sheetImgType (): 'svg' | 'png' { get sheetImgType (): 'svg' | 'png' {