Skip to content

Commit 93ebdb9

Browse files
authored
Merge pull request #11772 from v-sreekesh/v-sreekesh-external-fix-voting
updated public to external for the functions
2 parents 23b16a1 + 9b9e52e commit 93ebdb9

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

docs/examples/blind-auction.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ to receive their money - contracts cannot activate themselves.
7979
/// together with this transaction.
8080
/// The value will only be refunded if the
8181
/// auction is not won.
82-
function bid() public payable {
82+
function bid() external payable {
8383
// No arguments are necessary, all
8484
// information is already part of
8585
// the transaction. The keyword payable
@@ -113,7 +113,7 @@ to receive their money - contracts cannot activate themselves.
113113
}
114114
115115
/// Withdraw a bid that was overbid.
116-
function withdraw() public returns (bool) {
116+
function withdraw() external returns (bool) {
117117
uint amount = pendingReturns[msg.sender];
118118
if (amount > 0) {
119119
// It is important to set this to zero because the recipient
@@ -132,7 +132,7 @@ to receive their money - contracts cannot activate themselves.
132132
133133
/// End the auction and send the highest bid
134134
/// to the beneficiary.
135-
function auctionEnd() public {
135+
function auctionEnd() external {
136136
// It is a good guideline to structure functions that interact
137137
// with other contracts (i.e. they call functions or send Ether)
138138
// into three phases:
@@ -261,7 +261,7 @@ invalid bids.
261261
/// still make the required deposit. The same address can
262262
/// place multiple bids.
263263
function bid(bytes32 _blindedBid)
264-
public
264+
external
265265
payable
266266
onlyBefore(biddingEnd)
267267
{
@@ -275,11 +275,11 @@ invalid bids.
275275
/// correctly blinded invalid bids and for all bids except for
276276
/// the totally highest.
277277
function reveal(
278-
uint[] memory _values,
279-
bool[] memory _fake,
280-
bytes32[] memory _secret
278+
uint[] calldata _values,
279+
bool[] calldata _fake,
280+
bytes32[] calldata _secret
281281
)
282-
public
282+
external
283283
onlyAfter(biddingEnd)
284284
onlyBefore(revealEnd)
285285
{
@@ -311,7 +311,7 @@ invalid bids.
311311
}
312312
313313
/// Withdraw a bid that was overbid.
314-
function withdraw() public {
314+
function withdraw() external {
315315
uint amount = pendingReturns[msg.sender];
316316
if (amount > 0) {
317317
// It is important to set this to zero because the recipient
@@ -327,7 +327,7 @@ invalid bids.
327327
/// End the auction and send the highest bid
328328
/// to the beneficiary.
329329
function auctionEnd()
330-
public
330+
external
331331
onlyAfter(revealEnd)
332332
{
333333
if (ended) revert AuctionEndAlreadyCalled();

docs/examples/micropayment.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ The full contract
151151
152152
constructor() payable {}
153153
154-
function claimPayment(uint256 amount, uint256 nonce, bytes memory signature) public {
154+
function claimPayment(uint256 amount, uint256 nonce, bytes memory signature) external {
155155
require(!usedNonces[nonce]);
156156
usedNonces[nonce] = true;
157157
@@ -164,7 +164,7 @@ The full contract
164164
}
165165
166166
/// destroy the contract and reclaim the leftover funds.
167-
function shutdown() public {
167+
function shutdown() external {
168168
require(msg.sender == owner);
169169
selfdestruct(payable(msg.sender));
170170
}
@@ -357,7 +357,7 @@ The full contract
357357
/// the recipient can close the channel at any time by presenting a
358358
/// signed amount from the sender. the recipient will be sent that amount,
359359
/// and the remainder will go back to the sender
360-
function close(uint256 amount, bytes memory signature) public {
360+
function close(uint256 amount, bytes memory signature) external {
361361
require(msg.sender == recipient);
362362
require(isValidSignature(amount, signature));
363363
@@ -366,7 +366,7 @@ The full contract
366366
}
367367
368368
/// the sender can extend the expiration at any time
369-
function extend(uint256 newExpiration) public {
369+
function extend(uint256 newExpiration) external {
370370
require(msg.sender == sender);
371371
require(newExpiration > expiration);
372372
@@ -375,7 +375,7 @@ The full contract
375375
376376
/// if the timeout is reached without the recipient closing the channel,
377377
/// then the Ether is released back to the sender.
378-
function claimTimeout() public {
378+
function claimTimeout() external {
379379
require(block.timestamp >= expiration);
380380
selfdestruct(sender);
381381
}

docs/examples/modular.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,29 @@ and the sum of all balances is an invariant across the lifetime of the contract.
3939
event Transfer(address from, address to, uint amount);
4040
event Approval(address owner, address spender, uint amount);
4141
42-
function transfer(address to, uint amount) public returns (bool success) {
42+
function transfer(address to, uint amount) external returns (bool success) {
4343
balances.move(msg.sender, to, amount);
4444
emit Transfer(msg.sender, to, amount);
4545
return true;
4646
4747
}
4848
49-
function transferFrom(address from, address to, uint amount) public returns (bool success) {
49+
function transferFrom(address from, address to, uint amount) external returns (bool success) {
5050
require(allowed[from][msg.sender] >= amount);
5151
allowed[from][msg.sender] -= amount;
5252
balances.move(from, to, amount);
5353
emit Transfer(from, to, amount);
5454
return true;
5555
}
5656
57-
function approve(address spender, uint tokens) public returns (bool success) {
57+
function approve(address spender, uint tokens) external returns (bool success) {
5858
require(allowed[msg.sender][spender] == 0, "");
5959
allowed[msg.sender][spender] = tokens;
6060
emit Approval(msg.sender, spender, tokens);
6161
return true;
6262
}
6363
64-
function balanceOf(address tokenOwner) public view returns (uint balance) {
64+
function balanceOf(address tokenOwner) external view returns (uint balance) {
6565
return balances[tokenOwner];
6666
}
6767
}

docs/examples/safe-remote.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ you can use state machine-like constructs inside a contract.
8787
/// Can only be called by the seller before
8888
/// the contract is locked.
8989
function abort()
90-
public
90+
external
9191
onlySeller
9292
inState(State.Created)
9393
{
@@ -105,7 +105,7 @@ you can use state machine-like constructs inside a contract.
105105
/// The ether will be locked until confirmReceived
106106
/// is called.
107107
function confirmPurchase()
108-
public
108+
external
109109
inState(State.Created)
110110
condition(msg.value == (2 * value))
111111
payable
@@ -118,7 +118,7 @@ you can use state machine-like constructs inside a contract.
118118
/// Confirm that you (the buyer) received the item.
119119
/// This will release the locked ether.
120120
function confirmReceived()
121-
public
121+
external
122122
onlyBuyer
123123
inState(State.Locked)
124124
{
@@ -134,7 +134,7 @@ you can use state machine-like constructs inside a contract.
134134
/// This function refunds the seller, i.e.
135135
/// pays back the locked funds of the seller.
136136
function refundSeller()
137-
public
137+
external
138138
onlySeller
139139
inState(State.Release)
140140
{

docs/examples/voting.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ of votes.
8282
8383
// Give `voter` the right to vote on this ballot.
8484
// May only be called by `chairperson`.
85-
function giveRightToVote(address voter) public {
85+
function giveRightToVote(address voter) external {
8686
// If the first argument of `require` evaluates
8787
// to `false`, execution terminates and all
8888
// changes to the state and to Ether balances
@@ -106,7 +106,7 @@ of votes.
106106
}
107107
108108
/// Delegate your vote to the voter `to`.
109-
function delegate(address to) public {
109+
function delegate(address to) external {
110110
// assigns reference
111111
Voter storage sender = voters[msg.sender];
112112
require(!sender.voted, "You already voted.");
@@ -146,7 +146,7 @@ of votes.
146146
147147
/// Give your vote (including votes delegated to you)
148148
/// to proposal `proposals[proposal].name`.
149-
function vote(uint proposal) public {
149+
function vote(uint proposal) external {
150150
Voter storage sender = voters[msg.sender];
151151
require(sender.weight != 0, "Has no right to vote");
152152
require(!sender.voted, "Already voted.");
@@ -176,7 +176,7 @@ of votes.
176176
// Calls winningProposal() function to get the index
177177
// of the winner contained in the proposals array and then
178178
// returns the name of the winner
179-
function winnerName() public view
179+
function winnerName() external view
180180
returns (bytes32 winnerName_)
181181
{
182182
winnerName_ = proposals[winningProposal()].name;

0 commit comments

Comments
 (0)