From 4ab0464df62e46d7943c247822c0ed682790dec9 Mon Sep 17 00:00:00 2001 From: dikel Date: Fri, 4 Nov 2022 10:01:26 +0200 Subject: [PATCH] feat: Add auto-renew account support for files and accounts Signed-off-by: dikel --- CHANGELOG.md | 6 ++++ .../sdk/AccountCreateTransaction.java | 33 +++++++++++++++++++ .../com/hedera/hashgraph/sdk/AccountInfo.java | 20 +++++++++-- .../sdk/AccountUpdateTransaction.java | 33 +++++++++++++++++++ .../hashgraph/sdk/FileCreateTransaction.java | 30 +++++++++++++++++ .../com/hedera/hashgraph/sdk/FileInfo.java | 16 +++++++-- .../hashgraph/sdk/FileUpdateTransaction.java | 31 +++++++++++++++++ sdk/src/main/proto/crypto_create.proto | 10 +++++- sdk/src/main/proto/crypto_get_info.proto | 8 +++++ sdk/src/main/proto/crypto_update.proto | 8 +++++ sdk/src/main/proto/file_create.proto | 11 ++++++- sdk/src/main/proto/file_get_info.proto | 5 +++ sdk/src/main/proto/file_update.proto | 9 ++++- sdk/src/main/proto/token_burn.proto | 5 +-- sdk/src/main/proto/token_mint.proto | 5 +-- sdk/src/main/proto/token_wipe_account.proto | 5 +-- .../sdk/AccountCreateTransactionTest.java | 2 ++ .../sdk/AccountCreateTransactionTest.snap | 6 ++-- .../hedera/hashgraph/sdk/AccountInfoTest.java | 1 + .../hedera/hashgraph/sdk/AccountInfoTest.snap | 10 +++--- .../sdk/AccountUpdateTransactionTest.java | 2 ++ .../sdk/AccountUpdateTransactionTest.snap | 6 ++-- .../sdk/FileCreateTransactionTest.java | 1 + .../sdk/FileCreateTransactionTest.snap | 4 +-- .../hedera/hashgraph/sdk/FileInfoTest.java | 1 + .../hedera/hashgraph/sdk/FileInfoTest.snap | 10 +++--- .../sdk/FileUpdateTransactionTest.java | 1 + .../sdk/FileUpdateTransactionTest.snap | 4 +-- 28 files changed, 248 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83720208b..faf097dc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added +- `[Account|File][Create|Update]Transaction.[set|get]autoRenewAccountId()` +- `[Account|File].autoRenewAccountId` + ## 2.18.1 ### Added diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/AccountCreateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/AccountCreateTransaction.java index 7213129fa..0dd678220 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/AccountCreateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/AccountCreateTransaction.java @@ -62,6 +62,9 @@ public final class AccountCreateTransaction extends Transaction getMethodDescriptor() { return FileServiceGrpc.getCreateFileMethod(); @@ -253,6 +278,7 @@ void initFromTransactionBody() { } contents = body.getContents().toByteArray(); fileMemo = body.getMemo(); + autoRenewAccount = AccountId.fromProtobuf(body.getAutoRenewAccount()); } /** @@ -272,6 +298,10 @@ FileCreateTransactionBody.Builder build() { builder.setContents(ByteString.copyFrom(contents)); builder.setMemo(fileMemo); + if (autoRenewAccount != null) { + builder.setAutoRenewAccount(autoRenewAccount.toProtobuf()); + } + return builder; } diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileInfo.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileInfo.java index a6322d9b9..593719e92 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileInfo.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileInfo.java @@ -28,7 +28,6 @@ /** * Current information for a file, including its size. - * * See Hedera Documentation */ public final class FileInfo { @@ -66,6 +65,9 @@ public final class FileInfo { */ public final LedgerId ledgerId; + @Nullable + public final AccountId autoRenewAccountId; + private FileInfo( FileId fileId, long size, @@ -73,7 +75,8 @@ private FileInfo( boolean isDeleted, @Nullable KeyList keys, String fileMemo, - LedgerId ledgerId + LedgerId ledgerId, + @Nullable AccountId autoRenewAccountId ) { this.fileId = fileId; this.size = size; @@ -82,6 +85,7 @@ private FileInfo( this.keys = keys; this.fileMemo = fileMemo; this.ledgerId = ledgerId; + this.autoRenewAccountId = autoRenewAccountId; } /** @@ -102,7 +106,8 @@ static FileInfo fromProtobuf(FileGetInfoResponse.FileInfo fileInfo) { fileInfo.getDeleted(), keys, fileInfo.getMemo(), - LedgerId.fromByteString(fileInfo.getLedgerId()) + LedgerId.fromByteString(fileInfo.getLedgerId()), + AccountId.fromProtobuf(fileInfo.getAutoRenewAccount()) ); } @@ -141,6 +146,10 @@ FileGetInfoResponse.FileInfo toProtobuf() { fileInfoBuilder.setKeys(keyList); } + if (autoRenewAccountId != null) { + fileInfoBuilder.setAutoRenewAccount(autoRenewAccountId.toProtobuf()); + } + return fileInfoBuilder.build(); } @@ -154,6 +163,7 @@ public String toString() { .add("keys", keys) .add("fileMemo", fileMemo) .add("ledgerId", ledgerId) + .add("autoRenewAccountId", autoRenewAccountId) .toString(); } diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileUpdateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileUpdateTransaction.java index b7e9072b8..8cb419862 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileUpdateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileUpdateTransaction.java @@ -56,6 +56,9 @@ public final class FileUpdateTransaction extends Transactionauto_renew_account field to anything other + * than the sentinel 0.0.0, the key of the referenced account must sign. */ message CryptoUpdateTransactionBody { /** @@ -152,4 +154,10 @@ message CryptoUpdateTransactionBody { * If true, the account declines receiving a staking reward. The default value is false. */ google.protobuf.BoolValue decline_reward = 18; + + /** + * If set to the sentinel 0.0.0 AccountID, this field removes the account's auto-renew + * account. Otherwise it updates the account's auto-renew account to the referenced account. + */ + AccountID auto_renew_account = 19; } diff --git a/sdk/src/main/proto/file_create.proto b/sdk/src/main/proto/file_create.proto index a3ecd65a1..71c4c440f 100644 --- a/sdk/src/main/proto/file_create.proto +++ b/sdk/src/main/proto/file_create.proto @@ -44,7 +44,8 @@ import "timestamp.proto"; * (including other threshold keys). In other words, the behavior is an AND for create/modify, OR * for delete. This is useful for acting as a revocation server. If it is desired to have the * behavior be AND for all 3 operations (or OR for all 3), then the list should have only a single - * Key, which is a threshold key, with N=1 for OR, N=M for AND. + * Key, which is a threshold key, with N=1 for OR, N=M for AND. If the auto_renew_account field + * is set, the key of the referenced account must sign. * * If a file is created without ANY keys in the keys field, the file is immutable and ONLY the * expirationTime of the file can be changed with a FileUpdate transaction. The file contents or its @@ -99,4 +100,12 @@ message FileCreateTransactionBody { * The memo associated with the file (UTF-8 encoding max 100 bytes) */ string memo = 8; + + /** + * An account to charge for auto-renewal of this file. If not set, or set to an + * account with zero hbar balance, the file's expiration must be manually extended + * using a FileUpdate transaction, since the network will not have authorization + * for any kind of auto-renewal fee collection. + */ + AccountID auto_renew_account = 9; } diff --git a/sdk/src/main/proto/file_get_info.proto b/sdk/src/main/proto/file_get_info.proto index ae4356eb4..a49c09b99 100644 --- a/sdk/src/main/proto/file_get_info.proto +++ b/sdk/src/main/proto/file_get_info.proto @@ -96,6 +96,11 @@ message FileGetInfoResponse { * The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs. */ bytes ledger_id = 7; + + /** + * If set, the account that is used to pay for auto-renewal of the file. + */ + AccountID auto_renew_account = 8; } /** diff --git a/sdk/src/main/proto/file_update.proto b/sdk/src/main/proto/file_update.proto index e04b02abf..2074b81b4 100644 --- a/sdk/src/main/proto/file_update.proto +++ b/sdk/src/main/proto/file_update.proto @@ -35,7 +35,8 @@ import "google/protobuf/wrappers.proto"; * in the top level of a key list (M-of-M) of the file being updated. If the keys themselves are * being updated, then the transaction must also be signed by all the new keys. If the keys contain * additional KeyList or ThresholdKey then M-of-M secondary KeyList or ThresholdKey signing - * requirements must be meet + * requirements must be meet If the update transaction sets the auto_renew_account_id field + * to anything other than the sentinel 0.0.0, the key of the referenced account must sign. */ message FileUpdateTransactionBody { /** @@ -62,4 +63,10 @@ message FileUpdateTransactionBody { * If set, the new memo to be associated with the file (UTF-8 encoding max 100 bytes) */ google.protobuf.StringValue memo = 5; + + /** + * If set to the sentinel 0.0.0 AccountID, this field removes the file's auto-renew + * account. Otherwise it updates the file's auto-renew account to the referenced account. + */ + AccountID auto_renew_account = 6; } diff --git a/sdk/src/main/proto/token_burn.proto b/sdk/src/main/proto/token_burn.proto index 03b1c8208..17d9b67e4 100644 --- a/sdk/src/main/proto/token_burn.proto +++ b/sdk/src/main/proto/token_burn.proto @@ -36,8 +36,9 @@ import "basic_types.proto"; * to burn 100.55 tokens, one must provide amount of 10055. * For non fungible tokens the transaction body accepts serialNumbers list of integers as a parameter. * - * If neither the amount nor the serialNumbers get filled, a INVALID_TOKEN_BURN_AMOUNT response code - * will be returned. + * If the serialNumbers don't get filled for non-fungible token type, a INVALID_TOKEN_BURN_AMOUNT response + * code will be returned. + * If a zero amount is provided for a fungible token type, it will be treated as a regular transaction. * If both amount and serialNumbers get filled, a INVALID_TRANSACTION_BODY response code will be * returned. * If the serialNumbers' list count is greater than the batch size limit global dynamic property, a diff --git a/sdk/src/main/proto/token_mint.proto b/sdk/src/main/proto/token_mint.proto index 82e0104cd..76403a562 100644 --- a/sdk/src/main/proto/token_mint.proto +++ b/sdk/src/main/proto/token_mint.proto @@ -39,8 +39,9 @@ import "basic_types.proto"; * returned. * If the metadata list contains metadata which is too large, a METADATA_TOO_LONG response code will * be returned. - * If neither the amount nor the metadata list get filled, a INVALID_TOKEN_MINT_AMOUNT response code - * will be returned. + * If the metadata list is not filled for a non-fungible token type, a INVALID_TOKEN_MINT_AMOUNT response + * code will be returned. + * If a zero amount is provided for a fungible token type, it will be treated as a regular transaction. * If the metadata list count is greater than the batch size limit global dynamic property, a * BATCH_SIZE_LIMIT_EXCEEDED response code will be returned. */ diff --git a/sdk/src/main/proto/token_wipe_account.proto b/sdk/src/main/proto/token_wipe_account.proto index 2fe07cf82..376253645 100644 --- a/sdk/src/main/proto/token_wipe_account.proto +++ b/sdk/src/main/proto/token_wipe_account.proto @@ -44,8 +44,9 @@ import "basic_types.proto"; * * If both amount and serialNumbers get filled, a INVALID_TRANSACTION_BODY response code will be * returned. - * If neither the amount nor the serialNumbers get filled, a INVALID_WIPING_AMOUNT response code - * will be returned. + * If the serialNumbers don't get filled for a non-fungible token type, a INVALID_WIPING_AMOUNT response + * code will be returned. + * If a zero amount is provided for a fungible token type, it will be treated as a regular transaction. * If the serialNumbers list contains a non-positive integer as a serial number, a INVALID_NFT_ID * response code will be returned. * If the serialNumbers' list count is greater than the batch size limit global dynamic property, a diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.java index 9d89cadb4..f3e12eb9a 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.java @@ -60,6 +60,7 @@ AccountCreateTransaction spawnTestTransaction() { .setAliasKey(PublicKey.fromString("8776c6b831a1b61ac10dac0304a2843de4716f54b1919bb91a2685d0fe3f3048")) .setMaxAutomaticTokenAssociations(100) .setMaxTransactionFee(Hbar.fromTinybars(100_000)) + .setAutoRenewAccount(AccountId.fromString("0.0.1002")) .freeze() .sign(unusedPrivateKey); } @@ -78,6 +79,7 @@ AccountCreateTransaction spawnTestTransaction2() { .setAliasEvmAddress(EvmAddress.fromString("302a300506032b6570032100114e6abc371b82da")) .setMaxAutomaticTokenAssociations(100) .setMaxTransactionFee(Hbar.fromTinybars(100_000)) + .setAutoRenewAccount(AccountId.fromString("0.0.1002")) .freeze() .sign(unusedPrivateKey); } diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.snap b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.snap index 5ba48b532..2c205234e 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.snap +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountCreateTransactionTest.snap @@ -1,8 +1,8 @@ com.hedera.hashgraph.sdk.AccountCreateTransactionTest.shouldSerialize2=[ - "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_create_account {\n alias: \"0*0\\005\\006\\003+ep\\003!\\000\\021Nj\\2747\\033\\202\\332\"\n auto_renew_period {\n seconds: 36000\n }\n initial_balance: 450\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations: 100\n memo: \"some dumb memo\"\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receive_record_threshold: 0\n receiver_sig_required: true\n send_record_threshold: 0\n staked_node_id: 4\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" + "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_create_account {\n alias: \"0*0\\005\\006\\003+ep\\003!\\000\\021Nj\\2747\\033\\202\\332\"\n auto_renew_account {\n account_num: 1002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_period {\n seconds: 36000\n }\n initial_balance: 450\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations: 100\n memo: \"some dumb memo\"\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receive_record_threshold: 0\n receiver_sig_required: true\n send_record_threshold: 0\n staked_node_id: 4\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" ] com.hedera.hashgraph.sdk.AccountCreateTransactionTest.shouldSerialize=[ - "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_create_account {\n alias: \"\\022 \\207v\\306\\2701\\241\\266\\032\\301\\r\\254\\003\\004\\242\\204=\\344qoT\\261\\221\\233\\271\\032&\\205\\320\\376?0H\"\n auto_renew_period {\n seconds: 36000\n }\n initial_balance: 450\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations: 100\n memo: \"some dumb memo\"\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receive_record_threshold: 0\n receiver_sig_required: true\n send_record_threshold: 0\n staked_account_id {\n account_num: 3\n realm_num: 0\n shard_num: 0\n }\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" -] \ No newline at end of file + "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_create_account {\n alias: \"\\022 \\207v\\306\\2701\\241\\266\\032\\301\\r\\254\\003\\004\\242\\204=\\344qoT\\261\\221\\233\\271\\032&\\205\\320\\376?0H\"\n auto_renew_account {\n account_num: 1002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_period {\n seconds: 36000\n }\n initial_balance: 450\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations: 100\n memo: \"some dumb memo\"\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receive_record_threshold: 0\n receiver_sig_required: true\n send_record_threshold: 0\n staked_account_id {\n account_num: 3\n realm_num: 0\n shard_num: 0\n }\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" +] diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.java index 7cec30ce7..4d0251255 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.java @@ -55,6 +55,7 @@ public class AccountInfoTest { .addLiveHashes(liveHash) .setLedgerId(LedgerId.PREVIEWNET.toByteString()) .setEthereumNonce(1001) + .setAutoRenewAccount(new AccountId(9).toProtobuf()) .build(); @BeforeAll diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.snap b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.snap index 11e3c7785..bdfadbe95 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.snap +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountInfoTest.snap @@ -1,18 +1,18 @@ com.hedera.hashgraph.sdk.AccountInfoTest.fromBytes=[ - "AccountInfo{accountId=0.0.1, contractAccountId=, deleted=true, proxyAccountId=0.0.8, proxyReceived=2 tℏ, key=302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7, balance=3 tℏ, sendRecordThreshold=4 tℏ, receiveRecordThreshold=5 tℏ, receiverSignatureRequired=true, expirationTime=1970-01-01T00:00:00.006Z, autoRenewPeriod=PT168H, liveHashes=[LiveHash{accountId=0.0.10, hash=[0, 1, 2], keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, duration=PT264H}], tokenRelationships={}, accountMemo=, ownedNfts=0, maxAutomaticTokenAssociations=0, aliasKey=null, ledgerId=previewnet, ethereumNonce=1001, stakingInfo=null}" + "AccountInfo{accountId=0.0.1, contractAccountId=, deleted=true, proxyAccountId=0.0.8, proxyReceived=2 tℏ, key=302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7, balance=3 tℏ, sendRecordThreshold=4 tℏ, receiveRecordThreshold=5 tℏ, receiverSignatureRequired=true, expirationTime=1970-01-01T00:00:00.006Z, autoRenewPeriod=PT168H, liveHashes=[LiveHash{accountId=0.0.10, hash=[0, 1, 2], keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, duration=PT264H}], tokenRelationships={}, accountMemo=, ownedNfts=0, maxAutomaticTokenAssociations=0, aliasKey=null, ledgerId=previewnet, ethereumNonce=1001, stakingInfo=null, autoRenewAccountId=0.0.9}" ] com.hedera.hashgraph.sdk.AccountInfoTest.fromProtobufWithOtherOptions=[ - "AccountInfo{accountId=0.0.1, contractAccountId=, deleted=true, proxyAccountId=0.0.8, proxyReceived=2 tℏ, key=302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7, balance=3 tℏ, sendRecordThreshold=4 tℏ, receiveRecordThreshold=5 tℏ, receiverSignatureRequired=true, expirationTime=1970-01-01T00:00:00.006Z, autoRenewPeriod=PT168H, liveHashes=[LiveHash{accountId=0.0.10, hash=[0, 1, 2], keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, duration=PT264H}], tokenRelationships={}, accountMemo=, ownedNfts=0, maxAutomaticTokenAssociations=0, aliasKey=null, ledgerId=previewnet, ethereumNonce=1001, stakingInfo=null}" + "AccountInfo{accountId=0.0.1, contractAccountId=, deleted=true, proxyAccountId=0.0.8, proxyReceived=2 tℏ, key=302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7, balance=3 tℏ, sendRecordThreshold=4 tℏ, receiveRecordThreshold=5 tℏ, receiverSignatureRequired=true, expirationTime=1970-01-01T00:00:00.006Z, autoRenewPeriod=PT168H, liveHashes=[LiveHash{accountId=0.0.10, hash=[0, 1, 2], keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, duration=PT264H}], tokenRelationships={}, accountMemo=, ownedNfts=0, maxAutomaticTokenAssociations=0, aliasKey=null, ledgerId=previewnet, ethereumNonce=1001, stakingInfo=null, autoRenewAccountId=0.0.9}" ] com.hedera.hashgraph.sdk.AccountInfoTest.toBytes=[ - "CgIYARgBIgIYCDACOiISIODI7CdYpYef+sImoTwMUWt5nnLjUUGg3YKPlNN5iKS3QANIBFAFWAFiBRCAm+4CagQIgPUkcjUKAhgKEgMAAQIaJAoiEiDgyOwnWKWHn/rCJqE8DFFreZ5y41FBoN2Cj5TTeYiktyoECICBOqIBAQKoAekH" + "CgIYARgBIgIYCDACOiISIODI7CdYpYef+sImoTwMUWt5nnLjUUGg3YKPlNN5iKS3QANIBFAFWAFiBRCAm+4CagQIgPUkcjUKAhgKEgMAAQIaJAoiEiDgyOwnWKWHn/rCJqE8DFFreZ5y41FBoN2Cj5TTeYiktyoECICBOqIBAQKoAekHugECGAk=" ] com.hedera.hashgraph.sdk.AccountInfoTest.toProtobuf=[ - "# com.hedera.hashgraph.sdk.proto.CryptoGetInfoResponse$AccountInfo@57c9441\naccount_i_d {\n account_num: 1\n realm_num: 0\n shard_num: 0\n}\nauto_renew_period {\n seconds: 604800\n}\nbalance: 3\ndeleted: true\nethereum_nonce: 1001\nexpiration_time {\n nanos: 6000000\n seconds: 0\n}\ngenerate_receive_record_threshold: 5\ngenerate_send_record_threshold: 4\nkey {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n}\nledger_id: \"\\002\"\nlive_hashes {\n account_id {\n account_num: 10\n realm_num: 0\n shard_num: 0\n }\n duration {\n seconds: 950400\n }\n hash: \"\\000\\001\\002\"\n keys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n }\n}\nowned_nfts: 0\nproxy_account_i_d {\n account_num: 8\n realm_num: 0\n shard_num: 0\n}\nproxy_received: 2\nreceiver_sig_required: true" -] \ No newline at end of file + "# com.hedera.hashgraph.sdk.proto.CryptoGetInfoResponse$AccountInfo@22d2d0a5\naccount_i_d {\n account_num: 1\n realm_num: 0\n shard_num: 0\n}\nauto_renew_account {\n account_num: 9\n realm_num: 0\n shard_num: 0\n}\nauto_renew_period {\n seconds: 604800\n}\nbalance: 3\ndeleted: true\nethereum_nonce: 1001\nexpiration_time {\n nanos: 6000000\n seconds: 0\n}\ngenerate_receive_record_threshold: 5\ngenerate_send_record_threshold: 4\nkey {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n}\nledger_id: \"\\002\"\nlive_hashes {\n account_id {\n account_num: 10\n realm_num: 0\n shard_num: 0\n }\n duration {\n seconds: 950400\n }\n hash: \"\\000\\001\\002\"\n keys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n }\n}\nowned_nfts: 0\nproxy_account_i_d {\n account_num: 8\n realm_num: 0\n shard_num: 0\n}\nproxy_received: 2\nreceiver_sig_required: true" +] diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.java index 13ee394a9..b486143b4 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.java @@ -60,6 +60,7 @@ AccountUpdateTransaction spawnTestTransaction() { .setAccountMemo("Some memo") .setMaxTransactionFee(Hbar.fromTinybars(100_000)) .setStakedAccountId(AccountId.fromString("0.0.3")) + .setAutoRenewAccount(AccountId.fromString("0.0.1002")) .freeze() .sign(unusedPrivateKey); } @@ -78,6 +79,7 @@ AccountUpdateTransaction spawnTestTransaction2() { .setAccountMemo("Some memo") .setMaxTransactionFee(Hbar.fromTinybars(100_000)) .setStakedNodeId(4L) + .setAutoRenewAccount(AccountId.fromString("0.0.1002")) .freeze() .sign(unusedPrivateKey); } diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.snap b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.snap index c0b99c66e..11e17e8c8 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.snap +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/AccountUpdateTransactionTest.snap @@ -1,8 +1,8 @@ com.hedera.hashgraph.sdk.AccountUpdateTransactionTest.shouldSerialize2=[ - "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_update_account {\n account_i_d_to_update {\n account_num: 2002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_period {\n seconds: 36000\n }\n expiration_time {\n seconds: 1554158543\n }\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations {\n value: 100\n }\n memo {\n value: \"Some memo\"\n }\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receiver_sig_required_wrapper {\n }\n staked_node_id: 4\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" + "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_update_account {\n account_i_d_to_update {\n account_num: 2002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_account {\n account_num: 1002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_period {\n seconds: 36000\n }\n expiration_time {\n seconds: 1554158543\n }\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations {\n value: 100\n }\n memo {\n value: \"Some memo\"\n }\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receiver_sig_required_wrapper {\n }\n staked_node_id: 4\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" ] com.hedera.hashgraph.sdk.AccountUpdateTransactionTest.shouldSerialize=[ - "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_update_account {\n account_i_d_to_update {\n account_num: 2002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_period {\n seconds: 36000\n }\n expiration_time {\n seconds: 1554158543\n }\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations {\n value: 100\n }\n memo {\n value: \"Some memo\"\n }\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receiver_sig_required_wrapper {\n }\n staked_account_id {\n account_num: 3\n realm_num: 0\n shard_num: 0\n }\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" -] \ No newline at end of file + "# com.hedera.hashgraph.sdk.proto.TransactionBody\ncrypto_update_account {\n account_i_d_to_update {\n account_num: 2002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_account {\n account_num: 1002\n realm_num: 0\n shard_num: 0\n }\n auto_renew_period {\n seconds: 36000\n }\n expiration_time {\n seconds: 1554158543\n }\n key {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n max_automatic_token_associations {\n value: 100\n }\n memo {\n value: \"Some memo\"\n }\n proxy_account_i_d {\n account_num: 1001\n realm_num: 0\n shard_num: 0\n }\n receiver_sig_required_wrapper {\n }\n staked_account_id {\n account_num: 3\n realm_num: 0\n shard_num: 0\n }\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" +] diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.java index a3f5c9802..ddd374c56 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.java @@ -61,6 +61,7 @@ private FileCreateTransaction spawnTestTransaction() { .setKeys(unusedPrivateKey) .setMaxTransactionFee(Hbar.fromTinybars(100_000)) .setFileMemo("Hello memo") + .setAutoRenewAccount(AccountId.fromString("0.0.5007")) .freeze() .sign(unusedPrivateKey); } diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.snap b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.snap index f9fb98100..1f7575010 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.snap +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileCreateTransactionTest.snap @@ -1,3 +1,3 @@ com.hedera.hashgraph.sdk.FileCreateTransactionTest.shouldSerialize=[ - "# com.hedera.hashgraph.sdk.proto.TransactionBody\nfile_create {\n contents: \"\\001\\002\\003\\004\"\n expiration_time {\n seconds: 1554158728\n }\n keys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n }\n memo: \"Hello memo\"\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" -] \ No newline at end of file + "# com.hedera.hashgraph.sdk.proto.TransactionBody\nfile_create {\n auto_renew_account {\n account_num: 5007\n realm_num: 0\n shard_num: 0\n }\n contents: \"\\001\\002\\003\\004\"\n expiration_time {\n seconds: 1554158728\n }\n keys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n }\n memo: \"Hello memo\"\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" +] diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.java index af2b11257..edad16d1f 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.java @@ -42,6 +42,7 @@ public class FileInfoTest { .setKeys(KeyList.newBuilder() .addKeys(privateKey.getPublicKey().toProtobufKey())) .setLedgerId(LedgerId.MAINNET.toByteString()) + .setAutoRenewAccount(new AccountId(9).toProtobuf()) .build(); @BeforeAll diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.snap b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.snap index f82cadf2a..06b15490d 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.snap +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileInfoTest.snap @@ -1,18 +1,18 @@ com.hedera.hashgraph.sdk.FileInfoTest.fromBytes=[ - "FileInfo{fileId=0.0.1, size=2, expirationTime=1970-01-01T00:00:00.003Z, isDeleted=true, keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, fileMemo=, ledgerId=mainnet}" + "FileInfo{fileId=0.0.1, size=2, expirationTime=1970-01-01T00:00:00.003Z, isDeleted=true, keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, fileMemo=, ledgerId=mainnet, autoRenewAccountId=0.0.9}" ] com.hedera.hashgraph.sdk.FileInfoTest.fromProtobuf=[ - "FileInfo{fileId=0.0.1, size=2, expirationTime=1970-01-01T00:00:00.003Z, isDeleted=true, keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, fileMemo=, ledgerId=mainnet}" + "FileInfo{fileId=0.0.1, size=2, expirationTime=1970-01-01T00:00:00.003Z, isDeleted=true, keys=KeyList{threshold=null, keys=[302a300506032b6570032100e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b7]}, fileMemo=, ledgerId=mainnet, autoRenewAccountId=0.0.9}" ] com.hedera.hashgraph.sdk.FileInfoTest.toBytes=[ - "0a02180110021a0510c08db70120012a240a221220e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b73a0100" + "0a02180110021a0510c08db70120012a240a221220e0c8ec2758a5879ffac226a13c0c516b799e72e35141a0dd828f94d37988a4b73a010042021809" ] com.hedera.hashgraph.sdk.FileInfoTest.toProtobuf=[ - "# com.hedera.hashgraph.sdk.proto.FileGetInfoResponse$FileInfo@e51665b9\ndeleted: true\nexpiration_time {\n nanos: 3000000\n seconds: 0\n}\nfile_i_d {\n file_num: 1\n realm_num: 0\n shard_num: 0\n}\nkeys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n}\nledger_id: \"\\000\"\nsize: 2" -] \ No newline at end of file + "# com.hedera.hashgraph.sdk.proto.FileGetInfoResponse$FileInfo@6dab2e7d\nauto_renew_account {\n account_num: 9\n realm_num: 0\n shard_num: 0\n}\ndeleted: true\nexpiration_time {\n nanos: 3000000\n seconds: 0\n}\nfile_i_d {\n file_num: 1\n realm_num: 0\n shard_num: 0\n}\nkeys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n}\nledger_id: \"\\000\"\nsize: 2" +] diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.java index fc448c847..badac099d 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.java @@ -62,6 +62,7 @@ private FileUpdateTransaction spawnTestTransaction() { .setMaxTransactionFee(Hbar.fromTinybars(100_000)) .setKeys(unusedPrivateKey) .setFileMemo("Hello memo") + .setAutoRenewAccount(AccountId.fromString("0.0.5007")) .freeze() .sign(unusedPrivateKey); } diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.snap b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.snap index 572ce64a7..3927ad9c7 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.snap +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/FileUpdateTransactionTest.snap @@ -1,3 +1,3 @@ com.hedera.hashgraph.sdk.FileUpdateTransactionTest.shouldSerialize=[ - "# com.hedera.hashgraph.sdk.proto.TransactionBody\nfile_update {\n contents: \"\\001\\002\\003\\004\\005\"\n expiration_time {\n seconds: 1554158728\n }\n file_i_d {\n file_num: 6006\n realm_num: 0\n shard_num: 0\n }\n keys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n }\n memo {\n value: \"Hello memo\"\n }\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" -] \ No newline at end of file + "# com.hedera.hashgraph.sdk.proto.TransactionBody\nfile_update {\n auto_renew_account {\n account_num: 5007\n realm_num: 0\n shard_num: 0\n }\n contents: \"\\001\\002\\003\\004\\005\"\n expiration_time {\n seconds: 1554158728\n }\n file_i_d {\n file_num: 6006\n realm_num: 0\n shard_num: 0\n }\n keys {\n keys {\n ed25519: \"\\340\\310\\354\\'X\\245\\207\\237\\372\\302&\\241<\\fQky\\236r\\343QA\\240\\335\\202\\217\\224\\323y\\210\\244\\267\"\n }\n }\n memo {\n value: \"Hello memo\"\n }\n}\nnode_account_i_d {\n account_num: 5005\n realm_num: 0\n shard_num: 0\n}\ntransaction_fee: 100000\ntransaction_i_d {\n account_i_d {\n account_num: 5006\n realm_num: 0\n shard_num: 0\n }\n transaction_valid_start {\n seconds: 1554158542\n }\n}\ntransaction_valid_duration {\n seconds: 120\n}" +]