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.
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()
, andsend()
all recompute the derived token id before callinggetApprovedUpdate()
. Consider computing the derived token ID within thegetApprovedUpdate()
function. To avoid recomputing the derived token ID insend()
, the developers could havegetApprovedUpdate()
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 ofapproveAccountUpdates()
.o1js/src/lib/provable/merkle-list.ts
:from()
,fromReverse()
: Note thatfrom(array)
is simplyfromReverse([...array].reverse())
, but both functions instead implement the same logic.MerkleListIterator
,MerkleListIterator.Unsafe
: Both objects implementprevious()
andnext()
methods which share the majority of their logic.