Skip to content

Latest commit

 

History

History
141 lines (93 loc) · 2.06 KB

README.md

File metadata and controls

141 lines (93 loc) · 2.06 KB

VIP Score

Compile

npm run compile

Test

npm run test

Constructor

Set sender to default member of allowList.

constructor() {
    allowList[msg.sender] = true;
}

External functions

All functions can only be executed by addresses that are in the allow list.

prepareStage

Initialize Stage

function prepareStage(uint64 stage) external

finalizeStage

Finalize stage. Once stage finalized, can't change score of that stage anymore.

function finalizeStage(uint64 stage) external

increaseScore

Increase score.

function increaseScore(uint64 stage, address addr, uint64 amount) external

decreaseScore

Decrease score.

function decreaseScore(uint64 stage, address addr, uint64 amount) external

updateScore

Update the score by setting it to the given amount.

function updateScore(uint64 stage, address addr, uint64 amount) external

updateScores

Update several scores at once.

function updateScores(uint64 stage, address[] calldata addrs, uint64[] calldata amounts) external

addAllowList

Add new address to allow list

function addAllowList(address addr) external

removeAllowList

Remove address from allow list

function removeAllowList(address addr) external

Public storage

stages

mapping of stage Info

struct StageInfo {
    uint64 stage;
    uint64 totalScore;
    bool isFinalized;
}

mapping(uint64 => StageInfo) public stages;

scores

mapping of user score

struct ScoreResponse {
    address addr;
    uint64 amount;
    uint64 index;
}

mapping(uint64 => mapping(address => Score)) public scores; // stage => address => score

View functions

getScores

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;
}