Merge pull request 'Fix IPFS cat decoding for ipfs-http-client 56 (Uint8Array)' (#251) from fix/ipfs-uint8array-decode into master

Reviewed-on: #251
This commit is contained in:
raucao committed 2026-10-29 16:10:08 +00:00
commit cb46825483
2 files changed
+8 -4

No files matched your search

+7 -3
View File
@@ -50,11 +50,15 @@ class IPFS {
return fetch(`${this._config['gatewayUrl']}/${ipfsHash}`).then(r => r.text());
} else {
const res = this._ipfsAPI.cat(ipfsHash);
// ipfs-http-client >= 56 yields Uint8Array chunks. Their toString()
// returns comma-separated byte values instead of text, so decode the
// bytes explicitly (TextDecoder works in both Node and browsers).
const decoder = new TextDecoder();
let str = '';
for await (const buffer of res) {
str += buffer.toString();
for await (const chunk of res) {
str += decoder.decode(chunk, { stream: true });
}
return Promise.resolve(str);
return Promise.resolve(str + decoder.decode());
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@kredits/contracts",
"version": "7.5.0",
"version": "7.5.1",
"description": "Smart contracts and JavaScript API for Kredits",
"main": "./lib/kredits.js",
"directories": {