diff --git a/sdk/token_delete_transaction_unit_test.go b/sdk/token_delete_transaction_unit_test.go index 32777d95..46f356f2 100644 --- a/sdk/token_delete_transaction_unit_test.go +++ b/sdk/token_delete_transaction_unit_test.go @@ -229,3 +229,15 @@ func TestUnitTokenDeleteTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenDeleteTransactionFromToBytes(t *testing.T) { + tx := NewTokenDeleteTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenDeleteTransaction).buildProtoBody()) +} diff --git a/sdk/token_dissociate_transaction_unit_test.go b/sdk/token_dissociate_transaction_unit_test.go index e595b8b0..bf52c045 100644 --- a/sdk/token_dissociate_transaction_unit_test.go +++ b/sdk/token_dissociate_transaction_unit_test.go @@ -298,3 +298,15 @@ func TestUnitTokenDissociateTransactionMock(t *testing.T) { Execute(client) require.NoError(t, err) } + +func TestUnitTokenDissociateTransactionFromToBytes(t *testing.T) { + tx := NewTokenDissociateTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenDissociateTransaction).buildProtoBody()) +} diff --git a/sdk/token_fee_schedule_update_transaction_unit_test.go b/sdk/token_fee_schedule_update_transaction_unit_test.go index 358e9137..40a5c471 100644 --- a/sdk/token_fee_schedule_update_transaction_unit_test.go +++ b/sdk/token_fee_schedule_update_transaction_unit_test.go @@ -273,3 +273,15 @@ func TestUnitTokenFeeScheduleUpdateTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenFeeScheduleUpdateTransactionFromToBytes(t *testing.T) { + tx := NewTokenFeeScheduleUpdateTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenFeeScheduleUpdateTransaction).buildProtoBody()) +} diff --git a/sdk/token_freeze_transaction_unit_test.go b/sdk/token_freeze_transaction_unit_test.go index 4211c9dc..4ba36f9a 100644 --- a/sdk/token_freeze_transaction_unit_test.go +++ b/sdk/token_freeze_transaction_unit_test.go @@ -271,3 +271,15 @@ func TestUnitTokenFreezeTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenFreezeTransactionFromToBytes(t *testing.T) { + tx := NewTokenFreezeTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenFreezeTransaction).buildProtoBody()) +} diff --git a/sdk/token_grant_kyc_transaction_unit_test.go b/sdk/token_grant_kyc_transaction_unit_test.go index a52bb457..83ae08d5 100644 --- a/sdk/token_grant_kyc_transaction_unit_test.go +++ b/sdk/token_grant_kyc_transaction_unit_test.go @@ -271,3 +271,15 @@ func TestUnitTokenGrantKycTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenGrantKycTransactionFromToBytes(t *testing.T) { + tx := NewTokenGrantKycTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenGrantKycTransaction).buildProtoBody()) +} diff --git a/sdk/token_mint_transaction_unit_test.go b/sdk/token_mint_transaction_unit_test.go index c00bf901..5567a3a1 100644 --- a/sdk/token_mint_transaction_unit_test.go +++ b/sdk/token_mint_transaction_unit_test.go @@ -272,3 +272,15 @@ func TestUnitTokenMintTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenMintTransactionFromToBytes(t *testing.T) { + tx := NewTokenMintTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenMintTransaction).buildProtoBody()) +} diff --git a/sdk/token_pause_transaction_unit_test.go b/sdk/token_pause_transaction_unit_test.go index f72e9430..1a15eb97 100644 --- a/sdk/token_pause_transaction_unit_test.go +++ b/sdk/token_pause_transaction_unit_test.go @@ -478,3 +478,15 @@ func TestUnitTokenPauseTransaction_SetLogLevel(t *testing.T) { level := transaction.GetLogLevel() require.Equal(t, LoggerLevelDebug, *level) } + +func TestUnitTokenPauseTransactionFromToBytes(t *testing.T) { + tx := NewTokenPauseTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenPauseTransaction).buildProtoBody()) +} diff --git a/sdk/token_reject_transaction_unit_test.go b/sdk/token_reject_transaction_unit_test.go index 59d428dd..88f2229d 100644 --- a/sdk/token_reject_transaction_unit_test.go +++ b/sdk/token_reject_transaction_unit_test.go @@ -298,3 +298,15 @@ func TestUnitTokenRejectTransactionCoverage(t *testing.T) { b.AddSignature(newKey.PublicKey(), sig) } } + +func TestUnitTokenRejectTransactionFromToBytes(t *testing.T) { + tx := NewTokenRejectTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenRejectTransaction).buildProtoBody()) +} diff --git a/sdk/token_revoke_kys_transaction_unit_test.go b/sdk/token_revoke_kys_transaction_unit_test.go index 4ab577b8..503ee61a 100644 --- a/sdk/token_revoke_kys_transaction_unit_test.go +++ b/sdk/token_revoke_kys_transaction_unit_test.go @@ -271,3 +271,15 @@ func TestUnitTokenRevokeKycTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenRevokeKycTransactionFromToBytes(t *testing.T) { + tx := NewTokenRevokeKycTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenRevokeKycTransaction).buildProtoBody()) +} diff --git a/sdk/token_transfer_transaction_unit_test.go b/sdk/token_transfer_transaction_unit_test.go index 9c8ceab8..0df474c1 100644 --- a/sdk/token_transfer_transaction_unit_test.go +++ b/sdk/token_transfer_transaction_unit_test.go @@ -280,3 +280,15 @@ func TestUnitTokenTransferEncodeDecode(t *testing.T) { require.NoError(t, err) require.Equal(t, transfer, decoded) } + +func TestUnitTokenTransferTransactionFromToBytes(t *testing.T) { + tx := NewTransferTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TransferTransaction).buildProtoBody()) +} diff --git a/sdk/token_unfreeze_transaction_unit_test.go b/sdk/token_unfreeze_transaction_unit_test.go index c9525bb3..1f3a62d1 100644 --- a/sdk/token_unfreeze_transaction_unit_test.go +++ b/sdk/token_unfreeze_transaction_unit_test.go @@ -243,3 +243,15 @@ func TestUnitTokenUnfreezeTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenUnfreezeTransactionFromToBytes(t *testing.T) { + tx := NewTokenUnfreezeTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenUnfreezeTransaction).buildProtoBody()) +} diff --git a/sdk/token_update_nfts_transaction_unit_test.go b/sdk/token_update_nfts_transaction_unit_test.go index 2993fd25..6bae3fbb 100644 --- a/sdk/token_update_nfts_transaction_unit_test.go +++ b/sdk/token_update_nfts_transaction_unit_test.go @@ -221,3 +221,15 @@ func TestUnitTokenUpdateNftsTransactionSignWithOperator(t *testing.T) { _, err = tokenUpdate.SignWithOperator(client) require.NoError(t, err) } + +func TestUnitTokenUpdateNftsTransactionFromToBytes(t *testing.T) { + tx := NewTokenUpdateNftsTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenUpdateNfts).buildProtoBody()) +} diff --git a/sdk/token_update_transaction.go b/sdk/token_update_transaction.go index 78ff9e63..cd1dcc94 100644 --- a/sdk/token_update_transaction.go +++ b/sdk/token_update_transaction.go @@ -84,18 +84,51 @@ func NewTokenUpdateTransaction() *TokenUpdateTransaction { } func _TokenUpdateTransactionFromProtobuf(tx Transaction[*TokenUpdateTransaction], pb *services.TransactionBody) TokenUpdateTransaction { - adminKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetAdminKey()) - kycKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetKycKey()) - freezeKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetFreezeKey()) - wipeKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetWipeKey()) - scheduleKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetFeeScheduleKey()) - supplyKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetSupplyKey()) - pauseKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetPauseKey()) - metadataKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetMetadataKey()) + var adminKey Key + if pb.GetTokenUpdate().GetAdminKey() != nil { + adminKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetAdminKey()) + } + var kycKey Key + if pb.GetTokenUpdate().GetKycKey() != nil { + kycKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetKycKey()) + } + var freezeKey Key + if pb.GetTokenUpdate().GetFreezeKey() != nil { + freezeKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetFreezeKey()) + } + var wipeKey Key + if pb.GetTokenUpdate().GetWipeKey() != nil { + wipeKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetWipeKey()) + } + var scheduleKey Key + if pb.GetTokenUpdate().GetFeeScheduleKey() != nil { + scheduleKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetFeeScheduleKey()) + } + var supplyKey Key + if pb.GetTokenUpdate().GetSupplyKey() != nil { + supplyKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetSupplyKey()) + } + var pauseKey Key + if pb.GetTokenUpdate().GetPauseKey() != nil { + pauseKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetPauseKey()) + } + var metadataKey Key + if pb.GetTokenUpdate().GetMetadataKey() != nil { + metadataKey, _ = _KeyFromProtobuf(pb.GetTokenUpdate().GetMetadataKey()) + } + keyVerificationMode := pb.GetTokenUpdate().GetKeyVerificationMode() - expirationTime := _TimeFromProtobuf(pb.GetTokenUpdate().GetExpiry()) - autoRenew := _DurationFromProtobuf(pb.GetTokenUpdate().GetAutoRenewPeriod()) + var expirationTime *time.Time + if pb.GetTokenUpdate().GetExpiry() != nil { + expirationTimeVal := _TimeFromProtobuf(pb.GetTokenUpdate().GetExpiry()) + expirationTime = &expirationTimeVal + } + var autoRenew *time.Duration + if pb.GetTokenUpdate().GetAutoRenewPeriod() != nil { + autoRenewVal := _DurationFromProtobuf(pb.GetTokenUpdate().GetAutoRenewPeriod()) + autoRenew = &autoRenewVal + } var memo *string if m := pb.GetTokenUpdate().GetMemo(); m != nil { @@ -124,8 +157,8 @@ func _TokenUpdateTransactionFromProtobuf(tx Transaction[*TokenUpdateTransaction] pauseKey: pauseKey, metadataKey: metadataKey, tokenKeyVerificationMode: TokenKeyValidation(keyVerificationMode), - expirationTime: &expirationTime, - autoRenewPeriod: &autoRenew, + expirationTime: expirationTime, + autoRenewPeriod: autoRenew, } tx.childTransaction = &tokenUpdateTransaction diff --git a/sdk/token_update_transaction_unit_test.go b/sdk/token_update_transaction_unit_test.go index 1fbfdb65..b39d3979 100644 --- a/sdk/token_update_transaction_unit_test.go +++ b/sdk/token_update_transaction_unit_test.go @@ -307,3 +307,15 @@ func TestUnitTokenUpdateTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenUpdateTransactionFromToBytes(t *testing.T) { + tx := NewTokenUpdateTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenUpdateTransaction).buildProtoBody()) +} diff --git a/sdk/token_wipe_transaction_unit_test.go b/sdk/token_wipe_transaction_unit_test.go index 599743e9..4a9d86b2 100644 --- a/sdk/token_wipe_transaction_unit_test.go +++ b/sdk/token_wipe_transaction_unit_test.go @@ -285,3 +285,15 @@ func TestUnitTokenWipeTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTokenWipeTransactionFromToBytes(t *testing.T) { + tx := NewTokenWipeTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TokenWipeTransaction).buildProtoBody()) +} diff --git a/sdk/topic_create_transaction.go b/sdk/topic_create_transaction.go index 25fdd193..3f643ca4 100644 --- a/sdk/topic_create_transaction.go +++ b/sdk/topic_create_transaction.go @@ -31,16 +31,25 @@ func NewTopicCreateTransaction() *TopicCreateTransaction { } func _TopicCreateTransactionFromProtobuf(tx Transaction[*TopicCreateTransaction], pb *services.TransactionBody) TopicCreateTransaction { - adminKey, _ := _KeyFromProtobuf(pb.GetConsensusCreateTopic().GetAdminKey()) - submitKey, _ := _KeyFromProtobuf(pb.GetConsensusCreateTopic().GetSubmitKey()) - - autoRenew := _DurationFromProtobuf(pb.GetConsensusCreateTopic().GetAutoRenewPeriod()) + var adminKey Key + if pb.GetConsensusCreateTopic().GetAdminKey() != nil { + adminKey, _ = _KeyFromProtobuf(pb.GetConsensusCreateTopic().GetAdminKey()) + } + var submitKey Key + if pb.GetConsensusCreateTopic().GetSubmitKey() != nil { + submitKey, _ = _KeyFromProtobuf(pb.GetConsensusCreateTopic().GetSubmitKey()) + } + var autoRenew *time.Duration + if pb.GetConsensusCreateTopic().GetAutoRenewPeriod() != nil { + autoRenewVal := _DurationFromProtobuf(pb.GetConsensusCreateTopic().GetAutoRenewPeriod()) + autoRenew = &autoRenewVal + } topicCreateTransaction := TopicCreateTransaction{ autoRenewAccountID: _AccountIDFromProtobuf(pb.GetConsensusCreateTopic().GetAutoRenewAccount()), adminKey: adminKey, submitKey: submitKey, memo: pb.GetConsensusCreateTopic().GetMemo(), - autoRenewPeriod: &autoRenew, + autoRenewPeriod: autoRenew, } tx.childTransaction = &topicCreateTransaction diff --git a/sdk/topic_create_transaction_unit_test.go b/sdk/topic_create_transaction_unit_test.go index e40fa655..342c79f7 100644 --- a/sdk/topic_create_transaction_unit_test.go +++ b/sdk/topic_create_transaction_unit_test.go @@ -319,3 +319,15 @@ func TestUnitTopicCreateTransactionSerialization(t *testing.T) { submitKey, _ := result.GetSubmitKey() require.Equal(t, newKey.PublicKey(), submitKey) } + +func TestUnitTopicCreateTransactionFromToBytes(t *testing.T) { + tx := NewTopicCreateTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TopicCreateTransaction).buildProtoBody()) +} diff --git a/sdk/topic_delete_transaction_unit_test.go b/sdk/topic_delete_transaction_unit_test.go index f1a49792..c2bbc6ae 100644 --- a/sdk/topic_delete_transaction_unit_test.go +++ b/sdk/topic_delete_transaction_unit_test.go @@ -229,3 +229,15 @@ func TestUnitTopicDeleteTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTopicDeleteTransactionFromToBytes(t *testing.T) { + tx := NewTopicDeleteTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TopicDeleteTransaction).buildProtoBody()) +} diff --git a/sdk/topic_message_submit_transaction.go b/sdk/topic_message_submit_transaction.go index fc7d0a79..e6150b43 100644 --- a/sdk/topic_message_submit_transaction.go +++ b/sdk/topic_message_submit_transaction.go @@ -37,9 +37,13 @@ func NewTopicMessageSubmitTransaction() *TopicMessageSubmitTransaction { } func _TopicMessageSubmitTransactionFromProtobuf(tx Transaction[*TopicMessageSubmitTransaction], pb *services.TransactionBody) TopicMessageSubmitTransaction { + var message = make([]byte, 0) + if pb.GetConsensusSubmitMessage().GetMessage() != nil { + message = pb.GetConsensusSubmitMessage().GetMessage() + } topicMessageSubmitTransaction := TopicMessageSubmitTransaction{ maxChunks: 20, - message: pb.GetConsensusSubmitMessage().GetMessage(), + message: message, topicID: _TopicIDFromProtobuf(pb.GetConsensusSubmitMessage().GetTopicID()), } diff --git a/sdk/topic_message_submit_transaction_unit_test.go b/sdk/topic_message_submit_transaction_unit_test.go index ce5096a2..37f36ca8 100644 --- a/sdk/topic_message_submit_transaction_unit_test.go +++ b/sdk/topic_message_submit_transaction_unit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/hiero-ledger/hiero-sdk-go/v2/proto/services" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" protobuf "google.golang.org/protobuf/proto" ) @@ -333,3 +334,15 @@ func TestUnitTopicMessageSubmitTransactionSetMessage(t *testing.T) { require.Equal(t, []byte{}, transaction.GetMessage()) } + +func TestUnitTopicMessageSubmitTransactionFromToBytes(t *testing.T) { + tx := NewTopicMessageSubmitTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TopicMessageSubmitTransaction).buildProtoBody()) +} diff --git a/sdk/topic_update_transaction.go b/sdk/topic_update_transaction.go index 28c71cca..fa308da2 100644 --- a/sdk/topic_update_transaction.go +++ b/sdk/topic_update_transaction.go @@ -36,19 +36,34 @@ func NewTopicUpdateTransaction() *TopicUpdateTransaction { } func _TopicUpdateTransactionFromProtobuf(tx Transaction[*TopicUpdateTransaction], pb *services.TransactionBody) TopicUpdateTransaction { - adminKey, _ := _KeyFromProtobuf(pb.GetConsensusUpdateTopic().GetAdminKey()) - submitKey, _ := _KeyFromProtobuf(pb.GetConsensusUpdateTopic().GetSubmitKey()) + var adminKey Key + if pb.GetConsensusUpdateTopic().GetAdminKey() != nil { + adminKey, _ = _KeyFromProtobuf(pb.GetConsensusUpdateTopic().GetAdminKey()) + } + var submitKey Key + if pb.GetConsensusUpdateTopic().GetSubmitKey() != nil { + submitKey, _ = _KeyFromProtobuf(pb.GetConsensusUpdateTopic().GetSubmitKey()) + } - expirationTime := _TimeFromProtobuf(pb.GetConsensusUpdateTopic().GetExpirationTime()) - autoRenew := _DurationFromProtobuf(pb.GetConsensusUpdateTopic().GetAutoRenewPeriod()) + var expirationTime *time.Time + if pb.GetConsensusUpdateTopic().GetExpirationTime() != nil { + experationTimeVal := _TimeFromProtobuf(pb.GetConsensusUpdateTopic().GetExpirationTime()) + expirationTime = &experationTimeVal + } + + var autoRenew *time.Duration + if pb.GetConsensusUpdateTopic().GetAutoRenewPeriod() != nil { + autoRenewVal := _DurationFromProtobuf(pb.GetConsensusUpdateTopic().GetAutoRenewPeriod()) + autoRenew = &autoRenewVal + } topicCreateTransaction := TopicUpdateTransaction{ topicID: _TopicIDFromProtobuf(pb.GetConsensusUpdateTopic().GetTopicID()), autoRenewAccountID: _AccountIDFromProtobuf(pb.GetConsensusUpdateTopic().GetAutoRenewAccount()), adminKey: adminKey, submitKey: submitKey, memo: pb.GetConsensusUpdateTopic().GetMemo().Value, - autoRenewPeriod: &autoRenew, - expirationTime: &expirationTime, + autoRenewPeriod: autoRenew, + expirationTime: expirationTime, } tx.childTransaction = &topicCreateTransaction diff --git a/sdk/topic_update_transaction_unit_test.go b/sdk/topic_update_transaction_unit_test.go index 9ddf446e..8aa16041 100644 --- a/sdk/topic_update_transaction_unit_test.go +++ b/sdk/topic_update_transaction_unit_test.go @@ -304,3 +304,15 @@ func TestUnitTopicUpdateTransactionMock(t *testing.T) { _, err = freez.Sign(newKey).Execute(client) require.NoError(t, err) } + +func TestUnitTopicUpdateTransactionFromToBytes(t *testing.T) { + tx := NewTopicUpdateTransaction() + + txBytes, err := tx.ToBytes() + require.NoError(t, err) + + txFromBytes, err := TransactionFromBytes(txBytes) + require.NoError(t, err) + + assert.Equal(t, tx.buildProtoBody(), txFromBytes.(TopicUpdateTransaction).buildProtoBody()) +}