mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
updated public to external for the functions
changed public to external for the functions
This commit is contained in:
parent
23b16a1e20
commit
9b9e52e53e
@ -79,7 +79,7 @@ to receive their money - contracts cannot activate themselves.
|
|||||||
/// together with this transaction.
|
/// together with this transaction.
|
||||||
/// The value will only be refunded if the
|
/// The value will only be refunded if the
|
||||||
/// auction is not won.
|
/// auction is not won.
|
||||||
function bid() public payable {
|
function bid() external payable {
|
||||||
// No arguments are necessary, all
|
// No arguments are necessary, all
|
||||||
// information is already part of
|
// information is already part of
|
||||||
// the transaction. The keyword payable
|
// the transaction. The keyword payable
|
||||||
@ -113,7 +113,7 @@ to receive their money - contracts cannot activate themselves.
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Withdraw a bid that was overbid.
|
/// Withdraw a bid that was overbid.
|
||||||
function withdraw() public returns (bool) {
|
function withdraw() external returns (bool) {
|
||||||
uint amount = pendingReturns[msg.sender];
|
uint amount = pendingReturns[msg.sender];
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
// It is important to set this to zero because the recipient
|
// 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
|
/// End the auction and send the highest bid
|
||||||
/// to the beneficiary.
|
/// to the beneficiary.
|
||||||
function auctionEnd() public {
|
function auctionEnd() external {
|
||||||
// It is a good guideline to structure functions that interact
|
// It is a good guideline to structure functions that interact
|
||||||
// with other contracts (i.e. they call functions or send Ether)
|
// with other contracts (i.e. they call functions or send Ether)
|
||||||
// into three phases:
|
// into three phases:
|
||||||
@ -261,7 +261,7 @@ invalid bids.
|
|||||||
/// still make the required deposit. The same address can
|
/// still make the required deposit. The same address can
|
||||||
/// place multiple bids.
|
/// place multiple bids.
|
||||||
function bid(bytes32 _blindedBid)
|
function bid(bytes32 _blindedBid)
|
||||||
public
|
external
|
||||||
payable
|
payable
|
||||||
onlyBefore(biddingEnd)
|
onlyBefore(biddingEnd)
|
||||||
{
|
{
|
||||||
@ -275,11 +275,11 @@ invalid bids.
|
|||||||
/// correctly blinded invalid bids and for all bids except for
|
/// correctly blinded invalid bids and for all bids except for
|
||||||
/// the totally highest.
|
/// the totally highest.
|
||||||
function reveal(
|
function reveal(
|
||||||
uint[] memory _values,
|
uint[] calldata _values,
|
||||||
bool[] memory _fake,
|
bool[] calldata _fake,
|
||||||
bytes32[] memory _secret
|
bytes32[] calldata _secret
|
||||||
)
|
)
|
||||||
public
|
external
|
||||||
onlyAfter(biddingEnd)
|
onlyAfter(biddingEnd)
|
||||||
onlyBefore(revealEnd)
|
onlyBefore(revealEnd)
|
||||||
{
|
{
|
||||||
@ -311,7 +311,7 @@ invalid bids.
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Withdraw a bid that was overbid.
|
/// Withdraw a bid that was overbid.
|
||||||
function withdraw() public {
|
function withdraw() external {
|
||||||
uint amount = pendingReturns[msg.sender];
|
uint amount = pendingReturns[msg.sender];
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
// It is important to set this to zero because the recipient
|
// 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
|
/// End the auction and send the highest bid
|
||||||
/// to the beneficiary.
|
/// to the beneficiary.
|
||||||
function auctionEnd()
|
function auctionEnd()
|
||||||
public
|
external
|
||||||
onlyAfter(revealEnd)
|
onlyAfter(revealEnd)
|
||||||
{
|
{
|
||||||
if (ended) revert AuctionEndAlreadyCalled();
|
if (ended) revert AuctionEndAlreadyCalled();
|
||||||
|
@ -151,7 +151,7 @@ The full contract
|
|||||||
|
|
||||||
constructor() payable {}
|
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]);
|
require(!usedNonces[nonce]);
|
||||||
usedNonces[nonce] = true;
|
usedNonces[nonce] = true;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ The full contract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// destroy the contract and reclaim the leftover funds.
|
/// destroy the contract and reclaim the leftover funds.
|
||||||
function shutdown() public {
|
function shutdown() external {
|
||||||
require(msg.sender == owner);
|
require(msg.sender == owner);
|
||||||
selfdestruct(payable(msg.sender));
|
selfdestruct(payable(msg.sender));
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ The full contract
|
|||||||
/// the recipient can close the channel at any time by presenting a
|
/// the recipient can close the channel at any time by presenting a
|
||||||
/// signed amount from the sender. the recipient will be sent that amount,
|
/// signed amount from the sender. the recipient will be sent that amount,
|
||||||
/// and the remainder will go back to the sender
|
/// 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(msg.sender == recipient);
|
||||||
require(isValidSignature(amount, signature));
|
require(isValidSignature(amount, signature));
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ The full contract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// the sender can extend the expiration at any time
|
/// the sender can extend the expiration at any time
|
||||||
function extend(uint256 newExpiration) public {
|
function extend(uint256 newExpiration) external {
|
||||||
require(msg.sender == sender);
|
require(msg.sender == sender);
|
||||||
require(newExpiration > expiration);
|
require(newExpiration > expiration);
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ The full contract
|
|||||||
|
|
||||||
/// if the timeout is reached without the recipient closing the channel,
|
/// if the timeout is reached without the recipient closing the channel,
|
||||||
/// then the Ether is released back to the sender.
|
/// then the Ether is released back to the sender.
|
||||||
function claimTimeout() public {
|
function claimTimeout() external {
|
||||||
require(block.timestamp >= expiration);
|
require(block.timestamp >= expiration);
|
||||||
selfdestruct(sender);
|
selfdestruct(sender);
|
||||||
}
|
}
|
||||||
|
@ -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 Transfer(address from, address to, uint amount);
|
||||||
event Approval(address owner, address spender, 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);
|
balances.move(msg.sender, to, amount);
|
||||||
emit Transfer(msg.sender, to, amount);
|
emit Transfer(msg.sender, to, amount);
|
||||||
return true;
|
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);
|
require(allowed[from][msg.sender] >= amount);
|
||||||
allowed[from][msg.sender] -= amount;
|
allowed[from][msg.sender] -= amount;
|
||||||
balances.move(from, to, 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;
|
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, "");
|
require(allowed[msg.sender][spender] == 0, "");
|
||||||
allowed[msg.sender][spender] = tokens;
|
allowed[msg.sender][spender] = tokens;
|
||||||
emit Approval(msg.sender, spender, tokens);
|
emit Approval(msg.sender, spender, tokens);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function balanceOf(address tokenOwner) public view returns (uint balance) {
|
function balanceOf(address tokenOwner) external view returns (uint balance) {
|
||||||
return balances[tokenOwner];
|
return balances[tokenOwner];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ you can use state machine-like constructs inside a contract.
|
|||||||
/// Can only be called by the seller before
|
/// Can only be called by the seller before
|
||||||
/// the contract is locked.
|
/// the contract is locked.
|
||||||
function abort()
|
function abort()
|
||||||
public
|
external
|
||||||
onlySeller
|
onlySeller
|
||||||
inState(State.Created)
|
inState(State.Created)
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ you can use state machine-like constructs inside a contract.
|
|||||||
/// The ether will be locked until confirmReceived
|
/// The ether will be locked until confirmReceived
|
||||||
/// is called.
|
/// is called.
|
||||||
function confirmPurchase()
|
function confirmPurchase()
|
||||||
public
|
external
|
||||||
inState(State.Created)
|
inState(State.Created)
|
||||||
condition(msg.value == (2 * value))
|
condition(msg.value == (2 * value))
|
||||||
payable
|
payable
|
||||||
@ -118,7 +118,7 @@ you can use state machine-like constructs inside a contract.
|
|||||||
/// Confirm that you (the buyer) received the item.
|
/// Confirm that you (the buyer) received the item.
|
||||||
/// This will release the locked ether.
|
/// This will release the locked ether.
|
||||||
function confirmReceived()
|
function confirmReceived()
|
||||||
public
|
external
|
||||||
onlyBuyer
|
onlyBuyer
|
||||||
inState(State.Locked)
|
inState(State.Locked)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ you can use state machine-like constructs inside a contract.
|
|||||||
/// This function refunds the seller, i.e.
|
/// This function refunds the seller, i.e.
|
||||||
/// pays back the locked funds of the seller.
|
/// pays back the locked funds of the seller.
|
||||||
function refundSeller()
|
function refundSeller()
|
||||||
public
|
external
|
||||||
onlySeller
|
onlySeller
|
||||||
inState(State.Release)
|
inState(State.Release)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ of votes.
|
|||||||
|
|
||||||
// Give `voter` the right to vote on this ballot.
|
// Give `voter` the right to vote on this ballot.
|
||||||
// May only be called by `chairperson`.
|
// May only be called by `chairperson`.
|
||||||
function giveRightToVote(address voter) public {
|
function giveRightToVote(address voter) external {
|
||||||
// If the first argument of `require` evaluates
|
// If the first argument of `require` evaluates
|
||||||
// to `false`, execution terminates and all
|
// to `false`, execution terminates and all
|
||||||
// changes to the state and to Ether balances
|
// changes to the state and to Ether balances
|
||||||
@ -106,7 +106,7 @@ of votes.
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Delegate your vote to the voter `to`.
|
/// Delegate your vote to the voter `to`.
|
||||||
function delegate(address to) public {
|
function delegate(address to) external {
|
||||||
// assigns reference
|
// assigns reference
|
||||||
Voter storage sender = voters[msg.sender];
|
Voter storage sender = voters[msg.sender];
|
||||||
require(!sender.voted, "You already voted.");
|
require(!sender.voted, "You already voted.");
|
||||||
@ -146,7 +146,7 @@ of votes.
|
|||||||
|
|
||||||
/// Give your vote (including votes delegated to you)
|
/// Give your vote (including votes delegated to you)
|
||||||
/// to proposal `proposals[proposal].name`.
|
/// to proposal `proposals[proposal].name`.
|
||||||
function vote(uint proposal) public {
|
function vote(uint proposal) external {
|
||||||
Voter storage sender = voters[msg.sender];
|
Voter storage sender = voters[msg.sender];
|
||||||
require(sender.weight != 0, "Has no right to vote");
|
require(sender.weight != 0, "Has no right to vote");
|
||||||
require(!sender.voted, "Already voted.");
|
require(!sender.voted, "Already voted.");
|
||||||
@ -176,7 +176,7 @@ of votes.
|
|||||||
// Calls winningProposal() function to get the index
|
// Calls winningProposal() function to get the index
|
||||||
// of the winner contained in the proposals array and then
|
// of the winner contained in the proposals array and then
|
||||||
// returns the name of the winner
|
// returns the name of the winner
|
||||||
function winnerName() public view
|
function winnerName() external view
|
||||||
returns (bytes32 winnerName_)
|
returns (bytes32 winnerName_)
|
||||||
{
|
{
|
||||||
winnerName_ = proposals[winningProposal()].name;
|
winnerName_ = proposals[winningProposal()].name;
|
||||||
|
Loading…
Reference in New Issue
Block a user