| 1 | import { CID } from 'multiformats/cid' |
| 2 | import type { ValueCodec } from 'it-rpc' |
| 3 | |
| 4 | export const cidCodec: ValueCodec<CID> = { |
| 5 | type: 4096, |
| 6 | canEncode: (val) => val.code != null && val.version != null && val.multihash != null && val['/'] != null, |
| 7 | encode: (val) => val.bytes, |
| 8 | decode: (buf) => CID.decode(buf) |
| 9 | } |