diff --git a/README.md b/README.md index f0ea718b..f608afd1 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,14 @@ must be paid in ℏ from a cryptocurrency account. The payer authorizes a fee by signing an appropriate transaction with a sufficient subset of the Ed25519 key(s) associated to their account. +## Overview of state +State directory and its subdirectories contain the protobuf files that define the state of the network. +The state is divided into the following subdirectories, based on the service modules: +1. [Token](services/state/token) - The state of the Token service. +2. [Consensus](services/state/consensus) - The state of the Consensus service. + +The state directory and its subdirectories are in preview and are subject to change. + # For Developers ## Branching diff --git a/services/state/blockrecords/block_info.proto b/services/state/blockrecords/block_info.proto new file mode 100644 index 00000000..304a32d7 --- /dev/null +++ b/services/state/blockrecords/block_info.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "timestamp.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * Information about the most recently completed and last 256 blocks. + */ +message BlockInfo { + /** + * The last block number, this is the last completed immutable block. + */ + int64 last_block_no = 1; + /** + * The consensus time of the first transaction of the last block, this is the last completed immutable block. + */ + Timestamp first_cons_time_of_last_block = 2; + /** + * SHA384 48 byte hashes of the last 256 blocks in single byte array. + * First 48 bytes is the oldest block. + * Last 48 bytes is the newest block, which is the last fully completed immutable block. + * If we are shortly after genesis and there are less than 256 blocks then this could contain less than 256 hashes. + */ + bytes block_hashes = 3; +} diff --git a/services/state/blockrecords/running_hashes.proto b/services/state/blockrecords/running_hashes.proto new file mode 100644 index 00000000..8d2ae4c5 --- /dev/null +++ b/services/state/blockrecords/running_hashes.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * The running hash of a transaction records and the previous 3 running hashes. All hashes are 48 bytes SHA384 hashes. If the + * running hashes do not exist yet then they will be default values witch is empty bytes object or zero length byte array. + */ +message RunningHashes { + /** + * A running hash of all record stream items + */ + bytes running_hash = 1; + /** + * The previous running hash of all record stream items + */ + bytes n_minus_1_running_hash = 2; + /** + * The previous, previous running hash of all record stream items + */ + bytes n_minus_2_running_hash = 3; + /** + * The previous, previous, previous running hash of all record stream items + */ + bytes n_minus_3_running_hash = 4; +} diff --git a/services/state/common.proto b/services/state/common.proto new file mode 100644 index 00000000..c60fa550 --- /dev/null +++ b/services/state/common.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ +import "basic_types.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * A single 64-bit number identifying a Hedera native entity. + */ +message EntityNumber { + int64 number = 1; +} + +/** + * Pair of AccountID and TokenID to represent TokenRelation + */ +message EntityIDPair { + AccountID account_id = 1; + TokenID token_id = 2; +} + +/** + * Identifier for a unique token (or "NFT"), used by both contract and token services. + */ +message UniqueTokenId { + /** + * The id of the unique token this NFT is an instance of. + */ + TokenID token_id = 1; + + /** + * The serial number of this NFT within its token type. + */ + int64 serial_number = 2; +} diff --git a/services/state/consensus/topic.proto b/services/state/consensus/topic.proto index 6288e2f8..fbf75b04 100644 --- a/services/state/consensus/topic.proto +++ b/services/state/consensus/topic.proto @@ -68,7 +68,7 @@ message Topic { */ int64 auto_renew_period = 4; /** - * The number of the account (if any) that the network will attempt to charge for the + * The number of the account (if any) that the network will attempt to charge for the * topic's auto-renewal upon expiration. */ int64 auto_renew_account_number = 5; diff --git a/services/state/contract/bytecode.proto b/services/state/contract/bytecode.proto new file mode 100644 index 00000000..d144a195 --- /dev/null +++ b/services/state/contract/bytecode.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * The bytecode for a contract id. + */ +message Bytecode { + /** + * The raw bytes (not hex-encoded) of a contract's bytecode. + */ + bytes code = 1; +} diff --git a/services/state/contract/storage_slot.proto b/services/state/contract/storage_slot.proto new file mode 100644 index 00000000..5511d112 --- /dev/null +++ b/services/state/contract/storage_slot.proto @@ -0,0 +1,70 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "state/common.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * The key of a storage slot. A slot is scoped to a specific contract number. + * + * For each contract, its EVM storage is a mapping of 256-bit keys (or "words") to 256-bit values. + */ +message SlotKey { + /** + * The number of the contract whose storage this slot belongs to. + */ + int64 contract_number = 1; + + /** + * The EVM key of this slot, when left-padded with zeros to form a 256-bit word. + */ + bytes key = 2; +} + +/** + * The value of a contract storage slot. For the EVM, this is a single word. + * + * But because we need to be able to iterate through all the storage slots for an + * expired contract when purging it from state, our slot values also include the words + * of the previous and next keys in this contract's storage "list". + */ +message SlotValue { + /** + * The EVM value in this slot, when left-padded with zeros to form a 256-bit word. + */ + bytes value = 1; + + /** + * The word of the previous key in this contract's storage list (if any). + */ + bytes previous_key = 2; + + /** + * The word of the next key in this contract's storage list (if any). + */ + bytes next_key = 3; +} diff --git a/services/state/file/file.proto b/services/state/file/file.proto new file mode 100644 index 00000000..15cad7ea --- /dev/null +++ b/services/state/file/file.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "timestamp.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service file in the network Merkle tree. + * + * As with all network entities, a file has a unique entity number, which is usually given along + * with the network's shard and realm in the form of a shard.realm.number id. + */ +message File { + /** + * The file's unique entity number in the Merkle state. + */ + int64 file_number = 1; + /** + * The file's consensus expiration time in seconds since the epoch. + */ + int64 expiration_time = 2; + /** + * All keys at the top level of a key list must sign to create, modify and delete the file. + */ + KeyList keys = 3; + /** + * The bytes that are the contents of the file + */ + bytes contents = 4; + /** + * The memo associated with the file (UTF-8 encoding max 100 bytes) + */ + string memo = 5; + /** + * Whether this file is deleted. + */ + bool deleted = 6; +} \ No newline at end of file diff --git a/services/state/recordcache/recordcache.proto b/services/state/recordcache/recordcache.proto new file mode 100644 index 00000000..b68d1c2c --- /dev/null +++ b/services/state/recordcache/recordcache.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "transaction_record.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * As transactions are handled and records and receipts are created, they are stored in state for a configured time + * limit (perhaps, for example, 3 minutes). During this time window, any client can query the node and get the record + * or receipt for the transaction. The TransactionRecordEntry is the object stored in state with this information. + */ +message TransactionRecordEntry { + /** + * The ID of the node that submitted the transaction to consensus. The ID is the ID of the node as known by the + * address book. Valid node IDs are in the range 0..2^63-1, inclusive. + */ + int64 node_id = 1; + + /** + * The AccountID of the payer of the transaction. This may be the same as the account ID within the Transaction ID + * of the record, or it may be the account ID of the node that submitted the transaction to consensus if the account + * ID in the Transaction ID is not able to pay. + */ + AccountID payer_account_id = 2; + + /** + * The transaction record for the transaction. + */ + TransactionRecord transaction_record = 3; +} diff --git a/services/state/token/account.proto b/services/state/token/account.proto new file mode 100644 index 00000000..34d75b70 --- /dev/null +++ b/services/state/token/account.proto @@ -0,0 +1,228 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "state/common.proto"; +import "basic_types.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service account entity in the network Merkle tree. + * + * As with all network entities, account has an unique entity number represented as shard.realm.X. + * X can be an alias public key or an EVM address or a number. + * + */ + +message Account { + /** + * The unique entity id of the account. The shard and realm numbers are implied, based on the network + * this entity came from. + * FUTURE : Need to validate if this is needed + */ + AccountID account_id = 1; + /** + * The balance of the account, in tiny-bars. + */ + int64 tinybar_balance = 2; + /** + * A boolean marking if the account has been deleted. + */ + bool deleted = 3; + /** + * The expiration time of the account, in seconds since the epoch. + */ + int64 expiry = 4; + /** + * The alias to use for this account, if any. + */ + bytes alias = 5; + /** + * (Optional) The key to be used to sign transactions from the account, if any. + * This key will not be set for hollow accounts until the account is finalized. + * This key should be set on all the accounts, except for immutable accounts (0.0.800 and 0.0.801). + */ + Key key = 6; + /** + * An optional description of the account with UTF-8 encoding up to 100 bytes. + */ + string memo = 7; + /** + * The amount of hbars staked to the account. + */ + int64 staked_to_me = 8; + /** + * If this account stakes to another account, its value will be -1. It will + * be set to the time when the account starts staking to a node. + */ + int64 stake_period_start = 9; + /** + * The node number or the account number this account is staked to. + * It is negative if staking to a node and positive if staking to an account and 0 if not staking to anyone. + * When staking to a node, it is stored as -node-1 to differentiate node 0. + */ + int64 staked_number = 10; + /** + * A boolean marking if the account declines rewards. + */ + bool decline_reward = 11; + /** + * A boolean marking if the account requires a receiver signature. + */ + bool receiver_sig_required = 12; + /** + * The token ID of the head of the linked list from token relations map for the account. + */ + TokenID head_token_id = 13; + /** + * The NftId of the head of the linked list from unique tokens map for the account. + */ + UniqueTokenId head_nft_id = 14; + /** + * The serial number of the head NftId of the linked list from unique tokens map for the account. + */ + int64 head_nft_serial_number = 15; + /** + * The number of NFTs owned by the account. + */ + int64 number_owned_nfts = 16; + /** + * The maximum number of tokens that can be auto-associated with the account. + */ + int32 max_auto_associations = 17; + /** + * The number of used auto-association slots. + */ + int32 used_auto_associations = 18; + /** + * The number of tokens associated with the account. This number is used for + * fee calculation during renewal of the account. + */ + int32 number_associations = 19; + /** + * A boolean marking if the account is a smart contract. + */ + bool smart_contract = 20; + /** + * The number of tokens with a positive balance associated with the account. + * If the account has positive balance in a token, it can not be deleted. + */ + int32 number_positive_balances = 21; + /** + * The nonce of the account, used for Ethereum interoperability. + */ + int64 ethereum_nonce = 22; + /** + * The amount of hbars staked to the account at the start of the last rewarded period. + */ + int64 stake_at_start_of_last_rewarded_period = 23; + /** + * (Optional) The id of an auto-renew account, in the same shard and realm as the account, that + * has signed a transaction allowing the network to use its balance to automatically extend the account's + * expiration time when it passes. + */ + AccountID auto_renew_account_id = 24; + /** + * The number of seconds the network should automatically extend the account's expiration by, if the + * account has a valid auto-renew account, and is not deleted upon expiration. + * If this is not provided in a allowed range on account creation, the transaction will fail with INVALID_AUTO_RENEWAL_PERIOD. + * The default values for the minimum period and maximum period are 30 days and 90 days, respectively. + */ + int64 auto_renew_secs = 25; + /** + * If this account is a smart-contract, number of key-value pairs stored on the contract. + * This is used to determine the storage rent for the contract. + */ + int32 contract_kv_pairs_number = 26; + /** + * (Optional) List of crypto allowances approved by the account. + * It contains account number for which the allowance is approved to and + * the amount approved for that account. + */ + repeated AccountCryptoAllowance crypto_allowances = 27; + /** + * (Optional) List of non-fungible token allowances approved for all by the account. + * It contains account number approved for spending all serial numbers for the given + * NFT token number using approved_for_all flag. + * Allowances for a specific serial number is stored in the NFT itself in state. + */ + repeated AccountApprovalForAllAllowance approve_for_all_nft_allowances = 28; + + /** + * (Optional) List of fungible token allowances approved by the account. + * It contains account number for which the allowance is approved to and the token number. + * It also contains and the amount approved for that account. + */ + repeated AccountFungibleTokenAllowance token_allowances = 29; + /** + * The number of tokens for which this account is treasury + */ + uint32 number_treasury_titles = 30; + /** + * A flag indicating if the account is expired and pending removal. + * Only the entity expiration system task toggles this flag when it reaches this account + * and finds it expired. Before setting the flag the system task checks if the account has + * an auto-renew account with balance. This is done to prevent a zero-balance account with a funded + * auto-renew account from being treated as expired in the interval between its expiration + * and the time the system task actually auto-renews it. + */ + bool expired_and_pending_removal = 31; + /** + * The first key in the doubly-linked list of this contract's storage mappings; + * It will be null if if the account is not a contract or the contract has no storage mappings. + */ + bytes first_contract_storage_key = 32; +} + +/** + * Allowance granted by this account to a spender for a specific non-fungible token + * using ApproveForAll. This allows spender to spend all serial numbers for the given + * non-fungible token id. + */ +message AccountApprovalForAllAllowance { + TokenID token_id = 1; + AccountID spender_id = 2; +} + +/** + * Allowance granted by this account to another account for a specific fungible token. + * This also contains the amount of the token that is approved for the account. + * This allows spender to spend the amount of tokens approved for the account. + */ +message AccountFungibleTokenAllowance { + TokenID token_id = 1; + AccountID spender_id = 2; + int64 amount = 3; +} + +/** + * Allowance granted by this account to another account for an amount of hbars. + * This allows spender to spend the amount of hbars approved for the account. + */ +message AccountCryptoAllowance { + AccountID spender_id = 1; + int64 amount = 2; +} diff --git a/services/state/token/nft.proto b/services/state/token/nft.proto new file mode 100644 index 00000000..d31aeacd --- /dev/null +++ b/services/state/token/nft.proto @@ -0,0 +1,78 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "timestamp.proto"; +import "state/common.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service NFT in the network Merkle tree. + */ +message Nft { + + /** + * The id of this NFT. + */ + UniqueTokenId id = 1; + + /** + * The account or contract id that owns this NFT. + * + * If this number is zero in state, the NFT is owned by its token type's current treasury. + */ + AccountID owner_id = 2; + + /** + * The account or contract id approved to spend this NFT. + * + * If this number is zero, there is no approved spender. + */ + AccountID spender_id = 3; + + /** + * The consensus time of the TokenMint that created this NFT. + */ + Timestamp mint_time = 4; + + /** + * The metadata of this NFT, up to 100 bytes; usually the UTF-8 encoding of a URI. + */ + bytes metadata = 5; + + /** + * If the owner of this NFT is not its token treasury, the id of the previous NFT + * in the owner's "doubly-linked list" of owned NFTs (if any). + */ + UniqueTokenId owner_previous_nft_id = 6; + + /** + * If the owner of this NFT is not its token treasury, the id of the next NFT in + * the owner's "doubly-linked list" of owned NFTs (if any). + */ + UniqueTokenId owner_next_nft_id = 7; +} diff --git a/services/state/token/token.proto b/services/state/token/token.proto new file mode 100644 index 00000000..44cebc62 --- /dev/null +++ b/services/state/token/token.proto @@ -0,0 +1,165 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "custom_fees.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service token entity in the network Merkle tree. + * + * As with all network entities, a token has a unique entity number, which is usually given along + * with the network's shard and realm in the form of a shard.realm.number id. + */ + +message Token { + /** + * The unique entity id of this token. + * FUTURE : Need to validate if this is needed + */ + TokenID token_id = 1; + /** + * The human-readable name of this token and its not necessarily unique. Maximum length allowed is 100 bytes. + */ + string name = 2; + /** + * The human-readable symbol for the token. It is not necessarily unique. Maximum length allowed is 100 bytes. + */ + string symbol = 3; + /** + * The number of decimal places of this token. If decimals are 8 or 11, then the number of whole + * tokens can be at most a few billions or millions, respectively. For example, it could match + * Bitcoin (21 million whole tokens with 8 decimals) or hbars (50 billion whole tokens with 8 decimals). + * It could even match Bitcoin with milli-satoshis (21 million whole tokens with 11 decimals). + */ + int32 decimals = 4; + /** + * The total supply of this token. + */ + int64 total_supply = 5; + /** + * The treasury account id of this token. This account receives the initial supply of + * tokens as-well as the tokens from the Token Mint operation once executed. The balance + * of the treasury account is decreased when the Token Burn operation is executed. + */ + AccountID treasury_account_id = 6; + /** + * (Optional) The admin key of this token. If this key is set, the token is mutable. + * A mutable token can be modified. + * If this key is not set on token creation, it cannot be modified. + */ + Key admin_key = 7; + /** + * (Optional) The kyc key of this token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key kyc_key = 8; + /** + * (Optional) The freeze key of this token. This key is needed for freezing the token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key freeze_key = 9; + /** + * (Optional) The wipe key of this token. This key is needed for wiping the token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key wipe_key = 10; + /** + * (Optional) The supply key of this token. This key is needed for minting or burning token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key supply_key = 11; + /** + * (Optional) The fee schedule key of this token. This key should be set, in order to make any + * changes to the custom fee schedule. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key fee_schedule_key = 12; + /** + * (Optional) The pause key of this token. This key is needed for pausing the token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key pause_key = 13; + /** + * The last used serial number of this token. + */ + int64 last_used_serial_number = 14; + /** + * The flag indicating if this token is deleted. + */ + bool deleted = 15; + /** + * The type of this token. A token can be either FUNGIBLE_COMMON or NON_FUNGIBLE_UNIQUE. + * If it has been omitted during token creation, FUNGIBLE_COMMON type is used. + */ + TokenType token_type = 16; + /** + * The supply type of this token.A token can have either INFINITE or FINITE supply type. + * If it has been omitted during token creation, INFINITE type is used. + */ + TokenSupplyType supply_type = 17; + /** + * The account id (if any) that the network will attempt to charge for the + * token's auto-renewal upon expiration. + */ + AccountID auto_renew_account_id = 18; + /** + * The number of seconds the network should automatically extend the token's expiration by, if the + * token has a valid auto-renew account, and is not deleted upon expiration. + * If this is not provided in a allowed range on token creation, the transaction will fail with INVALID_AUTO_RENEWAL_PERIOD. + * The default values for the minimum period and maximum period are 30 days and 90 days, respectively. + */ + int64 auto_renew_secs = 19; + /** + * The expiration time of the token, in seconds since the epoch. + */ + int64 expiry = 20; + /** + * An optional description of the token with UTF-8 encoding up to 100 bytes. + */ + string memo = 21; + /** + * The maximum supply of this token. + */ + int64 max_supply = 22; + /** + * The flag indicating if this token is paused. + */ + bool paused = 23; + /** + * The flag indicating if this token has accounts associated to it that are frozen by default. + */ + bool accounts_frozen_by_default = 24; + /** + * The flag indicating if this token has accounts associated to it that are KYC granted by default. + */ + bool accounts_kyc_granted_by_default = 25; + /** + * (Optional) The custom fees of this token. + */ + repeated CustomFee custom_fees = 26; +} diff --git a/services/state/token/token_relation.proto b/services/state/token/token_relation.proto new file mode 100644 index 00000000..44ba191e --- /dev/null +++ b/services/state/token/token_relation.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; +/** + * First-draft representation of a Hedera Token Service token relationship entity in the network Merkle tree. + * + * As with all network entities, a token relationship has a unique entity number pair, which is represented + * with the account and the token involved in the relationship. + */ +message TokenRelation { + /** + * The token involved in this relation.It takes only positive + */ + TokenID token_id = 1; + /** + * The account involved in this association. + */ + AccountID account_id = 2; + /** + * The balance of the token relationship. + */ + int64 balance = 3; + /** + * The flags specifying the token relationship is frozen or not. + */ + bool frozen = 4; + /** + * The flag indicating if the token relationship has been granted KYC. + */ + bool kyc_granted = 5; + /** + * The flag indicating if the token relationship was deleted. + */ + bool deleted = 6; + /** + * The flag indicating if the token relationship was created using automatic association. + */ + bool automatic_association = 7; + /** + * The previous token id of account's association linked list + */ + TokenID previous_token = 8; + /** + * The next token id of account's association linked list + */ + TokenID next_token = 9; +} diff --git a/services/transaction.proto b/services/transaction.proto index a47569f1..940a6f54 100644 --- a/services/transaction.proto +++ b/services/transaction.proto @@ -42,7 +42,7 @@ import "transaction_body.proto"; */ message Transaction { /** - * the body of the transaction, which needs to be signed + * The body of the transaction, which needs to be signed */ TransactionBody body = 1 [deprecated = true];