Skip to content
Snippets Groups Projects

XX-4679 / Fix extension loading for channels

Merged Jono Wenger requested to merge XX-4679/extensionBuildersBindings into release
3 files
+ 27
351
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 17
9
@@ -256,13 +256,13 @@ func GetPublicChannelIdentityFromPrivate(_ js.Value, args []js.Value) any {
// using [Cmix.GetID].
// - args[1] - Bytes of a private identity ([channel.PrivateIdentity]) that is
// generated by [GenerateChannelIdentity] (Uint8Array).
// - args[2] - JSON of an array of integers of [channels.ExtensionBuilder]
// - args[2] - A function that initialises and returns a Javascript object
// that matches the [bindings.EventModel] interface. The function must match
// the Build function in [bindings.EventModelBuilder].
// - args[3] - JSON of an array of integers of [channels.ExtensionBuilder]
// IDs. The ID can be retrieved from an object with an extension builder
// (e.g., [ChannelsFileTransfer.GetExtensionBuilderID]). Leave empty if not
// using extension builders. Example: `[2,11,5]` (Uint8Array).
// - args[3] - A function that initialises and returns a Javascript object
// that matches the [bindings.EventModel] interface. The function must match
// the Build function in [bindings.EventModelBuilder].
//
// Returns:
// - Javascript representation of the [ChannelsManager] object.
@@ -270,11 +270,11 @@ func GetPublicChannelIdentityFromPrivate(_ js.Value, args []js.Value) any {
func NewChannelsManager(_ js.Value, args []js.Value) any {
cmixId := args[0].Int()
privateIdentity := utils.CopyBytesToGo(args[1])
extensionBuilderIDsJSON := utils.CopyBytesToGo(args[2])
em := newEventModelBuilder(args[3])
em := newEventModelBuilder(args[2])
extensionBuilderIDsJSON := utils.CopyBytesToGo(args[3])
cm, err := bindings.NewChannelsManager(
cmixId, privateIdentity, extensionBuilderIDsJSON, em)
cmixId, privateIdentity, em, extensionBuilderIDsJSON)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
@@ -296,16 +296,24 @@ func NewChannelsManager(_ js.Value, args []js.Value) any {
// using [Cmix.GetID].
// - args[1] - The storage tag associated with the previously created channel
// manager and retrieved with [ChannelsManager.GetStorageTag] (string).
// - args[2] - A function that initialises and returns a Javascript object
// - args[2] - A function that initializes and returns a Javascript object
// that matches the [bindings.EventModel] interface. The function must match
// the Build function in [bindings.EventModelBuilder].
// - args[3] - JSON of an array of integers of [channels.ExtensionBuilder]
// IDs. The ID can be retrieved from an object with an extension builder
// (e.g., [ChannelsFileTransfer.GetExtensionBuilderID]). Leave empty if not
// using extension builders. Example: `[2,11,5]`.
//
// Returns:
// - Javascript representation of the [ChannelsManager] object.
// - Throws a TypeError if loading the manager fails.
func LoadChannelsManager(_ js.Value, args []js.Value) any {
cmixID := args[0].Int()
storageTag := args[1].String()
em := newEventModelBuilder(args[2])
cm, err := bindings.LoadChannelsManager(args[0].Int(), args[1].String(), em)
extensionBuilderIDsJSON := utils.CopyBytesToGo(args[3])
cm, err := bindings.LoadChannelsManager(
cmixID, storageTag, em, extensionBuilderIDsJSON)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
Loading