Skip to content

Commit

Permalink
Merge branch 'develop' into fix_l1_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
Orland0x authored Aug 28, 2023
2 parents b63ed4d + a014145 commit 9ece175
Show file tree
Hide file tree
Showing 42 changed files with 1,422 additions and 394 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Step 2 - Install Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: 0.6.0-alpha.1
scarb-version: 0.6.2

- name: Step 3 - Check formatting
working-directory: ./starknet
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ out/

!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
/broadcast/**/dry-run/

.VSCodeCounter
11 changes: 6 additions & 5 deletions starknet/src/authenticators/eth_sig.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use starknet::{ContractAddress, EthAddress};
use starknet::SyscallResult;
use starknet::{ContractAddress, EthAddress, SyscallResult};
use sx::types::{Strategy, IndexedStrategy, Choice};

#[starknet::interface]
Expand Down Expand Up @@ -48,9 +47,11 @@ mod EthSigAuthenticator {
use starknet::{ContractAddress, EthAddress, syscalls::call_contract_syscall};
use core::array::{ArrayTrait, SpanTrait};
use clone::Clone;
use sx::space::space::{ISpaceDispatcher, ISpaceDispatcherTrait};
use sx::types::{Strategy, IndexedStrategy, Choice, UserAddress};
use sx::utils::{signatures, legacy_hash::LegacyHashEthAddress};
use sx::{
space::space::{ISpaceDispatcher, ISpaceDispatcherTrait},
types::{Strategy, IndexedStrategy, Choice, UserAddress},
utils::{signatures, legacy_hash::LegacyHashEthAddress}
};

#[storage]
struct Storage {
Expand Down
17 changes: 10 additions & 7 deletions starknet/src/authenticators/eth_tx.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ trait IEthTxAuthenticator<TContractState> {
#[starknet::contract]
mod EthTxAuthenticator {
use super::IEthTxAuthenticator;
use starknet::{ContractAddress, EthAddress, Felt252TryIntoEthAddress, EthAddressIntoFelt252};
use starknet::syscalls::call_contract_syscall;
use core::serde::Serde;
use core::array::{ArrayTrait, SpanTrait};
use starknet::{
ContractAddress, EthAddress, Felt252TryIntoEthAddress, EthAddressIntoFelt252,
syscalls::call_contract_syscall
};
use core::{serde::Serde, array::{ArrayTrait, SpanTrait}};
use traits::{PartialEq, TryInto, Into};
use option::OptionTrait;
use zeroable::Zeroable;
use sx::space::space::{ISpaceDispatcher, ISpaceDispatcherTrait};
use sx::types::{UserAddress, Strategy, IndexedStrategy, Choice};
use sx::utils::constants::{PROPOSE_SELECTOR, VOTE_SELECTOR, UPDATE_PROPOSAL_SELECTOR};
use sx::{
space::space::{ISpaceDispatcher, ISpaceDispatcherTrait},
types::{UserAddress, Strategy, IndexedStrategy, Choice},
utils::constants::{PROPOSE_SELECTOR, VOTE_SELECTOR, UPDATE_PROPOSAL_SELECTOR}
};

#[storage]
struct Storage {
Expand Down
7 changes: 4 additions & 3 deletions starknet/src/authenticators/stark_sig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ mod StarkSigAuthenticator {
use starknet::{ContractAddress, info};
use core::array::{ArrayTrait, SpanTrait};
use serde::Serde;
use sx::space::space::{ISpaceDispatcher, ISpaceDispatcherTrait};
use sx::types::{Strategy, IndexedStrategy, UserAddress, Choice};
use sx::utils::stark_eip712;
use sx::{
space::space::{ISpaceDispatcher, ISpaceDispatcherTrait},
types::{Strategy, IndexedStrategy, UserAddress, Choice}, utils::stark_eip712
};

#[storage]
struct Storage {
Expand Down
6 changes: 4 additions & 2 deletions starknet/src/authenticators/stark_tx.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ mod StarkTxAuthenticator {
use super::IStarkTxAuthenticator;
use starknet::{ContractAddress, info};
use core::array::ArrayTrait;
use sx::space::space::{ISpaceDispatcher, ISpaceDispatcherTrait};
use sx::types::{UserAddress, Strategy, IndexedStrategy, Choice};
use sx::{
space::space::{ISpaceDispatcher, ISpaceDispatcherTrait},
types::{UserAddress, Strategy, IndexedStrategy, Choice},
};

#[storage]
struct Storage {}
Expand Down
3 changes: 1 addition & 2 deletions starknet/src/authenticators/vanilla.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use starknet::ContractAddress;
use starknet::SyscallResult;
use starknet::{ContractAddress, SyscallResult};

#[starknet::interface]
trait IVanillaAuthenticator<TContractState> {
Expand Down
2 changes: 1 addition & 1 deletion starknet/src/execution_strategies/eth_relayer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod EthRelayerExecutionStrategy {
use starknet::info;
use sx::interfaces::IExecutionStrategy;
use sx::types::{Proposal};

#[storage]
struct Storage {}

Expand Down
3 changes: 1 addition & 2 deletions starknet/src/execution_strategies/vanilla.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ mod VanillaExecutionStrategy {
#[constructor]
fn constructor(ref self: ContractState, quorum: u256) {
// TODO: temporary until components are released
let mut state: SimpleQuorumExecutionStrategy::ContractState =
SimpleQuorumExecutionStrategy::unsafe_new_contract_state();
let mut state = SimpleQuorumExecutionStrategy::unsafe_new_contract_state();
SimpleQuorumExecutionStrategy::initializer(ref state, quorum);
}

Expand Down
3 changes: 1 addition & 2 deletions starknet/src/external/ownable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Migrated lib to v2
#[starknet::contract]
mod Ownable {
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::{ContractAddress, get_caller_address};
use zeroable::Zeroable;

#[storage]
Expand Down
28 changes: 18 additions & 10 deletions starknet/src/factory/factory.cairo
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use starknet::ContractAddress;
use starknet::ClassHash;
use starknet::{ContractAddress, ClassHash};

#[starknet::interface]
trait IFactory<TContractState> {
fn deploy(
self: @TContractState,
ref self: TContractState,
class_hash: ClassHash,
contract_address_salt: felt252,
initialize_calldata: Span<felt252>
Expand All @@ -15,24 +14,33 @@ trait IFactory<TContractState> {
#[starknet::contract]
mod Factory {
use super::IFactory;
use starknet::ContractAddress;
use starknet::contract_address_const;
use starknet::syscalls::{deploy_syscall, call_contract_syscall};
use starknet::ClassHash;
use starknet::{
ContractAddress, ClassHash, contract_address_const,
syscalls::{deploy_syscall, call_contract_syscall}
};
use result::ResultTrait;
use array::{ArrayTrait, SpanTrait};
use sx::utils::constants::INITIALIZE_SELECTOR;

#[event]
fn SpaceDeployed(class_hash: ClassHash, space_address: ContractAddress) {}
#[derive(Drop, starknet::Event)]
enum Event {
SpaceDeployed: SpaceDeployed
}

#[derive(Drop, starknet::Event)]
struct SpaceDeployed {
class_hash: ClassHash,
space_address: ContractAddress
}

#[storage]
struct Storage {}

#[external(v0)]
impl Factory of IFactory<ContractState> {
fn deploy(
self: @ContractState,
ref self: ContractState,
class_hash: ClassHash,
contract_address_salt: felt252,
initialize_calldata: Span<felt252>
Expand All @@ -46,7 +54,7 @@ mod Factory {
call_contract_syscall(space_address, INITIALIZE_SELECTOR, initialize_calldata)
.unwrap_syscall();

SpaceDeployed(class_hash, space_address);
self.emit(Event::SpaceDeployed(SpaceDeployed { class_hash, space_address }));

space_address
}
Expand Down
3 changes: 1 addition & 2 deletions starknet/src/interfaces/i_account.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use array::ArrayTrait;
use array::SpanTrait;
use array::{ArrayTrait, SpanTrait};
use starknet::account::Call;
use starknet::ContractAddress;

Expand Down
4 changes: 2 additions & 2 deletions starknet/src/interfaces/i_proposal_validation_strategy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trait IProposalValidationStrategy<TContractState> {
fn validate(
self: @TContractState,
author: UserAddress,
params: Array<felt252>,
user_params: Array<felt252>
params: Span<felt252>,
user_params: Span<felt252>
) -> bool;
}
4 changes: 2 additions & 2 deletions starknet/src/interfaces/i_voting_strategy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait IVotingStrategy<TContractState> {
self: @TContractState,
timestamp: u32,
voter: UserAddress,
params: Array<felt252>,
user_params: Array<felt252>,
params: Span<felt252>,
user_params: Span<felt252>,
) -> u256;
}
19 changes: 10 additions & 9 deletions starknet/src/proposal_validation_strategies/proposing_power.cairo
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#[starknet::contract]
mod ProposingPowerProposalValidationStrategy {
use sx::interfaces::IProposalValidationStrategy;
use sx::types::{UserAddress, IndexedStrategy, IndexedStrategyTrait, Strategy};
use sx::interfaces::{IVotingStrategyDispatcher, IVotingStrategyDispatcherTrait};
use starknet::ContractAddress;
use starknet::info;
use sx::{
interfaces::{
IProposalValidationStrategy, IVotingStrategyDispatcher, IVotingStrategyDispatcherTrait
},
types::{UserAddress, IndexedStrategy, IndexedStrategyTrait, Strategy},
utils::{bits::BitSetter, proposition_power::_validate}
};
use starknet::{ContractAddress, info};
use traits::{Into, TryInto};
use option::OptionTrait;
use result::ResultTrait;
use array::{ArrayTrait, SpanTrait};
use serde::Serde;
use sx::utils::bits::BitSetter;
use box::BoxTrait;
use clone::Clone;
use sx::utils::proposition_power::_validate;

#[storage]
struct Storage {}
Expand All @@ -23,8 +24,8 @@ mod ProposingPowerProposalValidationStrategy {
fn validate(
self: @ContractState,
author: UserAddress,
params: Array<felt252>, // [proposal_threshold: u256, allowed_strategies: Array<Strategy>]
user_params: Array<felt252> // [user_strategies: Array<IndexedStrategy>]
params: Span<felt252>, // [proposal_threshold: u256, allowed_strategies: Array<Strategy>]
user_params: Span<felt252> // [user_strategies: Array<IndexedStrategy>]
) -> bool {
_validate(author, params, user_params)
}
Expand Down
4 changes: 2 additions & 2 deletions starknet/src/proposal_validation_strategies/vanilla.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ mod VanillaProposalValidationStrategy {
fn validate(
self: @ContractState,
author: UserAddress,
params: Array<felt252>,
user_params: Array<felt252>
params: Span<felt252>,
user_params: Span<felt252>
) -> bool {
true
}
Expand Down
Loading

0 comments on commit 9ece175

Please sign in to comment.