Skip to content

Commit

Permalink
fix the declare all script and the factory mutability of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed May 1, 2024
1 parent b81618a commit c35a26e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions declare-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
# 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"
26 changes: 20 additions & 6 deletions src/factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -20,19 +20,23 @@ 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<TContractState> {
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;
}

#[starknet::contract]
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]
Expand All @@ -56,8 +60,18 @@ pub mod Factory {

#[abi(embed_v0)]
impl FactoryImpl of IFactory<ContractState> {
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<felt252> = ArrayTrait::new();
Serde::serialize(@(token), ref staker_constructor_args);
Expand Down

0 comments on commit c35a26e

Please sign in to comment.