Skip to content

Instantly share code, notes, and snippets.

@alexon1234
Created May 11, 2021
Embed
What would you like to do?
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