Skip to content

Commit

Permalink
resolve Todo
Browse files Browse the repository at this point in the history
  • Loading branch information
RequiemOfSoul committed Nov 2, 2023
1 parent 8efc7d6 commit bc9c215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions types/src/basic_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) mod params;
pub mod tx_hash;
pub mod zklink_address;

use crate::params::{ACCOUNT_ID_BIT_WIDTH, TOKEN_BIT_WIDTH};
use crate::params::{ACCOUNT_ID_BIT_WIDTH, RESCUE_HASH_INPUT_BYTES, TOKEN_BIT_WIDTH};
pub use num::BigUint;
use zklink_sdk_signers::zklink_signer::utils::rescue_hash_orders;

Expand Down Expand Up @@ -106,7 +106,7 @@ pub trait GetBytes {
/// calculate the hash of encoded bytes
fn rescue_hash(&self) -> Vec<u8> {
let mut hash_input = self.get_bytes();
hash_input.resize(self.bytes_len(), 0);
hash_input.resize(RESCUE_HASH_INPUT_BYTES, 0);
rescue_hash_orders(&hash_input)
}
}
Expand Down
8 changes: 3 additions & 5 deletions types/src/contract/prices.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::basic_types::pad::pad_front;
use crate::basic_types::{GetBytes, PairId, TokenId};
use crate::params::{
CONTRACT_PRICE_BYTES, MARGIN_PRICE_BYTES, PRICE_BIT_WIDTH, RESCUE_HASH_INPUT_BYTES,
CONTRACT_PRICE_BYTES, MARGIN_PRICE_BYTES, PRICE_BIT_WIDTH,
};
use crate::prelude::validator::*;
use num::BigUint;
Expand Down Expand Up @@ -97,13 +97,11 @@ impl GetBytes for OraclePrices {
let mut margins_encode = Vec::with_capacity(bytes_len);
margins_encode.extend(self.contract_prices.get_bytes());
margins_encode.extend(self.margin_prices.get_bytes());
// TODO: use assert_eq
// assert_eq!(margins_encode.len(), bytes_len);
assert_eq!(margins_encode.len(), bytes_len);
margins_encode
}

fn bytes_len(&self) -> usize {
// Todo: Need to wait for the front-end to modify their SDKs
RESCUE_HASH_INPUT_BYTES
self.margin_prices.bytes_len() + self.contract_prices.bytes_len()
}
}

0 comments on commit bc9c215

Please sign in to comment.