Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use named return #189

Merged
merged 8 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/gas-estimation/InterchainGasEstimation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ abstract contract InterchainGasEstimation is IInterchainGasEstimation {

uint256 txSize = _l1TxSize(payload) + overhead + (4 * 16);

return (l1GasInfo.relativeGasPrice * txSize * gasInfo.l1FeeScalar) / precision;
l1DataFee = (l1GasInfo.relativeGasPrice * txSize * gasInfo.l1FeeScalar) / precision;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions contracts/gateway/AxelarAmplifierGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ contract AxelarAmplifierGateway is BaseAmplifierGateway, BaseWeightedMultisig, U
* @return isLatestSigners True if provided signers are the current ones
*/
function validateProof(bytes32 dataHash, Proof calldata proof) external view returns (bool isLatestSigners) {
return _validateProof(dataHash, proof);
isLatestSigners = _validateProof(dataHash, proof);
}

/**
* @notice Returns the address of the gateway operator.
* @return The address of the operator.
* @return operatorAddress The address of the operator.
ahramy marked this conversation as resolved.
Show resolved Hide resolved
*/
function operator() external view returns (address) {
return _axelarAmplifierGatewayStorage().operator;
function operator() external view returns (address operatorAddress) {
operatorAddress = _axelarAmplifierGatewayStorage().operator;
}

/**
Expand Down
16 changes: 11 additions & 5 deletions contracts/gateway/BaseAmplifierGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ abstract contract BaseAmplifierGateway is IBaseAmplifierGateway {
* @notice Compute the commandId for a message.
* @param sourceChain The name of the source chain as registered on Axelar.
* @param messageId The unique message id for the message.
* @return The commandId for the message.
* @return commandId The commandId for the message.
*/
function messageToCommandId(string calldata sourceChain, string calldata messageId) public pure returns (bytes32) {
function messageToCommandId(string calldata sourceChain, string calldata messageId)
public
pure
returns (bytes32 commandId)
{
// Axelar doesn't allow `sourceChain` to contain '_', hence this encoding is umambiguous
return keccak256(bytes(string.concat(sourceChain, '_', messageId)));
commandId = keccak256(bytes(string.concat(sourceChain, '_', messageId)));
}

/*************************\
Expand Down Expand Up @@ -170,6 +174,7 @@ abstract contract BaseAmplifierGateway is IBaseAmplifierGateway {

/**
* @dev For backwards compatibility with `validateContractCall`, `commandId` is used here instead of `messageId`.
* @return valid True if message is valid
*/
function _validateMessage(
bytes32 commandId,
Expand Down Expand Up @@ -224,15 +229,16 @@ abstract contract BaseAmplifierGateway is IBaseAmplifierGateway {

/**
* @dev For backwards compatibility with `validateContractCall`, `commandId` is used here instead of `messageId`.
* @return hash the message hash
*/
function _messageHash(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
address contractAddress,
bytes32 payloadHash
) internal pure returns (bytes32) {
return keccak256(abi.encode(commandId, sourceChain, sourceAddress, contractAddress, payloadHash));
) internal pure returns (bytes32 hash) {
hash = keccak256(abi.encode(commandId, sourceChain, sourceAddress, contractAddress, payloadHash));
ahramy marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
18 changes: 9 additions & 9 deletions contracts/governance/BaseMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ contract BaseMultisig is IBaseMultisig {

/**
* @notice Returns the current signer threshold
* @return uint The signer threshold
* @return threshold The signer threshold
*/
function signerThreshold() external view override returns (uint256) {
return signers.threshold;
function signerThreshold() external view override returns (uint256 threshold) {
ahramy marked this conversation as resolved.
Show resolved Hide resolved
threshold = signers.threshold;
}

/**
* @notice Returns an array of current signers
* @return array of signer addresses
* @return signersAccounts array of signer addresses
*/
function signerAccounts() external view override returns (address[] memory) {
return signers.accounts;
function signerAccounts() external view override returns (address[] memory signersAccounts) {
signersAccounts = signers.accounts;
}

/**
Expand All @@ -85,10 +85,10 @@ contract BaseMultisig is IBaseMultisig {

/**
* @notice Get the number of votes for a topic
* @return uint256 indicating the number of votes for a topic
* @return singerVotesCount indicating the number of votes for a topic
*/
function getSignerVotesCount(bytes32 topic) external view override returns (uint256) {
return votingPerTopic[signerEpoch][topic].voteCount;
function getSignerVotesCount(bytes32 topic) external view override returns (uint256 singerVotesCount) {
singerVotesCount = votingPerTopic[signerEpoch][topic].voteCount;
}

/***********\
Expand Down
36 changes: 18 additions & 18 deletions contracts/governance/BaseWeightedMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,44 @@ abstract contract BaseWeightedMultisig is IBaseWeightedMultisig {

/**
* @notice This function returns the current signers epoch
* @return uint256 The current signers epoch
* @return epoch_ The current signers epoch
*/
function epoch() external view returns (uint256) {
return _baseWeightedMultisigStorage().epoch;
function epoch() external view returns (uint256 epoch_) {
epoch_ = _baseWeightedMultisigStorage().epoch;
}

/**
* @notice This function returns the signers hash for a given epoch
* @param signerEpoch The given epoch
* @return bytes32 The signers hash for the given epoch
* @return singerHashByEpoch_ The signers hash for the given epoch
*/
function signerHashByEpoch(uint256 signerEpoch) external view returns (bytes32) {
return _baseWeightedMultisigStorage().signerHashByEpoch[signerEpoch];
function signerHashByEpoch(uint256 signerEpoch) external view returns (bytes32 singerHashByEpoch_) {
singerHashByEpoch_ = _baseWeightedMultisigStorage().signerHashByEpoch[signerEpoch];
}

/**
* @notice This function returns the epoch for a given signers hash
* @param signerHash The signers hash
* @return uint256 The epoch for the given signers hash
* @return epochBySingerHash_ The epoch for the given signers hash
*/
function epochBySignerHash(bytes32 signerHash) external view returns (uint256) {
return _baseWeightedMultisigStorage().epochBySignerHash[signerHash];
function epochBySignerHash(bytes32 signerHash) external view returns (uint256 epochBySingerHash_) {
epochBySingerHash_ = _baseWeightedMultisigStorage().epochBySignerHash[signerHash];
}

/**
* @notice This function returns the timestamp for the last signer rotation
* @return uint256 The last rotation timestamp
* @return lastRotationTimestamp_ The last rotation timestamp
*/
function lastRotationTimestamp() external view returns (uint256) {
return _baseWeightedMultisigStorage().lastRotationTimestamp;
function lastRotationTimestamp() external view returns (uint256 lastRotationTimestamp_) {
lastRotationTimestamp_ = _baseWeightedMultisigStorage().lastRotationTimestamp;
}

/**
* @notice This function returns the time elapsed (in secs) since the last rotation
* @return uint256 The time since the last rotation
* @return timeSinceRotation_ The time since the last rotation
*/
function timeSinceRotation() external view returns (uint256) {
return block.timestamp - _baseWeightedMultisigStorage().lastRotationTimestamp;
function timeSinceRotation() external view returns (uint256 timeSinceRotation_) {
timeSinceRotation_ = (block.timestamp - _baseWeightedMultisigStorage().lastRotationTimestamp);
}

/*************************\
Expand Down Expand Up @@ -242,11 +242,11 @@ abstract contract BaseWeightedMultisig is IBaseWeightedMultisig {
*
* @param signersHash The hash of the weighted signers that sign off on the data
* @param dataHash The hash of the data
* @return The message hash to be signed
* @return hash The message hash to be signed
*/
function messageHashToSign(bytes32 signersHash, bytes32 dataHash) public view returns (bytes32) {
function messageHashToSign(bytes32 signersHash, bytes32 dataHash) public view returns (bytes32 hash) {
// 96 is the length of the trailing bytes
return keccak256(bytes.concat('\x19Ethereum Signed Message:\n96', domainSeparator, signersHash, dataHash));
hash = keccak256(bytes.concat('\x19Ethereum Signed Message:\n96', domainSeparator, signersHash, dataHash));
}

/**
Expand Down
13 changes: 7 additions & 6 deletions contracts/governance/InterchainGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ contract InterchainGovernance is AxelarGMPExecutable, TimeLock, Caller, IInterch
* @param target The address of the contract targeted by the proposal
* @param callData The call data to be sent to the target contract
* @param nativeValue The amount of native tokens to be sent to the target contract
* @return uint256 The ETA of the proposal
* @return eta The ETA of the proposal
*/
function getProposalEta(
address target,
bytes calldata callData,
uint256 nativeValue
) external view returns (uint256) {
return _getTimeLockEta(_getProposalHash(target, callData, nativeValue));
) external view returns (uint256 eta) {
eta = _getTimeLockEta(_getProposalHash(target, callData, nativeValue));
}

/**
Expand Down Expand Up @@ -174,14 +174,15 @@ contract InterchainGovernance is AxelarGMPExecutable, TimeLock, Caller, IInterch
}

/**
* @dev Get proposal hash using the target, callData, and nativeValue
* @notice Get proposal hash using the target, callData, and nativeValue
* @return hash The proposal hash
*/
function _getProposalHash(
address target,
bytes memory callData,
uint256 nativeValue
) internal pure returns (bytes32) {
return keccak256(abi.encode(target, callData, nativeValue));
) internal pure returns (bytes32 hash) {
hash = keccak256(abi.encode(target, callData, nativeValue));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/InterchainMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract InterchainMultisig is Caller, BaseWeightedMultisig, IInterchainMultisig
* @return isLatestSigners True if provided signers are the current ones
*/
function validateProof(bytes32 dataHash, Proof calldata proof) external view returns (bool isLatestSigners) {
return _validateProof(dataHash, proof);
isLatestSigners = _validateProof(dataHash, proof);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions contracts/interfaces/IBaseAmplifierGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ interface IBaseAmplifierGateway is IAxelarGMPGateway {
* @notice Compute the commandId for a message.
* @param sourceChain The name of the source chain as registered on Axelar.
* @param messageId The unique message id for the message.
* @return The commandId for the message.
* @return commandId The commandId for the message.
*/
function messageToCommandId(string calldata sourceChain, string calldata messageId) external pure returns (bytes32);
function messageToCommandId(string calldata sourceChain, string calldata messageId)
external
pure
returns (bytes32 commandId);
}
10 changes: 3 additions & 7 deletions contracts/utils/RolesBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ contract RolesBase is IRolesBase {
* @param roles The roles to convert
* @return accountRoles The roles in uint256 format
*/
function _toAccountRoles(uint8[] memory roles) internal pure returns (uint256) {
function _toAccountRoles(uint8[] memory roles) internal pure returns (uint256 accountRoles) {
uint256 length = roles.length;
uint256 accountRoles;

for (uint256 i = 0; i < length; ++i) {
accountRoles |= (1 << roles[i]);
}

return accountRoles;
}

/**
Expand All @@ -74,7 +70,7 @@ contract RolesBase is IRolesBase {
* @return key The key of the roles mapping
*/
function _rolesKey(address account) internal view virtual returns (bytes32 key) {
return keccak256(abi.encodePacked(ROLES_PREFIX, account));
key = keccak256(abi.encodePacked(ROLES_PREFIX, account));
}

/**
Expand Down Expand Up @@ -108,7 +104,7 @@ contract RolesBase is IRolesBase {
* @return key The key of the proposed roles mapping
*/
function _proposalKey(address fromAccount, address toAccount) internal view virtual returns (bytes32 key) {
return keccak256(abi.encodePacked(PROPOSE_ROLES_PREFIX, fromAccount, toAccount));
key = keccak256(abi.encodePacked(PROPOSE_ROLES_PREFIX, fromAccount, toAccount));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions contracts/utils/TimeLock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ contract TimeLock is ITimeLock {
/**
* @notice Returns the timestamp after which the TimeLock may be executed.
* @param hash The hash of the timelock
* @return uint The timestamp after which the timelock with the given hash can be executed
* @return timelockEta The timestamp after which the timelock with the given hash can be executed
*/
function getTimeLock(bytes32 hash) external view override returns (uint256) {
return _getTimeLockEta(hash);
function getTimeLock(bytes32 hash) external view override returns (uint256 timelockEta) {
timelockEta = _getTimeLockEta(hash);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/governance/AxelarServiceGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe('AxelarServiceGovernance', () => {
const bytecodeHash = keccak256(bytecode);

const expected = {
london: '0x87891d8e17e62bddae5afa47c6231b236207b7c9cfff0810bc62b226a3765600',
london: '0x2c8ea09d5c343652a353da978b2a9e7249331076e9e2b8f0ece9dc83c30ac1d0',
}[getEVMVersion()];

expect(bytecodeHash).to.be.equal(expected);
Expand Down
2 changes: 1 addition & 1 deletion test/governance/InterchainGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ describe('InterchainGovernance', () => {
const bytecodeHash = keccak256(bytecode);

const expected = {
london: '0x034b9b57bed553b7c9cfa5e4a14304776b65d8a3caefc87df9339203b04df56e',
london: '0x202ff17c4128aed83732fd8f7072e6dd1b19d03e71b28c4ddb10a00025fa0636',
}[getEVMVersion()];

expect(bytecodeHash).to.be.equal(expected);
Expand Down
Loading