Skip to content

Typescript implementation #1228

Open
Open

Description

@vacekj

Hi, I would be interested in converting this repo to Typescript, as per #1106 .

Would you as the maintainers be okay with that?

Activity

  1. haydenyoung commented on May 18, 2025

    @haydenyoung
    Member

    Any contributions to OrbitDB are very welcome, We can add the repo to the orbitdb organization and give you full access to be able to maintain the official repo.

    Before moving ahead, I would like to confirm the new repo with one of our other maintainers so if you don't mind holding of while I confirm this.

    Thanks for your interest in OrbitDB.

  2. haydenyoung commented on May 19, 2025

    @haydenyoung
    Member

    @vacekj If you would like to start the implementation in your own repo and then we can review and add to the OrbitDB repo once ready.

  3. vacekj commented on May 19, 2025

    @vacekj
    Author

    I already started the ts impl in vacekj/orbitdb. I'll also be reworking the build system to be faster and more modern. Still WIP

  4. robksawyer commented on Nov 6, 2025

    @robksawyer

    @vacekj Any new developments here? Considering this for a new project in the future.

  5. vacekj commented on Nov 7, 2025

    @vacekj
    Author

    @robksawyer feel free to take it on, build on my fork if you'd like.

  6. robksawyer commented on Nov 8, 2025

    @robksawyer

    Hi, I went ahead and started a fork the other day. At the moment, I have a rough draft going. It took quite a while and although I tried keeping files as .js at first, I ended up just going all in with .ts. I'm currently working towards getting the tests passing again.

  7. julienmalard commented on Nov 17, 2025

    @julienmalard
    Contributor

    Hello,
    I agree that a TypeScript implementation would help a lot. As of now we have a separate types repository, if that helps anyone, but sometimes it's briefly out of date with the main repo's releases.

  8. julienmalard commented on Nov 17, 2025

    @julienmalard
    Contributor

    Any contributions to OrbitDB are very welcome, We can add the repo to the orbitdb organization and give you full access to be able to maintain the official repo.

    Before moving ahead, I would like to confirm the new repo with one of our other maintainers so if you don't mind holding of while I confirm this.

    Thanks for your interest in OrbitDB.

    Are you considering a new (parallel) repository for TS or rather converting this JS repo to TS?

  9. robksawyer commented on Nov 18, 2025

    @robksawyer

    @julienmalard I was just considering converting this JS repo to TS unless you think we should do otherwise. Let me know. However, I must mention that I did make some upgrades as well. Right now I'm in the process of getting tests working again.

  10. julienmalard commented on Nov 19, 2025

    @julienmalard
    Contributor

    That would be my personal recommendation as well @robksawyer because maintaining two repositories (whether TS and JS or JS and TS types) is very complicated. However, the only doubt is that I'm not sure if the OrbitDB project owners agree to switching to TS... if they do I'd be very happy to help out if you like!

    Regarding upgrades, did you upgrade to libp2p v3? If so, that might be the issue, since it's so far incompatible with the @chainsage/libp2p-gossipsub module that is used for syncing OrbitDB databases and which is still working on libp2p v3 compatibility (ChainSafe/js-libp2p-gossipsub#532).

  11. robksawyer commented on Nov 19, 2025

    @robksawyer

    @julienmalard I honestly just plunged in to this without really doing much research as I should have. However, I approach most projects like that and end up learning throughout. So, with that said, maybe have a look and you can see where I'm at via the fork here https://github.com/shmaplex/orbitdb. I ended up changing over to vitest as well. It'd be great to get your feedback and the help on making the tests work. I'm not opposed to switching anything currently setup in the fork as well if you have better solutions.

  12. julienmalard commented on Nov 20, 2025

    @julienmalard
    Contributor

    @robksawyer I do believe that vitest is a good tool to adopt.
    I looked quickly at your fork and it looks quite good. Do you have any particular compilation difficulties or specific tests that are failing?

  13. robksawyer commented on Nov 29, 2025

    @robksawyer

    @julienmalard sorry for the delay, I've actually started to go ahead and implement the existing version with your core types. They're working really well so far!

    However, I'm getting a bit confused on some implementation and could use some help here. I'm working with a Wails app and trying to save the identity and restore it to use on existing local saved databases. And well, I keep running into various errors, considering I've tried multiple ways of restoring, via getIdentity.

    Mostly this one:

    2025/11/29 12:56:03 [P2P] ✨ Creating new OrbitDB identity...
    2025/11/29 12:56:03 [P2P] 💾 Saved new identity: 02dd95dd82f5a0ee6a3578eee4ed92a49f245d40d7c890c6260e3c2ea3fbc2cab8
    [P2P] 2025-11-29T03:56:03.209Z - ❌ Failed to open Debug DB: CBOR decode error: data to decode must be a Uint8Array
    2025/11/29 12:56:03 [P2P] [P2P] 2025-11-29T03:56:03.216Z - ⚠️ Fallback to in-memory Debug DB
    [P2P] 2025-11-29T03:56:03.216Z - ❌ Failed to initialize debug DB entries: CBOR decode error: data to decode must be a Uint8Array
    [P2P] 2025-11-29T03:56:03.228Z - Critical error initializing OrbitDB databases: CBOR decode error: data to decode must be a Uint8Array
    Failed to start P2P node: Error: Failed to initialize databases. Node cannot start.
        at wa (file:///Users/robksawyer/Sites/Nous/nous-app/frontend/dist/p2p/setup.js:23:173868)
        at async UI (file:///Users/robksawyer/Sites/Nous/nous-app/frontend/dist/p2p/setup.js:23:188071)
    

    It all works fine on first load, but then when restoring the identity or the databases, I start to run into trouble.

    Is there anyone (maybe @vacekj ?) available that can explain the proper way to implement this or take a look at: https://github.com/shmaplex/nous/blob/main/frontend/server/src/identity.ts here and give me any suggestions.

    If you want to contribute to the project as well, would love to have some help. It's not a small task.

  14. julienmalard commented on Nov 29, 2025

    @julienmalard
    Contributor

    Thanks @robksawyer !

    Regarding identities, I think you need to use decodeIdentity (https://github.com/orbitdb/orbitdb/blob/main/src/identities/identity.js) due to the Uint8Arrays in the identity object.

  15. robksawyer commented on Nov 29, 2025

    @robksawyer

    @julienmalard I'll give that a shot. Thanks!

    [UPDATE]: Upon further investigation I see that decodeIdentity is being run in getIdentity:

    /**
       * Gets an identity by hash.
       * @param {string} hash An identity hash.
       * @return {module:Identities~Identity} An instance of identity.
       * @memberof module:Identities~Identities
       * @instance
       */
      const getIdentity = async (hash) => {
        const bytes = await storage.get(hash)
        if (bytes) {
          return decodeIdentity(bytes)
        }
      }
    

    I am actually trying to run getIdentity with the saved hash. However, when I pass the hash that was retrieved from:

    const identity = await identities.createIdentity({
    		id: "nous-node",
    		type: "ed25519",
    	});
    

    it doesn't seem to like it. Say for instance I save the identity to a json file and then use getIdentity(savedIdentity.hash), it is throwing an error. Should this work, or is my implementation off?

    [UPDATE]: It seems my issue is related to #1244.

  16. julienmalard commented on Nov 30, 2025

    @julienmalard
    Contributor

    @robksawyer Ah, that might be it! Are you on libp2p@v2 ?

  17. robksawyer commented on Dec 10, 2025

    @robksawyer

    @julienmalard I'm currently using "libp2p": "^3.1.2", and "@orbitdb/core": "^3.0.2",. 🤔

  18. julienmalard commented on Dec 10, 2025

    @julienmalard
    Contributor

    That might explain things...orbitdb currently requires libp2p@2 (as well as the corresponding helia and blockstore versions).

  19. robksawyer commented on Dec 10, 2025

    @robksawyer

    @julienmalard Yeah, I figured as much. Hopefully, I can finish getting these tests working soon and then we'll have an up to date version of orbitdb. I ended up getting a bit side tracked by a project. But, I'm using orbitdb in it, so I'm going to need to make it happen soon enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions