npm run compile
npm run test
Set sender to default member of allowList.
constructor() {
allowList[msg.sender] = true;
}
All functions can only be executed by addresses that are in the allow list.
Initialize Stage
function prepareStage(uint64 stage) external
Finalize stage. Once stage finalized, can't change score of that stage anymore.
function finalizeStage(uint64 stage) external
Increase score.
function increaseScore(uint64 stage, address addr, uint64 amount) external
Decrease score.
function decreaseScore(uint64 stage, address addr, uint64 amount) external
Update the score by setting it to the given amount.
function updateScore(uint64 stage, address addr, uint64 amount) external
Update several scores at once.
function updateScores(uint64 stage, address[] calldata addrs, uint64[] calldata amounts) external
Add new address to allow list
function addAllowList(address addr) external
Remove address from allow list
function removeAllowList(address addr) external
mapping of stage Info
struct StageInfo {
uint64 stage;
uint64 totalScore;
bool isFinalized;
}
mapping(uint64 => StageInfo) public stages;
mapping of user score
struct ScoreResponse {
address addr;
uint64 amount;
uint64 index;
}
mapping(uint64 => mapping(address => Score)) public scores; // stage => address => score
Get scores
function getScores(uint64 stage, uint64 offset, uint8 limit) public view returns (ScoreResponse[] memory)
Response type
struct ScoreResponse {
address addr;
uint64 amount;
uint64 index;
}