Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/examples/blind-auction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/micropayment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
}
Expand Down Expand Up @@ -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));

Expand All @@ -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);

Expand All @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/modular.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ 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);
emit Transfer(from, to, amount);
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];
}
}
8 changes: 4 additions & 4 deletions docs/examples/safe-remote.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/voting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

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

winningProposal is used here. So that has to be made public. Here's the CI check that failed: https://app.circleci.com/pipelines/github/ethereum/solidity/17880/workflows/1a6d2776-037e-462b-a52c-a88feed5f637/jobs/799349

Could you please fix it in this PR / branch itself? We have a section on workflow for pull requests that may be relevant here: https://docs.soliditylang.org/en/v0.8.6/contributing.html?highlight=evmone#workflow-for-pull-requests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok i will use the same PR request to make new changes

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. You can ping me by using "re request" review button next to the Reviewers list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also update other files from docs/examples/*.rst?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course i will update the others as well

Expand Down