Skip to content

Replace hard-coded contract method strings with a typed enum #950

@kevindeforth

Description

@kevindeforth

Background

Today the MPC node calls NEAR contract methods using string literals, e.g.:

method_name: "get_pending_request".to_string(),

This is error-prone (typos, refactors) and makes it hard to identify the methods our node relies on.

Proposed approach:

  • Introduce an enum ContractInterface as the single source of truth for method names.
  • Provide as_str() and Display for ergonomic use and logging.
  • Add an integration test that probes a contract for a method’s availability (e.g., try a call)
  • Replace existing string literals at call sites with ContractMethod::X.as_str().
  • Centralize all mappings in one module (e.g., node/src/contracts/methods.rs).

User Story

As an MPC node developer/operator, I want contract method names to be defined in a single, typed place.

Acceptance Criteria

  • The contract API required by the node is centralized in a single file.
  • all existing string literals for method names of the contract are replaced with enum usage.
  • an integration test exists, checking if the methods are available on the contract.

Resources & Additional Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions