Skip to content

Commit

Permalink
Merge pull request #124 from sam-at-luther/sam-at-luther/fix_123_add_…
Browse files Browse the repository at this point in the history
…memo

Fix #123: Add SetTokenMemo
  • Loading branch information
janaakhterov authored Mar 5, 2021
2 parents fc2531f + 44f3cc9 commit 131e497
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions token_create_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func (transaction *TokenCreateTransaction) SetTokenSymbol(symbol string) *TokenC
return transaction
}

// The publicly visible token memo. It is max 100 bytes.
func (transaction *TokenCreateTransaction) SetTokenMemo(memo string) *TokenCreateTransaction {
transaction.requireNotFrozen()
transaction.pb.Memo = memo
return transaction
}

func (transaction *TokenCreateTransaction) GetTokenSymbol() string {
return transaction.pb.GetSymbol()
}
Expand Down
1 change: 1 addition & 0 deletions token_create_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestTokenCreateTransaction_Execute(t *testing.T) {
resp, err := NewTokenCreateTransaction().
SetTokenName("ffff").
SetTokenSymbol("F").
SetTokenMemo("fnord").
SetDecimals(3).
SetInitialSupply(1000000).
SetTreasuryAccountID(client.GetOperatorAccountID()).
Expand Down
3 changes: 3 additions & 0 deletions token_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type TokenInfo struct {
AutoRenewPeriod *time.Duration
AutoRenewAccountID AccountID
ExpirationTime *time.Time
Memo string
}

func freezeStatusFromProtobuf(pb proto.TokenFreezeStatus) *bool {
Expand Down Expand Up @@ -158,6 +159,7 @@ func tokenInfoFromProtobuf(pb *proto.TokenInfo) TokenInfo {
AutoRenewPeriod: &autoRenewPeriod,
AutoRenewAccountID: accountID,
ExpirationTime: &expirationTime,
Memo: pb.Memo,
}
}

Expand Down Expand Up @@ -215,6 +217,7 @@ func (tokenInfo *TokenInfo) toProtobuf() *proto.TokenInfo {
AutoRenewPeriod: autoRenewPeriod,
AutoRenewAccount: tokenInfo.AutoRenewAccountID.toProtobuf(),
Expiry: expirationTime,
Memo: tokenInfo.Symbol,
}
}

Expand Down

0 comments on commit 131e497

Please sign in to comment.