feat: persist mscz url

This commit is contained in:
Xmader 2020-11-24 16:50:52 -05:00
parent 0f4d032399
commit 6e895b3cc1
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
2 changed files with 5 additions and 3 deletions

View File

@ -18,7 +18,7 @@ export const fetchMscz = async (scoreinfo: ScoreInfo, _fetch = getFetch()): Prom
} }
const cidRes = await r0.json() const cidRes = await r0.json()
const r = await _fetch(scoreinfo.getMsczUrl(cidRes)) const r = await _fetch(scoreinfo.loadMsczUrl(cidRes))
assertRes(r) assertRes(r)
const data = await r.arrayBuffer() const data = await r.arrayBuffer()
return data return data

View File

@ -26,7 +26,8 @@ export abstract class ScoreInfo {
return `https://ipfs.infura.io:5001/api/v0/block/stat?arg=${this.msczIpfsRef}` return `https://ipfs.infura.io:5001/api/v0/block/stat?arg=${this.msczIpfsRef}`
} }
getMsczUrl (cidRes: { Key: string; Message: string }): string { public msczUrl: string;
public loadMsczUrl (cidRes: { Key: string; Message: string }): string {
const cid = cidRes.Key const cid = cidRes.Key
if (!cid) { if (!cid) {
// read further error msg // read further error msg
@ -37,7 +38,8 @@ export abstract class ScoreInfo {
throw new Error(err) throw new Error(err)
} }
} }
return `https://ipfs.infura.io/ipfs/${cid}` this.msczUrl = `https://ipfs.infura.io/ipfs/${cid}`
return this.msczUrl
} }
} }