-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
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
Feature/refferal contract #75
base: master
Are you sure you want to change the base?
Conversation
contracts/Referral.sol
Outdated
*/ | ||
modifier onlyOwner() { | ||
require(owner == msg.sender, "Not owner"); | ||
_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
contracts/Referral.sol
Outdated
function claim(bytes calldata hash, uint8 v, bytes32 r, bytes32 s) external { | ||
require(endDate > now, "Callable only before end date"); | ||
require(!userClaimed[msg.sender], "Already claimed"); | ||
require(msg.sender == abi.decode(hash, (address))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to take hash
as input. Just use msg.sender
as the hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
userClaimed[msg.sender] = true; | ||
bLotToken.mint(msg.sender, refferalAmount); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest adding a function to change the signer in case the signer gets compromised or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a function to update signer address
test/24_Refferal.test.js
Outdated
let signedHash = (await web3.eth.accounts.sign(hash, adminPrivateKey)); | ||
|
||
await refferal.claim(hash, signedHash.v, signedHash.r, signedHash.s, {from:user2}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add asserts to make sure the correct amount of blot were minted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Refferal amount can be claimed if the data is signed by the pre defined signer address.