-
Notifications
You must be signed in to change notification settings - Fork 86
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 #551 from cyjseagull/release-2.3.0-master-new
Release 2.3.0 to master
- Loading branch information
Showing
53 changed files
with
3,038 additions
and
382 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v2.2.3 | ||
v2.3.0 |
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 |
---|---|---|
@@ -1,89 +1,97 @@ | ||
pragma solidity ^0.4.24; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "./Table.sol"; | ||
|
||
contract TableTest { | ||
event CreateResult(int count); | ||
event InsertResult(int count); | ||
event UpdateResult(int count); | ||
event RemoveResult(int count); | ||
|
||
//create table | ||
function create() public returns(int){ | ||
TableFactory tf = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory | ||
|
||
int count = tf.createTable("t_test", "name", "item_id,item_name"); | ||
emit CreateResult(count); | ||
return count; | ||
event CreateResult(int256 count); | ||
event InsertResult(int256 count); | ||
event UpdateResult(int256 count); | ||
event RemoveResult(int256 count); | ||
|
||
TableFactory tableFactory; | ||
string constant TABLE_NAME = "t_test"; | ||
constructor() public { | ||
tableFactory = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory | ||
// the parameters of createTable are tableName,keyField,"vlaueFiled1,vlaueFiled2,vlaueFiled3,..." | ||
tableFactory.createTable(TABLE_NAME, "name", "item_id,item_name"); | ||
} | ||
|
||
//select records | ||
function select(string name) public constant returns(string[], int[], string[]){ | ||
TableFactory tf = TableFactory(0x1001); | ||
Table table = tf.openTable("t_test"); | ||
|
||
function select(string name) | ||
public | ||
view | ||
returns (string[], int256[], string[]) | ||
{ | ||
Table table = tableFactory.openTable(TABLE_NAME); | ||
|
||
Condition condition = table.newCondition(); | ||
|
||
Entries entries = table.select(name, condition); | ||
string[] memory user_name_bytes_list = new string[](uint256(entries.size())); | ||
int[] memory item_id_list = new int[](uint256(entries.size())); | ||
string[] memory item_name_bytes_list = new string[](uint256(entries.size())); | ||
|
||
for(int i=0; i<entries.size(); ++i) { | ||
string[] memory user_name_bytes_list = new string[]( | ||
uint256(entries.size()) | ||
); | ||
int256[] memory item_id_list = new int256[](uint256(entries.size())); | ||
string[] memory item_name_bytes_list = new string[]( | ||
uint256(entries.size()) | ||
); | ||
|
||
for (int256 i = 0; i < entries.size(); ++i) { | ||
Entry entry = entries.get(i); | ||
|
||
user_name_bytes_list[uint256(i)] = entry.getString("name"); | ||
item_id_list[uint256(i)] = entry.getInt("item_id"); | ||
item_name_bytes_list[uint256(i)] = entry.getString("item_name"); | ||
item_name_bytes_list[uint256(i)] = entry.getString("item_name"); | ||
} | ||
|
||
return (user_name_bytes_list, item_id_list, item_name_bytes_list); | ||
} | ||
//insert records | ||
function insert(string name, int item_id, string item_name) public returns(int) { | ||
TableFactory tf = TableFactory(0x1001); | ||
Table table = tf.openTable("t_test"); | ||
|
||
function insert(string name, int256 item_id, string item_name) | ||
public | ||
returns (int256) | ||
{ | ||
Table table = tableFactory.openTable(TABLE_NAME); | ||
|
||
Entry entry = table.newEntry(); | ||
entry.set("name", name); | ||
entry.set("item_id", item_id); | ||
entry.set("item_name", item_name); | ||
int count = table.insert(name, entry); | ||
|
||
int256 count = table.insert(name, entry); | ||
emit InsertResult(count); | ||
|
||
return count; | ||
} | ||
//update records | ||
function update(string name, int item_id, string item_name) public returns(int) { | ||
TableFactory tf = TableFactory(0x1001); | ||
Table table = tf.openTable("t_test"); | ||
|
||
function update(string name, int256 item_id, string item_name) | ||
public | ||
returns (int256) | ||
{ | ||
Table table = tableFactory.openTable(TABLE_NAME); | ||
|
||
Entry entry = table.newEntry(); | ||
entry.set("item_name", item_name); | ||
|
||
Condition condition = table.newCondition(); | ||
condition.EQ("name", name); | ||
condition.EQ("item_id", item_id); | ||
int count = table.update(name, entry, condition); | ||
|
||
int256 count = table.update(name, entry, condition); | ||
emit UpdateResult(count); | ||
|
||
return count; | ||
} | ||
//remove records | ||
function remove(string name, int item_id) public returns(int){ | ||
TableFactory tf = TableFactory(0x1001); | ||
Table table = tf.openTable("t_test"); | ||
|
||
function remove(string name, int256 item_id) public returns (int256) { | ||
Table table = tableFactory.openTable(TABLE_NAME); | ||
|
||
Condition condition = table.newCondition(); | ||
condition.EQ("name", name); | ||
condition.EQ("item_id", item_id); | ||
int count = table.remove(name, condition); | ||
|
||
int256 count = table.remove(name, condition); | ||
emit RemoveResult(count); | ||
|
||
return count; | ||
} | ||
} |
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
Oops, something went wrong.