Skip to content

Commit

Permalink
fix: Adding missing ScheduleInfo.getTransaction()
Browse files Browse the repository at this point in the history
  • Loading branch information
andrix10 authored and mehcode committed Mar 4, 2021
1 parent b0b1860 commit af48772
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion schedule_create_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ func TestScheduleCreateTransaction_Execute(t *testing.T) {
receipt, err := txID.GetReceipt(client)
assert.NoError(t, err)

_, err = NewScheduleInfoQuery().
info, err := NewScheduleInfoQuery().
SetScheduleID(*receipt.ScheduleID).
SetQueryPayment(NewHbar(2)).
Execute(client)
assert.NoError(t, err)

infoTx, err := info.getTransaction()
assert.NoError(t, err)

assert.NotNil(t, infoTx)

tx2, err := NewScheduleDeleteTransaction().
SetScheduleID(*receipt.ScheduleID).
FreezeWith(client)
Expand Down
14 changes: 14 additions & 0 deletions schedule_info.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hedera

import (
protobuf "github.com/golang/protobuf/proto"
"github.com/hashgraph/hedera-sdk-go/v2/proto"
)

Expand Down Expand Up @@ -54,3 +55,16 @@ func (scheduleInfo *ScheduleInfo) toProtobuf() *proto.ScheduleInfo {
AdminKey: adminKey,
}
}

func (scheduleInfo *ScheduleInfo) getTransaction() (interface{}, error) {
signedBytes, err := protobuf.Marshal(&proto.SignedTransaction{
BodyBytes: scheduleInfo.TransactionBody,
})
list := proto.TransactionList{TransactionList: []*proto.Transaction{{SignedTransactionBytes: signedBytes}}}
listBytes, err := protobuf.Marshal(&list)
if err != nil {
return Transaction{}, err
}
tx, err := TransactionFromBytes(listBytes)
return tx, err
}

0 comments on commit af48772

Please sign in to comment.