minty icon indicating copy to clipboard operation
minty copied to clipboard

TypeError: CID instance expected instead of object

Open 58bits opened this issue 3 years ago • 0 comments

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)
}

58bits avatar Aug 01 '21 06:08 58bits