refactor(common): consolidate duplicated primary-admin lookup - #602
Open
Hollujay wants to merge 2 commits into
Open
refactor(common): consolidate duplicated primary-admin lookup#602Hollujay wants to merge 2 commits into
Hollujay wants to merge 2 commits into
Conversation
Both bettapay_common's dead single-admin path and settlement/governance's inline `admins.get(0).unwrap()` reimplemented the same "first entry of the stored multisig admin list" semantics. Add storage::primary_admin as the one shared implementation and route settlement's read_admin and governance's stored-admin lookups through it. Closes Betta-Pay#553
Contributor
Author
|
Kindly review PR for merging @therealjhay |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
bettapay_common::storage::read_adminandsettlement_contract's localread_adminboth existed to answer "what is the first/primary admin," but with incompatible storage backends — the common one read a never-writtenCommonDataKey::AdminsingularAddress, while settlement (and governance) actually store the admin role as a multisigVec<Address>and pullget(0)for single-address contexts.bettapay_common::storage::primary_admin(admins: &Vec<Address>) -> Option<Address>as the one shared implementation of that "first entry" semantic.settlement_contract::storage::read_adminand the two governance call sites that pull the primary admin off a storage-readVec<Address>(execute_recovery,transfer_admin) through the new helper..get(0).unwrap()call sites untouched — those extract the acting caller from a caller-supplied signer list, a different concern from reading the stored admin.Usage audit
settlement_contract/src/storage.rs::read_admin— now callsstorage::primary_admin.governance_contract/src/lib.rs::execute_recovery— now callsstorage::primary_admin.governance_contract/src/lib.rs::transfer_admin— now callsstorage::primary_adminforold_admin.Test plan
cargo test --workspace— all 33 governance + 16 settlement + 2 new bettapay_common unit tests passcargo clippy --workspace --all-targets— cleanbettapay_common::storage::tests::primary_admin_returns_first_entry/primary_admin_returns_none_for_empty_listCloses #553