github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/token_update_transaction.go (about) 1 package hedera 2 3 /*- 4 * 5 * Hedera Go SDK 6 * 7 * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 */ 22 23 import ( 24 "time" 25 26 "google.golang.org/protobuf/types/known/wrapperspb" 27 28 "github.com/hashgraph/hedera-protobufs-go/services" 29 ) 30 31 // TokenUpdateTransaction 32 // At consensus, updates an already created token to the given values. 33 // 34 // If no value is given for a field, that field is left unchanged. For an immutable tokens (that is, 35 // a token without an admin key), only the expiry may be updated. Setting any other field in that 36 // case will cause the transaction status to resolve to TOKEN_IS_IMMUTABLE. 37 // 38 // --- Signing Requirements --- 39 // 1. Whether or not a token has an admin key, its expiry can be extended with only the transaction 40 // payer's signature. 41 // 2. Updating any other field of a mutable token requires the admin key's signature. 42 // 3. If a new admin key is set, this new key must sign <b>unless</b> it is exactly an empty 43 // <tt>KeyList</tt>. This special sentinel key removes the existing admin key and causes the 44 // token to become immutable. (Other <tt>Key</tt> structures without a constituent 45 // <tt>Ed25519</tt> key will be rejected with <tt>INVALID_ADMIN_KEY</tt>.) 46 // 4. If a new treasury is set, the new treasury account's key must sign the transaction. 47 // 48 // --- Nft Requirements --- 49 // 1. If a non fungible token has a positive treasury balance, the operation will abort with 50 // CURRENT_TREASURY_STILL_OWNS_NFTS. 51 type TokenUpdateTransaction struct { 52 Transaction 53 tokenID *TokenID 54 treasuryAccountID *AccountID 55 autoRenewAccountID *AccountID 56 tokenName string 57 memo *string 58 metadata []byte 59 tokenSymbol string 60 adminKey Key 61 kycKey Key 62 freezeKey Key 63 wipeKey Key 64 scheduleKey Key 65 supplyKey Key 66 pauseKey Key 67 metadataKey Key 68 tokenKeyVerificationMode TokenKeyValidation 69 expirationTime *time.Time 70 autoRenewPeriod *time.Duration 71 } 72 73 // NewTokenUpdateTransaction creates TokenUpdateTransaction which at consensus, 74 // updates an already created token to the given values. 75 // 76 // If no value is given for a field, that field is left unchanged. For an immutable tokens (that is, 77 // a token without an admin key), only the expiry may be updated. Setting any other field in that 78 // case will cause the transaction status to resolve to TOKEN_IS_IMMUTABLE. 79 // 80 // --- Signing Requirements --- 81 // 1. Whether or not a token has an admin key, its expiry can be extended with only the transaction 82 // payer's signature. 83 // 2. Updating any other field of a mutable token requires the admin key's signature. 84 // 3. If a new admin key is set, this new key must sign <b>unless</b> it is exactly an empty 85 // <tt>KeyList</tt>. This special sentinel key removes the existing admin key and causes the 86 // token to become immutable. (Other <tt>Key</tt> structures without a constituent 87 // <tt>Ed25519</tt> key will be rejected with <tt>INVALID_ADMIN_KEY</tt>.) 88 // 4. If a new treasury is set, the new treasury account's key must sign the transaction. 89 // 90 // --- Nft Requirements --- 91 // 1. If a non fungible token has a positive treasury balance, the operation will abort with 92 // CURRENT_TREASURY_STILL_OWNS_NFTS. 93 func NewTokenUpdateTransaction() *TokenUpdateTransaction { 94 tx := TokenUpdateTransaction{ 95 Transaction: _NewTransaction(), 96 memo: nil, 97 } 98 99 tx._SetDefaultMaxTransactionFee(NewHbar(30)) 100 101 return &tx 102 } 103 104 func _TokenUpdateTransactionFromProtobuf(tx Transaction, pb *services.TransactionBody) *TokenUpdateTransaction { 105 adminKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetAdminKey()) 106 kycKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetKycKey()) 107 freezeKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetFreezeKey()) 108 wipeKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetWipeKey()) 109 scheduleKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetFeeScheduleKey()) 110 supplyKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetSupplyKey()) 111 pauseKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetPauseKey()) 112 metadataKey, _ := _KeyFromProtobuf(pb.GetTokenUpdate().GetMetadataKey()) 113 keyVerificationMode := pb.GetTokenUpdate().GetKeyVerificationMode() 114 115 expirationTime := _TimeFromProtobuf(pb.GetTokenUpdate().GetExpiry()) 116 autoRenew := _DurationFromProtobuf(pb.GetTokenUpdate().GetAutoRenewPeriod()) 117 118 var memo *string 119 if m := pb.GetTokenUpdate().GetMemo(); m != nil { 120 memo = &m.Value 121 } 122 123 var metadata []byte 124 if m := pb.GetTokenUpdate().GetMetadata(); m != nil { 125 metadata = m.Value 126 } 127 128 return &TokenUpdateTransaction{ 129 Transaction: tx, 130 tokenID: _TokenIDFromProtobuf(pb.GetTokenUpdate().GetToken()), 131 treasuryAccountID: _AccountIDFromProtobuf(pb.GetTokenUpdate().GetTreasury()), 132 autoRenewAccountID: _AccountIDFromProtobuf(pb.GetTokenUpdate().GetAutoRenewAccount()), 133 tokenName: pb.GetTokenUpdate().GetName(), 134 memo: memo, 135 metadata: metadata, 136 tokenSymbol: pb.GetTokenUpdate().GetSymbol(), 137 adminKey: adminKey, 138 kycKey: kycKey, 139 freezeKey: freezeKey, 140 wipeKey: wipeKey, 141 scheduleKey: scheduleKey, 142 supplyKey: supplyKey, 143 pauseKey: pauseKey, 144 metadataKey: metadataKey, 145 tokenKeyVerificationMode: TokenKeyValidation(keyVerificationMode), 146 expirationTime: &expirationTime, 147 autoRenewPeriod: &autoRenew, 148 } 149 } 150 151 type TokenKeyValidation int32 152 153 const ( 154 // FULL_VALIDATION performs all token key validations. 155 FULL_VALIDATION TokenKeyValidation = iota 156 // NO_VALIDATION performs no validations at all for all passed token keys. 157 NO_VALIDATION 158 ) 159 160 // SetTokenID Sets the Token to be updated 161 func (tx *TokenUpdateTransaction) SetTokenID(tokenID TokenID) *TokenUpdateTransaction { 162 tx._RequireNotFrozen() 163 tx.tokenID = &tokenID 164 return tx 165 } 166 167 // GetTokenID returns the TokenID for this TokenUpdateTransaction 168 func (tx *TokenUpdateTransaction) GetTokenID() TokenID { 169 if tx.tokenID == nil { 170 return TokenID{} 171 } 172 173 return *tx.tokenID 174 } 175 176 // SetTokenSymbol Sets the new Symbol of the Token. 177 // Must be UTF-8 capitalized alphabetical string identifying the token. 178 func (tx *TokenUpdateTransaction) SetTokenSymbol(symbol string) *TokenUpdateTransaction { 179 tx._RequireNotFrozen() 180 tx.tokenSymbol = symbol 181 return tx 182 } 183 184 func (tx *TokenUpdateTransaction) GetTokenSymbol() string { 185 return tx.tokenSymbol 186 } 187 188 // SetTokenName Sets the new Name of the Token. Must be a string of ASCII characters. 189 func (tx *TokenUpdateTransaction) SetTokenName(name string) *TokenUpdateTransaction { 190 tx._RequireNotFrozen() 191 tx.tokenName = name 192 return tx 193 } 194 195 // GetTokenName returns the TokenName for this TokenUpdateTransaction 196 func (tx *TokenUpdateTransaction) GetTokenName() string { 197 return tx.tokenName 198 } 199 200 // SetTreasuryAccountID sets thehe new Treasury account of the Token. 201 // If the provided treasury account is not existing or deleted, 202 // the _Response will be INVALID_TREASURY_ACCOUNT_FOR_TOKEN. If successful, the Token 203 // balance held in the previous Treasury Account is transferred to the new one. 204 func (tx *TokenUpdateTransaction) SetTreasuryAccountID(treasuryAccountID AccountID) *TokenUpdateTransaction { 205 tx._RequireNotFrozen() 206 tx.treasuryAccountID = &treasuryAccountID 207 return tx 208 } 209 210 func (tx *TokenUpdateTransaction) GetTreasuryAccountID() AccountID { 211 if tx.treasuryAccountID == nil { 212 return AccountID{} 213 } 214 215 return *tx.treasuryAccountID 216 } 217 218 // SetAdminKey Sets the new Admin key of the Token. 219 // If Token is immutable, transaction will resolve to TOKEN_IS_IMMUTABlE. 220 func (tx *TokenUpdateTransaction) SetAdminKey(publicKey Key) *TokenUpdateTransaction { 221 tx._RequireNotFrozen() 222 tx.adminKey = publicKey 223 return tx 224 } 225 226 func (tx *TokenUpdateTransaction) GetAdminKey() Key { 227 return tx.adminKey 228 } 229 230 // SetPauseKey Sets the Key which can pause and unpause the Token. If the Token does not currently have a pause key, 231 // transaction will resolve to TOKEN_HAS_NO_PAUSE_KEY 232 func (tx *TokenUpdateTransaction) SetPauseKey(publicKey Key) *TokenUpdateTransaction { 233 tx._RequireNotFrozen() 234 tx.pauseKey = publicKey 235 return tx 236 } 237 238 // GetPauseKey returns the Key which can pause and unpause the Token 239 func (tx *TokenUpdateTransaction) GetPauseKey() Key { 240 return tx.pauseKey 241 } 242 243 // SetMetadataKey Set the Key which can update the metadata. 244 func (tx *TokenUpdateTransaction) SetMetadataKey(key Key) *TokenUpdateTransaction { 245 tx._RequireNotFrozen() 246 tx.metadataKey = key 247 return tx 248 } 249 250 // GetMetadataKey returns the metadata key 251 func (tx *TokenUpdateTransaction) GetMetadataKey() Key { 252 return tx.metadataKey 253 } 254 255 // SetKycKey Sets the new KYC key of the Token. If Token does not have currently a KYC key, transaction will 256 // resolve to TOKEN_HAS_NO_KYC_KEY. 257 func (tx *TokenUpdateTransaction) SetKycKey(publicKey Key) *TokenUpdateTransaction { 258 tx._RequireNotFrozen() 259 tx.kycKey = publicKey 260 return tx 261 } 262 263 // GetKycKey returns the new KYC key of the Token 264 func (tx *TokenUpdateTransaction) GetKycKey() Key { 265 return tx.kycKey 266 } 267 268 // SetFreezeKey Sets the new Freeze key of the Token. If the Token does not have currently a Freeze key, transaction 269 // will resolve to TOKEN_HAS_NO_FREEZE_KEY. 270 func (tx *TokenUpdateTransaction) SetFreezeKey(publicKey Key) *TokenUpdateTransaction { 271 tx._RequireNotFrozen() 272 tx.freezeKey = publicKey 273 return tx 274 } 275 276 // GetFreezeKey returns the new Freeze key of the Token 277 func (tx *TokenUpdateTransaction) GetFreezeKey() Key { 278 return tx.freezeKey 279 } 280 281 // SetWipeKey Sets the new Wipe key of the Token. If the Token does not have currently a Wipe key, transaction 282 // will resolve to TOKEN_HAS_NO_WIPE_KEY. 283 func (tx *TokenUpdateTransaction) SetWipeKey(publicKey Key) *TokenUpdateTransaction { 284 tx._RequireNotFrozen() 285 tx.wipeKey = publicKey 286 return tx 287 } 288 289 // GetWipeKey returns the new Wipe key of the Token 290 func (tx *TokenUpdateTransaction) GetWipeKey() Key { 291 return tx.wipeKey 292 } 293 294 // SetSupplyKey Sets the new Supply key of the Token. If the Token does not have currently a Supply key, transaction 295 // will resolve to TOKEN_HAS_NO_SUPPLY_KEY. 296 func (tx *TokenUpdateTransaction) SetSupplyKey(publicKey Key) *TokenUpdateTransaction { 297 tx._RequireNotFrozen() 298 tx.supplyKey = publicKey 299 return tx 300 } 301 302 // GetSupplyKey returns the new Supply key of the Token 303 func (tx *TokenUpdateTransaction) GetSupplyKey() Key { 304 return tx.supplyKey 305 } 306 307 // SetFeeScheduleKey 308 // If set, the new key to use to update the token's custom fee schedule; if the token does not 309 // currently have this key, transaction will resolve to TOKEN_HAS_NO_FEE_SCHEDULE_KEY 310 func (tx *TokenUpdateTransaction) SetFeeScheduleKey(key Key) *TokenUpdateTransaction { 311 tx._RequireNotFrozen() 312 tx.scheduleKey = key 313 return tx 314 } 315 316 // GetFeeScheduleKey returns the new key to use to update the token's custom fee schedule 317 func (tx *TokenUpdateTransaction) GetFeeScheduleKey() Key { 318 return tx.scheduleKey 319 } 320 321 // SetAutoRenewAccount Sets the new account which will be automatically charged to renew the token's expiration, at 322 // autoRenewPeriod interval. 323 func (tx *TokenUpdateTransaction) SetAutoRenewAccount(autoRenewAccountID AccountID) *TokenUpdateTransaction { 324 tx._RequireNotFrozen() 325 tx.autoRenewAccountID = &autoRenewAccountID 326 return tx 327 } 328 329 func (tx *TokenUpdateTransaction) GetAutoRenewAccount() AccountID { 330 if tx.autoRenewAccountID == nil { 331 return AccountID{} 332 } 333 334 return *tx.autoRenewAccountID 335 } 336 337 // SetAutoRenewPeriod Sets the new interval at which the auto-renew account will be charged to extend the token's expiry. 338 func (tx *TokenUpdateTransaction) SetAutoRenewPeriod(autoRenewPeriod time.Duration) *TokenUpdateTransaction { 339 tx._RequireNotFrozen() 340 tx.autoRenewPeriod = &autoRenewPeriod 341 return tx 342 } 343 344 // GetAutoRenewPeriod returns the new interval at which the auto-renew account will be charged to extend the token's expiry. 345 func (tx *TokenUpdateTransaction) GetAutoRenewPeriod() time.Duration { 346 if tx.autoRenewPeriod != nil { 347 return time.Duration(int64(tx.autoRenewPeriod.Seconds()) * time.Second.Nanoseconds()) 348 } 349 350 return time.Duration(0) 351 } 352 353 // SetExpirationTime Sets the new expiry time of the token. Expiry can be updated even if admin key is not set. 354 // If the provided expiry is earlier than the current token expiry, transaction wil resolve to 355 // INVALID_EXPIRATION_TIME 356 func (tx *TokenUpdateTransaction) SetExpirationTime(expirationTime time.Time) *TokenUpdateTransaction { 357 tx._RequireNotFrozen() 358 tx.expirationTime = &expirationTime 359 return tx 360 } 361 362 func (tx *TokenUpdateTransaction) GetExpirationTime() time.Time { 363 if tx.expirationTime != nil { 364 return *tx.expirationTime 365 } 366 return time.Time{} 367 } 368 369 // SetTokenMemo 370 // If set, the new memo to be associated with the token (UTF-8 encoding max 100 bytes) 371 func (tx *TokenUpdateTransaction) SetTokenMemo(memo string) *TokenUpdateTransaction { 372 tx._RequireNotFrozen() 373 tx.memo = &memo 374 375 return tx 376 } 377 378 func (tx *TokenUpdateTransaction) GetTokenMemo() string { 379 return *tx.memo 380 } 381 382 // SetTokenMetadata sets the token metadata 383 func (tx *TokenUpdateTransaction) SetTokenMetadata(metadata []byte) *TokenUpdateTransaction { 384 tx._RequireNotFrozen() 385 tx.metadata = metadata 386 387 return tx 388 } 389 390 // GetTokenMetadata returns the token metadata 391 func (tx *TokenUpdateTransaction) GetTokenMetadata() []byte { 392 return tx.metadata 393 } 394 395 // SetKeyVerificationMode sets the token key verification mode 396 func (tx *TokenUpdateTransaction) SetKeyVerificationMode(verificationMode TokenKeyValidation) *TokenUpdateTransaction { 397 tx._RequireNotFrozen() 398 tx.tokenKeyVerificationMode = verificationMode 399 return tx 400 } 401 402 // GetKeyVerificationMode returns the token metadata 403 func (tx *TokenUpdateTransaction) GetKeyVerificationMode() TokenKeyValidation { 404 return tx.tokenKeyVerificationMode 405 } 406 407 // ---- Required Interfaces ---- // 408 409 // Sign uses the provided privateKey to sign the transaction. 410 func (tx *TokenUpdateTransaction) Sign(privateKey PrivateKey) *TokenUpdateTransaction { 411 tx.Transaction.Sign(privateKey) 412 return tx 413 } 414 415 // SignWithOperator signs the transaction with client's operator privateKey. 416 func (tx *TokenUpdateTransaction) SignWithOperator(client *Client) (*TokenUpdateTransaction, error) { 417 _, err := tx.Transaction.signWithOperator(client, tx) 418 if err != nil { 419 return nil, err 420 } 421 return tx, nil 422 } 423 424 // SignWith executes the TransactionSigner and adds the resulting signature data to the Transaction's signature map 425 // with the publicKey as the map key. 426 func (tx *TokenUpdateTransaction) SignWith( 427 publicKey PublicKey, 428 signer TransactionSigner, 429 ) *TokenUpdateTransaction { 430 tx.Transaction.SignWith(publicKey, signer) 431 return tx 432 } 433 434 // AddSignature adds a signature to the transaction. 435 func (tx *TokenUpdateTransaction) AddSignature(publicKey PublicKey, signature []byte) *TokenUpdateTransaction { 436 tx.Transaction.AddSignature(publicKey, signature) 437 return tx 438 } 439 440 // When execution is attempted, a single attempt will timeout when this deadline is reached. (The SDK may subsequently retry the execution.) 441 func (tx *TokenUpdateTransaction) SetGrpcDeadline(deadline *time.Duration) *TokenUpdateTransaction { 442 tx.Transaction.SetGrpcDeadline(deadline) 443 return tx 444 } 445 446 func (tx *TokenUpdateTransaction) Freeze() (*TokenUpdateTransaction, error) { 447 return tx.FreezeWith(nil) 448 } 449 450 func (tx *TokenUpdateTransaction) FreezeWith(client *Client) (*TokenUpdateTransaction, error) { 451 _, err := tx.Transaction.freezeWith(client, tx) 452 return tx, err 453 } 454 455 // SetMaxTransactionFee sets the max transaction fee for this TokenUpdateTransaction. 456 func (tx *TokenUpdateTransaction) SetMaxTransactionFee(fee Hbar) *TokenUpdateTransaction { 457 tx.Transaction.SetMaxTransactionFee(fee) 458 return tx 459 } 460 461 // SetRegenerateTransactionID sets if transaction IDs should be regenerated when `TRANSACTION_EXPIRED` is received 462 func (tx *TokenUpdateTransaction) SetRegenerateTransactionID(regenerateTransactionID bool) *TokenUpdateTransaction { 463 tx.Transaction.SetRegenerateTransactionID(regenerateTransactionID) 464 return tx 465 } 466 467 // SetTransactionMemo sets the memo for this TokenUpdateTransaction. 468 func (tx *TokenUpdateTransaction) SetTransactionMemo(memo string) *TokenUpdateTransaction { 469 tx.Transaction.SetTransactionMemo(memo) 470 return tx 471 } 472 473 // SetTransactionValidDuration sets the valid duration for this TokenUpdateTransaction. 474 func (tx *TokenUpdateTransaction) SetTransactionValidDuration(duration time.Duration) *TokenUpdateTransaction { 475 tx.Transaction.SetTransactionValidDuration(duration) 476 return tx 477 } 478 479 // ToBytes serialise the tx to bytes, no matter if it is signed (locked), or not 480 func (tx *TokenUpdateTransaction) ToBytes() ([]byte, error) { 481 bytes, err := tx.Transaction.toBytes(tx) 482 if err != nil { 483 return nil, err 484 } 485 return bytes, nil 486 } 487 488 // SetTransactionID sets the TransactionID for this TokenUpdateTransaction. 489 func (tx *TokenUpdateTransaction) SetTransactionID(transactionID TransactionID) *TokenUpdateTransaction { 490 tx.Transaction.SetTransactionID(transactionID) 491 return tx 492 } 493 494 // SetNodeAccountIDs sets the _Node AccountID for this TokenUpdateTransaction. 495 func (tx *TokenUpdateTransaction) SetNodeAccountIDs(nodeID []AccountID) *TokenUpdateTransaction { 496 tx.Transaction.SetNodeAccountIDs(nodeID) 497 return tx 498 } 499 500 // SetMaxRetry sets the max number of errors before execution will fail. 501 func (tx *TokenUpdateTransaction) SetMaxRetry(count int) *TokenUpdateTransaction { 502 tx.Transaction.SetMaxRetry(count) 503 return tx 504 } 505 506 // SetMaxBackoff The maximum amount of time to wait between retries. 507 // Every retry attempt will increase the wait time exponentially until it reaches this time. 508 func (tx *TokenUpdateTransaction) SetMaxBackoff(max time.Duration) *TokenUpdateTransaction { 509 tx.Transaction.SetMaxBackoff(max) 510 return tx 511 } 512 513 // SetMinBackoff sets the minimum amount of time to wait between retries. 514 func (tx *TokenUpdateTransaction) SetMinBackoff(min time.Duration) *TokenUpdateTransaction { 515 tx.Transaction.SetMinBackoff(min) 516 return tx 517 } 518 519 func (tx *TokenUpdateTransaction) SetLogLevel(level LogLevel) *TokenUpdateTransaction { 520 tx.Transaction.SetLogLevel(level) 521 return tx 522 } 523 524 func (tx *TokenUpdateTransaction) Execute(client *Client) (TransactionResponse, error) { 525 return tx.Transaction.execute(client, tx) 526 } 527 528 func (tx *TokenUpdateTransaction) Schedule() (*ScheduleCreateTransaction, error) { 529 return tx.Transaction.schedule(tx) 530 } 531 532 // ----------- Overridden functions ---------------- 533 534 func (tx *TokenUpdateTransaction) getName() string { 535 return "TokenUpdateTransaction" 536 } 537 538 func (tx *TokenUpdateTransaction) validateNetworkOnIDs(client *Client) error { 539 if client == nil || !client.autoValidateChecksums { 540 return nil 541 } 542 543 if tx.tokenID != nil { 544 if err := tx.tokenID.ValidateChecksum(client); err != nil { 545 return err 546 } 547 } 548 549 if tx.treasuryAccountID != nil { 550 if err := tx.treasuryAccountID.ValidateChecksum(client); err != nil { 551 return err 552 } 553 } 554 555 if tx.autoRenewAccountID != nil { 556 if err := tx.autoRenewAccountID.ValidateChecksum(client); err != nil { 557 return err 558 } 559 } 560 561 return nil 562 } 563 564 func (tx *TokenUpdateTransaction) build() *services.TransactionBody { 565 return &services.TransactionBody{ 566 TransactionFee: tx.transactionFee, 567 Memo: tx.Transaction.memo, 568 TransactionValidDuration: _DurationToProtobuf(tx.GetTransactionValidDuration()), 569 TransactionID: tx.transactionID._ToProtobuf(), 570 Data: &services.TransactionBody_TokenUpdate{ 571 TokenUpdate: tx.buildProtoBody(), 572 }, 573 } 574 } 575 576 func (tx *TokenUpdateTransaction) buildScheduled() (*services.SchedulableTransactionBody, error) { 577 return &services.SchedulableTransactionBody{ 578 TransactionFee: tx.transactionFee, 579 Memo: tx.Transaction.memo, 580 Data: &services.SchedulableTransactionBody_TokenUpdate{ 581 TokenUpdate: tx.buildProtoBody(), 582 }, 583 }, nil 584 } 585 586 func (tx *TokenUpdateTransaction) buildProtoBody() *services.TokenUpdateTransactionBody { 587 body := &services.TokenUpdateTransactionBody{ 588 Name: tx.tokenName, 589 Symbol: tx.tokenSymbol, 590 KeyVerificationMode: services.TokenKeyValidation(tx.tokenKeyVerificationMode), 591 } 592 593 if tx.memo != nil { 594 body.Memo = &wrapperspb.StringValue{Value: *tx.memo} 595 } 596 597 if tx.tokenID != nil { 598 body.Token = tx.tokenID._ToProtobuf() 599 } 600 601 if tx.autoRenewPeriod != nil { 602 body.AutoRenewPeriod = _DurationToProtobuf(*tx.autoRenewPeriod) 603 } 604 605 if tx.expirationTime != nil { 606 body.Expiry = _TimeToProtobuf(*tx.expirationTime) 607 } 608 609 if tx.treasuryAccountID != nil { 610 body.Treasury = tx.treasuryAccountID._ToProtobuf() 611 } 612 613 if tx.autoRenewAccountID != nil { 614 body.AutoRenewAccount = tx.autoRenewAccountID._ToProtobuf() 615 } 616 617 if tx.adminKey != nil { 618 body.AdminKey = tx.adminKey._ToProtoKey() 619 } 620 621 if tx.freezeKey != nil { 622 body.FreezeKey = tx.freezeKey._ToProtoKey() 623 } 624 625 if tx.scheduleKey != nil { 626 body.FeeScheduleKey = tx.scheduleKey._ToProtoKey() 627 } 628 629 if tx.kycKey != nil { 630 body.KycKey = tx.kycKey._ToProtoKey() 631 } 632 633 if tx.wipeKey != nil { 634 body.WipeKey = tx.wipeKey._ToProtoKey() 635 } 636 637 if tx.supplyKey != nil { 638 body.SupplyKey = tx.supplyKey._ToProtoKey() 639 } 640 641 if tx.pauseKey != nil { 642 body.PauseKey = tx.pauseKey._ToProtoKey() 643 } 644 645 if tx.metadataKey != nil { 646 body.MetadataKey = tx.metadataKey._ToProtoKey() 647 } 648 649 if tx.metadata != nil { 650 body.Metadata = &wrapperspb.BytesValue{Value: tx.metadata} 651 } 652 653 return body 654 } 655 656 func (tx *TokenUpdateTransaction) getMethod(channel *_Channel) _Method { 657 return _Method{ 658 transaction: channel._GetToken().UpdateToken, 659 } 660 } 661 func (tx *TokenUpdateTransaction) _ConstructScheduleProtobuf() (*services.SchedulableTransactionBody, error) { 662 return tx.buildScheduled() 663 }