diff --git a/protobufs/integrity.proto b/protobufs/integrity.proto deleted file mode 100644 index fa2c2fc..0000000 --- a/protobufs/integrity.proto +++ /dev/null @@ -1,50 +0,0 @@ -syntax = "proto3"; - -package arbiter.integrity; - -import "google/protobuf/timestamp.proto"; - -message IntegrityTransactionRateLimit { - uint32 count = 1; - int64 window_secs = 2; -} - -message IntegrityVolumeRateLimit { - bytes max_volume = 1; // U256 as fixed-width 32-byte little-endian bytes - int64 window_secs = 2; -} - -message IntegritySharedGrantSettings { - int32 wallet_access_id = 1; - uint64 chain_id = 2; - optional google.protobuf.Timestamp valid_from = 3; - optional google.protobuf.Timestamp valid_until = 4; - optional bytes max_gas_fee_per_gas = 5; // U256 as fixed-width 32-byte little-endian bytes - optional bytes max_priority_fee_per_gas = 6; // U256 as fixed-width 32-byte little-endian bytes - optional IntegrityTransactionRateLimit rate_limit = 7; -} - -message IntegrityEtherTransferSettings { - repeated bytes targets = 1; // sorted list of 20-byte addresses - IntegrityVolumeRateLimit limit = 2; -} - -message IntegrityTokenTransferSettings { - bytes token_contract = 1; // 20-byte address - optional bytes target = 2; // 20-byte address - repeated IntegrityVolumeRateLimit volume_limits = 3; // sorted by (window_secs, max_volume) -} - -message IntegritySpecificGrant { - oneof grant { - IntegrityEtherTransferSettings ether_transfer = 1; - IntegrityTokenTransferSettings token_transfer = 2; - } -} - -message IntegrityEvmGrantPayloadV1 { - int32 basic_grant_id = 1; - IntegritySharedGrantSettings shared = 2; - IntegritySpecificGrant specific = 3; - optional google.protobuf.Timestamp revoked_at = 4; -} diff --git a/server/crates/arbiter-proto/build.rs b/server/crates/arbiter-proto/build.rs index 28a8048..657066c 100644 --- a/server/crates/arbiter-proto/build.rs +++ b/server/crates/arbiter-proto/build.rs @@ -13,7 +13,6 @@ fn main() -> Result<(), Box> { format!("{}/user_agent.proto", PROTOBUF_DIR), format!("{}/client.proto", PROTOBUF_DIR), format!("{}/evm.proto", PROTOBUF_DIR), - format!("{}/integrity.proto", PROTOBUF_DIR), ], &[PROTOBUF_DIR.to_string()], ) diff --git a/server/crates/arbiter-server/src/integrity/evm.rs b/server/crates/arbiter-server/src/integrity/evm.rs index 4f8e44b..8a82c34 100644 --- a/server/crates/arbiter-server/src/integrity/evm.rs +++ b/server/crates/arbiter-server/src/integrity/evm.rs @@ -1,9 +1,4 @@ use alloy::primitives::Address; -use arbiter_proto::proto::integrity::{ - IntegrityEtherTransferSettings, IntegrityEvmGrantPayloadV1, IntegritySharedGrantSettings, - IntegritySpecificGrant, IntegrityTokenTransferSettings, IntegrityTransactionRateLimit, - IntegrityVolumeRateLimit, integrity_specific_grant, -}; use chrono::{DateTime, Utc}; use diesel::sqlite::Sqlite; use diesel::{ExpressionMethods as _, OptionalExtension as _, QueryDsl, SelectableHelper as _}; @@ -19,6 +14,88 @@ use crate::{ pub const EVM_GRANT_ENTITY_KIND: &str = "evm_grant"; +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegrityVolumeRateLimit { + #[prost(bytes, tag = "1")] + pub max_volume: Vec, + #[prost(int64, tag = "2")] + pub window_secs: i64, +} + +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegrityTransactionRateLimit { + #[prost(uint32, tag = "1")] + pub count: u32, + #[prost(int64, tag = "2")] + pub window_secs: i64, +} + +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegritySharedGrantSettings { + #[prost(int32, tag = "1")] + pub wallet_access_id: i32, + #[prost(uint64, tag = "2")] + pub chain_id: u64, + #[prost(message, optional, tag = "3")] + pub valid_from: Option<::prost_types::Timestamp>, + #[prost(message, optional, tag = "4")] + pub valid_until: Option<::prost_types::Timestamp>, + #[prost(bytes, optional, tag = "5")] + pub max_gas_fee_per_gas: Option>, + #[prost(bytes, optional, tag = "6")] + pub max_priority_fee_per_gas: Option>, + #[prost(message, optional, tag = "7")] + pub rate_limit: Option, +} + +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegrityEtherTransferSettings { + #[prost(bytes, repeated, tag = "1")] + pub targets: Vec>, + #[prost(message, optional, tag = "2")] + pub limit: Option, +} + +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegrityTokenTransferSettings { + #[prost(bytes, tag = "1")] + pub token_contract: Vec, + #[prost(bytes, optional, tag = "2")] + pub target: Option>, + #[prost(message, repeated, tag = "3")] + pub volume_limits: Vec, +} + +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegritySpecificGrant { + #[prost(oneof = "integrity_specific_grant::Grant", tags = "1, 2")] + pub grant: Option, +} + +pub mod integrity_specific_grant { + use super::*; + + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Grant { + #[prost(message, tag = "1")] + EtherTransfer(IntegrityEtherTransferSettings), + #[prost(message, tag = "2")] + TokenTransfer(IntegrityTokenTransferSettings), + } +} + +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IntegrityEvmGrantPayloadV1 { + #[prost(int32, tag = "1")] + pub basic_grant_id: i32, + #[prost(message, optional, tag = "2")] + pub shared: Option, + #[prost(message, optional, tag = "3")] + pub specific: Option, + #[prost(message, optional, tag = "4")] + pub revoked_at: Option<::prost_types::Timestamp>, +} + #[derive(Debug, Clone)] pub struct SignedEvmGrant { pub basic_grant_id: i32,