/
schedule_delete_transaction.go
85 lines (68 loc) · 3.24 KB
/
schedule_delete_transaction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package hedera
import (
"github.com/hashgraph/hedera-sdk-go/proto"
"time"
)
type ScheduleDeleteTransaction struct {
TransactionBuilder
pb *proto.ScheduleDeleteTransactionBody
}
func NewScheduleDeleteTransaction() ScheduleDeleteTransaction {
pb := &proto.ScheduleDeleteTransactionBody{}
inner := newTransactionBuilder()
inner.pb.Data = &proto.TransactionBody_ScheduleDelete{ScheduleDelete: pb}
builder := ScheduleDeleteTransaction{inner, pb}
return builder
}
func scheduleDeleteTransactionFromProtobuf(transactionBuilder TransactionBuilder, pb *proto.TransactionBody) ScheduleDeleteTransaction {
return ScheduleDeleteTransaction{
TransactionBuilder: transactionBuilder,
pb: pb.GetScheduleDelete(),
}
}
func (builder ScheduleDeleteTransaction) SetScheduleID(scheduleID ScheduleID) ScheduleDeleteTransaction {
builder.pb.ScheduleID = scheduleID.toProto()
return builder
}
func (builder ScheduleDeleteTransaction) Schedule() (ScheduleCreateTransaction, error) {
scheduled, err := builder.constructScheduleProtobuf()
if err != nil {
return ScheduleCreateTransaction{}, err
}
return NewScheduleCreateTransaction().setSchedulableTransactionBody(scheduled), nil
}
func (builder ScheduleDeleteTransaction) constructScheduleProtobuf() (*proto.SchedulableTransactionBody, error) {
return &proto.SchedulableTransactionBody{
TransactionFee: builder.TransactionBuilder.pb.GetTransactionFee(),
Memo: builder.TransactionBuilder.pb.GetMemo(),
Data: &proto.SchedulableTransactionBody_ScheduleDelete{
ScheduleDelete: &proto.ScheduleDeleteTransactionBody{
ScheduleID: builder.pb.GetScheduleID(),
},
},
}, nil
}
//
// The following methods must be copy-pasted/overriden at the bottom of **every** _transaction.go file
// We override the embedded fluent setter methods to return the outer type
//
// SetMaxTransactionFee sets the max transaction fee for this Transaction.
func (builder ScheduleDeleteTransaction) SetMaxTransactionFee(maxTransactionFee Hbar) ScheduleDeleteTransaction {
return ScheduleDeleteTransaction{builder.TransactionBuilder.SetMaxTransactionFee(maxTransactionFee), builder.pb}
}
// SetTransactionMemo sets the memo for this Transaction.
func (builder ScheduleDeleteTransaction) SetTransactionMemo(memo string) ScheduleDeleteTransaction {
return ScheduleDeleteTransaction{builder.TransactionBuilder.SetTransactionMemo(memo), builder.pb}
}
// SetTransactionValidDuration sets the valid duration for this Transaction.
func (builder ScheduleDeleteTransaction) SetTransactionValidDuration(validDuration time.Duration) ScheduleDeleteTransaction {
return ScheduleDeleteTransaction{builder.TransactionBuilder.SetTransactionValidDuration(validDuration), builder.pb}
}
// SetTransactionID sets the TransactionID for this Transaction.
func (builder ScheduleDeleteTransaction) SetTransactionID(transactionID TransactionID) ScheduleDeleteTransaction {
return ScheduleDeleteTransaction{builder.TransactionBuilder.SetTransactionID(transactionID), builder.pb}
}
// SetNodeAccountID sets the node AccountID for this Transaction.
func (builder ScheduleDeleteTransaction) SetNodeAccountID(nodeAccountID AccountID) ScheduleDeleteTransaction {
return ScheduleDeleteTransaction{builder.TransactionBuilder.SetNodeAccountID(nodeAccountID), builder.pb}
}