-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swap and Ics 20 Withdrawal effect hash #9
Conversation
de7c1eb
to
53b6b39
Compare
|
||
pub fn to_proto_swap(&self) -> [u8; Self::PROTO_LEN] { | ||
let mut proto = [0u8; Self::PROTO_LEN]; | ||
proto[0..4].copy_from_slice(&[0x22, 0x22, 0x0a, 0x20]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From where that array values come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These bytes are for protobuf headers. If the .proto file is modified, these bytes may change. We can discuss if there is another way to make this more flexible
|
||
pub fn to_proto_swap(&self) -> [u8; Self::PROTO_LEN] { | ||
let mut proto = [0u8; Self::PROTO_LEN]; | ||
proto[0..4].copy_from_slice(&[0x0a, 0x22, 0x0a, 0x20]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also define that array as a constant, similarly to Self::PROTO_LEN
app/rust/src/parser/trading_pair.rs
Outdated
|
||
pub fn to_bytes(&self) -> Result<[u8; 64], ParserError> { | ||
let mut bytes = [0u8; 64]; | ||
let asset_1_bytes = self.asset_1.to_bytes().expect("asset_1 conversion failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use expect or unwraps, however if the code execution path would never fail, unwrap is preferable because it does not have the overhead of a static string in the final binary, also a safety comment explaining a bit why it won't panic
Parser and computation of effect hash of Swap and Ics 20 Withdrawal actions