Skip to content

Implement updateFile JSON-RPC method #18

Description

@aceppaluni

Problem

The TCK server does not implement updateFile, so the TCK driver's FileUpdateTransaction suite cannot run against the Python SDK. The SDK transaction (src/hiero_sdk_python/file/file_update_transaction.py) already exists with all needed setters: set_file_id, set_keys, set_expiration_time, set_contents, set_file_memo.

Blocked by hiero-ledger#2488 (createFile) — this handler goes in the file-service TCK modules hiero-ledger#2488 creates, and the driver needs a created file to update. Use hiero-ledger#2489 (getFileContents) / hiero-ledger#2490 (getFileInfo) to verify update results end-to-end.

Solution

Add an updateFile handler wrapping FileUpdateTransaction. Structurally identical to the createFile handler from hiero-ledger#2488, plus fileId, returning status only.

Method contract (from the spec): all inputs optional.

Input Type Notes
fileId string File to update
keys string[] DER-encoded hex; threshold keys not allowed for update (unlike create)
contents string New contents; empty string means "leave unchanged"
expirationTime string Seconds since epoch; must be strictly later than current
memo string UTF-8, max 100 bytes
commonTransactionParams object

Output: status — reuse StatusOnlyResponse from tck/response/base.py; no new response class needed.

Implementation steps:

  1. Add UpdateFileParams(BaseTransactionParams) to tck/param/file.py — mirror CreateFileParams plus fileId.
  2. Add the handler to tck/handlers/file.py: parse fileId via FileId.from_string(), map the rest as in createFile, execute, return StatusOnlyResponse(ResponseCode(receipt.status).name).
  3. Add a unit test under tests/tck/.

Details that matter:

  • contents="" must NOT clear the file. Per the spec, empty string means content unchanged — so parse with non_empty_string_or_none() (tck/util/param_utils.py) so "" becomes None and set_contents is never called with it. Add a comment explaining this, since it looks like a bug otherwise.
  • expirationTime validation is server-side — the network rejects non-increasing values; don't validate client-side, let the error propagate.
  • Threshold keys are disallowed by the spec for update but get_key_from_string() won't reject them — the network will. Acceptable; note it in the PR.
  • Only call setters for non-None params: the spec distinguishes omitted fields (unchanged) from set fields.

Acceptance criteria

  • updateFile registered and dispatchable
  • contents="" leaves file content unchanged (verified via getFileContents)
  • All inputs mapped; omitted params leave fields untouched
  • Invalid fileId format → SDK internal error; non-existent ID → network INVALID_FILE_ID
  • Unit test added; uv run pytest tests/tck -q passes

Spec: https://github.com/hiero-ledger/hiero-sdk-tck/blob/main/docs/test-specifications/file-service/FileUpdateTransaction.md

JS reference: https://github.com/hiero-ledger/hiero-sdk-js/blob/main/tck/methods/file.ts (updateFile)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions