From b5d0e673247d3e2e82761f251d4c3ae9cac65780 Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:40:22 +0000 Subject: [PATCH 1/7] Protobuf changes for implementation of metadata hips 646, 657 and 765 Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/token_create.proto | 11 +++++++ services/token_update.proto | 11 +++++++ services/token_update_nft.proto | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 services/token_update_nft.proto diff --git a/services/token_create.proto b/services/token_create.proto index 00b80d49..73f4efe0 100644 --- a/services/token_create.proto +++ b/services/token_create.proto @@ -198,4 +198,15 @@ message TokenCreateTransactionBody { * If Empty the token pause status defaults to PauseNotApplicable, otherwise Unpaused. */ Key pause_key = 22; + + /** + * Metadata of the created token definition. + */ + bytes metadata = 23; + + /** + * The key which can change the metadata of a token + * (token definition, partition definition, and individual NFTs). + */ + Key metadata_key = 24; } diff --git a/services/token_update.proto b/services/token_update.proto index 50560391..b007bb80 100644 --- a/services/token_update.proto +++ b/services/token_update.proto @@ -142,4 +142,15 @@ message TokenUpdateTransactionBody { * transaction will resolve to TOKEN_HAS_NO_PAUSE_KEY */ Key pause_key = 15; + + /** + * Metadata of the created token definition + */ + google.protobuf.BytesValue metadata = 16; + + /** + * The key which can change the metadata of a token + * (token definition, partition definition, and individual NFTs). + */ + Key metadata_key = 17; } diff --git a/services/token_update_nft.proto b/services/token_update_nft.proto new file mode 100644 index 00000000..6bed77fc --- /dev/null +++ b/services/token_update_nft.proto @@ -0,0 +1,52 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2024 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; + +import "basic_types.proto"; +import "duration.proto"; +import "timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +/** + * At consensus, updates an already created Non Fungible Token to the given values. + * + * If no value is given for a field, that field is left unchanged. For an immutable tokens (that is, + * a token without an admin key), only the expiry may be updated. Setting any other field in that + * case will cause the transaction status to resolve to TOKEN_IS_IMMUTABLE. + * + */ +message TokenUpdateNftTransactionBody { + /** + * The NftID of the NFT + */ + NftID nft_id = 1; + + /** + * The new metadata of the NFT + */ + google.protobuf.BytesValue metadata = 2; +} From acce74596b34c1c924f1175638bcc5c024cc05c4 Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:38:57 +0000 Subject: [PATCH 2/7] adding endpoint for updating an NFT, metadata and key field to getTokenInfo Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/token_get_info.proto | 11 +++++++++++ services/token_service.proto | 3 +++ 2 files changed, 14 insertions(+) diff --git a/services/token_get_info.proto b/services/token_get_info.proto index ae335510..307144e8 100644 --- a/services/token_get_info.proto +++ b/services/token_get_info.proto @@ -198,6 +198,17 @@ message TokenInfo { * The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs. */ bytes ledger_id = 26; + + /** + * Represents the metadata of the token definition. + */ + bytes metadata = 27; + + /** + * The key which can change the metadata of a token + * (token definition, partition definition, and individual NFTs). + */ + Key metadata_key = 28; } /** diff --git a/services/token_service.proto b/services/token_service.proto index b521580b..08261b4c 100644 --- a/services/token_service.proto +++ b/services/token_service.proto @@ -128,4 +128,7 @@ service TokenService { // Unpause the token rpc unpauseToken (Transaction) returns (TransactionResponse); + + // Update an NFT + rpc updateNft (Transaction) returns (TransactionResponse); } From a0e45a20c456e3f8722d0c4d1e7944caf7951da1 Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Thu, 18 Jan 2024 17:07:57 +0000 Subject: [PATCH 3/7] Temporary workaround for google.protobuf.BytesValue PBJ bug Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/token_update.proto | 2 +- services/token_update_nft.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/token_update.proto b/services/token_update.proto index b007bb80..9f118463 100644 --- a/services/token_update.proto +++ b/services/token_update.proto @@ -146,7 +146,7 @@ message TokenUpdateTransactionBody { /** * Metadata of the created token definition */ - google.protobuf.BytesValue metadata = 16; + bytes metadata = 16; /** * The key which can change the metadata of a token diff --git a/services/token_update_nft.proto b/services/token_update_nft.proto index 6bed77fc..ce76d5e3 100644 --- a/services/token_update_nft.proto +++ b/services/token_update_nft.proto @@ -48,5 +48,5 @@ message TokenUpdateNftTransactionBody { /** * The new metadata of the NFT */ - google.protobuf.BytesValue metadata = 2; + bytes metadata = 2; } From c5dfc0b4e9e3f71c72693593a7ce69da5a7c1ada Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:38:14 +0000 Subject: [PATCH 4/7] Addition of metadata to Token Entity Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/state/token/token.proto | 11 +++++++++++ services/token_create.proto | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/services/state/token/token.proto b/services/state/token/token.proto index c90201c1..b6b8ad1e 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -161,4 +161,15 @@ message Token { * (Optional) The custom fees of this token. */ repeated CustomFee custom_fees = 26; + + /** + * Metadata of the created token definition + */ + bytes metadata = 27; + + /** + * The key which can change the metadata of a token + * (token definition, partition definition, and individual NFTs). + */ + Key metadata_key = 28; } diff --git a/services/token_create.proto b/services/token_create.proto index 73f4efe0..7922deb8 100644 --- a/services/token_create.proto +++ b/services/token_create.proto @@ -200,8 +200,8 @@ message TokenCreateTransactionBody { Key pause_key = 22; /** - * Metadata of the created token definition. - */ + * Metadata of the created token definition. + */ bytes metadata = 23; /** From 1527cee3957438dc1e7919ef0b988bf5492ab54e Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:22:47 +0000 Subject: [PATCH 5/7] Adding Invalid Metadata Key Response Code Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/response_code.proto | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/response_code.proto b/services/response_code.proto index 7adbc624..c24712cc 100644 --- a/services/response_code.proto +++ b/services/response_code.proto @@ -1373,4 +1373,9 @@ enum ResponseCodeEnum { * An alias that is assigned to an account or contract cannot be assigned to another account or contract. */ ALIAS_ALREADY_ASSIGNED = 332; + + /** + * A provided metadata key was invalid. Verify the bytes for an Ed25519 public key are exactly 32 bytes; and the bytes for a compressed ECDSA(secp256k1) key are exactly 33 bytes, with the first byte either 0x02 or 0x03.. + */ + INVALID_METADATA_KEY = 333; } From c426e1e731356b05af4bf0ff233e335d31e2a979 Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:32:41 +0000 Subject: [PATCH 6/7] Removing partition verbiage Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/state/token/token.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/state/token/token.proto b/services/state/token/token.proto index b6b8ad1e..0f581258 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -169,7 +169,7 @@ message Token { /** * The key which can change the metadata of a token - * (token definition, partition definition, and individual NFTs). + * (token definition and individual NFTs). */ Key metadata_key = 28; } From e0101f439b395e1c1c4faea7f722c243fe528857 Mon Sep 17 00:00:00 2001 From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:28:34 +0000 Subject: [PATCH 7/7] Reverting to used google.protobuf.BytesValue Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com> --- services/token_update.proto | 2 +- services/token_update_nft.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/token_update.proto b/services/token_update.proto index 9f118463..b007bb80 100644 --- a/services/token_update.proto +++ b/services/token_update.proto @@ -146,7 +146,7 @@ message TokenUpdateTransactionBody { /** * Metadata of the created token definition */ - bytes metadata = 16; + google.protobuf.BytesValue metadata = 16; /** * The key which can change the metadata of a token diff --git a/services/token_update_nft.proto b/services/token_update_nft.proto index ce76d5e3..6bed77fc 100644 --- a/services/token_update_nft.proto +++ b/services/token_update_nft.proto @@ -48,5 +48,5 @@ message TokenUpdateNftTransactionBody { /** * The new metadata of the NFT */ - bytes metadata = 2; + google.protobuf.BytesValue metadata = 2; }