From 6e9f5655873e576e94831fce150bb0fdd5727282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Mon, 20 Jan 2025 15:32:50 -0500 Subject: [PATCH] Add more logs for IPFS failures --- lib/contracts/contributor.js | 5 +++++ lib/utils/ipfs.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/contracts/contributor.js b/lib/contracts/contributor.js index 5edbfa9..05e3abc 100644 --- a/lib/contracts/contributor.js +++ b/lib/contracts/contributor.js @@ -52,6 +52,7 @@ class Contributor extends Record { const jsonStr = contributor.serialize(); + // console.log('Adding IPFS doc for', contributorAttr.account); return this.ipfs .add(jsonStr) .then((ipfsHashAttr) => { @@ -62,7 +63,11 @@ class Contributor extends Record { ipfsHashAttr.hashSize, ]; + // console.log('Adding onchain record for', contributorAttr.account); return this.contract.addContributor(...contributor, callOptions); + }).catch(err => { + console.log('Failed to add IPFS document:', err.message); + throw(err); }); } diff --git a/lib/utils/ipfs.js b/lib/utils/ipfs.js index 3b4ee17..7382bda 100644 --- a/lib/utils/ipfs.js +++ b/lib/utils/ipfs.js @@ -9,6 +9,13 @@ class IPFS { } this._config = config; this._ipfsAPI = ipfsClient.create(config); + + this._ipfsAPI.id().then(res => { + console.debug('IPFS ID:', res.id); + }).catch(e => { + console.debug('IPFS config:', config); + console.warn('Failed to initialize IPFS:', e.message); + }); } async catAndMerge (contractData, deserialize) {