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

Fix comments

parent 3a8a86b9
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
...@@ -20,6 +20,7 @@ update_release: ...@@ -20,6 +20,7 @@ update_release:
update_master: update_master:
GOFLAGS="" go get -d gitlab.com/elixxir/client@master GOFLAGS="" go get -d gitlab.com/elixxir/client@master
GOFLAGS="" go get gitlab.com/elixxir/crypto@master GOFLAGS="" go get gitlab.com/elixxir/crypto@master
GOFLAGS="" go get gitlab.com/elixxir/primitives@master
GOFLAGS="" go get gitlab.com/xx_network/primitives@master GOFLAGS="" go get gitlab.com/xx_network/primitives@master
binary: binary:
......
...@@ -68,10 +68,11 @@ func (ac *AuthenticatedConnection) GetId(js.Value, []js.Value) interface{} { ...@@ -68,10 +68,11 @@ func (ac *AuthenticatedConnection) GetId(js.Value, []js.Value) interface{} {
// [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array).
// - Rejected with an error if sending fails. // - Rejected with an error if sending fails.
func (ac *AuthenticatedConnection) SendE2E(_ js.Value, args []js.Value) interface{} { func (ac *AuthenticatedConnection) SendE2E(_ js.Value, args []js.Value) interface{} {
payload := utils.CopyBytesToGo(args[2]) mt := args[0].Int()
payload := utils.CopyBytesToGo(args[1])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
sendReport, err := ac.api.SendE2E(args[0].Int(), payload) sendReport, err := ac.api.SendE2E(mt, payload)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
...@@ -135,12 +136,13 @@ func (ac *AuthenticatedConnection) RegisterListener( ...@@ -135,12 +136,13 @@ func (ac *AuthenticatedConnection) RegisterListener(
// - Resolves to a Javascript representation of the [Connection] object. // - Resolves to a Javascript representation of the [Connection] object.
// - Rejected with an error if loading the parameters or connecting fails. // - Rejected with an error if loading the parameters or connecting fails.
func (c *Cmix) ConnectWithAuthentication(_ js.Value, args []js.Value) interface{} { func (c *Cmix) ConnectWithAuthentication(_ js.Value, args []js.Value) interface{} {
e2eID := args[0].Int()
recipientContact := utils.CopyBytesToGo(args[1]) recipientContact := utils.CopyBytesToGo(args[1])
e2eParamsJSON := utils.CopyBytesToGo(args[2]) e2eParamsJSON := utils.CopyBytesToGo(args[2])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
ac, err := c.api.ConnectWithAuthentication( ac, err := c.api.ConnectWithAuthentication(
args[0].Int(), recipientContact, e2eParamsJSON) e2eID, recipientContact, e2eParamsJSON)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
package wasm package wasm
import ( import (
"gitlab.com/elixxir/client/channels"
"syscall/js" "syscall/js"
"gitlab.com/elixxir/client/bindings" "gitlab.com/elixxir/client/bindings"
...@@ -135,7 +134,9 @@ type eventModelBuilder struct { ...@@ -135,7 +134,9 @@ type eventModelBuilder struct {
build func(args ...interface{}) js.Value build func(args ...interface{}) js.Value
} }
// Build initializes and returns the event model. // Build initializes and returns the event model. It wraps a Javascript object
// that has all the methods in [bindings.EventModel] to make it adhere to the Go
// interface [bindings.EventModel].
func (emb *eventModelBuilder) Build(path string) bindings.EventModel { func (emb *eventModelBuilder) Build(path string) bindings.EventModel {
emJs := emb.build(path) emJs := emb.build(path)
return &eventModel{ return &eventModel{
...@@ -233,21 +234,12 @@ func LoadChannelsManager(_ js.Value, args []js.Value) interface{} { ...@@ -233,21 +234,12 @@ func LoadChannelsManager(_ js.Value, args []js.Value) interface{} {
// - Resolves to a Javascript representation of the [ChannelsManager] object. // - Resolves to a Javascript representation of the [ChannelsManager] object.
// - Rejected with an error if loading indexedDb or the manager fails. // - Rejected with an error if loading indexedDb or the manager fails.
func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} { func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
cmixID := args[0].Int()
privateIdentity := utils.CopyBytesToGo(args[1]) privateIdentity := utils.CopyBytesToGo(args[1])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
emBuilder := func(path string) channels.EventModel {
em, err := indexedDb.NewWasmEventModel(path)
if err != nil {
reject(utils.JsTrace(err))
return nil
}
return em
}
cm, err := bindings.NewChannelsManagerGoEventModel( cm, err := bindings.NewChannelsManagerGoEventModel(
args[0].Int(), privateIdentity, emBuilder) cmixID, privateIdentity, indexedDb.NewWasmEventModel)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
...@@ -276,19 +268,12 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} { ...@@ -276,19 +268,12 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
// - Resolves to a Javascript representation of the [ChannelsManager] object. // - Resolves to a Javascript representation of the [ChannelsManager] object.
// - Rejected with an error if loading indexedDb or the manager fails. // - Rejected with an error if loading indexedDb or the manager fails.
func LoadChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} { func LoadChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) interface{} {
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { cmixID := args[0].Int()
emBuilder := func(path string) channels.EventModel { storageTag := args[1].String()
em, err := indexedDb.NewWasmEventModel(path)
if err != nil {
reject(utils.JsTrace(err))
return nil
}
return em
}
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
cm, err := bindings.LoadChannelsManagerGoEventModel( cm, err := bindings.LoadChannelsManagerGoEventModel(
args[0].Int(), args[1].String(), emBuilder) cmixID, storageTag, indexedDb.NewWasmEventModel)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
...@@ -569,15 +554,15 @@ func (ch *ChannelsManager) SendMessage(_ js.Value, args []js.Value) interface{} ...@@ -569,15 +554,15 @@ func (ch *ChannelsManager) SendMessage(_ js.Value, args []js.Value) interface{}
return utils.CreatePromise(promiseFn) return utils.CreatePromise(promiseFn)
} }
// SendReply is used to send a formatted message over a channel. // SendReply is used to send a formatted message over a channel. Due to the
// Due to the underlying encoding using compression, it isn't possible to define // underlying encoding using compression, it isn't possible to define the
// the largest payload that can be sent, but it will always be possible to send // largest payload that can be sent, but it will always be possible to send a
// a payload of 766 bytes at minimum. // payload of 766 bytes at minimum.
// //
// If the message ID the reply is sent to does not exist, then the other side // If the message ID the reply is sent to is nonexistent, the other side will
// will post the message as a normal message and not a reply. // post the message as a normal message and not a reply. The message will auto
// The message will auto delete validUntil after the round it is sent in, // delete validUntil after the round it is sent in, lasting forever if
// lasting forever if ValidForever is used. // [channels.ValidForever] is used.
// //
// Parameters: // Parameters:
// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). // - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array).
......
...@@ -61,11 +61,12 @@ func (c *Connection) GetId(js.Value, []js.Value) interface{} { ...@@ -61,11 +61,12 @@ func (c *Connection) GetId(js.Value, []js.Value) interface{} {
// - Resolves to a Javascript representation of the [Connection] object. // - Resolves to a Javascript representation of the [Connection] object.
// - Rejected with an error if loading the parameters or connecting fails. // - Rejected with an error if loading the parameters or connecting fails.
func (c *Cmix) Connect(_ js.Value, args []js.Value) interface{} { func (c *Cmix) Connect(_ js.Value, args []js.Value) interface{} {
e2eID := args[0].Int()
recipientContact := utils.CopyBytesToGo(args[1]) recipientContact := utils.CopyBytesToGo(args[1])
e2eParamsJSON := utils.CopyBytesToGo(args[2]) e2eParamsJSON := utils.CopyBytesToGo(args[2])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
api, err := c.api.Connect(args[0].Int(), recipientContact, e2eParamsJSON) api, err := c.api.Connect(e2eID, recipientContact, e2eParamsJSON)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
...@@ -92,10 +93,11 @@ func (c *Cmix) Connect(_ js.Value, args []js.Value) interface{} { ...@@ -92,10 +93,11 @@ func (c *Cmix) Connect(_ js.Value, args []js.Value) interface{} {
// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array).
// - Rejected with an error if sending fails. // - Rejected with an error if sending fails.
func (c *Connection) SendE2E(_ js.Value, args []js.Value) interface{} { func (c *Connection) SendE2E(_ js.Value, args []js.Value) interface{} {
e2eID := args[0].Int()
payload := utils.CopyBytesToGo(args[1]) payload := utils.CopyBytesToGo(args[1])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
sendReport, err := c.api.SendE2E(args[0].Int(), payload) sendReport, err := c.api.SendE2E(e2eID, payload)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
......
...@@ -170,13 +170,13 @@ func (e *E2e) RemoveService(_ js.Value, args []js.Value) interface{} { ...@@ -170,13 +170,13 @@ func (e *E2e) RemoveService(_ js.Value, args []js.Value) interface{} {
// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array).
// - Rejected with an error if sending fails. // - Rejected with an error if sending fails.
func (e *E2e) SendE2E(_ js.Value, args []js.Value) interface{} { func (e *E2e) SendE2E(_ js.Value, args []js.Value) interface{} {
mt := args[0].Int()
recipientId := utils.CopyBytesToGo(args[1]) recipientId := utils.CopyBytesToGo(args[1])
payload := utils.CopyBytesToGo(args[2]) payload := utils.CopyBytesToGo(args[2])
e2eParams := utils.CopyBytesToGo(args[3]) e2eParams := utils.CopyBytesToGo(args[3])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
sendReport, err := e.api.SendE2E( sendReport, err := e.api.SendE2E(mt, recipientId, payload, e2eParams)
args[0].Int(), recipientId, payload, e2eParams)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
......
...@@ -91,8 +91,9 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} { ...@@ -91,8 +91,9 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} {
// - A promise that resolves if the network is healthy and rejects if the // - A promise that resolves if the network is healthy and rejects if the
// network is not healthy. // network is not healthy.
func (c *Cmix) WaitForNetwork(_ js.Value, args []js.Value) interface{} { func (c *Cmix) WaitForNetwork(_ js.Value, args []js.Value) interface{} {
timeoutMS := args[0].Int()
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
if c.api.WaitForNetwork(args[0].Int()) { if c.api.WaitForNetwork(timeoutMS) {
resolve() resolve()
} else { } else {
reject() reject()
......
...@@ -113,8 +113,9 @@ func (g *GroupChat) MakeGroup(_ js.Value, args []js.Value) interface{} { ...@@ -113,8 +113,9 @@ func (g *GroupChat) MakeGroup(_ js.Value, args []js.Value) interface{} {
// into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array). // into [Cmix.WaitForRoundResult] to see if the send succeeded (Uint8Array).
// - Rejected with an error if resending the request fails. // - Rejected with an error if resending the request fails.
func (g *GroupChat) ResendRequest(_ js.Value, args []js.Value) interface{} { func (g *GroupChat) ResendRequest(_ js.Value, args []js.Value) interface{} {
groupId := utils.CopyBytesToGo(args[0])
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
sendReport, err := g.api.ResendRequest(utils.CopyBytesToGo(args[0])) sendReport, err := g.api.ResendRequest(groupId)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
...@@ -181,9 +182,10 @@ func (g *GroupChat) LeaveGroup(_ js.Value, args []js.Value) interface{} { ...@@ -181,9 +182,10 @@ func (g *GroupChat) LeaveGroup(_ js.Value, args []js.Value) interface{} {
func (g *GroupChat) Send(_ js.Value, args []js.Value) interface{} { func (g *GroupChat) Send(_ js.Value, args []js.Value) interface{} {
groupId := utils.CopyBytesToGo(args[0]) groupId := utils.CopyBytesToGo(args[0])
message := utils.CopyBytesToGo(args[1]) message := utils.CopyBytesToGo(args[1])
tag := args[2].String()
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
sendReport, err := g.api.Send(groupId, message, args[2].String()) sendReport, err := g.api.Send(groupId, message, tag)
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
......
...@@ -28,9 +28,11 @@ import ( ...@@ -28,9 +28,11 @@ import (
// - Resolves to the JSON of the NDF ([ndf.NetworkDefinition]) (Uint8Array). // - Resolves to the JSON of the NDF ([ndf.NetworkDefinition]) (Uint8Array).
// - Rejected with an error if downloading fails. // - Rejected with an error if downloading fails.
func DownloadAndVerifySignedNdfWithUrl(_ js.Value, args []js.Value) interface{} { func DownloadAndVerifySignedNdfWithUrl(_ js.Value, args []js.Value) interface{} {
url := args[0].String()
cert := args[1].String()
promiseFn := func(resolve, reject func(args ...interface{}) js.Value) { promiseFn := func(resolve, reject func(args ...interface{}) js.Value) {
ndf, err := bindings.DownloadAndVerifySignedNdfWithUrl( ndf, err := bindings.DownloadAndVerifySignedNdfWithUrl(url, cert)
args[0].String(), args[1].String())
if err != nil { if err != nil {
reject(utils.JsTrace(err)) reject(utils.JsTrace(err))
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment