Skip to content

Commit 7df33f0

Browse files
authored
Merge pull request #11777 from Ahmed-Ali/improving_naming_consistency
[DOCS] Improving the naming consistency in Solidity by Example documentation
2 parents 6e6bbb2 + e09b0ae commit 7df33f0

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

docs/examples/blind-auction.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ to receive their money - contracts cannot activate themselves.
6464
/// The function auctionEnd has already been called.
6565
error AuctionEndAlreadyCalled();
6666
67-
/// Create a simple auction with `_biddingTime`
67+
/// Create a simple auction with `biddingTime`
6868
/// seconds bidding time on behalf of the
69-
/// beneficiary address `_beneficiary`.
69+
/// beneficiary address `beneficiaryAddress`.
7070
constructor(
71-
uint _biddingTime,
72-
address payable _beneficiary
71+
uint biddingTime,
72+
address payable beneficiaryAddress
7373
) {
74-
beneficiary = _beneficiary;
75-
auctionEndTime = block.timestamp + _biddingTime;
74+
beneficiary = beneficiaryAddress;
75+
auctionEndTime = block.timestamp + biddingTime;
7676
}
7777
7878
/// Bid on the auction with the value sent
@@ -232,26 +232,26 @@ invalid bids.
232232
// functions. `onlyBefore` is applied to `bid` below:
233233
// The new function body is the modifier's body where
234234
// `_` is replaced by the old function body.
235-
modifier onlyBefore(uint _time) {
236-
if (block.timestamp >= _time) revert TooLate(_time);
235+
modifier onlyBefore(uint time) {
236+
if (block.timestamp >= time) revert TooLate(time);
237237
_;
238238
}
239-
modifier onlyAfter(uint _time) {
240-
if (block.timestamp <= _time) revert TooEarly(_time);
239+
modifier onlyAfter(uint time) {
240+
if (block.timestamp <= time) revert TooEarly(time);
241241
_;
242242
}
243243
244244
constructor(
245-
uint _biddingTime,
246-
uint _revealTime,
247-
address payable _beneficiary
245+
uint biddingTime,
246+
uint revealTime,
247+
address payable beneficiaryAddress
248248
) {
249-
beneficiary = _beneficiary;
250-
biddingEnd = block.timestamp + _biddingTime;
251-
revealEnd = biddingEnd + _revealTime;
249+
beneficiary = beneficiaryAddress;
250+
biddingEnd = block.timestamp + biddingTime;
251+
revealEnd = biddingEnd + revealTime;
252252
}
253253
254-
/// Place a blinded bid with `_blindedBid` =
254+
/// Place a blinded bid with `blindedBid` =
255255
/// keccak256(abi.encodePacked(value, fake, secret)).
256256
/// The sent ether is only refunded if the bid is correctly
257257
/// revealed in the revealing phase. The bid is valid if the
@@ -260,13 +260,13 @@ invalid bids.
260260
/// not the exact amount are ways to hide the real bid but
261261
/// still make the required deposit. The same address can
262262
/// place multiple bids.
263-
function bid(bytes32 _blindedBid)
263+
function bid(bytes32 blindedBid)
264264
external
265265
payable
266266
onlyBefore(biddingEnd)
267267
{
268268
bids[msg.sender].push(Bid({
269-
blindedBid: _blindedBid,
269+
blindedBid: blindedBid,
270270
deposit: msg.value
271271
}));
272272
}
@@ -275,24 +275,24 @@ invalid bids.
275275
/// correctly blinded invalid bids and for all bids except for
276276
/// the totally highest.
277277
function reveal(
278-
uint[] calldata _values,
279-
bool[] calldata _fake,
280-
bytes32[] calldata _secret
278+
uint[] calldata values,
279+
bool[] calldata fakes,
280+
bytes32[] calldata secrets
281281
)
282282
external
283283
onlyAfter(biddingEnd)
284284
onlyBefore(revealEnd)
285285
{
286286
uint length = bids[msg.sender].length;
287-
require(_values.length == length);
288-
require(_fake.length == length);
289-
require(_secret.length == length);
287+
require(values.length == length);
288+
require(fakes.length == length);
289+
require(secrets.length == length);
290290
291291
uint refund;
292292
for (uint i = 0; i < length; i++) {
293293
Bid storage bidToCheck = bids[msg.sender][i];
294294
(uint value, bool fake, bytes32 secret) =
295-
(_values[i], _fake[i], _secret[i]);
295+
(values[i], fakes[i], secrets[i]);
296296
if (bidToCheck.blindedBid != keccak256(abi.encodePacked(value, fake, secret))) {
297297
// Bid was not actually revealed.
298298
// Do not refund deposit.

docs/examples/micropayment.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ The full contract
346346
address payable public recipient; // The account receiving the payments.
347347
uint256 public expiration; // Timeout in case the recipient never closes.
348348
349-
constructor (address payable _recipient, uint256 duration)
349+
constructor (address payable recipientAddress, uint256 duration)
350350
payable
351351
{
352352
sender = payable(msg.sender);
353-
recipient = _recipient;
353+
recipient = recipientAddress;
354354
expiration = block.timestamp + duration;
355355
}
356356

docs/examples/safe-remote.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ you can use state machine-like constructs inside a contract.
3636
// The state variable has a default value of the first member, `State.created`
3737
State public state;
3838
39-
modifier condition(bool _condition) {
40-
require(_condition);
39+
modifier condition(bool condition_) {
40+
require(condition_);
4141
_;
4242
}
4343
@@ -62,8 +62,8 @@ you can use state machine-like constructs inside a contract.
6262
_;
6363
}
6464
65-
modifier inState(State _state) {
66-
if (state != _state)
65+
modifier inState(State state_) {
66+
if (state != state_)
6767
revert InvalidState();
6868
_;
6969
}

0 commit comments

Comments
 (0)