Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:snapshot-labs/sx-starknet into c…
Browse files Browse the repository at this point in the history
…hore_test_events
  • Loading branch information
pscott committed Sep 4, 2023
2 parents e1a3e53 + 698d4dd commit cd3eaf8
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 133 deletions.
18 changes: 9 additions & 9 deletions starknet/src/authenticators/eth_sig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait IEthSigAuthenticator<TContractState> {
author: EthAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: u256,
);
fn authenticate_vote(
Expand All @@ -25,7 +25,7 @@ trait IEthSigAuthenticator<TContractState> {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
);
fn authenticate_update_proposal(
ref self: TContractState,
Expand All @@ -36,7 +36,7 @@ trait IEthSigAuthenticator<TContractState> {
author: EthAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: u256
);
}
Expand Down Expand Up @@ -69,7 +69,7 @@ mod EthSigAuthenticator {
author: EthAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: u256,
) {
signatures::verify_propose_sig(
Expand All @@ -90,7 +90,7 @@ mod EthSigAuthenticator {
UserAddress::Ethereum(author),
execution_strategy,
user_proposal_validation_params,
metadata_URI
metadata_uri
);
}

Expand All @@ -104,7 +104,7 @@ mod EthSigAuthenticator {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
) {
signatures::verify_vote_sig(
r,
Expand All @@ -126,7 +126,7 @@ mod EthSigAuthenticator {
proposal_id,
choice,
user_voting_strategies,
metadata_URI
metadata_uri
);
}

Expand All @@ -139,7 +139,7 @@ mod EthSigAuthenticator {
author: EthAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: u256
) {
signatures::verify_update_proposal_sig(
Expand All @@ -157,7 +157,7 @@ mod EthSigAuthenticator {

ISpaceDispatcher { contract_address: target }
.update_proposal(
UserAddress::Ethereum(author), proposal_id, execution_strategy, metadata_URI
UserAddress::Ethereum(author), proposal_id, execution_strategy, metadata_uri
);
}
}
Expand Down
24 changes: 12 additions & 12 deletions starknet/src/authenticators/eth_tx.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait IEthTxAuthenticator<TContractState> {
author: EthAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
);
fn authenticate_vote(
ref self: TContractState,
Expand All @@ -18,15 +18,15 @@ trait IEthTxAuthenticator<TContractState> {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
);
fn authenticate_update_proposal(
ref self: TContractState,
target: ContractAddress,
author: EthAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
);
// TODO: Should L1 handlers be part of the interface?
}
Expand Down Expand Up @@ -55,15 +55,15 @@ mod EthTxAuthenticator {
author: EthAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
) {
let mut payload = array![];
target.serialize(ref payload);
PROPOSE_SELECTOR.serialize(ref payload);
author.serialize(ref payload);
execution_strategy.serialize(ref payload);
user_proposal_validation_params.serialize(ref payload);
metadata_URI.serialize(ref payload);
metadata_uri.serialize(ref payload);
let payload_hash = poseidon::poseidon_hash_span(payload.span());

consume_commit(ref self, payload_hash, author);
Expand All @@ -73,7 +73,7 @@ mod EthTxAuthenticator {
UserAddress::Ethereum(author),
execution_strategy,
user_proposal_validation_params,
metadata_URI
metadata_uri
);
}

Expand All @@ -84,7 +84,7 @@ mod EthTxAuthenticator {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
) {
let mut payload = array![];
target.serialize(ref payload);
Expand All @@ -93,7 +93,7 @@ mod EthTxAuthenticator {
proposal_id.serialize(ref payload);
choice.serialize(ref payload);
user_voting_strategies.serialize(ref payload);
metadata_URI.serialize(ref payload);
metadata_uri.serialize(ref payload);
let payload_hash = poseidon::poseidon_hash_span(payload.span());

consume_commit(ref self, payload_hash, voter);
Expand All @@ -104,7 +104,7 @@ mod EthTxAuthenticator {
proposal_id,
choice,
user_voting_strategies,
metadata_URI
metadata_uri
);
}

Expand All @@ -114,22 +114,22 @@ mod EthTxAuthenticator {
author: EthAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
) {
let mut payload = array![];
target.serialize(ref payload);
UPDATE_PROPOSAL_SELECTOR.serialize(ref payload);
author.serialize(ref payload);
proposal_id.serialize(ref payload);
execution_strategy.serialize(ref payload);
metadata_URI.serialize(ref payload);
metadata_uri.serialize(ref payload);
let payload_hash = poseidon::poseidon_hash_span(payload.span());

consume_commit(ref self, payload_hash, author);

ISpaceDispatcher { contract_address: target }
.update_proposal(
UserAddress::Ethereum(author), proposal_id, execution_strategy, metadata_URI
UserAddress::Ethereum(author), proposal_id, execution_strategy, metadata_uri
);
}
}
Expand Down
24 changes: 12 additions & 12 deletions starknet/src/authenticators/stark_sig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait IStarkSigAuthenticator<TContractState> {
author: ContractAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: felt252,
account_type: felt252
);
Expand All @@ -22,7 +22,7 @@ trait IStarkSigAuthenticator<TContractState> {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
account_type: felt252
);
fn authenticate_update_proposal(
Expand All @@ -32,7 +32,7 @@ trait IStarkSigAuthenticator<TContractState> {
author: ContractAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: felt252,
account_type: felt252
);
Expand Down Expand Up @@ -62,7 +62,7 @@ mod StarkSigAuthenticator {
author: ContractAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: felt252,
account_type: felt252
) {
Expand All @@ -75,7 +75,7 @@ mod StarkSigAuthenticator {
author,
@execution_strategy,
user_proposal_validation_params.span(),
metadata_URI.span(),
metadata_uri.span(),
salt,
account_type
);
Expand All @@ -86,7 +86,7 @@ mod StarkSigAuthenticator {
UserAddress::Starknet(author),
execution_strategy,
user_proposal_validation_params,
metadata_URI
metadata_uri
);
}

Expand All @@ -98,7 +98,7 @@ mod StarkSigAuthenticator {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
account_type: felt252
) {
// No need to check salts here, as double voting is prevented by the space itself.
Expand All @@ -111,7 +111,7 @@ mod StarkSigAuthenticator {
proposal_id,
choice,
user_voting_strategies.span(),
metadata_URI.span(),
metadata_uri.span(),
account_type
);

Expand All @@ -121,7 +121,7 @@ mod StarkSigAuthenticator {
proposal_id,
choice,
user_voting_strategies,
metadata_URI
metadata_uri
);
}

Expand All @@ -132,7 +132,7 @@ mod StarkSigAuthenticator {
author: ContractAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>,
metadata_uri: Array<felt252>,
salt: felt252,
account_type: felt252
) {
Expand All @@ -145,15 +145,15 @@ mod StarkSigAuthenticator {
author,
proposal_id,
@execution_strategy,
metadata_URI.span(),
metadata_uri.span(),
salt,
account_type
);

self._used_salts.write((author, salt), true);
ISpaceDispatcher { contract_address: target }
.update_proposal(
UserAddress::Starknet(author), proposal_id, execution_strategy, metadata_URI
UserAddress::Starknet(author), proposal_id, execution_strategy, metadata_uri
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions starknet/src/authenticators/stark_tx.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait IStarkTxAuthenticator<TContractState> {
author: ContractAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
);
fn authenticate_vote(
ref self: TContractState,
Expand All @@ -18,15 +18,15 @@ trait IStarkTxAuthenticator<TContractState> {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
);
fn authenticate_update_proposal(
ref self: TContractState,
space: ContractAddress,
author: ContractAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
);
}

Expand All @@ -50,7 +50,7 @@ mod StarkTxAuthenticator {
author: ContractAddress,
execution_strategy: Strategy,
user_proposal_validation_params: Array<felt252>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
) {
assert(info::get_caller_address() == author, 'Invalid Caller');

Expand All @@ -59,7 +59,7 @@ mod StarkTxAuthenticator {
UserAddress::Starknet(author),
execution_strategy,
user_proposal_validation_params,
metadata_URI
metadata_uri
);
}

Expand All @@ -70,7 +70,7 @@ mod StarkTxAuthenticator {
proposal_id: u256,
choice: Choice,
user_voting_strategies: Array<IndexedStrategy>,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
) {
assert(info::get_caller_address() == voter, 'Invalid Caller');

Expand All @@ -80,7 +80,7 @@ mod StarkTxAuthenticator {
proposal_id,
choice,
user_voting_strategies,
metadata_URI
metadata_uri
);
}

Expand All @@ -90,13 +90,13 @@ mod StarkTxAuthenticator {
author: ContractAddress,
proposal_id: u256,
execution_strategy: Strategy,
metadata_URI: Array<felt252>
metadata_uri: Array<felt252>
) {
assert(info::get_caller_address() == author, 'Invalid Caller');

ISpaceDispatcher { contract_address: space }
.update_proposal(
UserAddress::Starknet(author), proposal_id, execution_strategy, metadata_URI
UserAddress::Starknet(author), proposal_id, execution_strategy, metadata_uri
);
}
}
Expand Down
Loading

0 comments on commit cd3eaf8

Please sign in to comment.