Repository navigation
feat(tck): implement executeContract JSON-RPC method - #2713
Conversation
Add the executeContract handler, ExecuteContractParams and ExecuteContractResponse to the contract TCK modules, wiring contractId, gas, amount and hex-encoded functionParameters onto ContractExecuteTransaction. ContractExecuteTransaction now rejects negative gas locally, like ContractCreateTransaction, and no longer raises when the contract ID is missing so the network can reject it with INVALID_CONTRACT_ID, matching the other SDKs and the TCK driver's expectations. Fixes hiero-ledger#2602 Signed-off-by: Ntege Daniel <danientege785@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #2713 +/- ##
=======================================
Coverage 95.67% 95.67%
=======================================
Files 169 169
Lines 11078 11080 +2
=======================================
+ Hits 10599 10601 +2
Misses 479 479 🚀 New features to boost your workflow:
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe SDK now rejects negative contract execution gas and builds transaction bodies without a contract ID. The TCK server adds ChangesContract execution TCK support
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant TCK as TCK caller
participant Params as ExecuteContractParams
participant Handler as execute_contract
participant Transaction as ContractExecuteTransaction
TCK->>Params: Parse executeContract parameters
Params->>Handler: Supply parsed parameters
Handler->>Transaction: Set contract ID, gas, amount, and function parameters
Handler->>Transaction: Execute with status validation
Transaction-->>Handler: Return receipt status
Handler-->>TCK: Return status response
Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
c4395e04-0642-443a-bf9c-47d40b49cb37
📒 Files selected for processing (6)
src/hiero_sdk_python/contract/contract_execute_transaction.pytck/handlers/contract.pytck/param/contract.pytck/response/contract.pytests/tck/contract_handler_test.pytests/unit/contract_execute_transaction_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
e1904e62-ba59-4f2a-a4d2-dc4b03de30ae
📒 Files selected for processing (4)
src/hiero_sdk_python/contract/contract_execute_transaction.pytck/handlers/contract.pytck/param/contract.pytests/tck/contract_handler_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
|
Hi, this is WorkflowBot.
|
|
please update the branch @danielmarv |
|
@danielmarv, please update the branch |
|
👋 Hi @danielmarv! Great work completing a Intermediate issue! 🎉 Thanks for your contribution! 🚀 Here are some issues you might want to explore next:
🌟 Stay connected: Happy coding! 🚀 |
Description:
Implement the
executeContractJSON-RPC method in the TCK server so the TCK driver'sContractExecuteTransactionsuite can run against the Python SDK.ExecuteContractParamsdataclass intck/param/contract.py(contractId,gas,amount,functionParameters,commonTransactionParams).ExecuteContractResponsedataclass intck/response/contract.pyextendingStatusOnlyResponse._build_execute_contract_transactionand theexecute_contracthandler intck/handlers/contract.py, following thecreateContractpattern. Call data is hex-decoded and passed straight toset_function_parameters(); no ABI encoding in the handler.ContractExecuteTransactionnow rejects negative gas withValueError("Gas cannot be negative")in the constructor andset_gas, matchingContractCreateTransaction.ContractExecuteTransactionno longer raisesValueError("Missing required ContractID")when building the body; a missing contract ID is left unset for the network to reject withINVALID_CONTRACT_ID, matchingContractDeleteTransactionand the other SDKs.tests/tck/contract_handler_test.pyandtests/unit/contract_execute_transaction_test.py.Related issue(s):
Fixes #2602
Notes for reviewer:
parameters, but the TCK driver (src/tests/contract-service/test-contract-execute-transaction.ts) and the JS TCK server sendfunctionParameters. The handler follows the driver.INVALID_CONTRACT_IDfrom the network. The SDK previously failed locally, so the request never reached the network; that check is removed (see above).INTERNAL_ERRORforgas="-1"and int64 min values. The SDK previously sent negative gas to the network; the new SDK guard raisesValueError, whichhandle_sdk_errorsmaps toINTERNAL_ERROR.CONTRACT_NEGATIVE_VALUE, as the driver expects.gas/amountraiseINVALID_PARAMS, reusing the module's existing_require_int64.uv run --extra tck pytest tests/unit tests/tck: 3378 passed).gitleaks,end-of-file-fixer,trailing-whitespace,ruff-check,ruff-format,bandit) pass.ContractExecuteTransactionsuite has not been run locally yet.Checklist