Skip to content
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

Unused and duplicate program constructs in o1js #78

Open
kantp opened this issue Jul 2, 2024 · 0 comments
Open

Unused and duplicate program constructs in o1js #78

kantp opened this issue Jul 2, 2024 · 0 comments
Labels
audit Addresses findings from the audit info o1js Issues that require changes in o1js itself, rather than in this repository

Comments

@kantp
Copy link
Collaborator

kantp commented Jul 2, 2024

The following program constructs are unused or have repeated functionality which could be abstracted into a common function.

  • src/lib/mina/token/token-methods.ts:
    • tokenMethods(): mint(), burn(), and send() all recompute the derived token id before calling getApprovedUpdate(). Consider computing the derived token ID within the getApprovedUpdate() function.
      To avoid recomputing the derived token ID in send(), the developers could have getApprovedUpdate() take the token ID as an optional parameter, and return the computed value.

  • src/lib/mina/token/token-contract.ts:
    • TokenContract.approveAccountUpdate(): This function duplicates most of the body of approveAccountUpdates().

  • o1js/src/lib/provable/merkle-list.ts:
    • from(), fromReverse(): Note that from(array) is simply fromReverse([...array].reverse()), but both functions instead implement the same logic.
    • MerkleListIterator, MerkleListIterator.Unsafe: Both objects implement previous() and next() methods which share the majority of their logic.
@kantp kantp added audit Addresses findings from the audit info o1js Issues that require changes in o1js itself, rather than in this repository labels Jul 2, 2024
@kantp kantp moved this to Todo in Fungible Token Audit Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit Addresses findings from the audit info o1js Issues that require changes in o1js itself, rather than in this repository
Projects
Development

No branches or pull requests

1 participant