hyperlane_plugin_rpc/
const.rs1pub const JSONRPC_VERSION: &str = "2.0";
3
4pub const DEFAULT_RPC_ENDPOINT: &str = "/rpc";
6
7pub const DEFAULT_RPC_MAX_BODY_SIZE: usize = 1024 * 1024;
9
10pub const DEFAULT_RPC_MAX_BATCH_SIZE: usize = 64;
12
13pub const RPC_PARSE_ERROR: i64 = -32700;
15
16pub const RPC_INVALID_REQUEST: i64 = -32600;
18
19pub const RPC_METHOD_NOT_FOUND: i64 = -32601;
21
22pub const RPC_INVALID_PARAMS: i64 = -32602;
24
25pub const RPC_INTERNAL_ERROR: i64 = -32603;
27
28pub(crate) const MSG_PARSE_ERROR: &str = "Parse error";
30
31pub(crate) const MSG_INVALID_REQUEST: &str = "Invalid Request";
33
34pub(crate) const MSG_METHOD_NOT_FOUND: &str = "Method not found";
36
37pub(crate) const MSG_INVALID_PARAMS: &str = "Invalid params";
39
40pub(crate) const MSG_INTERNAL_ERROR: &str = "Internal error";
42
43pub(crate) const PREBUILT_PARSE_ERROR: &[u8] =
45 br#"{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}"#;
46
47pub(crate) const PREBUILT_INVALID_REQUEST: &[u8] =
49 br#"{"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request"},"id":null}"#;
50
51pub(crate) const PREBUILT_BATCH_TOO_LARGE: &[u8] = br#"{"jsonrpc":"2.0","error":{"code":-32600,"message":"Batch size exceeds configured limit"},"id":null}"#;
53
54pub(crate) const RPC_SINGLE_RESPONSE_CAP: usize = 128;
56
57pub(crate) const FIELD_JSONRPC: &str = "jsonrpc";
59
60pub(crate) const FIELD_METHOD: &str = "method";
62
63pub(crate) const FIELD_PARAMS: &str = "params";
65
66pub(crate) const FIELD_ID: &str = "id";
68
69pub(crate) const EXPECT_FIELD_KEY: &str = "JSON-RPC field key";
71
72pub(crate) const EXPECT_LENIENT_STR: &str = "JSON value";
74
75pub(crate) const EXPECT_RPC_ID: &str = "JSON-RPC id";
77
78pub(crate) const EXPECT_BATCH_ITEM: &str = "JSON-RPC request item";
80
81pub(crate) const RPC_JSON_PREFIX: &[u8] = br#"{"jsonrpc":"2.0","id":"#;
83
84pub(crate) const RPC_JSON_RESULT_KEY: &[u8] = br#","result":"#;
86
87pub(crate) const RPC_JSON_ERROR_KEY: &[u8] = br#","error":"#;
89
90pub(crate) const STATIC_ERR_INVALID_REQUEST: &[u8] =
92 br#"{"code":-32600,"message":"Invalid Request"}"#;
93
94pub(crate) const STATIC_ERR_METHOD_NOT_FOUND: &[u8] =
96 br#"{"code":-32601,"message":"Method not found"}"#;
97
98pub(crate) const JSON_NULL: &[u8] = b"null";
100
101pub(crate) const JSON_TRUE: &[u8] = b"true";
103
104pub(crate) const JSON_FALSE: &[u8] = b"false";
106
107pub(crate) const WIRE_HTTP11_200_JSON_PREFIX: &[u8] =
109 b"HTTP/1.1 200 OK\r\ncontent-type: application/json\r\nconnection: keep-alive\r\ncontent-length: ";
110
111pub(crate) const WIRE_HEADER_END: &[u8] = b"\r\n\r\n";
113
114pub(crate) const RPC_WIRE_STACK_CAP: usize = 1024;
116
117pub(crate) const RPC_PAYLOAD_STACK_CAP: usize = 512;
119
120pub(crate) const FX_HASH_K: u64 = 0x517c_c1b7_2722_0a95;
122
123pub(crate) const DEC_DIGITS_LUT: &[u8; 200] = b"00010203040506070809\
12510111213141516171819\
12620212223242526272829\
12730313233343536373839\
12840414243444546474849\
12950515253545556575859\
13060616263646566676869\
13170717273747576777879\
13280818283848586878889\
13390919293949596979899";
134
135pub(crate) const BYTE_LBRACE: u8 = b'{';
137
138pub(crate) const BYTE_RBRACE: u8 = b'}';
140
141pub(crate) const BYTE_LBRACKET: u8 = b'[';
143
144pub(crate) const BYTE_RBRACKET: u8 = b']';
146
147pub(crate) const BYTE_COMMA: u8 = b',';
149
150pub(crate) const BYTE_QUOTE: u8 = b'"';
152
153pub(crate) const BYTE_BACKSLASH: u8 = b'\\';
155
156pub(crate) const BYTE_DASH: u8 = b'-';
158
159pub(crate) const BYTE_ZERO: u8 = b'0';
161
162pub(crate) const BYTE_SPACE: u8 = b' ';
164
165pub(crate) const BYTE_TAB: u8 = b'\t';
167
168pub(crate) const BYTE_CR: u8 = b'\r';
170
171pub(crate) const BYTE_LF: u8 = b'\n';