Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Conversation

@panpansh
Copy link

@panpansh panpansh commented Apr 2, 2022

import path from "path";
import ODBKeystore from "orbit-db-keystore";
import Identities from "orbit-db-identity-provider";

const account = accounts[0];
const odbIdentitykeysPath = path.join("./orbitdb", "identity", "identitykeys");
const keystore = new ODBKeystore(odbIdentitykeysPath);
// if account exist in IDB: restore else sign
const identity = await keystore.hasKey(account)
    ? await Identities.createIdentity({
        type: "orbitdb",
        id: account,
    })
   : await Identities.createIdentity({
        type: "ethereum",
        wallet: provider.getSigner(),
    });

```js
import path from "path";
import ODBKeystore from "orbit-db-keystore";
import Identities from "orbit-db-identity-provider";

const account = accounts[0];
const odbIdentitykeysPath = path.join("./orbitdb", "identity", "identitykeys");
const keystore = new ODBKeystore(odbIdentitykeysPath);
// if account exist in IDB: restore else sign
const identity = await keystore.hasKey(account)
    ? await Identities.createIdentity({
        type: "orbitdb",
        id: account,
    })
   : await Identities.createIdentity({
        type: "ethereum",
        wallet: provider.getSigner(),
    });
```
@panpansh
Copy link
Author

panpansh commented Apr 2, 2022

https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/identities.js#L58-L64 to be clear the create works fine, the problem is when i want to restore my identity, actually in the code in my case i want "identityProvider.getId" as Ethereum but i want "identityProvider.signIdentity" as Orbitdb.

Because if a wallet is not specified when he getId as ethereum, he create a new one and return the new one https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/ethereum-identity-provider.js#L18

And giving the id like that as createIdentity param, I dont need this transformation as orbitdb https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/orbit-db-identity-provider.js#L26

@panpansh
Copy link
Author

panpansh commented Apr 2, 2022

I'm certainly wrong, I can't restore the identity without asking for the signature after refreshing the page

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant