refactor: establish contract-interfac/call_args.rs as source of truth#3729
Conversation
| big_y: (&response.0.0).into(), | ||
| big_c: (&response.0.1).into(), | ||
| }, | ||
| )?; |
There was a problem hiding this comment.
note: this method never required a failure path.
Pull request overviewConsolidates all NEAR MPC contract function-call argument types into a single Changes:
Reviewed changesPer-file summary
FindingsWire compatibility looks preserved: every renamed struct keeps the same serde field names ( Non-blocking (nits):
✅ Approved |
pbeza
left a comment
There was a problem hiding this comment.
LGTM.
FWIW, re this and this PR: I had a short session with Claude to research how other teams handle this, since it seemed like a common problem. I found there’s a #[near_kit::contract] macro that generates typed call builders from a trait. Since these structs (SignatureRespondArgs, CKDRespondArgs, VotePkArgs, SubmitParticipantInfoArgs, etc.) now live in one place here, I think they're exactly the input the macro would need:
#[near_kit::contract]
pub trait MpcSigner {
#[call]
fn respond(&mut self, args: SignatureRespondArgs);
#[call]
fn respond_ckd(&mut self, args: CKDRespondArgs);
// ...vote_pk, submit_participant_info, etc.
}NEAR Intents already does this for their Wallet contract, reused as-is by both their production relayer and sandbox tests (client, sandbox reuse).
Just flagging it before the next layer (call construction / CallContract; #3727) gets built by hand, in case it saves us that work.
There was a problem hiding this comment.
Pull request overview
This PR centralizes the NEAR MPC contract function call argument DTOs in near-mpc-contract-interface (behind a new call-args feature), and updates node/TEE code to consume those types as the single source of truth, aligning with issue #3728.
Changes:
- Introduced
near-mpc-contract-interface::call_args(feature-gated viacall-args) to host contract call argument types. - Refactored
mpc-nodeandtee-contextto construct and send contract call args usingcontract_interface::call_args::*instead of node-localChain*Args. - Added serde derives where needed (e.g.,
CKDRequest) to support JSON encoding of moved call argument types.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/tee-context/src/lib.rs | Switches attestation submission args construction to contract_interface::call_args. |
| crates/tee-context/Cargo.toml | Enables near-mpc-contract-interface call-args feature for tee-context. |
| crates/node/src/trait_extensions/convert_to_contract_dto.rs | Adds conversions from node-internal request types to contract-interface DTO request types. |
| crates/node/src/tee/remote_attestation.rs | Uses contract_args::SubmitParticipantInfoArgs instead of node-local args type. |
| crates/node/src/requests/queue.rs | Updates tests to use contract_args::*RespondArgs types. |
| crates/node/src/requests/debug.rs | Updates tests to use contract_args::*RespondArgs types. |
| crates/node/src/mpc_client.rs | Uses contract_args::*RespondArgs constructors/extension traits for on-chain responses. |
| crates/node/src/migration_service/onboarding.rs | Uses contract_args::ConcludeNodeMigrationArgs for migration conclude tx. |
| crates/node/src/key_events.rs | Uses contract_args::* for key-event related contract call args. |
| crates/node/src/indexer/types.rs | Removes node-local Chain*Args DTOs; rebinds ChainSendTransactionRequest variants to contract_args DTOs and factors out recovery-id logic. |
| crates/node/src/indexer/fake.rs | Updates fake indexer plumbing to send/receive contract_args response args types. |
| crates/node/src/indexer.rs | Uses contract_args::*GetPending*Args and GetAttestationArgs for view calls. |
| crates/node/Cargo.toml | Enables near-mpc-contract-interface call-args feature for node. |
| crates/near-mpc-crypto-types/src/ckd.rs | Adds Serialize/Deserialize to CKDRequest so it can be used in JSON call args. |
| crates/near-mpc-contract-interface/src/types/attestation.rs | Removes SubmitParticipantInfoArgs from types (it’s now in call_args). |
| crates/near-mpc-contract-interface/src/lib.rs | Exposes call_args module behind call-args feature; stops re-exporting removed args from types. |
| crates/near-mpc-contract-interface/src/call_args.rs | Adds the new centralized contract call argument DTO module. |
| crates/near-mpc-contract-interface/Cargo.toml | Introduces the call-args feature flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Oh, that's very cool! I need to check if we can make this work with all the other stuff we use. Do you know how stable |
Not totally sure, but if NEAR Intents is using it, and that’s apparently one of NEAR’s core products, I’d guess it’s stable enough. Also looks like they’ve been releasing pretty regularly for the last ~5 months: https://crates.io/crates/near-kit/versions. We can ask Ricky, who seems to be |
0ae8a0c to
9af5463
Compare
resolves #3728
ci blocked by #3730