-
Notifications
You must be signed in to change notification settings - Fork 0
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
Address comments for PR 6 #7
Conversation
…odd number of ether.
What Adel meant is: const result = await contract.methods.split(beneficiary1Address, beneficiary2Address).call(...
if (result) {
do the .send |
As for the receipt, I see you are checking its status 👍 . You could also check the presence of the expected event. |
@xavierlepretre @adelRestom I have tried out the following code
I found out whether the transaction fails or not in Can you guys tell me how can I meet @adelRestom 's requirement? |
|
||
function withdrawAll() external onlyOwner whenKilled { | ||
uint256 balanceToWithdraw = address(this).balance; | ||
require(balanceToWithdraw > 0, "Balance must be grater than zero to withdraw!"); |
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 think this line of code becomes irrelevant because the normal withdraw is locked now.
function isKilled() public view returns (bool) { | ||
return killed; | ||
} | ||
|
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.
Make this functionality part of the Pausable contract, we want to protect the user from accidentally calling this function by turning it into a 2 step-process:
- The user pauses the contract
- The user kills the contract (the kill function checks that the contract is paused)
@@ -27,8 +27,8 @@ contract Pausable is Ownable { | |||
emit LogPaused(msg.sender); | |||
} | |||
|
|||
function unpause() public onlyOwner { | |||
require(paused, "Can't unpause a non-paused contract!"); | |||
function resume() public onlyOwner { |
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 a modifier called whenPaused
; you'll need it for "kill" function anyway.
@@ -11,6 +11,9 @@ contract Splitter is Pausable { | |||
|
|||
mapping (address => uint256) public balances; |
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'll also need to update your migration script and test file to pass the value to the constructor when calling new()
.
Regarding the |
@adelRestom I have followed your advice to add
And add the
However, even I send 0 wei to the contract, So I don't know how can I check before I |
@xavierlepretre can you please remind me how we used to do this? ☝️ |
I cloned your repo, checked out this branch, replaced 9545, npm installed both folders, truffle migrated into Ganache, npm started.
|
I would try to |
@xavierlepretre I just merged the PR, can you rebase master? |
I'm looking at my old work and I had something like: return myContract.myFunction.call()
.then(() => myContract.myFunction())
.then...more code
.catch(error => console.log(error)); So the catch would show the error. |
thanks @adelRestom I am working on project 2 and 3 to try to make meet the deadline, will come back to this soon. |
I still have the same error when loading the web page:
|
@xavierlepretre sorry, for some reason, I didn't commit the fix to github. I have pushed the commit 522d3d8 now, it should be OK now. |
Now I get a revert on withdraw. "Balance must be grater than zero to withdraw!" |
That's weird, may I come back to this later? I am trying to finish the other projects |
In this PR, I addressed the comments for PR #6
@adelRestom I have addressed all your comments except for the App.js.
For the first comment, do you call all the
send
method likeawait contract.methods.split(beneficiary1Address, beneficiary2Address).call();
before
For the second comment, I have checked the
receipt
in the promise call - seetx
variable, please.I print out
receipt
andtx
, they are exactly same.@xavierlepretre can you please have a look as well? thanks