We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is your feature request related to a problem? Please describe. 目前還沒有機制去防止用戶一天只能 check in 一次,也沒有檢查用戶 reputation 是否為 negative
Describe the solution you'd like
contract UnirepApp is Ownable { struct DailyEpochData { uint48 startTimestamp; // setup while deploying uint48 currentEpoch; uint48 epochLength; // 60 * 60 * 24 } DailyEpochData dailyEpochData; function _updateDailyEpochIfNeeded( uint256 attesterId ) public returns (uint epoch) { // 可參考 https://github.com/Unirep/Unirep/blob/36e5adf8c1eaa7398716ff3653327d5bd98181b3/packages/contracts/contracts/Unirep.sol#L406 } function dailyCurrentEpoch() public view returns (uint48) { uint48 timestamp = dailyEpochData.startTimestamp; uint48 epochLength = dailyEpochData.epochLength; return (uint48(block.timestamp) - timestamp) / epochLength; } function claimDailyLoginRep( uint256[] calldata publicSignals, uint256[8] calldata proof <-- daily claim proof ) public onlyOwner() { _updateDailyEpochIfNeeded(); // TODO: 需要將publicSignals轉換成 DailyClaimSignals DailyClaimVerifierHelper.DailyClaimSignals memory signals = dailyClaimHelper.decodeEpochKeySignals( publicSignals ); // TODO: check signals.dailyEpoch == dailyEpochData.currentEpoch; // check if proof is used before bytes32 nullifier = signals.dailyNullifier; if (proofNullifier[nullifier]) { revert ProofHasUsed(); } proofNullifier[nullifier] = true; // check the epoch != current epoch (ppl can only post in current aepoch) uint48 epoch = unirep.attesterCurrentEpoch(signals.attesterId); if (signals.epoch > epoch) { revert InvalidEpoch(); } dailyClaimHelper.verifyAndCheckCaller(publicSignals, proof); require(signals.minRep - signals.maxRep < 0, "bad boy"); // attesting on Unirep contract: unirep.attest( signals.epochKey, epoch, posRepFieldIndex, // field index: posRep 1 ); emit ClaimPosRep( signals.epochKey, epoch ); } }
The text was updated successfully, but these errors were encountered:
@chentihe 記得要 tag 對應的 issue
Sorry, something went wrong.
chentihe
Successfully merging a pull request may close this issue.
Is your feature request related to a problem? Please describe.
目前還沒有機制去防止用戶一天只能 check in 一次,也沒有檢查用戶 reputation 是否為 negative
Describe the solution you'd like
可參考https://github.com/social-tw/social-tw-website/tree/main/packages/contracts/contracts/verifierHelpers
The text was updated successfully, but these errors were encountered: