From 6e895b3cc1ec6f3fc282ef3ec533d4cef3a33689 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 24 Nov 2020 16:50:52 -0500 Subject: [PATCH] feat: persist mscz url --- src/mscz.ts | 2 +- src/scoreinfo.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mscz.ts b/src/mscz.ts index 8b64d79..72df082 100644 --- a/src/mscz.ts +++ b/src/mscz.ts @@ -18,7 +18,7 @@ export const fetchMscz = async (scoreinfo: ScoreInfo, _fetch = getFetch()): Prom } const cidRes = await r0.json() - const r = await _fetch(scoreinfo.getMsczUrl(cidRes)) + const r = await _fetch(scoreinfo.loadMsczUrl(cidRes)) assertRes(r) const data = await r.arrayBuffer() return data diff --git a/src/scoreinfo.ts b/src/scoreinfo.ts index a0849fd..6be1c24 100644 --- a/src/scoreinfo.ts +++ b/src/scoreinfo.ts @@ -26,7 +26,8 @@ export abstract class ScoreInfo { 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 if (!cid) { // read further error msg @@ -37,7 +38,8 @@ export abstract class ScoreInfo { throw new Error(err) } } - return `https://ipfs.infura.io/ipfs/${cid}` + this.msczUrl = `https://ipfs.infura.io/ipfs/${cid}` + return this.msczUrl } }