Skip to content

Repeated env.storage().instance().get(&Key).unwrap_or(default) boilerplate has no shared accessor #226

Description

@N-thnI

Problem

The pattern env.storage().instance().get(&Key).unwrap_or(default) is repeated 40+ times across src/contracts/logic.rs and src/contracts/proxy_entry.rs (e.g. logic.rs around the snapshot/vote-processing functions), with no shared accessor — even though src/storage.rs already demonstrates the alternative pattern (thin named wrapper functions like get_active_task/get_archived_task) for task storage specifically.

Why it matters

The storage.rs pattern isn't applied consistently to the many DataKey reads scattered through logic.rs/proxy_entry.rs, so those reads carry no named intent (what value, what default, why) and any change to how a given key is stored/defaulted has to be hunted down across many inline call sites instead of one wrapper function.

Suggested fix

Extract named accessor functions (following the existing storage.rs convention) for the most frequently repeated DataKey reads in logic.rs/proxy_entry.rs.

Acceptance criteria

  • The most repeated raw storage-read patterns are replaced with named accessor functions
  • Existing tests covering the affected reads still pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions