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

Add GetContactFromReceptionIdentity to get the marshalled contact bytes from a reception identity

parent 1b919a06
No related branches found
No related tags found
1 merge request!60Revert "Fail a test to be sure it works"
......@@ -58,6 +58,8 @@ func main() {
js.FuncOf(wasm.StoreReceptionIdentity))
js.Global().Set("LoadReceptionIdentity",
js.FuncOf(wasm.LoadReceptionIdentity))
js.Global().Set("GetContactFromReceptionIdentity",
js.FuncOf(wasm.GetContactFromReceptionIdentity))
js.Global().Set("GetIDFromContact",
js.FuncOf(wasm.GetIDFromContact))
js.Global().Set("GetPubkeyFromContact",
......
......@@ -11,6 +11,7 @@ package wasm
import (
"gitlab.com/elixxir/client/bindings"
"gitlab.com/elixxir/client/xxdk"
"syscall/js"
)
......@@ -109,6 +110,27 @@ func (c *Cmix) GetReceptionRegistrationValidationSignature(
// Contact Functions //
////////////////////////////////////////////////////////////////////////////////
// GetContactFromReceptionIdentity returns the [contact.Contact] object from the
// [xxdk.ReceptionIdentity].
//
// Parameters:
// - args[0] - JSON of [xxdk.ReceptionIdentity] (Uint8Array)
//
// Returns:
// - Marshalled bytes of [contact.Contact] (string)
// - Throws a TypeError if unmarshalling the identity fails
func GetContactFromReceptionIdentity(_ js.Value, args []js.Value) interface{} {
// Note that this function does not appear in normal bindings
identityJSON := CopyBytesToGo(args[0])
identity, err := xxdk.UnmarshalReceptionIdentity(identityJSON)
if err != nil {
Throw(TypeError, err)
return nil
}
return CopyBytesToJS(identity.GetContact().Marshal())
}
// GetIDFromContact returns the ID in the [contact.Contact] object.
//
// Parameters:
......
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