Skip to content

Instantly share code, notes, and snippets.

@alexon1234
Created May 11, 2021 22:33
Show Gist options
  • Save alexon1234/7b6799434cccda5e3f3d461b8186ec89 to your computer and use it in GitHub Desktop.
Save alexon1234/7b6799434cccda5e3f3d461b8186ec89 to your computer and use it in GitHub Desktop.
Using calldata when not needed

In StakingTokenProvider, we have two method using calldata for passing string that do not call external contracts. Calldata should be used just when the argument will be used to call an external contract

    function setPairedTokenForVaultToken(
        address _vaultToken,
        address _newPairedToken,
        string calldata _newPrefix
    ) external onlyOwner {
        emit NewPairedTokenForVault(
            _vaultToken,
            pairedToken[_vaultToken],
            _newPairedToken
        );
        pairedToken[_vaultToken] = _newPairedToken;
        pairedPrefix[_vaultToken] = _newPrefix;
    }

    function setDefaultPairedToken(
        address _newDefaultPaired,
        //FIXME: Calldata ??
        string calldata _newDefaultPrefix
    ) external onlyOwner {
        emit NewDefaultPaired(defaultPairedToken, _newDefaultPaired);
        defaultPairedToken = _newDefaultPaired;
        defaultPrefix = _newDefaultPrefix;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment