Merge pull request #4465 from al-ias/fix/solidity

[solidity] Solidity minor fixes
This commit is contained in:
Marcel Ribeiro Dantas 2022-08-02 14:55:06 +02:00 committed by GitHub
commit da4c77d05b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,7 +278,7 @@ f(22); // call
// Delete can be called on most types // Delete can be called on most types
// (does NOT destroy value, but sets value to 0, the initial value) // (does NOT destroy value, but sets value to 0, the initial value)
uint x = 5; delete x;
// Destructuring/Tuples // Destructuring/Tuples
@ -388,7 +388,7 @@ block.gasLimit();
storage['abc'] = 'def'; // maps 256 bit words to 256 bit words storage['abc'] = 'def'; // maps 256 bit words to 256 bit words
// 4. FUNCTIONS AND MORE // 5. FUNCTIONS AND MORE
// A. Functions // A. Functions
// Simple function // Simple function
function increment(uint x) returns (uint) { function increment(uint x) returns (uint) {
@ -435,7 +435,7 @@ function increment(uint x) view returns (uint x) {
// Functions hoisted - and can assign a function to a variable // Functions hoisted - and can assign a function to a variable
function a() { function a() {
var z = b; var z = b;
b(); z();
} }
function b() { function b() {
@ -494,9 +494,9 @@ Coin.LogSent().watch({}, '', function(error, result) {
// '_' (underscore) often included as last line in body, and indicates // '_' (underscore) often included as last line in body, and indicates
// function being called should be placed there // function being called should be placed there
modifier onlyAfter(uint _time) { require (now >= _time); _; } modifier onlyAfter(uint _time) { require (now >= _time); _; }
modifier onlyOwner { require(msg.sender == owner) _; } modifier onlyOwner { require(msg.sender == owner); _; }
// commonly used with state machines // commonly used with state machines
modifier onlyIfStateA (State currState) { require(currState == State.A) _; } modifier onlyIfStateA (State currState) { require(currState == State.A); _; }
// Append right after function declaration // Append right after function declaration
function changeOwner(newOwner) function changeOwner(newOwner)
@ -646,7 +646,7 @@ reveal(100, "mySecret");
// All data to start of time is stored in blockchain, so // All data to start of time is stored in blockchain, so
// anyone can observe all previous data and changes // anyone can observe all previous data and changes
// E. Oracles and External Data // D. Oracles and External Data
// Oracles are ways to interact with your smart contracts outside the blockchain. // Oracles are ways to interact with your smart contracts outside the blockchain.
// They are used to get data from the real world, send post requests, to the real world // They are used to get data from the real world, send post requests, to the real world
// or vise versa. // or vise versa.
@ -671,12 +671,12 @@ reveal(100, "mySecret");
// Setting up oracle networks yourself // Setting up oracle networks yourself
// D. Cron Job // E. Cron Job
// Contracts must be manually called to handle time-based scheduling; can create external // Contracts must be manually called to handle time-based scheduling; can create external
// code to regularly ping, or provide incentives (ether) for others to // code to regularly ping, or provide incentives (ether) for others to
// //
// E. Observer Pattern // F. Observer Pattern
// An Observer Pattern lets you register as a subscriber and // An Observer Pattern lets you register as a subscriber and
// register a function which is called by the oracle (note, the oracle pays // register a function which is called by the oracle (note, the oracle pays
// for this action to be run) // for this action to be run)
@ -714,7 +714,7 @@ contract SomeOracle {
// Now, your client contract can addSubscriber by importing SomeOracleCallback // Now, your client contract can addSubscriber by importing SomeOracleCallback
// and registering with Some Oracle // and registering with Some Oracle
// F. State machines // G. State machines
// see example below for State enum and inState modifier // see example below for State enum and inState modifier
``` ```