ethersphere / bee-js

Javascript client library for connecting to Bee decentralised storage
https://bee-js.ethswarm.org/
BSD 3-Clause "New" or "Revised" License
60 stars 27 forks source link

BeeJS modularisation #413

Open nugaon opened 3 years ago

nugaon commented 3 years ago

In the upcoming period we would like to split the bee-js library into several reusable modules that give more freedom over swarm primitives. Currently the bee-js mostly does API wrapping of the go Bee client. This functionality will resign in bee-js-client with no extra logic around that. Additional packages are the following:

agazso commented 3 years ago

Just a minor note regarding naming: currently the bee-js package name is @ethersphere/bee-js which is consistent with the github repo name. However this may not necessarily be possible with some other proposed package names, because there are already go projects with those names. For example there is already a feeds repo under https://github.com/ethersphere/feeds.

It would be good to come up with a solution that can provide consistent naming without introducing clashing names.

nugaon commented 3 years ago

great notice, my idea was append the package names with trailing -js.

Any other idea?

r0qs commented 3 years ago

Hey this is great news! And I like the originally proposed names (without the -js). About the feeds repo, I believe that the existent one pointed by @agazso looks more like a poc around feeds, and maybe could be renamed to give room to the other. But anyway, it is very good to have those modules as independent packages, it will bring much more flexibility to dapps developers.

AuHau commented 3 years ago

Also, another thing is to consider how the multi-package setup will be created. The obvious solution that I think everyone has in mind at the moment is to create for each package separate repository. This might have some disadvantages though. Usually, with this setup, the problem is that when you start to work on changes that spawn across multiple packages it is hard to coordinate (you have to release and then propagate the changes), and sometimes even development is quite challenging (you have to use heavily npm link, which sometimes fell short). Another potential problem is the Contribution barrier that this setup creates, where if somebody wants to contribute he has to clone/fork multiple packages and then again coordinate with the maintainers their work.

Another solution is going with monorepo and a system like lerna heaving all the packages as part of one repo (I guess the bee-js repo could be the place), which then makes it easier for cross-package development work. Lerna supports different versioning strategy so we could also decide on that.

I remember people around js-ipfs dealing with this problem in the way of adopting the Lerna monorepo, so maybe we could learn from their work and directly adopt it? I am not saying necessary for all JS projects/repos, but for this bee-js modularization, it would make sense IMO.

Related issue in js-ipfs: https://github.com/ipfs/js-ipfs/issues/2877

r0qs commented 6 months ago

Hi, is there any progress on this? We are interested in using the @ethersphere/chunker but I couldn't find it. Specifically, we are currently using swarmhash to generate swarm hashes for the Solidity compiler binaries (https://github.com/ethereum/solc-bin/blob/6fe4cced82cf0e5149bcf6537b443e2cfafc43a4/update.mjs#L158). However, this library has become outdated since Swarm migrated to the BMT hash scheme, resulting in incorrect hashes being generated for some time now (please see: https://github.com/ethereum/solidity/issues/14700, https://github.com/ethereum/solidity/issues/4092 and https://github.com/axic/swarmhash/issues/1).

We need to replace swarmhash due to its dependency on node version 16, which is coming to its end-of-life. Therefore, to continue supporting swarm-compatible hashes for our release binaries, we're eager to know if there are any plans to expose the low-level chunk functionalities in bee-js.

I believe we could replace our current use of swarmhash by bmtHash or even makeContentAddressedChunk.

However, neither of those functions are exposed in BeeJs. Consequently, we find ourselves unable to utilize it as a replacement.

Cafe137 commented 1 week ago

@r0qs Sorry for the late reply.

You may be interested in https://github.com/fairDataSociety/bmt-js which is a standalone module for this purpose.