From fa57578563d4659ad330b080827ed6df1fd5c6bb Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Wed, 14 Aug 2024 21:05:01 -0700 Subject: [PATCH] bump starknet deps --- Cargo.lock | 57 ++++++++++++++++++++++++++----- Cargo.toml | 1 + cli/src/command/auth/session.rs | 3 +- slot/Cargo.toml | 6 ++-- slot/src/session.rs | 59 ++++++++++----------------------- 5 files changed, 71 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b6073b..2e75893 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,6 @@ version = 3 [[package]] name = "account_sdk" version = "0.1.0" -source = "git+https://github.com/cartridge-gg/controller?rev=2427a9805a8e7f4b00844429f61ce577048e8d5b#2427a9805a8e7f4b00844429f61ce577048e8d5b" dependencies = [ "anyhow", "async-trait", @@ -32,7 +31,7 @@ dependencies = [ "serde_with 3.9.0", "sha2", "starknet 0.11.0", - "starknet-crypto 0.7.1", + "starknet-crypto 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "starknet-types-core", "thiserror", "tokio", @@ -4158,7 +4157,7 @@ dependencies = [ "starknet-accounts 0.10.0", "starknet-contract 0.10.0", "starknet-core 0.11.1", - "starknet-crypto 0.7.1", + "starknet-crypto 0.7.1 (git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694)", "starknet-macros 0.2.0", "starknet-providers 0.11.0", "starknet-signers 0.9.0", @@ -4186,7 +4185,7 @@ dependencies = [ "async-trait", "auto_impl", "starknet-core 0.11.1", - "starknet-crypto 0.7.1", + "starknet-crypto 0.7.1 (git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694)", "starknet-providers 0.11.0", "starknet-signers 0.9.0", "thiserror", @@ -4253,7 +4252,7 @@ dependencies = [ "serde_json_pythonic", "serde_with 3.9.0", "sha3", - "starknet-crypto 0.7.1", + "starknet-crypto 0.7.1 (git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694)", "starknet-types-core", ] @@ -4271,7 +4270,7 @@ dependencies = [ "num-traits 0.2.19", "rfc6979", "sha2", - "starknet-crypto-codegen", + "starknet-crypto-codegen 0.3.3", "starknet-curve 0.3.0", "starknet-ff", "zeroize", @@ -4291,12 +4290,32 @@ dependencies = [ "num-traits 0.2.19", "rfc6979", "sha2", - "starknet-crypto-codegen", + "starknet-crypto-codegen 0.3.3", "starknet-curve 0.4.2", "starknet-ff", "zeroize", ] +[[package]] +name = "starknet-crypto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2a821ad8d98c6c3e4d0e5097f3fe6e2ed120ada9d32be87cd1330c7923a2f0" +dependencies = [ + "crypto-bigint", + "hex", + "hmac", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "rfc6979", + "sha2", + "starknet-crypto-codegen 0.4.0", + "starknet-curve 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "starknet-types-core", + "zeroize", +] + [[package]] name = "starknet-crypto" version = "0.7.1" @@ -4310,7 +4329,7 @@ dependencies = [ "num-traits 0.2.19", "rfc6979", "sha2", - "starknet-curve 0.5.0", + "starknet-curve 0.5.0 (git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694)", "starknet-types-core", "zeroize", ] @@ -4326,6 +4345,17 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "starknet-crypto-codegen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e179dedc3fa6da064e56811d3e05d446aa2f7459e4eb0e3e49378a337235437" +dependencies = [ + "starknet-curve 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "starknet-types-core", + "syn 2.0.66", +] + [[package]] name = "starknet-curve" version = "0.3.0" @@ -4344,6 +4374,15 @@ dependencies = [ "starknet-ff", ] +[[package]] +name = "starknet-curve" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56935b306dcf0b8f14bb2a1257164b8478bb8be4801dfae0923f5b266d1b457c" +dependencies = [ + "starknet-types-core", +] + [[package]] name = "starknet-curve" version = "0.5.0" @@ -4454,7 +4493,7 @@ dependencies = [ "getrandom", "rand", "starknet-core 0.11.1", - "starknet-crypto 0.7.1", + "starknet-crypto 0.7.1 (git+https://github.com/xJonathanLEI/starknet-rs?rev=2ddc694)", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index ac5388b..781428d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ thiserror = "1.0.32" url = "2.2.2" rand = "0.8.4" +# Must be synced across all downstream crates starknet = "0.11.0" starknet-types-core = "~0.1.4" diff --git a/cli/src/command/auth/session.rs b/cli/src/command/auth/session.rs index eb80986..723dd1e 100644 --- a/cli/src/command/auth/session.rs +++ b/cli/src/command/auth/session.rs @@ -26,8 +26,7 @@ impl CreateSession { let url = Url::parse(&self.rpc_url)?; let chain_id = get_network_chain_id(url.clone()).await?; let session = session::create(url, &self.policies).await?; - println!("session: {session:?}"); - // session::store(chain_id, &session)?; + session::store(chain_id, &session)?; Ok(()) } } diff --git a/slot/Cargo.toml b/slot/Cargo.toml index 48319ad..c5c956e 100644 --- a/slot/Cargo.toml +++ b/slot/Cargo.toml @@ -28,7 +28,7 @@ tempfile = "3.10.1" hyper.workspace = true serde_with = "3.9.0" -[dependencies.account_sdk] -git = "https://github.com/cartridge-gg/controller" +# Must be synced across Dojo # Branch `controllerabstraction` with cainome updated. -rev = "2427a9805a8e7f4b00844429f61ce577048e8d5b" +# account_sdk = { git = "https://github.com/cartridge-gg/controller", rev = "2427a9805a8e7f4b00844429f61ce577048e8d5b" } +account_sdk = { path = "../../controller/packages/account_sdk" } diff --git a/slot/src/session.rs b/slot/src/session.rs index 012097a..f80b02a 100644 --- a/slot/src/session.rs +++ b/slot/src/session.rs @@ -30,25 +30,6 @@ pub struct Policy { pub method: String, } -#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)] -#[serde(rename_all = "camelCase")] -pub struct SessionDetails { - /// The expiration date of the session. - // TODO(kariy): change this to u64 - pub expires_at: String, - /// The session's policies. - pub policies: Vec, - pub credentials: SessionCredentials, -} - -#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)] -#[serde(rename_all = "camelCase")] -pub struct SessionCredentials { - /// The signing key of the session. - pub private_key: Felt, - pub authorization: Vec, -} - /// Retrieves the session for the given chain id of the currently authenticated user. /// Returns `None` if no session can be found for the chain id. /// @@ -66,7 +47,7 @@ pub fn get(chain: Felt) -> Result, Error> { /// /// This function will return an error if there is no authenticated user. /// -pub fn store(chain: Felt, session: &SessionDetails) -> Result { +pub fn store(chain: Felt, session: &SessionMetadata) -> Result { store_at(utils::config_dir(), chain, session) } @@ -114,7 +95,7 @@ where /// Stores the session token of the chain id `chain` for the currently authenticated user. It will /// use `config_dir` as the root path to store the session file. -fn store_at

(config_dir: P, chain: Felt, session: &SessionDetails) -> Result +fn store_at

(config_dir: P, chain: Felt, session: &SessionMetadata) -> Result where P: AsRef, { @@ -273,7 +254,7 @@ mod tests { use crate::account::{Account, AccountCredentials}; use crate::credential::{AccessToken, Credentials}; use crate::error::Error::Unauthorized; - use crate::session::{get_at, get_user_relative_file_path, store_at, SessionDetails}; + use crate::session::{get_at, get_user_relative_file_path, store_at}; use crate::utils; use account_sdk::storage::SessionMetadata; use starknet::{core::types::Felt, macros::felt}; @@ -343,16 +324,14 @@ mod tests { let username = authenticate(&config_dir); let chain = felt!("0x999"); - let expected = SessionDetails::default(); + let expected = SessionMetadata::default(); let path = store_at(&config_dir, chain, &expected).unwrap(); let user_path = get_user_relative_file_path(username, chain); let actual = get_at(config_dir, chain).unwrap(); - todo!() - - // assert_eq!(Some(expected), actual); - // assert!(path.ends_with(user_path)); + assert_eq!(Some(expected), actual); + assert!(path.ends_with(user_path)); } #[test] @@ -360,7 +339,7 @@ mod tests { let config_dir = utils::config_dir(); let chain = felt!("0x999"); - let session = SessionDetails::default(); + let session = SessionMetadata::default(); let err = store_at(config_dir, chain, &session).unwrap_err(); assert!(err.to_string().contains("No credentials found")) @@ -378,20 +357,18 @@ mod tests { // start the callback server tokio::spawn(server.start()); - // // call the callback url - // let session = SessionMetadata::default(); - // let res = reqwest::Client::new() - // .post(url) - // .json(&session) - // .send() - // .await - // .expect("failed to call callback url"); - - // assert!(res.status().is_success()); + // call the callback url + let session = SessionMetadata::default(); + let res = reqwest::Client::new() + .post(url) + .json(&session) + .send() + .await + .expect("failed to call callback url"); - // let actual = rx.recv().await.expect("failed to receive session"); - // assert_eq!(session, actual) + assert!(res.status().is_success()); - todo!() + let actual = rx.recv().await.expect("failed to receive session"); + assert_eq!(session, actual) } }