From a678b1286ee0f1d0fbeafedc3dcff4206bb911b4 Mon Sep 17 00:00:00 2001 From: panpansh Date: Sat, 2 Apr 2022 02:31:27 +0200 Subject: [PATCH] Ability to restore Eth Identity from without Signer ```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(), }); ``` --- src/identities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/identities.js b/src/identities.js index 2ef25fa..a2d2c6f 100644 --- a/src/identities.js +++ b/src/identities.js @@ -55,7 +55,7 @@ class Identities { const keystore = options.keystore || this.keystore const type = options.type || defaultType const identityProvider = type === defaultType ? new OrbitDBIdentityProvider(options.signingKeystore || keystore) : new (getHandlerFor(type))(options) - const id = await identityProvider.getId(options) + const id = options.id || await identityProvider.getId(options) if (options.migrate) { await options.migrate({ targetStore: keystore._store, targetId: id })