-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from EYBlockchain/lydia/require
Lydia/require
- Loading branch information
Showing
9 changed files
with
167 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: CC0 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Assign { | ||
|
||
|
||
struct myStruct { | ||
uint256 prop1; | ||
uint256 prop2; | ||
} | ||
|
||
secret myStruct public w; | ||
secret uint256 public a; | ||
|
||
|
||
uint256 public index; | ||
|
||
|
||
function add(secret uint256 value) public { | ||
require(a + value > 10, "a + value too low"); | ||
index++; | ||
require(a + index > 10, "a + index too low"); | ||
known a += value; | ||
} | ||
|
||
function add2(secret uint256 value) public { | ||
require(a + index > 10, "original a + index too low"); | ||
index++; | ||
a += index; | ||
require(a + index > 10, "new a + index too low"); | ||
known a += index + value; | ||
} | ||
|
||
function add1(secret uint256 value) public { | ||
require(index < 5) ; | ||
index++; | ||
known a += index + value; | ||
} | ||
|
||
|
||
|
||
function remove(secret uint256 value) public { | ||
require(a > 5, "original value of a is too low"); | ||
a -= value; | ||
require(a > index, "new value of a is too low"); | ||
} | ||
|
||
function remove1(secret uint256 value) public { | ||
require(index < 10, "index is too high"); | ||
a -= value; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: CC0 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Assign { | ||
|
||
|
||
struct myStruct { | ||
uint256 prop1; | ||
uint256 prop2; | ||
} | ||
|
||
secret myStruct public w; | ||
secret uint256 public a; | ||
|
||
|
||
uint256 public index; | ||
|
||
|
||
function add(secret uint256 value, uint256 value1) public { | ||
require(value < 10, "value too high"); | ||
index++; | ||
value1++; | ||
a += index; | ||
require(value + index + value1 < 20, "value + index + value1 too high"); | ||
known a += index + value; | ||
} | ||
|
||
function add1(secret uint256 value) public { | ||
require(value < 10, "value too high"); | ||
index++; | ||
secret uint256 c = value; | ||
require(c > 5, "c too low"); | ||
c += value; | ||
uint256 d = 5; | ||
require(c -d > index, "c -d too low"); | ||
a += c +d; | ||
} | ||
|
||
function remove(secret uint256 value) public { | ||
a -= value; | ||
} | ||
|
||
|
||
|
||
|
||
} |