You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The getPowerUpInfo function in the powerUps contract returns an "empty" powerUp when id is out of range / does not exist. Should we instead have getPowerUpInfo revert when the passed id is out of range / does not exist?
Current code:
/**
* @dev Returns info about a given PowerUp
* @param id The index of the PowerUp in the powerUps array
*/
function getPowerUpInfo(
uint256 id
)
external
view
returns (
string memory contentAddress,
uint256 tokensBurned,
uint256 lastTopupTime,
bytes32 keyword
)
{
if (powerUps.length > id) {
PowerUp storage powerUp = powerUps[id];
contentAddress = powerUp.contentAddress;
tokensBurned = powerUp.tokensBurned;
lastTopupTime = powerUp.lastTopupTime;
keyword = powerUp.keyword;
}
return (contentAddress, tokensBurned, lastTopupTime, keyword);
}
Proposed change:
/**
* @dev Returns info about a given PowerUp
* @param id The index of the PowerUp in the powerUps array
*/
function getPowerUpInfo(
uint256 id
)
external
view
returns (
string memory contentAddress,
uint256 tokensBurned,
uint256 lastTopupTime,
bytes32 keyword
)
{
require(id < powerUps.length, "id is out of range");
PowerUp storage powerUp = powerUps[id];
contentAddress = powerUp.contentAddress;
tokensBurned = powerUp.tokensBurned;
lastTopupTime = powerUp.lastTopupTime;
keyword = powerUp.keyword;
return (contentAddress, tokensBurned, lastTopupTime, keyword);
}
The text was updated successfully, but these errors were encountered:
The
getPowerUpInfo
function in thepowerUps
contract returns an "empty" powerUp whenid
is out of range / does not exist. Should we instead havegetPowerUpInfo
revert when the passed id is out of range / does not exist?Current code:
Proposed change:
The text was updated successfully, but these errors were encountered: