Skip to content

πŸ“ SafeTransferLib: checkBalanceOf NatSpec for implemented return value is invertedΒ #1530

@BhariGowda

Description

@BhariGowda

Summary

The NatSpec for checkBalanceOf describes the implemented return value
incorrectly β€” the description is semantically inverted relative to the actual
code behavior.

Current NatSpec (line 458)

/// `implemented` denotes whether the `token` does not implement `balanceOf`.

Actual behavior

implemented := and(
    gt(returndatasize(), 0x1f),
    staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)
)

staticcall returns 1 on success. implemented is therefore true when the
call succeeds β€” i.e., when the token does implement balanceOf.

The word "not" in the NatSpec inverts the meaning. A developer reading the docs
would expect implemented == true to mean "token lacks balanceOf", but the
opposite is true.

Suggested fix

/// `implemented` is `true` if the `token` implements `balanceOf`, `false` otherwise.
/// `amount` is zero if the `token` does not implement `balanceOf`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions