From e1e0602f3c96d98259d235068d275d4434fe0ac8 Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Thu, 1 Jun 2023 15:26:50 -0700
Subject: [PATCH] Modify function signature of SendInvite methods

---
 go.mod           |  2 +-
 go.sum           |  4 ++++
 wasm/channels.go | 28 +++++++++++++---------------
 wasm/dm.go       | 38 ++++++++++++++++----------------------
 4 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/go.mod b/go.mod
index 4c53c088..01de58aa 100644
--- a/go.mod
+++ b/go.mod
@@ -9,7 +9,7 @@ require (
 	github.com/spf13/cobra v1.7.0
 	github.com/spf13/jwalterweatherman v1.1.0
 	github.com/stretchr/testify v1.8.2
-	gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191127-0a0562f6a839
+	gitlab.com/elixxir/client/v4 v4.6.4-0.20230601222154-74fb1bf4adac
 	gitlab.com/elixxir/crypto v0.0.7-0.20230601185515-3813919cfa93
 	gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c
 	gitlab.com/elixxir/wasm-utils v0.0.0-20230522231408-a43b2c1481b2
diff --git a/go.sum b/go.sum
index 3df7760c..31242146 100644
--- a/go.sum
+++ b/go.sum
@@ -547,6 +547,10 @@ gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191127-0a0562f6a839 h1:PfeNQArnqe0
 gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191127-0a0562f6a839/go.mod h1:BSxUKi3xOPJfQgUBUc+uWDOXa18umYsDj3A1K3IwBEE=
 gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191407-1b0289b33708 h1:wNIKci4XuDfzAJM8+4awP5CgY0jlOEaVbHgp+BkEtz4=
 gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191407-1b0289b33708/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
+gitlab.com/elixxir/client/v4 v4.6.4-0.20230601221846-fb2ecba0317c h1:5lf0gPu0LVcM5U8KtWB5+iag5kwk2LREqTOReELWq5o=
+gitlab.com/elixxir/client/v4 v4.6.4-0.20230601221846-fb2ecba0317c/go.mod h1:BSxUKi3xOPJfQgUBUc+uWDOXa18umYsDj3A1K3IwBEE=
+gitlab.com/elixxir/client/v4 v4.6.4-0.20230601222154-74fb1bf4adac h1:/bySSyJrXxv49kO9flnxzCJBLgNx8i5DT4FUw3CDrPQ=
+gitlab.com/elixxir/client/v4 v4.6.4-0.20230601222154-74fb1bf4adac/go.mod h1:BSxUKi3xOPJfQgUBUc+uWDOXa18umYsDj3A1K3IwBEE=
 gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938 h1:f27+QUFiGWrprKm+fstOg3ABkYLpWcZi3+8Lf5eDnqY=
 gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938/go.mod h1:z+qW0D9VpY5QKTd7wRlb5SK4kBNqLYsa4DXBcUXue9Q=
 gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235 h1:0BySdXTzRWxzH8k5RiNNMmmn2lpuQWLVcDDA/7ehyqc=
diff --git a/wasm/channels.go b/wasm/channels.go
index c452d1ad..7cb49056 100644
--- a/wasm/channels.go
+++ b/wasm/channels.go
@@ -1241,19 +1241,18 @@ func (cm *ChannelsManager) SendSilent(_ js.Value, args []js.Value) any {
 //
 // Parameters:
 //   - args[0] - Marshalled bytes of the invited channel [id.ID] (Uint8Array).
-//   - args[1] - Marshalled bytes of the invitee channel [id.ID] (Uint8Array).
+//   - args[1] - JSON of the invitee channel [id.ID].
+//     This can be retrieved from [GetChannelJSON]. (Uint8Array).
 //   - args[2] - The contents of the message (string).
 //   - args[3] - The URL to append the channel info to (string).
-//   - args[4] - The maximum number of uses the link can be used (0 for
-//     unlimited) (int).
-//   - args[5] - The lease of the message. This will be how long the
+//   - args[4] - The lease of the message. This will be how long the
 //     message is available from the network, in milliseconds (int). As per the
 //     [channels.Manager] documentation, this has different meanings depending
 //     on the use case. These use cases may be generic enough that they will not
 //     be enumerated here. Use [ValidForever] to last the max message life.
-//   - args[6] - JSON of [xxdk.CMIXParams]. If left empty
+//   - args[5] - JSON of [xxdk.CMIXParams]. If left empty
 //     [bindings.GetDefaultCMixParams] will be used internally (Uint8Array).
-//   - args[7] - JSON of a slice of public keys of users that should receive
+//   - args[6] - JSON of a slice of public keys of users that should receive
 //     mobile notifications for the message.
 //
 // Example slice of public keys:
@@ -1269,19 +1268,18 @@ func (cm *ChannelsManager) SendSilent(_ js.Value, args []js.Value) any {
 //   - Rejected with an error if sending fails.
 func (cm *ChannelsManager) SendInvite(_ js.Value, args []js.Value) any {
 	var (
-		marshalledChanId     = utils.CopyBytesToGo(args[0])
-		marshalledInviteToId = utils.CopyBytesToGo(args[1])
-		msg                  = args[2].String()
-		host                 = args[3].String()
-		maxUses              = args[4].Int()
-		leaseTimeMS          = int64(args[5].Int())
-		cmixParamsJSON       = utils.CopyBytesToGo(args[6])
-		pingsJSON            = utils.CopyBytesToGo(args[7])
+		marshalledChanId = utils.CopyBytesToGo(args[0])
+		inviteToJSON     = utils.CopyBytesToGo(args[1])
+		msg              = args[2].String()
+		host             = args[3].String()
+		leaseTimeMS      = int64(args[4].Int())
+		cmixParamsJSON   = utils.CopyBytesToGo(args[5])
+		pingsJSON        = utils.CopyBytesToGo(args[6])
 	)
 
 	promiseFn := func(resolve, reject func(args ...any) js.Value) {
 		sendReport, err := cm.api.SendInvite(marshalledChanId,
-			marshalledInviteToId, msg, host, maxUses, leaseTimeMS,
+			inviteToJSON, msg, host, leaseTimeMS,
 			cmixParamsJSON, pingsJSON)
 		if err != nil {
 			reject(exception.NewTrace(err))
diff --git a/wasm/dm.go b/wasm/dm.go
index 40575745..5be52439 100644
--- a/wasm/dm.go
+++ b/wasm/dm.go
@@ -524,20 +524,16 @@ func (dmc *DMClient) SendSilent(_ js.Value, args []js.Value) any {
 // then an error will be returned.
 //
 // Parameters:
-//   - args[0] - The ID of [ChannelsManager] object in tracker. This can be
-//     retrieved using [ChannelsManager.GetID].
-//   - args[1] - The bytes of the public key of the partner's ED25519 signing
+//   - args[0] - The bytes of the public key of the partner's ED25519 signing
 //     key (Uint8Array).
-//   - args[2] - The token used to derive the reception ID for the partner (int).
-//   - args[3] - Marshalled bytes of the channel the user is inviting another
-//     user to.
-//   - args[4] - The contents of the message. The message should be at most 510
+//   - args[1] - The token used to derive the reception ID for the partner (int).
+//   - args[2] - JSON of the invitee channel [id.ID].
+//     This can be retrieved from [GetChannelJSON]. (Uint8Array).
+//   - args[3] - The contents of the message. The message should be at most 510
 //     bytes. This is expected to be Unicode, and thus a string data type is
 //     expected.
-//   - args[5] - The URL to append the channel info to.
-//   - args[6] - The maximum number of uses the link can be used (0 for
-//     unlimited).
-//   - args[7] - A JSON marshalled [xxdk.CMIXParams]. This may be empty,
+//   - args[4] - The URL to append the channel info to.
+//   - args[5] - A JSON marshalled [xxdk.CMIXParams]. This may be empty,
 //     and GetDefaultCMixParams will be used internally.
 //
 // Returns a promise:
@@ -545,20 +541,18 @@ func (dmc *DMClient) SendSilent(_ js.Value, args []js.Value) any {
 //   - Rejected with an error if sending fails.
 func (dmc *DMClient) SendInvite(_ js.Value, args []js.Value) any {
 	var (
-		channelManagerId     = args[0].Int()
-		partnerPubKeyBytes   = utils.CopyBytesToGo(args[1])
-		partnerToken         = int32(args[2].Int())
-		marshalledInviteToId = utils.CopyBytesToGo(args[3])
-		msg                  = args[4].String()
-		host                 = args[5].String()
-		maxUses              = args[6].Int()
-		cmixParamsJSON       = utils.CopyBytesToGo(args[7])
+		partnerPubKeyBytes = utils.CopyBytesToGo(args[0])
+		partnerToken       = int32(args[1].Int())
+		inviteToJSON       = utils.CopyBytesToGo(args[2])
+		msg                = args[3].String()
+		host               = args[4].String()
+		cmixParamsJSON     = utils.CopyBytesToGo(args[5])
 	)
 
 	promiseFn := func(resolve, reject func(args ...any) js.Value) {
-		sendReport, err := dmc.api.SendInvite(channelManagerId,
-			partnerPubKeyBytes, partnerToken, marshalledInviteToId, msg, host,
-			maxUses, cmixParamsJSON)
+		sendReport, err := dmc.api.SendInvite(
+			partnerPubKeyBytes, partnerToken, inviteToJSON, msg, host,
+			cmixParamsJSON)
 		if err != nil {
 			reject(exception.NewTrace(err))
 		} else {
-- 
GitLab