Wny does `getProxyImplementation` method in `ProxyAdmin` contract need to be `view`

function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
        // We need to manually run the static call since the getter cannot be flagged as view
        // bytes4(keccak256("implementation()")) == 0x5c60da1b
        (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
        return abi.decode(returndata, (address));

I am having trouble understanding the getProxyImplementation method mutability, why does it need to be strict to view.

Is this solely because marking functions as view facilitates users to interact with the contract on Etherscan? because non-view functions need a transaction while view functions don't?

Because it ultimately triggers a storage-read from this storage slot.

You can observe this by following the stack trace:

  • ProxyAdmin.getProxyImplementation
  • TransparentUpgradeableProxy.implementation
  • ERC1967Proxy._implementation
  • ERC1967Upgrade._getImplementation

Yes. Getters generally should be view.

Thanks for the reply, ser!