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

Ability to restore Eth Identity from without Signer #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

None yet

1 participant