Skip to content
Snippets Groups Projects
Commit 00ee3eaa authored by Jono Wenger's avatar Jono Wenger
Browse files

Make NewChannelsManagerWithIndexedDb use the public key as its codename

parent e2cc8547
No related branches found
No related tags found
2 merge requests!60Revert "Fail a test to be sure it works",!8Updates to match the client fullyDecentrilizedChannels branch
......@@ -10,6 +10,8 @@
package wasm
import (
"encoding/base64"
"gitlab.com/elixxir/crypto/channel"
"syscall/js"
"gitlab.com/elixxir/client/bindings"
......@@ -184,7 +186,6 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} {
// using [Cmix.GetID].
// - args[1] - Bytes of a private identity ([channel.PrivateIdentity]) that is
// generated by [GenerateChannelIdentity] (Uint8Array).
// - args[2] - Username (string).
//
// Returns:
// - Javascript representation of the [ChannelsManager] object.
......@@ -192,7 +193,16 @@ func NewChannelsManager(_ js.Value, args []js.Value) interface{} {
// manager fails.
func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
privateIdentity := utils.CopyBytesToGo(args[1])
em, err := indexedDb.NewWasmEventModel(args[2].String())
// Get the public key to use as a key for indexedDb
pi, err := channel.UnmarshalPrivateIdentity(privateIdentity)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
key := base64.StdEncoding.EncodeToString(pi.Identity.PubKey)
em, err := indexedDb.NewWasmEventModel(key)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment