Skip to content

ACL: Add transfer super admin api#94

Merged
mooori merged 2 commits into
masterfrom
transfer-super-admin
Mar 15, 2023
Merged

ACL: Add transfer super admin api#94
mooori merged 2 commits into
masterfrom
transfer-super-admin

Conversation

@karim-en
Copy link
Copy Markdown
Collaborator

Currently, the ACL plugin provides api to init single super admin by acl_init_super_admin. But to transfer the admin to another account, the developers need to write their own method, like this:

    pub fn transfer_super_admin(&mut self, account_id: AccountId) {
        let current_super_admin = env::predecessor_account_id();

        near_sdk::require!(
            self.acl_get_or_init()
                .revoke_super_admin_unchecked(&current_super_admin),
            "Failed to revoke super-admin."
        );

        near_sdk::require!(
            self.acl_get_or_init().init_super_admin(&account_id),
            "Failed to init super-admin."
        );
    }

This pull request adds a default implementation to transfer the super admin permissions to another account, this could be useful for transferring the super admin to DAO or another account, or on migration from one DAO to another.

Added pubic APIs:

fn acl_transfer_super_admin(&mut self, account_id: AccountId) -> Option<bool>;

@karim-en karim-en added the enhancement New feature or request label Mar 14, 2023
@karim-en karim-en requested review from birchmd, mooori and sept-en March 14, 2023 02:24
Copy link
Copy Markdown
Contributor

@mooori mooori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this devx improvement! Docs should be changed slightly and I would add another assertion in the test. Otherwise LGTM.

Comment thread near-plugins/src/access_controllable.rs Outdated
Comment thread near-plugins/src/access_controllable.rs Outdated
Comment thread near-plugins/src/access_controllable.rs Outdated
Comment thread near-plugins-derive/tests/access_controllable.rs
Co-authored-by: mooori <moritz.zielke@aurora.dev>
Copy link
Copy Markdown

@birchmd birchmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @karim-en !

@mooori mooori merged commit 18b08df into master Mar 15, 2023
@mooori mooori deleted the transfer-super-admin branch March 15, 2023 06:49
Comment thread near-plugins-derive/src/access_controllable.rs
This was referenced Mar 27, 2026
This was referenced Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants