From f16271877c9dbf08bc7bf61e4fc72decc13ff73d Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Fri, 15 Sep 2023 14:17:41 -0600 Subject: [PATCH] feat: change Argent account factory for Cairo 1 (#472) --- examples/deploy_argent_account.rs | 8 +++---- starknet-accounts/src/factory/argent.rs | 31 ++++++------------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/examples/deploy_argent_account.rs b/examples/deploy_argent_account.rs index e56ac833..140dcc79 100644 --- a/examples/deploy_argent_account.rs +++ b/examples/deploy_argent_account.rs @@ -8,9 +8,8 @@ use starknet::{ #[tokio::main] async fn main() { - // Latest hashes as of 2023-01-21. For demo only. - let proxy_hash = felt!("0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"); - let impl_hash = felt!("0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2"); + // Latest hash as of 2023-09-15. For demo only. + let class_hash = felt!("0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"); // Anything you like here as salt let salt = felt!("12345678"); @@ -21,8 +20,7 @@ async fn main() { )); let factory = ArgentAccountFactory::new( - proxy_hash, - impl_hash, + class_hash, chain_id::TESTNET, FieldElement::ZERO, signer, diff --git a/starknet-accounts/src/factory/argent.rs b/starknet-accounts/src/factory/argent.rs index 667de9f1..acc73419 100644 --- a/starknet-accounts/src/factory/argent.rs +++ b/starknet-accounts/src/factory/argent.rs @@ -5,19 +5,10 @@ use starknet_core::types::FieldElement; use starknet_providers::Provider; use starknet_signers::Signer; -/// Selector for "initialize" -const SELECTOR_INITIALIZE: FieldElement = FieldElement::from_mont([ - 14382173896205878522, - 7380089477680411368, - 4404362358337226556, - 132905214994424316, -]); - pub struct ArgentAccountFactory { - proxy_class_hash: FieldElement, - impl_class_hash: FieldElement, + class_hash: FieldElement, chain_id: FieldElement, - signer_public_key: FieldElement, + owner_public_key: FieldElement, guardian_public_key: FieldElement, signer: S, provider: P, @@ -28,8 +19,7 @@ where S: Signer, { pub async fn new( - proxy_class_hash: FieldElement, - impl_class_hash: FieldElement, + class_hash: FieldElement, chain_id: FieldElement, guardian_public_key: FieldElement, signer: S, @@ -37,10 +27,9 @@ where ) -> Result { let signer_public_key = signer.get_public_key().await?; Ok(Self { - proxy_class_hash, - impl_class_hash, + class_hash, chain_id, - signer_public_key: signer_public_key.scalar(), + owner_public_key: signer_public_key.scalar(), guardian_public_key, signer, provider, @@ -59,17 +48,11 @@ where type SignError = S::SignError; fn class_hash(&self) -> FieldElement { - self.proxy_class_hash + self.class_hash } fn calldata(&self) -> Vec { - vec![ - self.impl_class_hash, - SELECTOR_INITIALIZE, - FieldElement::TWO, - self.signer_public_key, - self.guardian_public_key, - ] + vec![self.owner_public_key, self.guardian_public_key] } fn chain_id(&self) -> FieldElement {