Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

TypeError: CID instance expected instead of object #26

Open
58bits opened this issue Aug 1, 2021 · 0 comments
Open

TypeError: CID instance expected instead of object #26

58bits opened this issue Aug 1, 2021 · 0 comments

Comments

@58bits
Copy link

58bits commented Aug 1, 2021

The latest version of ipfs-http-client client is using CIDs from https://www.npmjs.com/package/multiformats but Minty is currently configured to use CIDS from https://www.npmjs.com/package/cids

Which means that the 'pin to remote service' functions like pinTokenData will fail with TypeError: CID instance expected instead of object.

As far as I can tell, the way to fix this is to use the CID classes that come with the multiformats dependency in ipfs-http-client

such as...

const { CID } = require('multiformats/cid')

and then update the extractCID helper method to use the multiformats CID.parse method...

function extractCID(cidOrURI) {
  // remove the ipfs:// prefix, split on '/' and return first path component (root CID)
  const cidString = stripIpfsUriPrefix(cidOrURI).split('/')[0]
  return CID.parse(cidString)
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant