-
Notifications
You must be signed in to change notification settings - Fork 81
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
Quitting the DAO #67
Open
swfsql
wants to merge
14
commits into
near-daos:main
Choose a base branch
from
chikai-io:issue/41/quitting-updated-binaries3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Quitting the DAO #67
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fb634f6
init implementation
482f1d0
added direct interface; simplified removal
0e71873
Merge branch 'main' into issue/41/quitting
11a4091
use crate::* and remove ContractContract workaround
mikedotexe d03f261
small typo fix
mikedotexe ecd8db6
Merge pull request #1 from near-daos/hotfix/remove-sim-test-code
swfsql 0966774
rm unnecessary braces
f6c7ea4
fix comment
cf80656
tests reorg; started adding new tests
409279e
init test-based dev
0fe72ad
test_quit_removes_votes1 passes
c8f43d9
ignored 2nd test
760dc07
Merge branch 'main' into issue/41/quitting-updated-binaries3
0bad2ea
update wasm binary
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::*; | ||
use near_sdk::{env, near_bindgen, AccountId}; | ||
|
||
#[near_bindgen] | ||
impl Contract { | ||
/// Removes a user from all roles. | ||
/// Returns `true` if the user was removed from at least one role. | ||
/// | ||
/// The required parameters are used for checking against the caller | ||
/// and the DAO's name to help in preventing mistakes. | ||
pub fn quit_from_all_roles(&mut self, user: AccountId, dao: String) -> bool { | ||
let quitting_member = env::predecessor_account_id(); | ||
if quitting_member != user { | ||
env::panic_str("ERR_QUIT_WRONG_ACC"); | ||
} | ||
|
||
let dao_name = self.get_config().name; | ||
if dao_name != dao { | ||
env::panic_str("ERR_QUIT_WRONG_DAO"); | ||
} | ||
|
||
let mut new_policy = self.policy.get().unwrap().to_policy(); | ||
let removed = new_policy.remove_member_from_all_roles(&quitting_member); | ||
self.policy | ||
.set(&crate::VersionedPolicy::Current(new_policy)); | ||
removed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,14 @@ use near_sdk::{ | |
}; | ||
|
||
use crate::bounties::{Bounty, BountyClaim, VersionedBounty}; | ||
pub use crate::policy::{Policy, RoleKind, RolePermission, VersionedPolicy, VotePolicy}; | ||
pub use crate::policy::{ | ||
Policy, ProposalPermission, RoleKind, RolePermission, VersionedPolicy, VotePolicy, | ||
}; | ||
use crate::proposals::VersionedProposal; | ||
pub use crate::proposals::{Proposal, ProposalInput, ProposalKind, ProposalStatus}; | ||
pub use crate::types::{Action, Config}; | ||
|
||
mod basic_action; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit pick here - but can this file be called "council" or something, so its a file dedicated to council actions/abilities/controls? |
||
mod bounties; | ||
mod delegation; | ||
mod policy; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@swfsql I think it should check that this DAO wouldn't lock, like if this was the last council / etc. Would be sad to have a user quit and lock the DAO for scenarios with diff groups or token weights that leave a community hanging.