Skip to content

Commit

Permalink
feat: add token reject transaction (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroslavGatsanoga authored May 16, 2024
1 parent 45b72af commit 42b61af
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/basic_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,11 @@ enum HederaFunctionality {
* Get Node information
*/
NodeGetInfo = 92;

/**
* Transfer one or more token balances held by the requesting account to the treasury for each token type.
*/
TokenReject = 93;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions services/response_code.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1443,4 +1443,15 @@ enum ResponseCodeEnum {
* The most common cause for this error is a value less than `-1`.
*/
INVALID_MAX_AUTO_ASSOCIATIONS = 346;

/**
* The transaction attempted to use duplicate `TokenReference`.<br/>
* This affects `TokenReject` attempting to reject same token reference more than once.
*/
TOKEN_REFERENCE_REPEATED = 347;

/**
* The account id specified as the owner in `TokenReject` is invalid or does not exist.
*/
INVALID_OWNER_ID = 348;
}
89 changes: 89 additions & 0 deletions services/token_reject.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* # Token Reject
* Messages used to implement a transaction to reject a token type from an
* account.
*
* ### Keywords
* The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
* "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
* document are to be interpreted as described in [RFC2119](https://www.ietf.org/rfc/rfc2119).
*/
syntax = "proto3";

package proto;

/*-
* ‌
* Hedera Network Services Protobuf
* ​
* Copyright (C) 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";
// <<<pbj.java_package = "com.hedera.hapi.node.token">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

import "basic_types.proto";

/**
* Reject undesired token(s).<br/>
* Transfer one or more token balances held by the requesting account to the treasury for each
* token type.<br/>
* Each transfer SHALL be one of the following
* - A single non-fungible/unique token.
* - The full balance held for a fungible/common token type.
*
* A single tokenReject transaction SHALL support a maximum of 10 transfers.
*
* ### Transaction Record Effects
* - Each successful transfer from `payer` to `treasury` SHALL be recorded in `token_transfer_list` for the transaction record.
*/
message TokenRejectTransactionBody {
/**
* An account holding the tokens to be rejected.<br/>
* If set, this account MUST sign this transaction.
* If not set, the payer for this transaction SHALL be the account rejecting tokens.
*/
AccountID owner = 1;

/**
* A list of one or more token rejections.<br/>
* On success each rejected token serial number or balance SHALL be transferred from
* the requesting account to the treasury account for that token type.<br/>
* After rejection the requesting account SHALL continue to be associated with the token.<br/>
* if dissociation is desired then a separate TokenDissociate transaction MUST be submitted to remove the association.
*/
repeated TokenReference rejections = 2;
}

/**
* A union token identifier.
*
* Identify a fungible/common token type, or a single non-fungible/unique token serial.
*/
message TokenReference {
oneof token_identifier {
/**
* A fungible/common token type.
*/
TokenID fungible_token = 1;

/**
* A single specific serialized non-fungible/unique token.
*/
NftID nft = 2;
}
}
17 changes: 17 additions & 0 deletions services/token_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,21 @@ service TokenService {
* Updates the NFTs in a collection by TokenID and serial number
*/
rpc updateNfts (Transaction) returns (TransactionResponse);

/**
* Reject one or more tokens.<br/>
* This transaction SHALL transfer the full balance of one or more tokens from the requesting
* account to the treasury for each token. This transfer SHALL NOT charge any custom fee or
* royalty defined for the token(s) to be rejected.<br/>
* <h3>Effects on success</h3>
* <ul>
* <li>If the rejected token is fungible/common, the requesting account SHALL have a balance
* of 0 for the rejected token. The treasury balance SHALL increase by the amount that
* the requesting account decreased.</li>
* <li>If the rejected token is non-fungible/unique the requesting account SHALL NOT hold
* the specific serialized token that is rejected. The treasury account SHALL hold each
* specific serialized token that was rejected.</li>
* </li>
*/
rpc rejectToken (Transaction) returns (TransactionResponse);
}

0 comments on commit 42b61af

Please sign in to comment.