Skip to content

Commit

Permalink
fix: mark input parameters as const
Browse files Browse the repository at this point in the history
  • Loading branch information
as-iotex authored and as-iotex committed Apr 17, 2022
1 parent a3d9e3c commit 629b539
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/account/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Account::Account()
GenerateAddressesFromPrivateKey();
}

Account::Account(uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE])
Account::Account(const uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE])
{
setDepsFromGlobals();
// Copy the private key
Expand All @@ -30,7 +30,7 @@ Account::Account(uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE])
}

Account::Account(Random* pRandomGenerator, Encoder* pEncoder, Signer* pSigner,
uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE])
const uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE])
{
_pRandomGenerator = pRandomGenerator;
_pSigner = pSigner;
Expand Down
4 changes: 2 additions & 2 deletions src/account/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Account
*
* @param privateKey The private key
*/
Account(uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE]);
Account(const uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE]);

/**************************************************************************/
/* Getters */
Expand Down Expand Up @@ -217,7 +217,7 @@ class Account
public:
// Allow to inject mock dependencies in constructor
Account(Random* pRandomGenerator, Encoder* pEncoder, Signer* pSigner,
uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE] = nullptr);
const uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE] = nullptr);
};
} // namespace iotex

Expand Down
4 changes: 2 additions & 2 deletions src/contract/xrc20Contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void Xrc20Contract::generateCallDataForTotalSupply(uint8_t data[4])
memcpy(data, functionSelector, sizeof(functionSelector));
}

void Xrc20Contract::generateCallDataForBalanceOf(uint8_t address[ETH_ADDRESS_SIZE],
void Xrc20Contract::generateCallDataForBalanceOf(const uint8_t address[ETH_ADDRESS_SIZE],
uint8_t data[36])
{
uint8_t* it = data;
Expand All @@ -19,7 +19,7 @@ void Xrc20Contract::generateCallDataForBalanceOf(uint8_t address[ETH_ADDRESS_SIZ
Contract::generateBytesForAddress(address, it);
}

void Xrc20Contract::generateCallDataForTransfer(uint8_t to[ETH_ADDRESS_SIZE], uint64_t value,
void Xrc20Contract::generateCallDataForTransfer(const uint8_t to[ETH_ADDRESS_SIZE], uint64_t value,
uint8_t data[68])
{
uint8_t* it = data;
Expand Down
4 changes: 2 additions & 2 deletions src/contract/xrc20Contract.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Xrc20Contract
* @param address The ethereum address
* @param[out] data The buffere where the data is stored
*/
static void generateCallDataForBalanceOf(uint8_t address[ETH_ADDRESS_SIZE],
static void generateCallDataForBalanceOf(const uint8_t address[ETH_ADDRESS_SIZE],
uint8_t data[IOTEX_CONTRACT_ENCODED_TOTALSUPPLY_SIZE]);

/**
Expand All @@ -39,7 +39,7 @@ class Xrc20Contract
* @param value The amount to transfer
* @param data
*/
static void generateCallDataForTransfer(uint8_t to[ETH_ADDRESS_SIZE], uint64_t value,
static void generateCallDataForTransfer(const uint8_t to[ETH_ADDRESS_SIZE], uint64_t value,
uint8_t data[IOTEX_CONTRACT_ENCODED_TRANSFER_SIZE]);
};
} // namespace iotex
Expand Down

0 comments on commit 629b539

Please sign in to comment.