bee-js icon indicating copy to clipboard operation
bee-js copied to clipboard

`ChunkReference` is misleading or should be exposed

Open r0qs opened this issue 4 years ago • 4 comments

Hi, I would like to use the type ChunkReference as an argument for some functions in a lib that I'm writing, but it seems that although the type is exported it is not exposed in the API. There is a reason for that?

r0qs avatar Apr 19 '21 21:04 r0qs

Oh, now I noticed that there is a type Reference that is exposed, but it is HexString instead of Bytes: https://github.com/ethersphere/bee-js/blob/master/src/types/index.ts#L21 So I imagine that the ChunkReference is intended only to be used in the context of the feed module, and the high-level Reference is the one that I should use. Is that right?

r0qs avatar Apr 19 '21 21:04 r0qs

Hey there :-)

I see, we have might have some inconsistency here, which was raised by some of our refactors. Generally, across the public API we use Reference which as you pointed out is an HexString. But for Feed's purposes, we are internally working with the binary representation of the Reference and because of that ChunkReference was introduced and is also accepted by Feed's API. We might do some clean-up for this.

To answer your question, yes Reference is the way to go.

AuHau avatar Apr 20 '21 06:04 AuHau

Thanks. I just asked because before I was using bytes, and then I found the ChunkReference type and I would like to used it, but HexString works fine for me.

By the way, could you expose the hash module in the utils folder? I saw that it was moved there, but it was not added to the expose.ts file. Currently, I'm doing the keccak256Hash myself, but it would be good to reuse as much as possible of existing code. :)

Should I close this issue then?

r0qs avatar Apr 20 '21 09:04 r0qs

Sweet, sounds good!

By the way, could you expose the hash module in the utils folder? I saw that it was moved there, but it was not added to the expose.ts file. Currently, I'm doing the keccak256Hash myself, but it would be good to reuse as much as possible of existing code. :)

Yeah, good idea.

Should I close this issue then?

No, we will keep it as issue for clearing up the confuse between Reference and ChunkReference, maybe with some rename.

AuHau avatar Apr 20 '21 13:04 AuHau