Skip to content

Feature/refferal contract - #75

Open
udkreddySomish wants to merge 19 commits into
masterfrom
feature/refferalContract
Open

Feature/refferal contract#75
udkreddySomish wants to merge 19 commits into
masterfrom
feature/refferalContract

Conversation

@udkreddySomish

Copy link
Copy Markdown
Collaborator

Refferal amount can be claimed if the data is signed by the pre defined signer address.

@udkreddySomishudkreddySomish linked an issue Oct 22, 2020 that may be closed by this pull request
Comment threadcontracts/Referral.sol Outdated
*/
modifier onlyOwner() {
require(owner == msg.sender, "Not owner");
_;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment threadcontracts/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)));

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
CollaboratorAuthor

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

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
CollaboratorAuthor

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

Comment threadtest/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});

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create contract for Referral Program

2 participants

@udkreddySomish@maxsam4