Skip to content

Commit

Permalink
optimize: small code (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
RequiemOfSoul authored Dec 21, 2023
1 parent 8758d58 commit ad0295e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bindings/wasm/src/json_rpc_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct JsonRpcSigner {
}

//#[wasm_bindgen(constructor)]
#[wasm_bindgen(js_name=newRpcSignerWtihProvider)]
#[wasm_bindgen(js_name=newRpcSignerWithProvider)]
pub fn new_with_provider(provider: Provider) -> Result<JsonRpcSigner, JsValue> {
let inner = InterfaceJsonRpcSigner::new(JsonRpcProvider::Provider(provider), None, None)?;
Ok(JsonRpcSigner { inner })
Expand Down
14 changes: 7 additions & 7 deletions signers/src/starknet_signer/typed_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ impl TypedData {
struct_type: &str,
data: &M,
) -> Result<FieldElement, StarkSignerError> {
let mut types_arry = vec![];
let mut data_arry = vec![];
types_arry.push("felt".to_string());
let mut types_array = vec![];
let mut data_array = vec![];
types_array.push("felt".to_string());
let type_hash = starknet_keccak(self.encode_type(struct_type).as_bytes());
data_arry.push(type_hash);
data_array.push(type_hash);
let data_value =
serde_json::to_value(data).map_err(|e| StarkSignerError::SignError(e.to_string()))?;
let data_map = data_value.as_object().unwrap();
Expand All @@ -165,15 +165,15 @@ impl TypedData {
}

for t in td {
types_arry.push(t.r#type.clone());
types_array.push(t.r#type.clone());
let v_str = data_map.get(&t.name).unwrap().as_str().unwrap();
let v = Self::string_to_hex(v_str);
let v = FieldElement::from_hex_be(&v)
.map_err(|e| StarkSignerError::SignError(e.to_string()))?;
data_arry.push(v);
data_array.push(v);
}

Ok(compute_hash_on_elements(&data_arry))
Ok(compute_hash_on_elements(&data_array))
}

pub fn encode(&self, addr: FieldElement) -> Result<Vec<FieldElement>, StarkSignerError> {
Expand Down
1 change: 0 additions & 1 deletion types/src/tx_type/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ impl Transfer {
impl GetBytes for Transfer {
fn get_bytes(&self) -> Vec<u8> {
let bytes_len = self.bytes_len();
println!("{:?}", pack_fee_amount(&self.fee));
let mut out = Vec::with_capacity(bytes_len);
out.extend_from_slice(&[Self::TX_TYPE]);
out.extend_from_slice(&self.account_id.to_be_bytes());
Expand Down

0 comments on commit ad0295e

Please sign in to comment.