hashgraph / hedera-sdk-go

Hedera™ Hashgraph SDK for Go
https://docs.hedera.com/docs/hedera-sdks
Apache License 2.0
108 stars 65 forks source link

TopicMessageSubmitTransaction.SetMessage in the Go SDK is not functionally equivalent to TopicMessageSubmitTransaction.setMessage in the JS SDK #1066

Closed bguiz closed 1 month ago

bguiz commented 1 month ago

Description

In the Go SDK, and extra step is required. See the steps to reproduce below.

Steps to reproduce

In the JS SDK you can do this:

  const topicMsgSubmitTx = await new TopicMessageSubmitTransaction()
    .setTopicId(topicId)
    .setMessage('Hello HCS!')
    .freezeWith(client);

However, in the Go SDK, if you do this, you will get an error:

    topicMsgSubmitTx, _ := hedera.NewTopicMessageSubmitTransaction().
      SetTopicID(*topicId).
      SetMessage("Hello HCS!").
      FreezeWith(client);

Turns out that the Go SDK does not accept a string as the parameter, and a typecast to be done manually:

    topicMsgSubmitTx, _ := hedera.NewTopicMessageSubmitTransaction().
      SetTopicID(*topicId).
      SetMessage([]byte("Hello HCS!")).
      FreezeWith(client);

Additional context

nil

Hedera network

testnet

Version

github.com/hashgraph/hedera-sdk-go/v2 v2.37.0 // indirect

Operating system

macOS

0xivanov commented 1 month ago

Hey @bguiz , thanks for opening this issue. It seems like in Go we are missing the method that accepts string as a parameter. Will be added in the next release.