Merge pull request #11772 from v-sreekesh/v-sreekesh-external-fix-voting

updated public to external for the functions
This commit is contained in:
chriseth 2021-08-12 19:08:19 +02:00 committed by GitHub
commit 93ebdb9e6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 27 deletions

View File

@ -79,7 +79,7 @@ to receive their money - contracts cannot activate themselves.
/// together with this transaction.
/// The value will only be refunded if the
/// auction is not won.
function bid() public payable {
function bid() external payable {
// No arguments are necessary, all
// information is already part of
// the transaction. The keyword payable
@ -113,7 +113,7 @@ to receive their money - contracts cannot activate themselves.
}
/// Withdraw a bid that was overbid.
function withdraw() public returns (bool) {
function withdraw() external returns (bool) {
uint amount = pendingReturns[msg.sender];
if (amount > 0) {
// It is important to set this to zero because the recipient
@ -132,7 +132,7 @@ to receive their money - contracts cannot activate themselves.
/// End the auction and send the highest bid
/// to the beneficiary.
function auctionEnd() public {
function auctionEnd() external {
// It is a good guideline to structure functions that interact
// with other contracts (i.e. they call functions or send Ether)
// into three phases:
@ -261,7 +261,7 @@ invalid bids.
/// still make the required deposit. The same address can
/// place multiple bids.
function bid(bytes32 _blindedBid)
public
external
payable
onlyBefore(biddingEnd)
{
@ -275,11 +275,11 @@ invalid bids.
/// correctly blinded invalid bids and for all bids except for
/// the totally highest.
function reveal(
uint[] memory _values,
bool[] memory _fake,
bytes32[] memory _secret
uint[] calldata _values,
bool[] calldata _fake,
bytes32[] calldata _secret
)
public
external
onlyAfter(biddingEnd)
onlyBefore(revealEnd)
{
@ -311,7 +311,7 @@ invalid bids.
}
/// Withdraw a bid that was overbid.
function withdraw() public {
function withdraw() external {
uint amount = pendingReturns[msg.sender];
if (amount > 0) {
// It is important to set this to zero because the recipient
@ -327,7 +327,7 @@ invalid bids.
/// End the auction and send the highest bid
/// to the beneficiary.
function auctionEnd()
public
external
onlyAfter(revealEnd)
{
if (ended) revert AuctionEndAlreadyCalled();

View File

@ -151,7 +151,7 @@ The full contract
constructor() payable {}
function claimPayment(uint256 amount, uint256 nonce, bytes memory signature) public {
function claimPayment(uint256 amount, uint256 nonce, bytes memory signature) external {
require(!usedNonces[nonce]);
usedNonces[nonce] = true;
@ -164,7 +164,7 @@ The full contract
}
/// destroy the contract and reclaim the leftover funds.
function shutdown() public {
function shutdown() external {
require(msg.sender == owner);
selfdestruct(payable(msg.sender));
}
@ -357,7 +357,7 @@ The full contract
/// the recipient can close the channel at any time by presenting a
/// signed amount from the sender. the recipient will be sent that amount,
/// and the remainder will go back to the sender
function close(uint256 amount, bytes memory signature) public {
function close(uint256 amount, bytes memory signature) external {
require(msg.sender == recipient);
require(isValidSignature(amount, signature));
@ -366,7 +366,7 @@ The full contract
}
/// the sender can extend the expiration at any time
function extend(uint256 newExpiration) public {
function extend(uint256 newExpiration) external {
require(msg.sender == sender);
require(newExpiration > expiration);
@ -375,7 +375,7 @@ The full contract
/// if the timeout is reached without the recipient closing the channel,
/// then the Ether is released back to the sender.
function claimTimeout() public {
function claimTimeout() external {
require(block.timestamp >= expiration);
selfdestruct(sender);
}

View File

@ -39,14 +39,14 @@ and the sum of all balances is an invariant across the lifetime of the contract.
event Transfer(address from, address to, uint amount);
event Approval(address owner, address spender, uint amount);
function transfer(address to, uint amount) public returns (bool success) {
function transfer(address to, uint amount) external returns (bool success) {
balances.move(msg.sender, to, amount);
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(address from, address to, uint amount) public returns (bool success) {
function transferFrom(address from, address to, uint amount) external returns (bool success) {
require(allowed[from][msg.sender] >= amount);
allowed[from][msg.sender] -= amount;
balances.move(from, to, amount);
@ -54,14 +54,14 @@ and the sum of all balances is an invariant across the lifetime of the contract.
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
function approve(address spender, uint tokens) external returns (bool success) {
require(allowed[msg.sender][spender] == 0, "");
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
function balanceOf(address tokenOwner) external view returns (uint balance) {
return balances[tokenOwner];
}
}

View File

@ -87,7 +87,7 @@ you can use state machine-like constructs inside a contract.
/// Can only be called by the seller before
/// the contract is locked.
function abort()
public
external
onlySeller
inState(State.Created)
{
@ -105,7 +105,7 @@ you can use state machine-like constructs inside a contract.
/// The ether will be locked until confirmReceived
/// is called.
function confirmPurchase()
public
external
inState(State.Created)
condition(msg.value == (2 * value))
payable
@ -118,7 +118,7 @@ you can use state machine-like constructs inside a contract.
/// Confirm that you (the buyer) received the item.
/// This will release the locked ether.
function confirmReceived()
public
external
onlyBuyer
inState(State.Locked)
{
@ -134,7 +134,7 @@ you can use state machine-like constructs inside a contract.
/// This function refunds the seller, i.e.
/// pays back the locked funds of the seller.
function refundSeller()
public
external
onlySeller
inState(State.Release)
{

View File

@ -82,7 +82,7 @@ of votes.
// Give `voter` the right to vote on this ballot.
// May only be called by `chairperson`.
function giveRightToVote(address voter) public {
function giveRightToVote(address voter) external {
// If the first argument of `require` evaluates
// to `false`, execution terminates and all
// changes to the state and to Ether balances
@ -106,7 +106,7 @@ of votes.
}
/// Delegate your vote to the voter `to`.
function delegate(address to) public {
function delegate(address to) external {
// assigns reference
Voter storage sender = voters[msg.sender];
require(!sender.voted, "You already voted.");
@ -146,7 +146,7 @@ of votes.
/// Give your vote (including votes delegated to you)
/// to proposal `proposals[proposal].name`.
function vote(uint proposal) public {
function vote(uint proposal) external {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
@ -176,7 +176,7 @@ of votes.
// Calls winningProposal() function to get the index
// of the winner contained in the proposals array and then
// returns the name of the winner
function winnerName() public view
function winnerName() external view
returns (bytes32 winnerName_)
{
winnerName_ = proposals[winningProposal()].name;