diff --git a/declare-all.sh b/declare-all.sh index 6fab179..d5de1af 100755 --- a/declare-all.sh +++ b/declare-all.sh @@ -60,5 +60,5 @@ echo "Governor @ $GOVERNOR_CLASS_HASH" echo "Timelock @ $TIMELOCK_CLASS_HASH" echo "Factory @ $FACTORY_CLASS_HASH" -# starkli deploy --max-fee 0.001 --watch --network sepolia --keystore-password "$STARKNET_KEYSTORE_PASSWORD" "$AIRDROP_CLAIM_CHECK_CLASS_HASH" -# starkli deploy --max-fee 0.001 --watch --network sepolia --keystore-password "$STARKNET_KEYSTORE_PASSWORD" "$FACTORY_CLASS_HASH" "$STAKER_CLASS_HASH" "$GOVERNOR_CLASS_HASH" "$TIMELOCK_CLASS_HASH" \ No newline at end of file +# starkli deploy --max-fee 0.001 --watch --network "$NETWORK" --keystore-password "$STARKNET_KEYSTORE_PASSWORD" "$AIRDROP_CLAIM_CHECK_CLASS_HASH" +# starkli deploy --max-fee 0.001 --watch --network "$NETWORK" --keystore-password "$STARKNET_KEYSTORE_PASSWORD" "$FACTORY_CLASS_HASH" "$STAKER_CLASS_HASH" "$GOVERNOR_CLASS_HASH" "$TIMELOCK_CLASS_HASH" \ No newline at end of file diff --git a/src/factory.cairo b/src/factory.cairo index 279a852..7e11c2f 100644 --- a/src/factory.cairo +++ b/src/factory.cairo @@ -2,7 +2,7 @@ use governance::governor::{Config as GovernorConfig}; use governance::governor::{IGovernorDispatcher}; use governance::staker::{IStakerDispatcher}; use governance::timelock::{ITimelockDispatcher, Config as TimelockConfig}; -use starknet::{ContractAddress}; +use starknet::{ClassHash, ContractAddress}; #[derive(Copy, Drop, Serde)] pub struct DeploymentParameters { @@ -20,8 +20,12 @@ pub struct DeploymentResult { // This contract makes it easy to deploy a set of governance contracts from a block explorer just by specifying parameters #[starknet::interface] pub trait IFactory { + fn get_staker_class_hash(self: @TContractState) -> ClassHash; + fn get_governor_class_hash(self: @TContractState) -> ClassHash; + fn get_timelock_class_hash(self: @TContractState) -> ClassHash; + fn deploy( - self: @TContractState, token: ContractAddress, params: DeploymentParameters + ref self: TContractState, token: ContractAddress, params: DeploymentParameters ) -> DeploymentResult; } @@ -29,10 +33,10 @@ pub trait IFactory { pub mod Factory { use core::result::{ResultTrait}; use governance::interfaces::erc20::{IERC20Dispatcher, IERC20DispatcherTrait}; - use starknet::{ClassHash, syscalls::{deploy_syscall}, get_caller_address, get_contract_address}; + use starknet::{syscalls::{deploy_syscall}, get_caller_address, get_contract_address}; use super::{ - IFactory, DeploymentParameters, DeploymentResult, ContractAddress, IGovernorDispatcher, - ITimelockDispatcher, IStakerDispatcher + ClassHash, IFactory, DeploymentParameters, DeploymentResult, ContractAddress, + IGovernorDispatcher, ITimelockDispatcher, IStakerDispatcher }; #[storage] @@ -56,8 +60,18 @@ pub mod Factory { #[abi(embed_v0)] impl FactoryImpl of IFactory { + fn get_staker_class_hash(self: @ContractState) -> ClassHash { + self.staker_class_hash.read() + } + fn get_governor_class_hash(self: @ContractState) -> ClassHash { + self.governor_class_hash.read() + } + fn get_timelock_class_hash(self: @ContractState) -> ClassHash { + self.timelock_class_hash.read() + } + fn deploy( - self: @ContractState, token: ContractAddress, params: DeploymentParameters + ref self: ContractState, token: ContractAddress, params: DeploymentParameters ) -> DeploymentResult { let mut staker_constructor_args: Array = ArrayTrait::new(); Serde::serialize(@(token), ref staker_constructor_args);