diff --git a/types/src/tx_type/contract/mod.rs b/types/src/tx_type/contract/mod.rs index e01b42b..f06d912 100644 --- a/types/src/tx_type/contract/mod.rs +++ b/types/src/tx_type/contract/mod.rs @@ -12,22 +12,24 @@ pub use liquidation::Liquidation; pub use prices::{ContractPrice, OraclePrices, SpotPriceInfo}; pub use update_global_var::{Parameter, UpdateGlobalVar}; +use super::zklink_tx::ZkLinkTxType; + impl Contract { pub const MSG_TYPE: u8 = 0xfe; } impl ContractMatching { - pub const TX_TYPE: u8 = 0x09; + pub const TX_TYPE: u8 = ZkLinkTxType::ContractMatching as u8; } impl Liquidation { - pub const TX_TYPE: u8 = 0x0a; + pub const TX_TYPE: u8 = ZkLinkTxType::Liquidation as u8; } impl AutoDeleveraging { - pub const TX_TYPE: u8 = 0x0b; + pub const TX_TYPE: u8 = ZkLinkTxType::AutoDeleveraging as u8; } impl UpdateGlobalVar { - pub const TX_TYPE: u8 = 0x0c; + pub const TX_TYPE: u8 = ZkLinkTxType::UpdateGlobalVar as u8; } impl Funding { - pub const TX_TYPE: u8 = 0x0d; + pub const TX_TYPE: u8 = ZkLinkTxType::Funding as u8; } diff --git a/types/src/tx_type/mod.rs b/types/src/tx_type/mod.rs index d3fc5b1..6b39626 100644 --- a/types/src/tx_type/mod.rs +++ b/types/src/tx_type/mod.rs @@ -19,6 +19,7 @@ use zklink_sdk_signers::zklink_signer::error::ZkSignerError; use zklink_sdk_signers::zklink_signer::pk_signer::{sha256_bytes, ZkLinkSigner}; use zklink_sdk_signers::zklink_signer::signature::ZkLinkSignature; use zklink_sdk_signers::zklink_signer::PubKeyHash; +use zklink_tx::ZkLinkTxType; pub mod validator; @@ -34,25 +35,25 @@ pub mod withdraw; pub mod zklink_tx; impl Deposit { - pub const TX_TYPE: u8 = 0x01; + pub const TX_TYPE: u8 = ZkLinkTxType::Deposit as u8; } impl Withdraw { - pub const TX_TYPE: u8 = 0x03; + pub const TX_TYPE: u8 = ZkLinkTxType::Withdraw as u8; } impl Transfer { - pub const TX_TYPE: u8 = 0x04; + pub const TX_TYPE: u8 = ZkLinkTxType::Transfer as u8; } impl FullExit { - pub const TX_TYPE: u8 = 0x05; + pub const TX_TYPE: u8 = ZkLinkTxType::FullExit as u8; } impl ChangePubKey { - pub const TX_TYPE: u8 = 0x06; + pub const TX_TYPE: u8 = ZkLinkTxType::ChangePubKey as u8; } impl ForcedExit { - pub const TX_TYPE: u8 = 0x07; + pub const TX_TYPE: u8 = ZkLinkTxType::ForcedExit as u8; } impl OrderMatching { - pub const TX_TYPE: u8 = 0x08; + pub const TX_TYPE: u8 = ZkLinkTxType::OrderMatching as u8; } /// Construct the first part of the message that should be signed by Ethereum key. diff --git a/types/src/tx_type/zklink_tx.rs b/types/src/tx_type/zklink_tx.rs index 9bcb359..6405310 100644 --- a/types/src/tx_type/zklink_tx.rs +++ b/types/src/tx_type/zklink_tx.rs @@ -17,18 +17,18 @@ use wasm_bindgen::prelude::wasm_bindgen; #[wasm_bindgen] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub enum ZkLinkTxType { - Deposit, - FullExit, - ChangePubKey, - Transfer, - Withdraw, - ForcedExit, - OrderMatching, - AutoDeleveraging, - ContractMatching, - Funding, - Liquidation, - UpdateGlobalVar, + Deposit = 0x01, + FullExit = 0x05, + ChangePubKey = 0x06, + Transfer = 0x04, + Withdraw = 0x03, + ForcedExit = 0x07, + OrderMatching = 0x08, + AutoDeleveraging = 0x0b, + ContractMatching = 0x09, + Funding = 0x0d, + Liquidation = 0x0a, + UpdateGlobalVar = 0x0c, } /// A set of L2 transaction supported by the zklink network.