-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix a couple nits with the interfaces and code #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marked up with rationale for changes
// Cancel the proposal with the given ID. The proposal may be canceled at any time before it is executed. | ||
// There are two ways the proposal cancellation can be authorized: | ||
// - The proposer can cancel the proposal | ||
// - Anyone can cancel if the average voting weight of the proposer was below the proposal_creation_threshold during the voting period (at the given breach_timestamp) | ||
fn cancel_at_timestamp(ref self: TContractState, id: felt252, breach_timestamp: u64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this method so that a proposal can be canceled by anyone if the proposer's voting weight dips below the threshold at any time t
between when the proposal is created and when the proposal ends
@@ -100,6 +105,7 @@ pub mod Governor { | |||
#[derive(starknet::Event, Drop)] | |||
pub struct Canceled { | |||
pub id: felt252, | |||
pub breach_timestamp: u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously we knew it was always the block in which the event was emitted
since it's no longer true, we need to emit it from the event to know
assert( | ||
breach_timestamp < (proposal.execution_state.created | ||
+ config.voting_start_delay | ||
+ config.voting_period), | ||
'VOTING_ENDED' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that the proposal can still be canceled after voting ends, but before it is executed
executed: 0, | ||
canceled: timestamp_current | ||
canceled: get_block_timestamp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still, we use the current timestamp for the time at which it was canceled
// Transfer the specified amount of token from the caller into this contract and delegates the voting weight to the specified delegate | ||
fn stake_amount(ref self: TContractState, delegate: ContractAddress, amount: u128); | ||
|
||
// Unstakes and withdraws all of the tokens delegated by the sender to the delegate from the contract to the given recipient address | ||
fn withdraw(ref self: TContractState, delegate: ContractAddress, recipient: ContractAddress); | ||
|
||
// Unstakes and withdraws the specified amount of tokens delegated by the sender to the delegate from the contract to the given recipient address | ||
fn withdraw_amount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these improvements to the interface allow you to approve once and then stake for multiple delegates, or move a partial delegation
self | ||
.token | ||
.read() | ||
.allowance(get_caller_address(), get_contract_address()) | ||
.try_into() | ||
.expect('ALLOWANCE_OVERFLOW') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if called without an amount argument, stakes the entire approval
No description provided.