Skip to content

fix: accept native byte arrays in the bytes arg encoder - #22

Open
scarmuega wants to merge 1 commit into
mainfrom
fix/bytes-arg-native-byte-arrays
Open

fix: accept native byte arrays in the bytes arg encoder#22
scarmuega wants to merge 1 commit into
mainfrom
fix/bytes-arg-native-byte-arrays

Conversation

@scarmuega

Copy link
Copy Markdown
Contributor

Plan

Tx3 Trellis domain plan plans/feedback-cba-04-sdks-imports-utxoref-signer-encoding.md (domain root not yet on a forge; plan ref by path). Executed by org/coder under plan dispatch — this is the python-sdk share of the fleet-wide bytes/List<Bytes> encoding fix (reference change: tx3-lang/rust-sdk#47; behavioral reference: web-sdk #36 + tx3-lang/web-sdk#38).

Done criterion (python share): the encoder accepts native bytes for byte params and emits a tagged list of byte-strings for List<Bytes> — pinned by mirrored unit tests covering the Hydra init participants/parties/head_id and Asteria pilot/ship-name shapes ((-32005) value is not bytes regression).

What changed

fix(tii) — the bytes encoder previously rejected native bytes/bytearray (the type the python codegen contract emits for Bytes params) and integer lists (the JSON shape other SDKs' native byte arrays serialize to). It now canonicalizes them to 0x-prefixed hex, per SDK spec §3.9 value marshalling.

Audit finding (in-scope audit, fix deferred to a follow-up plan)

Same fleet-wide gap as rust/web: the type-directed encoder runs only on the dynamic Invocation path; the facade TxBuilder (used by codegen-generated bindings) sends args raw. The facade param-map wiring landed in rust-sdk#47 / web-sdk#38 and is filed as a follow-up plan in the domain root for python/go parity. Ed25519Signer.from_mnemonic carries the same non-derivation defect removed from web-sdk in #38 — also in the follow-up.

Verification

  • pytest tests -m "not e2e" (python:3.11, docker): 90 passed (86 baseline + 4 new).
  • ruff check on the touched files: clean (repo-wide ruff has 12 pre-existing findings in untouched files; ruff is not in CI).

🤖 Generated with Claude Code

Native `bytes`/`bytearray` values (and integer lists — the JSON shape
other SDKs' native byte arrays serialize to) were rejected by the
encoder, so byte params could only be supplied as hex strings.
Canonicalize them to 0x-prefixed hex, per SDK spec §3.9 value
marshalling — mirroring the rust-sdk/web-sdk change.

Covers the Hydra `init` participants/parties/head_id and Asteria
create_ship pilot/ship-name shapes with regression tests
(TRP `(-32005) value is not bytes`).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant