Skip to content

Commit

Permalink
Make signup/login input lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Jul 16, 2024
1 parent 102cebf commit a8227d7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 59 deletions.
34 changes: 17 additions & 17 deletions packages/account-wasm/pkg/account_wasm_bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,6 @@ export function __wbindgen_object_drop_ref(arg0) {
takeObject(arg0);
};

export function __wbindgen_string_new(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};

export function __wbindgen_error_new(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand Down Expand Up @@ -482,16 +477,6 @@ export function __wbindgen_jsval_eq(arg0, arg1) {
return ret;
};

export function __wbindgen_cb_drop(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
};

export function __wbindgen_boolean_get(arg0) {
const v = getObject(arg0);
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
Expand Down Expand Up @@ -526,6 +511,16 @@ export function __wbindgen_is_undefined(arg0) {
return ret;
};

export function __wbindgen_cb_drop(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
};

export function __wbindgen_jsval_loose_eq(arg0, arg1) {
const ret = getObject(arg0) == getObject(arg1);
return ret;
Expand All @@ -536,6 +531,11 @@ export function __wbindgen_number_new(arg0) {
return addHeapObject(ret);
};

export function __wbindgen_string_new(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};

export function __wbg_getwithrefkey_edc2c8960f0f1191(arg0, arg1) {
const ret = getObject(arg0)[getObject(arg1)];
return addHeapObject(ret);
Expand Down Expand Up @@ -1002,8 +1002,8 @@ export function __wbindgen_memory() {
return addHeapObject(ret);
};

export function __wbindgen_closure_wrapper1521(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 516, __wbg_adapter_48);
export function __wbindgen_closure_wrapper1519(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 512, __wbg_adapter_48);
return addHeapObject(ret);
};

Binary file modified packages/account-wasm/pkg/account_wasm_bg.wasm
Binary file not shown.
16 changes: 2 additions & 14 deletions packages/account-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ use types::invocation::JsInvocationsDetails;
use types::outside_execution::JsOutsideExecution;
use types::session::{JsCredentials, JsSession};
use url::Url;
use utils::{policies_match, set_panic_hook, calculate_contract_address};
use utils::{policies_match, set_panic_hook};
use wasm_bindgen::prelude::*;
use web_sys::console;

use crate::types::TryFromJsValue;

Expand All @@ -62,8 +61,6 @@ pub struct CartridgeAccount {
device_signer: DeviceSigner,
username: String,
rpc_url: Url,
rp_id: String,
origin: String,
}

#[wasm_bindgen]
Expand Down Expand Up @@ -120,9 +117,7 @@ impl CartridgeAccount {
account,

Check warning on line 117 in packages/account-wasm/src/lib.rs

View workflow job for this annotation

GitHub Actions / rust-fmt

Diff in /home/runner/work/controller/controller/packages/account-wasm/src/lib.rs
device_signer,
username,
rpc_url,
rp_id,
origin,
rpc_url
})
}

Expand Down Expand Up @@ -320,13 +315,6 @@ impl CartridgeAccount {
constructor_calldata[0] = Felt::TWO; // incorrect signer enum from serialization
constructor_calldata.push(Felt::ONE); // no guardian

let address = calculate_contract_address(starknetutils::cairo_short_string_to_felt(&self.username)?, Felt::from_str(ACCOUNT_CLASS_HASH)?, &constructor_calldata);
console::log_1(&format!("constructor {:#?}", constructor_calldata).into());
console::log_1(&format!("deployment address: {:#x}", address).into());
console::log_1(&format!("backend address: {:#x}", self.account.address()).into());
console::log_1(&format!("rp_id: {}", self.rp_id).into());
console::log_1(&format!("origin: {}", self.origin).into());

let factory = CartridgeAccountFactory::new(
Felt::from_str(ACCOUNT_CLASS_HASH)?,
self.account.chain_id(),
Expand Down
29 changes: 1 addition & 28 deletions packages/account-wasm/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
use std::collections::HashMap;

use starknet::accounts::Call;
use starknet::core::crypto::compute_hash_on_elements;
use starknet::core::types::{Felt, NonZeroFelt};
use starknet::core::types::Felt;
use starknet::core::utils::get_selector_from_name;

use crate::types::policy::JsPolicy;

const PREFIX_CONTRACT_ADDRESS: Felt = Felt::from_raw([
533439743893157637,
8635008616843941496,
17289941567720117366,
3829237882463328880,
]);

const ADDR_BOUND: NonZeroFelt = NonZeroFelt::from_raw([
576459263475590224,
18446744073709255680,
160989183,
18446743986131443745,
]);


pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
Expand All @@ -47,15 +31,4 @@ pub fn policies_match(calls: &[Call], policies: &[JsPolicy]) -> bool {
calls
.iter()

Check warning on line 32 in packages/account-wasm/src/utils.rs

View workflow job for this annotation

GitHub Actions / rust-fmt

Diff in /home/runner/work/controller/controller/packages/account-wasm/src/utils.rs
.all(|call| policy_map.contains_key(&call.selector))
}

pub fn calculate_contract_address(salt: Felt, class_hash: Felt, constructor_calldata: &[Felt]) -> Felt {
compute_hash_on_elements(&[
PREFIX_CONTRACT_ADDRESS,
Felt::ZERO,
salt,
class_hash,
compute_hash_on_elements(constructor_calldata),
])
.mod_floor(&ADDR_BOUND)
}
1 change: 1 addition & 0 deletions packages/keychain/src/components/connect/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export function Login({
}}
autoFocus
placeholder="Username"
textTransform="lowercase"
touched={meta.touched}
error={meta.error}
isLoading={props.isValidating}
Expand Down
1 change: 1 addition & 0 deletions packages/keychain/src/components/connect/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function Form({ isSlot, onLogin, onSuccess }: SignupProps) {
{...field}
autoFocus
placeholder="Username"
textTransform="lowercase"
touched={meta.touched}
error={meta.error || errors?.username}
onChange={(e) => {
Expand Down

0 comments on commit a8227d7

Please sign in to comment.