From 9269cb1ae1ff8d5873c3820e84066e91a0195345 Mon Sep 17 00:00:00 2001 From: Harsh Sawarkar Date: Fri, 21 Feb 2025 23:24:50 +0530 Subject: [PATCH 1/2] Updated the Rest endpoints in /transaction and /transaction/id to have max_custom_fees. Signed-off-by: Harsh Sawarkar --- .../__tests__/integrationDomainOps.js | 1 + .../account-id-deterministic-response.json | 2 + .../account-id-only-token-transfers.json | 12 +++ .../specs/transactions/account-id.json | 14 +++ .../specs/transactions/all-params.json | 3 + ...redit-type-crypto-and-token-transfers.json | 3 + .../credit-type-only-token-transfers.json | 1 + .../specs/transactions/credit-type.json | 3 + ...debit-type-crypto-and-token-transfers.json | 1 + .../debit-type-only-token-transfers.json | 1 + .../specs/transactions/debit-type.json | 1 + .../duplicate-token-transfers-bug.json | 1 + .../specs/transactions/fail-result.json | 2 + .../__tests__/specs/transactions/limit.json | 6 ++ .../specs/transactions/nft-transfers.json | 1 + .../specs/transactions/no-params.json | 6 ++ .../specs/transactions/success-result.json | 3 + .../transactions/timestamp-no-transfers.json | 1 + .../specs/transactions/timestamp.json | 4 + .../specs/transactions/tokenwipe.json | 1 + .../specs/transactions/transactiontype.json | 9 ++ .../specs/transactions/unknown-result.json | 1 + ...fees-with-effective-payer-account-ids.json | 1 + .../{id}/assessed-custom-fees.json | 12 +++ .../{id}/duplicate-schedule-create.json | 2 + .../{id}/duplicate-transactions.json | 2 + .../{id}/nft-transfers-multiple-tokens.json | 1 + .../transactions/{id}/nft-transfers.json | 1 + .../specs/transactions/{id}/no-params.json | 4 + .../specs/transactions/{id}/no-transfers.json | 1 + .../specs/transactions/{id}/nonce.json | 1 + .../repeated-valid-params-schedule-false.json | 2 + .../repeated-valid-params-schedule-true.json | 1 + .../{id}/return-multiple-nonce.json | 2 + .../scheduled-create-shorter-max-age.json | 1 + .../transactions/{id}/scheduled-false.json | 2 + .../{id}/scheduled-long-term.json | 4 + .../{id}/scheduled-no-filter.json | 2 + .../transactions/{id}/scheduled-true.json | 1 + .../transactions/{id}/tokentransfer.json | 1 + .../specs/transactions/{id}/tokenwipe.json | 1 + .../__tests__/transactions.test.js | 5 + .../viewmodel/customFeeLimitViewModel.test.js | 99 +++++++++++++++++++ hedera-mirror-rest/api/v1/openapi.yml | 16 +++ hedera-mirror-rest/model/customFeeLimit.js | 41 ++++++++ hedera-mirror-rest/model/transaction.js | 7 ++ hedera-mirror-rest/package.json | 1 - hedera-mirror-rest/transactions.js | 22 +++++ .../viewmodel/customFeeLimitViewModel.js | 31 ++++++ 49 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 hedera-mirror-rest/__tests__/viewmodel/customFeeLimitViewModel.test.js create mode 100644 hedera-mirror-rest/model/customFeeLimit.js create mode 100644 hedera-mirror-rest/viewmodel/customFeeLimitViewModel.js diff --git a/hedera-mirror-rest/__tests__/integrationDomainOps.js b/hedera-mirror-rest/__tests__/integrationDomainOps.js index 27b848a984a..19c2dee2513 100644 --- a/hedera-mirror-rest/__tests__/integrationDomainOps.js +++ b/hedera-mirror-rest/__tests__/integrationDomainOps.js @@ -866,6 +866,7 @@ const defaultTransaction = { charged_tx_fee: NODE_FEE + NETWORK_FEE + SERVICE_FEE, consensus_timestamp: null, entity_id: null, + max_custom_fees: null, max_fee: 33, nft_transfer: null, node_account_id: null, diff --git a/hedera-mirror-rest/__tests__/specs/transactions/account-id-deterministic-response.json b/hedera-mirror-rest/__tests__/specs/transactions/account-id-deterministic-response.json index e93a6cc7b0a..3fde1b2336c 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/account-id-deterministic-response.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/account-id-deterministic-response.json @@ -82,6 +82,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779604.000000002", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -120,6 +121,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779603.000000002", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/account-id-only-token-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/account-id-only-token-transfers.json index 2d15b9913da..b166634c18b 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/account-id-only-token-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/account-id-only-token-transfers.json @@ -67,6 +67,18 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [ + { + "account_id": "0.0.8", + "amount": 1000, + "denominating_token_id": null + }, + { + "account_id": "0.0.9", + "amount": 500, + "denominating_token_id": "0.0.2000" + } + ], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/account-id.json b/hedera-mirror-rest/__tests__/specs/transactions/account-id.json index 4781bf5c337..f530d42ffb7 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/account-id.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/account-id.json @@ -138,6 +138,7 @@ "consensus_timestamp": "1565779444.711927004", "entity_id": "0.0.900", "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOCREATEACCOUNT", "nft_transfers": [], @@ -176,6 +177,7 @@ "consensus_timestamp": "1565779444.711927003", "entity_id": "0.0.8", "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", "nft_transfers": [], @@ -214,6 +216,7 @@ "consensus_timestamp": "1565779444.711927001", "entity_id": "0.0.8", "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", "nft_transfers": [], @@ -252,6 +255,7 @@ "consensus_timestamp": "1565779400.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -295,6 +299,7 @@ "consensus_timestamp": "1565779333.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -333,6 +338,7 @@ "consensus_timestamp": "1565779209.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -386,6 +392,7 @@ "consensus_timestamp": "1565779500.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -429,6 +436,7 @@ "consensus_timestamp": "1565779444.711927004", "entity_id": "0.0.900", "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOCREATEACCOUNT", "nft_transfers": [], @@ -467,6 +475,7 @@ "consensus_timestamp": "1565779444.711927003", "entity_id": "0.0.8", "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", "nft_transfers": [], @@ -505,6 +514,7 @@ "consensus_timestamp": "1565779444.711927001", "entity_id": "0.0.8", "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", "nft_transfers": [], @@ -543,6 +553,7 @@ "consensus_timestamp": "1565779400.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -586,6 +597,7 @@ "consensus_timestamp": "1565779333.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -624,6 +636,7 @@ "consensus_timestamp": "1565779209.711927001", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], @@ -661,6 +674,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779111.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/all-params.json b/hedera-mirror-rest/__tests__/specs/transactions/all-params.json index 2d66bf97d4a..7afe4a9400b 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/all-params.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/all-params.json @@ -87,6 +87,7 @@ "valid_start_timestamp": "1565779209.711927000", "charged_tx_fee": 7, "memo_base64": null, + "max_custom_fees": [], "result": "SUCCESS", "scheduled": false, "staking_reward_transfers": [], @@ -135,6 +136,7 @@ "entity_id": null, "valid_start_timestamp": "1565779209.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS", "scheduled": false, @@ -172,6 +174,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779666.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/credit-type-crypto-and-token-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/credit-type-crypto-and-token-transfers.json index d3eb93f256b..af26b0565e7 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/credit-type-crypto-and-token-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/credit-type-crypto-and-token-transfers.json @@ -128,6 +128,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000005", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -185,6 +186,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000003", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -223,6 +225,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/credit-type-only-token-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/credit-type-only-token-transfers.json index 072597b8cc7..8f776de0b4b 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/credit-type-only-token-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/credit-type-only-token-transfers.json @@ -91,6 +91,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/credit-type.json b/hedera-mirror-rest/__tests__/specs/transactions/credit-type.json index 6a87fa0f7f2..1ec4db88bcb 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/credit-type.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/credit-type.json @@ -81,6 +81,7 @@ "valid_start_timestamp": "1565779333.711927000", "charged_tx_fee": 7, "memo_base64": null, + "max_custom_fees": [], "result": "FAIL_BALANCE", "scheduled": false, "staking_reward_transfers": [], @@ -118,6 +119,7 @@ "entity_id": null, "valid_start_timestamp": "1565779209.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS", "scheduled": false, @@ -156,6 +158,7 @@ "entity_id": null, "valid_start_timestamp": "1565779111.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "FAIL_FEE", "scheduled": false, diff --git a/hedera-mirror-rest/__tests__/specs/transactions/debit-type-crypto-and-token-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/debit-type-crypto-and-token-transfers.json index f95fc0ba0de..86f0616ed8f 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/debit-type-crypto-and-token-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/debit-type-crypto-and-token-transfers.json @@ -130,6 +130,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000005", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/debit-type-only-token-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/debit-type-only-token-transfers.json index e37e13034ba..f430a48f2c2 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/debit-type-only-token-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/debit-type-only-token-transfers.json @@ -90,6 +90,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/debit-type.json b/hedera-mirror-rest/__tests__/specs/transactions/debit-type.json index b8e81d821ba..f728c17a0a9 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/debit-type.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/debit-type.json @@ -68,6 +68,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779209.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/duplicate-token-transfers-bug.json b/hedera-mirror-rest/__tests__/specs/transactions/duplicate-token-transfers-bug.json index 8750efa02a8..7ff6483b9d7 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/duplicate-token-transfers-bug.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/duplicate-token-transfers-bug.json @@ -95,6 +95,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/fail-result.json b/hedera-mirror-rest/__tests__/specs/transactions/fail-result.json index 0dd93824181..61ef189ad0d 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/fail-result.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/fail-result.json @@ -70,6 +70,7 @@ "valid_start_timestamp": "1565779333.711927000", "charged_tx_fee": 7, "memo_base64": null, + "max_custom_fees": [], "result": "FAIL_BALANCE", "scheduled": false, "staking_reward_transfers": [], @@ -107,6 +108,7 @@ "entity_id": null, "valid_start_timestamp": "1565779111.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "FAIL_FEE", "scheduled": false, diff --git a/hedera-mirror-rest/__tests__/specs/transactions/limit.json b/hedera-mirror-rest/__tests__/specs/transactions/limit.json index 7ec57d4a0a5..3b66461fe8e 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/limit.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/limit.json @@ -109,6 +109,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779666.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -147,6 +148,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779600.711927001", "entity_id": "0.0.8", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", @@ -196,6 +198,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779666.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -234,6 +237,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779600.711927001", "entity_id": "0.0.8", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", @@ -272,6 +276,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779555.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -329,6 +334,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779333.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/nft-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/nft-transfers.json index 3b71c800f73..e1c2cba0f05 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/nft-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/nft-transfers.json @@ -65,6 +65,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/no-params.json b/hedera-mirror-rest/__tests__/specs/transactions/no-params.json index 9a445d6bb72..a5d0d4405d2 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/no-params.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/no-params.json @@ -99,6 +99,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000005", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -137,6 +138,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000004", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -188,6 +190,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000003", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -226,6 +229,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000002", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -264,6 +268,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -301,6 +306,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567800.000000009", "entity_id": "0.0.10", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/success-result.json b/hedera-mirror-rest/__tests__/specs/transactions/success-result.json index dbeab949432..f75448b1490 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/success-result.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/success-result.json @@ -79,6 +79,7 @@ "entity_id": null, "valid_start_timestamp": "1565779777.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS_BUT_MISSING_EXPECTED_OPERATION", "scheduled": false, @@ -117,6 +118,7 @@ "entity_id": null, "valid_start_timestamp": "1565779666.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "FEE_SCHEDULE_FILE_PART_UPLOADED", "scheduled": false, @@ -155,6 +157,7 @@ "entity_id": null, "valid_start_timestamp": "1565779209.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS", "scheduled": false, diff --git a/hedera-mirror-rest/__tests__/specs/transactions/timestamp-no-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/timestamp-no-transfers.json index 111797ff98c..0ba7d8e50b5 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/timestamp-no-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/timestamp-no-transfers.json @@ -61,6 +61,7 @@ "charged_tx_fee": 0, "consensus_timestamp": "1565779209.711927001", "entity_id": "0.0.8", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/timestamp.json b/hedera-mirror-rest/__tests__/specs/transactions/timestamp.json index 7b5a8f3466a..3eb527e0e8b 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/timestamp.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/timestamp.json @@ -63,6 +63,7 @@ "entity_id": null, "valid_start_timestamp": "1565779209.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS", "scheduled": false, @@ -114,6 +115,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779333.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -153,6 +155,7 @@ "entity_id": null, "valid_start_timestamp": "1565779209.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS", "scheduled": false, @@ -207,6 +210,7 @@ "entity_id": null, "valid_start_timestamp": "1565779333.711927000", "charged_tx_fee": 7, + "max_custom_fees": [], "memo_base64": null, "result": "SUCCESS", "scheduled": false, diff --git a/hedera-mirror-rest/__tests__/specs/transactions/tokenwipe.json b/hedera-mirror-rest/__tests__/specs/transactions/tokenwipe.json index c927321ccf2..6e23f728a33 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/tokenwipe.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/tokenwipe.json @@ -51,6 +51,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": "0.0.90000", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "TOKENWIPE", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/transactiontype.json b/hedera-mirror-rest/__tests__/specs/transactions/transactiontype.json index 42b3369c52c..96560c21f84 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/transactiontype.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/transactiontype.json @@ -84,6 +84,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779666.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -122,6 +123,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779333.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -160,6 +162,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779209.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -198,6 +201,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779111.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -247,6 +251,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779666.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -285,6 +290,7 @@ "charged_tx_fee": 0, "consensus_timestamp": "1565779444.711927001", "entity_id": "0.0.8", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "TOKENUPDATENFTS", @@ -307,6 +313,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779333.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -345,6 +352,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779209.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -383,6 +391,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779111.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/unknown-result.json b/hedera-mirror-rest/__tests__/specs/transactions/unknown-result.json index 33443b5ac11..92cece48257 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/unknown-result.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/unknown-result.json @@ -43,6 +43,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779111.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees-with-effective-payer-account-ids.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees-with-effective-payer-account-ids.json index 702009b4331..45196017b5c 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees-with-effective-payer-account-ids.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees-with-effective-payer-account-ids.json @@ -82,6 +82,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779555.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees.json index 153efc32bf5..9c7ee5544dc 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/assessed-custom-fees.json @@ -76,6 +76,18 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779555.711927001", "entity_id": null, + "max_custom_fees": [ + { + "account_id": "0.0.8", + "amount": 1000, + "denominating_token_id": null + }, + { + "account_id": "0.0.9", + "amount": 500, + "denominating_token_id": "0.0.2000" + } + ], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-schedule-create.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-schedule-create.json index 83fab6b4ef1..204a98233ee 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-schedule-create.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-schedule-create.json @@ -78,6 +78,7 @@ "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -111,6 +112,7 @@ "consensus_timestamp": "1234567890.000000004", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-transactions.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-transactions.json index d086c77529e..0aac89a0758 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-transactions.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/duplicate-transactions.json @@ -87,6 +87,7 @@ "consensus_timestamp": "1234567890.000000040", "charged_tx_fee": 20, "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -130,6 +131,7 @@ "consensus_timestamp": "1234567891.000000123", "charged_tx_fee": 15, "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers-multiple-tokens.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers-multiple-tokens.json index c3f3d1eb4e2..cd69f4f14a0 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers-multiple-tokens.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers-multiple-tokens.json @@ -76,6 +76,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers.json index 5a7411f5ea9..71d2d39f6be 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/nft-transfers.json @@ -63,6 +63,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-params.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-params.json index 5700d98b100..b7862c66b12 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-params.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-params.json @@ -187,6 +187,7 @@ "consensus_timestamp": "1234567890.000000002", "charged_tx_fee": 7, "entity_id": "0.0.100", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -220,6 +221,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000003", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -258,6 +260,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000040", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -303,6 +306,7 @@ "consensus_timestamp": "1234567890.000000002", "charged_tx_fee": 7, "entity_id": "0.0.100", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-transfers.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-transfers.json index 13ce4d415e7..20fbdb78f9e 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-transfers.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/no-transfers.json @@ -38,6 +38,7 @@ "charged_tx_fee": 0, "consensus_timestamp": "1234567890.999999999", "entity_id": "0.0.9", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOUPDATEACCOUNT", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/nonce.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/nonce.json index 0d3c8f0234c..f8dbac8dc0f 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/nonce.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/nonce.json @@ -95,6 +95,7 @@ "charged_tx_fee": 8, "consensus_timestamp": "1234567890.000000045", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-false.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-false.json index 30032720d35..0009a2a0e11 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-false.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-false.json @@ -80,6 +80,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -114,6 +115,7 @@ "consensus_timestamp": "1234567890.000000040", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-true.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-true.json index 20e69b45ec8..718ee8c2146 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-true.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/repeated-valid-params-schedule-true.json @@ -80,6 +80,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000003", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/return-multiple-nonce.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/return-multiple-nonce.json index 0dec11b7a6a..6822e04e0f0 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/return-multiple-nonce.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/return-multiple-nonce.json @@ -90,6 +90,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000040", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -156,6 +157,7 @@ "charged_tx_fee": 9, "consensus_timestamp": "1234567890.000000050", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-create-shorter-max-age.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-create-shorter-max-age.json index 267eeded8e1..6a12396534c 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-create-shorter-max-age.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-create-shorter-max-age.json @@ -54,6 +54,7 @@ "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-false.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-false.json index e9c76d38c6c..30fc872558e 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-false.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-false.json @@ -86,6 +86,7 @@ "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -120,6 +121,7 @@ "consensus_timestamp": "1234567890.000000040", "entity_id": null, "max_fee": "33", + "max_custom_fees": [], "memo_base64": null, "name": "CRYPTOTRANSFER", "nft_transfers": [], diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-long-term.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-long-term.json index 0e6aca463cb..68a39554800 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-long-term.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-long-term.json @@ -49,6 +49,7 @@ "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -82,6 +83,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1237159890.000000002", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", @@ -128,6 +130,7 @@ "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -169,6 +172,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1237159890.000000002", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-no-filter.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-no-filter.json index c4068344ddd..47d2f4a2f6b 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-no-filter.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-no-filter.json @@ -47,6 +47,7 @@ "consensus_timestamp": "1234567890.000000002", "entity_id": "0.0.1000", "charged_tx_fee": 7, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "SCHEDULECREATE", @@ -80,6 +81,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000003", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-true.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-true.json index 8a9bf7cc7e8..59acb446dc4 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-true.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/scheduled-true.json @@ -74,6 +74,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000003", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokentransfer.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokentransfer.json index 7c6d643d827..9481e9f4c4c 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokentransfer.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokentransfer.json @@ -54,6 +54,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1565779555.711927001", "entity_id": null, + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "CRYPTOTRANSFER", diff --git a/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokenwipe.json b/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokenwipe.json index 274a9456a13..0e3b11ab0a9 100644 --- a/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokenwipe.json +++ b/hedera-mirror-rest/__tests__/specs/transactions/{id}/tokenwipe.json @@ -42,6 +42,7 @@ "charged_tx_fee": 7, "consensus_timestamp": "1234567890.000000001", "entity_id": "0.0.90000", + "max_custom_fees": [], "max_fee": "33", "memo_base64": null, "name": "TOKENWIPE", diff --git a/hedera-mirror-rest/__tests__/transactions.test.js b/hedera-mirror-rest/__tests__/transactions.test.js index de8f68f0637..4eae4cdb96d 100644 --- a/hedera-mirror-rest/__tests__/transactions.test.js +++ b/hedera-mirror-rest/__tests__/transactions.test.js @@ -276,6 +276,7 @@ describe('formatTransactionRows', () => { entity_id: 98, memo: null, charged_tx_fee: 5, + max_custom_fees: [], max_fee: 33, nonce: 0, parent_consensus_timestamp: null, @@ -297,6 +298,7 @@ describe('formatTransactionRows', () => { entity_id: 100, memo: null, charged_tx_fee: 5, + max_custom_fees: [], max_fee: 33, nonce: 1, parent_consensus_timestamp: 1, @@ -346,6 +348,7 @@ describe('formatTransactionRows', () => { consensus_timestamp: '0.000000001', charged_tx_fee: 5, entity_id: '0.0.98', + max_custom_fees: [], max_fee: '33', memo_base64: null, name: 'CRYPTOTRANSFER', @@ -375,6 +378,7 @@ describe('formatTransactionRows', () => { consensus_timestamp: '0.000000002', charged_tx_fee: 5, entity_id: '0.0.100', + max_custom_fees: [], max_fee: '33', memo_base64: null, name: 'CRYPTOTRANSFER', @@ -419,6 +423,7 @@ describe('extractSqlFromTransactionsByIdOrHashRequest', () => { t.charged_tx_fee, t.consensus_timestamp, t.entity_id, + t.max_custom_fees, t.max_fee, t.memo, t.nft_transfer, diff --git a/hedera-mirror-rest/__tests__/viewmodel/customFeeLimitViewModel.test.js b/hedera-mirror-rest/__tests__/viewmodel/customFeeLimitViewModel.test.js new file mode 100644 index 00000000000..e150631d0db --- /dev/null +++ b/hedera-mirror-rest/__tests__/viewmodel/customFeeLimitViewModel.test.js @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2021-2025 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 CustomFeeLimitViewModel from '../../viewmodel/CustomFeeLimitViewModel'; + +describe('CustomFeeLimitViewModel', () => { + const testCases = [ + { + name: 'Single fixed fee', + input: [ + { + accountId: '0.0.1234', + fixedFees: [{amount: 100, denominatingTokenId: '0.0.5678'}], + }, + ], + expected: { + max_custom_fees: [ + { + account_id: '0.0.1234', + amount: 100, + denominating_token_id: '0.0.5678', + }, + ], + }, + }, + { + name: 'Multiple fixed fees', + input: [ + { + accountId: '0.0.1234', + fixedFees: [{amount: 100, denominatingTokenId: '0.0.5678'}], + }, + { + accountId: '0.0.4321', + fixedFees: [{amount: 200, denominatingTokenId: null}], + }, + ], + expected: { + max_custom_fees: [ + { + account_id: '0.0.1234', + amount: 100, + denominating_token_id: '0.0.5678', + }, + { + account_id: '0.0.4321', + amount: 200, + denominating_token_id: null, + }, + ], + }, + }, + { + name: 'Fixed fee with missing fields', + input: [ + { + accountId: '0.0.5555', + fixedFees: [{}], + }, + ], + expected: { + max_custom_fees: [ + { + account_id: '0.0.5555', + amount: 0, // Default value when amount is missing + denominating_token_id: null, // Default value when token ID is missing + }, + ], + }, + }, + { + name: 'Empty input', + input: [], + expected: { + max_custom_fees: [], + }, + }, + ]; + + testCases.forEach(({name, input, expected}) => { + test(name, () => { + const actual = new CustomFeeLimitViewModel(input); + expect(actual).toEqual(expected); + }); + }); +}); diff --git a/hedera-mirror-rest/api/v1/openapi.yml b/hedera-mirror-rest/api/v1/openapi.yml index b6c3074339b..9ae7627d377 100644 --- a/hedera-mirror-rest/api/v1/openapi.yml +++ b/hedera-mirror-rest/api/v1/openapi.yml @@ -2694,6 +2694,17 @@ components: $ref: "#/components/schemas/EntityId" denominating_token_id: $ref: "#/components/schemas/EntityId" + CustomFeeLimit: + type: object + properties: + account_id: + $ref: "#/components/schemas/EntityId" + amount: + example: 100 + format: int64 + type: integer + denominating_token_id: + $ref: "#/components/schemas/EntityId" FractionalFee: type: object properties: @@ -3762,6 +3773,11 @@ components: $ref: "#/components/schemas/EntityId" max_fee: type: string + max_custom_fees: + type: array + nullable: true + items: + $ref: "#/components/schemas/CustomFeeLimit" memo_base64: format: byte nullable: true diff --git a/hedera-mirror-rest/model/customFeeLimit.js b/hedera-mirror-rest/model/customFeeLimit.js new file mode 100644 index 00000000000..c084ece42fa --- /dev/null +++ b/hedera-mirror-rest/model/customFeeLimit.js @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2021-2025 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 {proto} from '@hashgraph/proto'; +import {FileDecodeError} from '../errors/index.js'; +import FixedFee from './fixedFee.js'; + +class CustomFeeLimit { + /** + * Parses an array of serialized CustomFeeLimit messages from transaction.max_custom_fees + * @param {Buffer[]} customFeeLimits - An array of byte arrays representing serialized CustomFeeLimit messages. + */ + constructor(customFeeLimits) { + this.fees = customFeeLimits.map((feeBytes) => { + try { + const customFeeLimitSet = proto.CustomFeeLimit.decode(feeBytes); + return { + accountId: customFeeLimitSet.accountId, + fixedFees: (customFeeLimitSet.fees ?? []).map((fee) => new FixedFee(fee)), + }; + } catch (error) { + throw new FileDecodeError(error.message); + } + }); + } +} + +export default CustomFeeLimit; diff --git a/hedera-mirror-rest/model/transaction.js b/hedera-mirror-rest/model/transaction.js index d16473bd520..179bc0dad61 100644 --- a/hedera-mirror-rest/model/transaction.js +++ b/hedera-mirror-rest/model/transaction.js @@ -16,6 +16,8 @@ import {filterKeys} from '../constants'; import NftTransfer from './nftTransfer'; +import CustomFeeLimit from './customFeeLimit.js'; +import TransactionType from './transactionType.js'; class Transaction { static BASE64_HASH_SIZE = 64; @@ -30,6 +32,7 @@ class Transaction { static ENTITY_ID = `entity_id`; static INITIAL_BALANCE = `initial_balance`; static MAX_FEE = `max_fee`; + static MAX_CUSTOM_FEES = `max_custom_fees`; static MEMO = `memo`; static NFT_TRANSFER = 'nft_transfer'; static NODE_ACCOUNT_ID = `node_account_id`; @@ -57,6 +60,10 @@ class Transaction { this.entityId = transaction.entity_id; this.initialBalance = transaction.initial_balance; this.maxFee = transaction.max_fee; + this.maxCustomFee = + transaction.type === TransactionType.getName(27) + ? (transaction.max_custom_fees ?? []).map((n) => new CustomFeeLimit(n)) + : []; this.memo = transaction.memo; this.nftTransfer = (transaction.nft_transfer ?? []).map((n) => new NftTransfer(n)); this.nodeAccountId = transaction.node_account_id; diff --git a/hedera-mirror-rest/package.json b/hedera-mirror-rest/package.json index 44901f2c7e9..e16d1a93062 100644 --- a/hedera-mirror-rest/package.json +++ b/hedera-mirror-rest/package.json @@ -12,7 +12,6 @@ "dev": "HEDERA_MIRROR_REST_LOG_LEVEL=trace nodemon --experimental-specifier-resolution=node server.js", "lint": "eslint --ignore-pattern node_modules/ --fix .", "start": "node --experimental-specifier-resolution=node server.js", - "pretest": "node --experimental-specifier-resolution=node __tests__/integration/generator.js", "test": "node --experimental-specifier-resolution=node --experimental-vm-modules node_modules/jest/bin/jest.js" }, "author": "Hedera Mirror Node Team", diff --git a/hedera-mirror-rest/transactions.js b/hedera-mirror-rest/transactions.js index 9229dc60aac..426882a456c 100644 --- a/hedera-mirror-rest/transactions.js +++ b/hedera-mirror-rest/transactions.js @@ -38,6 +38,8 @@ import { } from './model'; import {AssessedCustomFeeViewModel, NftTransferViewModel} from './viewmodel'; +import CustomFeeLimit from './model/customFeeLimit.js'; +import CustomFeeLimitViewModel from './viewmodel/customFeeLimitViewModel.js'; const SUCCESS_PROTO_IDS = TransactionResult.getSuccessProtoIds(); @@ -62,6 +64,7 @@ const transactionFields = [ Transaction.CONSENSUS_TIMESTAMP, Transaction.ENTITY_ID, Transaction.MAX_FEE, + Transaction.MAX_CUSTOM_FEES, Transaction.MEMO, Transaction.NFT_TRANSFER, Transaction.NODE_ACCOUNT_ID, @@ -178,6 +181,24 @@ const createNftTransferList = (nftTransferList) => { }); }; +/** + * Creates a custom fee limit transfer list from an aggregated array of JSON objects in the query result + * + * @param {Object[]} maxCustomFeesList - The list of max custom fees + * @return {CustomFeeLimitViewModel[]} An array of custom fee limit view models + */ +const createMaxCustomFeesTransferList = (maxCustomFeesList) => { + if (!maxCustomFeesList || maxCustomFeesList.length === 0) { + return []; + } + + return maxCustomFeesList.map((fee) => { + const feeBuffers = Array.isArray(fee) ? fee.map((f) => Buffer.from(f)) : [Buffer.from(fee)]; + const customFeeLimit = new CustomFeeLimit(feeBuffers); + return new CustomFeeLimitViewModel([customFeeLimit]); + }); +}; + /** * Format the output of the SQL query as an array of transaction objects per the view model. * @@ -196,6 +217,7 @@ const formatTransactionRows = async (rows) => { consensus_timestamp: utils.nsToSecNs(row.consensus_timestamp), entity_id: EntityId.parse(row.entity_id, {isNullable: true}).toString(), max_fee: utils.getNullableNumber(row.max_fee), + max_custom_fees: createMaxCustomFeesTransferList(row.max_custom_fees), memo_base64: utils.encodeBase64(row.memo), name: TransactionType.getName(row.type), nft_transfers: createNftTransferList(row.nft_transfer), diff --git a/hedera-mirror-rest/viewmodel/customFeeLimitViewModel.js b/hedera-mirror-rest/viewmodel/customFeeLimitViewModel.js new file mode 100644 index 00000000000..471c63c309f --- /dev/null +++ b/hedera-mirror-rest/viewmodel/customFeeLimitViewModel.js @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019-2025 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. + */ + +class CustomFeeLimitViewModel { + /** + * Formats the CustomFeeLimit data for API response. + * @param {Object[]} fees - Array of parsed CustomFeeLimit objects. + */ + constructor(fees) { + this.max_custom_fees = fees.map((fee) => ({ + account_id: fee.accountId, + amount: fee.fixedFees[0]?.amount || 0, + denominating_token_id: fee.fixedFees[0]?.denominatingTokenId || null, + })); + } +} + +export default CustomFeeLimitViewModel; From 8c886f6905b95caf73676deb0fa202e693841315 Mon Sep 17 00:00:00 2001 From: Harsh Sawarkar Date: Fri, 21 Feb 2025 23:36:23 +0530 Subject: [PATCH 2/2] Updated the Rest endpoints in /transaction and /transaction/id to have max_custom_fees. Signed-off-by: Harsh Sawarkar --- hedera-mirror-rest/api/v1/openapi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hedera-mirror-rest/api/v1/openapi.yml b/hedera-mirror-rest/api/v1/openapi.yml index 9ae7627d377..89a49c30cd4 100644 --- a/hedera-mirror-rest/api/v1/openapi.yml +++ b/hedera-mirror-rest/api/v1/openapi.yml @@ -3771,13 +3771,13 @@ components: $ref: "#/components/schemas/Timestamp" entity_id: $ref: "#/components/schemas/EntityId" - max_fee: - type: string max_custom_fees: type: array nullable: true items: $ref: "#/components/schemas/CustomFeeLimit" + max_fee: + type: string memo_base64: format: byte nullable: true