-
Notifications
You must be signed in to change notification settings - Fork 148
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 #277 from tronprotocol/develop
1.0.3 merge develop to master
- Loading branch information
Showing
562 changed files
with
7,124 additions
and
757 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract DataModel { | ||
enum TokenKind { | ||
TRX, // 0 | ||
TRC10, // 1 | ||
TRC20, // 2 | ||
TRC721 // 3 | ||
} | ||
enum Status { | ||
SUCCESS, // 0 | ||
LOCKING, // 1 | ||
FAIL, // 2 | ||
REFUNDED // 3 | ||
} | ||
} |
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,21 @@ | ||
library ECVerify { | ||
|
||
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { | ||
uint8 v; | ||
bytes32 r; | ||
bytes32 s; | ||
assembly { | ||
r := mload(add(signature, 32)) | ||
s := mload(add(signature, 64)) | ||
v := and(mload(add(signature, 65)), 255) | ||
} | ||
if (v < 27) { | ||
v += 27; | ||
} | ||
return ecrecover(hash, v, r, s); | ||
} | ||
|
||
function ecverify(bytes32 hash, bytes memory sig, address signer) internal pure returns (bool) { | ||
return signer == recover(hash, sig); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
dapp-chain/contract/v1.0.2/common/delegatecallable/Delegatecallable.sol
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,31 @@ | ||
import "../versionable/Versionable.sol"; | ||
|
||
contract Delegatecallable is Versionable { | ||
address public logicAddress; | ||
|
||
event DelegateResult(bool result, bytes msg); | ||
event LogicAddressChanged(address oldAddress, address newAddress); | ||
modifier goDelegateCall { | ||
if (logicAddress != address(0)) { | ||
(bool result,bytes memory mesg) = logicAddress.delegatecall(msg.data); | ||
if (!result) { | ||
revert(string(mesg)); | ||
} | ||
emit DelegateResult(result, mesg); | ||
return; | ||
} | ||
_; | ||
} | ||
function changeLogicAddress(address newLogicAddress) internal { | ||
string memory newVersion; | ||
if (newLogicAddress == address(0)) { | ||
newVersion = initVersion; | ||
} else { | ||
newVersion = Versionable(newLogicAddress).getCodeVersion(); | ||
} | ||
emit ChangeVersion(codeVersion, newVersion); | ||
emit LogicAddressChanged(logicAddress, newLogicAddress); | ||
codeVersion = newVersion; | ||
logicAddress = newLogicAddress; | ||
} | ||
} |
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,49 @@ | ||
/** | ||
* @title SafeMath | ||
* @dev Math operations with safety checks that throw on error | ||
*/ | ||
library SafeMath { | ||
|
||
/** | ||
* @dev Multiplies two numbers, throws on overflow. | ||
*/ | ||
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { | ||
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the | ||
// benefit is lost if 'b' is also tested. | ||
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 | ||
if (a == 0) { | ||
return 0; | ||
} | ||
|
||
c = a * b; | ||
require(c / a == b); | ||
return c; | ||
} | ||
|
||
/** | ||
* @dev Integer division of two numbers, truncating the quotient. | ||
*/ | ||
function div(uint256 a, uint256 b) internal pure returns (uint256) { | ||
// assert(b > 0); // Solidity automatically throws when dividing by 0 | ||
// uint256 c = a / b; | ||
// require(a == b * c + a % b); // There is no case in which this doesn't hold | ||
return a / b; | ||
} | ||
|
||
/** | ||
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). | ||
*/ | ||
function sub(uint256 a, uint256 b) internal pure returns (uint256) { | ||
require(b <= a); | ||
return a - b; | ||
} | ||
|
||
/** | ||
* @dev Adds two numbers, throws on overflow. | ||
*/ | ||
function add(uint256 a, uint256 b) internal pure returns (uint256 c) { | ||
c = a + b; | ||
require(c >= a); | ||
return c; | ||
} | ||
} |
Oops, something went wrong.