Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"base58check": "^2.0.0",
"bech32": "^1.1.3",
"bs58": "^4.0.1",
"content-hash": "^2.4.1",
"content-hash": "^2.5.2",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs new release with fixes from pldespaigne/content-hash#43

"cross-fetch": "^3.0.2",
"eth-ens-namehash": "^2.0.8",
"ethers": "4.0.36",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('Blockchain tests', () => {
const content = await getContent('abittooawesome.eth')
expect(content.contentType).toBe('contenthash')
expect(content.value).toBe(
'ipfs://QmTeW79w7QQ6Npa3b1d5tANreCDxF2iDaAPsDvW6KtLmfB'
'ipfs://bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y'
)
})

Expand Down
5 changes: 5 additions & 0 deletions src/utils/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export function decodeContenthash(encoded) {
decoded = contentHash.decode(encoded)
const codec = contentHash.getCodec(encoded)
if (codec === 'ipfs-ns') {

// convert the ipfs from base58 to base32 (url host compatible)
// if needed the hash can now be resolved through a secured origin gateway (<hash>.gateway.com)
decoded = contentHash.helpers.cidV0ToV1Base32(decoded)
Copy link

@lidel lidel Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makoto
Unsure about context, but if this is needed for subdomain gateways, it should use cidForWeb from pldespaigne/content-hash#43 instead.

Feel free to ping me if more context from IPFS side is needed.


protocolType = 'ipfs'
} else if (codec === 'swarm-ns') {
protocolType = 'bzz'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/contents.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('test contenthash utility functions for swarm', () => {
)

expect(decoded.decoded).toBe(
'QmaEBknbGT4bTQiQoe2VNgBJbRfygQGktnaW5TbuKixjYL'
'bafybeifqurebcya65zrw4b4idhozkx2tbxwtedl4rn7etc7abfmbapocne' // same hash but in cid v1 base32
)
expect(decoded.protocolType).toBe('ipfs')
expect(decoded.error).toBe(undefined)
Expand Down
Loading