Skip to content

Commit

Permalink
add documentation for consensus topic create transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestofIranon committed Feb 20, 2020
1 parent bc7466c commit 1ee57cb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions consensus_topic_create_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type ConsensusTopicCreateTransaction struct {
pb *proto.ConsensusCreateTopicTransactionBody
}

// NewConsensusTopicCreateTransaction creates a ConsensusTopicCreateTransaction builder which can be
// used to construct and execute a Consensus Create Topic Transaction.
func NewConsensusTopicCreateTransaction() ConsensusTopicCreateTransaction {
pb := &proto.ConsensusCreateTopicTransactionBody{}

Expand All @@ -22,35 +24,44 @@ func NewConsensusTopicCreateTransaction() ConsensusTopicCreateTransaction {
return builder.SetAutoRenewPeriod(7890000 * time.Second)
}

// SetAdminKey sets the key required to update or delete the topic. If unspecified, anyone can increase the topic's
// expirationTime.
func (builder ConsensusTopicCreateTransaction) SetAdminKey(publicKey Ed25519PublicKey) ConsensusTopicCreateTransaction {
builder.pb.AdminKey = publicKey.toProto()
return builder
}

// SetSubmitKey sets the key required for submitting messages to the topic. If unspecified, all submissions are allowed.
func (builder ConsensusTopicCreateTransaction) SetSubmitKey(publicKey Ed25519PublicKey) ConsensusTopicCreateTransaction {
builder.pb.SubmitKey = publicKey.toProto()
return builder
}

// SetTopicMemo sets a short publicly visible memo about the topic. No guarantee of uniqueness.
func (builder ConsensusTopicCreateTransaction) SetTopicMemo(memo string) ConsensusTopicCreateTransaction {
builder.pb.Memo = memo
return builder
}

// SetAutoRenewPeriod sets the initial lifetime of the topic and the amount of time to extend the topic's lifetime
// automatically at expirationTime if the autoRenewAccount is configured and has sufficient funds.
//
// Required. Limited to a maximum of 90 days (server-side configuration which may change).
func (builder ConsensusTopicCreateTransaction) SetAutoRenewPeriod(period time.Duration) ConsensusTopicCreateTransaction {
builder.pb.AutoRenewPeriod = durationToProto(period)
return builder
}

// SetAutoRenewAccountID sets an optional account to be used at the topic's expirationTime to extend the life of the
// topic. The topic lifetime will be extended up to a maximum of the autoRenewPeriod or however long the topic can be
// extended using all funds on the account (whichever is the smaller duration/amount).
//
//If specified, there must be an adminKey and the autoRenewAccount must sign this transaction.
func (builder ConsensusTopicCreateTransaction) SetAutoRenewAccountID(id AccountID) ConsensusTopicCreateTransaction {
builder.pb.AutoRenewAccount = id.toProto()
return builder
}

func (builder ConsensusTopicCreateTransaction) Build(client *Client) (Transaction, error) {
return builder.TransactionBuilder.Build(client)
}

//
// The following _5_ must be copy-pasted at the bottom of **every** _transaction.go file
// We override the embedded fluent setter methods to return the outer type
Expand Down

0 comments on commit 1ee57cb

Please sign in to comment.