Skip to content

refactor: use canonical types from contract interface in test-parallel-contract#2858

Merged
pbeza merged 2 commits intomainfrom
1057-mpc-contract-type-redundancy
Apr 14, 2026
Merged

refactor: use canonical types from contract interface in test-parallel-contract#2858
pbeza merged 2 commits intomainfrom
1057-mpc-contract-type-redundancy

Conversation

@pbeza
Copy link
Copy Markdown
Contributor

@pbeza pbeza commented Apr 14, 2026

Replace locally-redefined Payload, SignRequest, SignArgs, and CKDRequestArgs with canonical types from near-mpc-contract-interface, resolving the TODO(#1057) in test-parallel-contract.

Closes #1057

…l-contract (#1057)

Replace locally-redefined Payload, SignRequest, SignArgs, and
CKDRequestArgs with canonical types from near-mpc-contract-interface,
resolving the TODO(#1057) in test-parallel-contract.
@pbeza pbeza linked an issue Apr 14, 2026 that may be closed by this pull request
@pbeza pbeza marked this pull request as ready for review April 14, 2026 10:25
Copilot AI review requested due to automatic review settings April 14, 2026 10:25
@claude
Copy link
Copy Markdown

claude bot commented Apr 14, 2026

Code Review: refactor test-parallel-contract to use canonical types (#1057)

Clean refactor that replaces locally-defined types with canonical ones from near-mpc-contract-interface. Verified:

  • Serialization compatibility: Old Payload used #[serde(rename_all = "PascalCase")] + String; canonical Payload uses default PascalCase enum variants + hex_serde on BoundedVec<u8> — both produce identical JSON (hex-encoded string under "Ecdsa"/"Eddsa" keys).
  • Field optionality: Old code had Option<Payload> / Option<u64> but always passed Some(...); canonical types are non-optional — no behavioral change.
  • CKDAppPublicKey wrapping: Correctly wraps Bls12381G1PublicKey in CKDAppPublicKey::AppPublicKey() to match the canonical enum.
  • .try_into().unwrap() on SHA-256 output (always 32 bytes) converting to BoundedVec — safe since the size is guaranteed to match ECDSA_PAYLOAD_SIZE_BYTES. This is test contract code, so unwrap is acceptable per project conventions.

No critical issues found.

✅ Approved

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors test-parallel-contract to reuse canonical signing/CKD request types from near-mpc-contract-interface, eliminating locally duplicated request/payload structs and aligning the test contract’s JSON arguments with the shared interface.

Changes:

  • Replace locally defined Payload, SignRequest, and CKDRequestArgs with near_mpc_contract_interface::types::{Payload, SignRequestArgs, CKDRequestArgs, DomainId, CKDAppPublicKey}.
  • Update payload construction to operate on raw bytes (SHA-256 output) rather than pre-hex-encoded strings.
  • Remove the hex dependency from test-parallel-contract (and corresponding lockfile entry).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/test-parallel-contract/src/lib.rs Switch to canonical interface types for sign/CKD args and adapt payload/domain_id construction accordingly.
crates/test-parallel-contract/Cargo.toml Drop unused hex dependency after moving to interface Payload serialization.
Cargo.lock Remove hex from test-parallel-contract dependency list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/test-parallel-contract/src/lib.rs Outdated
Change closure signature from Fn(Vec<u8>) to Fn([u8; 32]) and use
.into() instead of .try_into().unwrap(), leveraging the infallible
From<[T; L]> impl on BoundedVec
@pbeza pbeza changed the title refactor: use canonical types from contract interface in test-parallel-contract (#1057) refactor: use canonical types from contract interface in test-parallel-contract Apr 14, 2026
@pbeza pbeza requested review from DSharifi, gilcu3 and netrome April 14, 2026 10:45
Copy link
Copy Markdown
Contributor

@gilcu3 gilcu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@pbeza pbeza enabled auto-merge April 14, 2026 11:06
@pbeza pbeza added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit e67277e Apr 14, 2026
55 of 56 checks passed
@pbeza pbeza deleted the 1057-mpc-contract-type-redundancy branch April 14, 2026 11:26
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.

MPC contract type redundancy

4 participants