Skip to content

[Intermediate]: Implement deleteContract in the TCK contract serviceย #1376

@rwalworth

Description

@rwalworth

๐Ÿ› ๏ธ Intermediate Issue

This issue is a great fit for contributors who are ready to own a solution end-to-end.

Intermediate Issues involve exploring existing patterns, reasoning about trade-offs, and choosing an implementation approach with confidence. You'll navigate multiple related files and explain your decisions in review โ€” the implementation details are yours to work out.

Important

Prerequisite: You must have completed at least 3 Beginner Issues in this repository before being assigned. The /assign bot enforces this automatically.


๐Ÿ‘พ Description of the Task

The Hiero C++ SDK TCK server does not yet implement the deleteContract JSON-RPC method. This method is required by the TCK test suite to verify that the SDK can correctly delete smart contracts on the Hedera network.

The TCK server exposes a JSON-RPC interface that maps incoming method calls to SDK transactions and queries. The contract service scaffolding (ContractService.h, ContractService.cc) either already exists (from the createContract issue) or needs to be created following the same pattern as AccountService.

Relevant files to create:

src/tck/include/contract/params/DeleteContractParams.h

Relevant files to modify:

src/tck/include/contract/ContractService.h
src/tck/src/contract/ContractService.cc
src/tck/src/TckServer.cc

Reference SDK class:

src/sdk/main/include/ContractDeleteTransaction.h

๐Ÿ’ก Proposed Approach

Follow the existing service pattern established by AccountService and TokenService:

  1. Create DeleteContractParams.h with an adl_serializer specialization to deserialize the JSON request
  2. Add the deleteContract function declaration to ContractService.h
  3. Implement deleteContract in ContractService.cc using ContractDeleteTransaction
  4. Register the method in TckServer.cc and add the explicit template instantiation

If ContractService.h and ContractService.cc do not yet exist, create them first following the pattern of AccountService.h and AccountService.cc, and ensure ContractService.cc is listed in src/tck/CMakeLists.txt.

The response should return the transaction status string only (no contractId โ€” the contract being deleted already exists).


๐Ÿ‘ฉโ€๐Ÿ’ป Implementation Steps

  • Check whether src/tck/include/contract/ContractService.h and src/tck/src/contract/ContractService.cc already exist
    • If not, create them following the pattern of AccountService.h and AccountService.cc, and add src/contract/ContractService.cc to src/tck/CMakeLists.txt
  • Create src/tck/include/contract/params/DeleteContractParams.h with the following optional fields:
    • mContractId (std::optional<std::string>) โ€” JSON key "contractId"
    • mTransferAccountId (std::optional<std::string>) โ€” JSON key "transferAccountId" (account to receive remaining balance)
    • mTransferContractId (std::optional<std::string>) โ€” JSON key "transferContractId" (contract to receive remaining balance)
    • mCommonTxParams (std::optional<CommonTransactionParams>) โ€” JSON key "commonTransactionParams"
  • Add deleteContract declaration to src/tck/include/contract/ContractService.h
  • Implement deleteContract in src/tck/src/contract/ContractService.cc:
    • Construct a ContractDeleteTransaction
    • Set setGrpcDeadline(SdkClient::DEFAULT_TCK_REQUEST_TIMEOUT)
    • Apply mContractId via ContractId::fromString if present
    • Apply mTransferAccountId via AccountId::fromString if present
    • Apply mTransferContractId via ContractId::fromString if present
    • Apply mCommonTxParams if present via fillOutTransaction
    • Execute and get the receipt; return { "status": ... }
  • Add includes, addMethod call, and explicit template instantiation for DeleteContractParams to src/tck/src/TckServer.cc
  • Build the project:
    cmake --preset linux-x64-debug && cmake --build --preset linux-x64-debug
  • Confirm the TCK server binary compiles and the new method is reachable
  • Open a pull request with the change

โœ”๏ธ Acceptance Criteria

  • DeleteContractParams.h is created following the established params pattern
  • deleteContract is declared in ContractService.h and implemented in ContractService.cc
  • deleteContract is registered in TckServer.cc with its explicit template instantiation
  • The TCK server compiles without errors or warnings introduced by this change
  • All optional params are handled correctly; missing params do not cause crashes
  • No unrelated files are modified

๐Ÿ“‹ Step-by-Step Contribution Guide

  • Comment /assign to request the issue
  • Wait for assignment
  • Fork the repository and create a branch
  • Set up the project using the instructions in README.md
  • Make the requested changes
  • Sign each commit using -s -S
  • Push your branch and open a pull request

Read Workflow Guide for step-by-step workflow guidance. Read README.md for setup instructions.

โ— Pull requests cannot be merged without S and s signed commits. See the Signing Guide.


๐Ÿค” Additional Information

  • Reference implementation pattern: src/tck/include/account/AccountService.h, src/tck/src/account/AccountService.cc
  • Reference params pattern: src/tck/include/account/params/DeleteAccountParams.h
  • TCK test file (in the hiero-sdk-tck repo): src/tests/contract-service/test-contract-delete-transaction.ts
  • SDK transaction class: src/sdk/main/include/ContractDeleteTransaction.h

If you have questions while working on this issue, feel free to ask! Hiero-SDK-C++ Discord

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: testingAdding or improving unit tests, integration tests, or test infrastructurepriority: mediumNormal priority; to be addressed in the standard development cycleskill: intermediateRequires familiarity with the codebase structure and SDK conceptsstatus: ready for devThe issue is fully defined and ready for a contributor

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      โšก