OpenZeppelin / OpenZeppelin/compact-contracts

Followups: `NFT refactor -> replace pk with sk #469`

Open
#511 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1-medium effort: 2-S feat:token
Dominant language
TypeScript
Stars
55
Forks
29
Avg merge
5d 7h
Merged PRs (30d)
25

Description

⚪ Nitpicks
  1. Witness naming convention — camelCase (https://github.com/OpenZeppelin/compact-contracts/pull/469) NonFungibleToken.compact:137 — Rename wit_NonFungibleTokenSK()wit_nonFungibleTokenSK(). If agreed, apply consistently to the rest of the refactors.
🔵 Followups
  1. Move `` to a utility module (https://github.com/OpenZeppelin/compact-contracts/pull/469) NonFungibleToken.compact:145
  2. **Redundant canonicalization in **`` (https://github.com/OpenZeppelin/compact-contracts/pull/469) NonFungibleToken.compact:549 — `canonOwner`/`canonSpender` are canonicalized, then `isApprovedForAll(canonOwner, canonSpender)` re-canonicalizes them at L391–392. Same pattern in `_update` line 615 where `fromAddress` (already canonical, sourced from `_ownerOf`) is re-canonicalized.
  3. Move helper to a separate module (https://github.com/OpenZeppelin/compact-contracts/pull/469) NonFungibleToken.compact:924
  4. Move helper to Utils (https://github.com/OpenZeppelin/compact-contracts/pull/469) NonFungibleToken.compact:935
  5. Test hasher drift risk (https://github.com/OpenZeppelin/compact-contracts/pull/469) contracts/src/token/test/nonFungibleToken.test.ts:14 — Fine for now, but if the hasher in the circuit changes, this fn must change too. Worth adding a note on the function.
  6. **Drop redundant **** calls in ** (https://github.com/OpenZeppelin/compact-contracts/pull/469) NonFungibleToken.compact:612–617
    • L612: _isTargetZero(disclose(fromAddress))_isTargetZero(fromAddress)
    • L616: _balances.lookup(disclose(canonFrom))_balances.lookup(canonFrom)
    • L617: _balances.insert(disclose(canonFrom), disclose(newBalance))_balances.insert(canonFrom, newBalance)
      Rationale: fromAddress = _ownerOf(tokenId) is a ledger read (untainted), canonFrom inherits that, lookup - 1 stays untainted. Cross-cutting: worth running the same audit on the merged FT / AC / Ownable refactors.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced NonFungibleToken.compact locations and contracts/src/token/test/nonFungibleToken.test.ts, then review PR #469 for the surrounding refactor context. Resolve the listed naming, utility-module, canonicalization, disclosure, and test-maintenance followups, and audit the merged FT, AC, and Ownable refactors for the same redundant calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.