From 17a007565d9f55f682acc942a3d08f36cb6eb0e3 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Sun, 30 Jun 2024 12:53:32 +0300 Subject: [PATCH] feat: add name method to builtin enum --- src/transaction.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/transaction.rs b/src/transaction.rs index d4a1d2af..a2190a1d 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -944,3 +944,27 @@ pub enum Builtin { #[serde(rename = "segment_arena_builtin")] SegmentArena, } + +const RANGE_CHACK_BUILTIN_NAME: &str = "range_check"; +const PEDERSEN_BUILTIN_NAME: &str = "pedersen"; +const POSEIDON_BUILTIN_NAME: &str = "poseidon"; +const EC_OP_BUILTIN_NAME: &str = "ec_op"; +const ECDSA_BUILTIN_NAME: &str = "ecdsa"; +const BITWISE_BUILTIN_NAME: &str = "bitwise"; +const KECCAK_BUILTIN_NAME: &str = "keccak"; +const SEGMENT_ARENA_BUILTIN_NAME: &str = "segment_arena"; + +impl Builtin { + pub fn name(&self) -> &'static str { + match self { + Builtin::RangeCheck => RANGE_CHACK_BUILTIN_NAME, + Builtin::Pedersen => PEDERSEN_BUILTIN_NAME, + Builtin::Poseidon => POSEIDON_BUILTIN_NAME, + Builtin::EcOp => EC_OP_BUILTIN_NAME, + Builtin::Ecdsa => ECDSA_BUILTIN_NAME, + Builtin::Bitwise => BITWISE_BUILTIN_NAME, + Builtin::Keccak => KECCAK_BUILTIN_NAME, + Builtin::SegmentArena => SEGMENT_ARENA_BUILTIN_NAME, + } + } +}