Skip to content

Commit dcca2ad

Browse files
Michał Sieczkowskipkuchtatt
andauthored
👮‍♀️ Add TokenControllerV2 to contracts-por and split across files (#1203)
* Add flatten script * Add source of currently deployed TokenControllerV2.sol (verified on E) * Create TokenControllerV3 by splitting TokenControllerV2.sol (flattened source of the last deployed version) into original source files. Flattened TokenControllerV2 and V3 are now identical except generated comments and '2' vs '3'. * Add files forgotten in previous commit * Add files forgotten in previous commit * Fix import paths * Remove unused files * Save flat files to flattened_contracts and ignore the dir in git * Rename files Co-authored-by: Peter Kuchta <[email protected]>
1 parent abb1419 commit dcca2ad

18 files changed

+4494
-0
lines changed

packages/contracts-por/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/node_modules
22
/build
33
/cache
4+
/flattened_contracts
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerVersion": "v0.6.10+commit.00c0fcaf",
3+
"compilerOptions": {
4+
"optimizer": {
5+
"enabled": true,
6+
"runs": 20000
7+
}
8+
},
9+
"sourceDirectory": "./contracts",
10+
"flattenOutputDirectory": "./flattened_contracts"
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
pragma solidity ^0.6.0;
3+
4+
/*
5+
* @dev Provides information about the current execution context, including the
6+
* sender of the transaction and its data. While these are generally available
7+
* via msg.sender and msg.data, they should not be accessed in such a direct
8+
* manner, since when dealing with GSN meta-transactions the account sending and
9+
* paying for execution may not be the actual sender (as far as an application
10+
* is concerned).
11+
*
12+
* This contract is only required for intermediate, library-like contracts.
13+
*/
14+
abstract contract Context {
15+
function _msgSender() internal view virtual returns (address payable) {
16+
return msg.sender;
17+
}
18+
19+
function _msgData() internal view virtual returns (bytes memory) {
20+
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
21+
return msg.data;
22+
}
23+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
// File: @openzeppelin/contracts/math/SafeMath.sol
4+
5+
pragma solidity ^0.6.0;
6+
7+
/**
8+
* @dev Wrappers over Solidity's arithmetic operations with added overflow
9+
* checks.
10+
*
11+
* Arithmetic operations in Solidity wrap on overflow. This can easily result
12+
* in bugs, because programmers usually assume that an overflow raises an
13+
* error, which is the standard behavior in high level programming languages.
14+
* `SafeMath` restores this intuition by reverting the transaction when an
15+
* operation overflows.
16+
*
17+
* Using this library instead of the unchecked operations eliminates an entire
18+
* class of bugs, so it's recommended to use it always.
19+
*/
20+
library SafeMath {
21+
/**
22+
* @dev Returns the addition of two unsigned integers, reverting on
23+
* overflow.
24+
*
25+
* Counterpart to Solidity's `+` operator.
26+
*
27+
* Requirements:
28+
*
29+
* - Addition cannot overflow.
30+
*/
31+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
32+
uint256 c = a + b;
33+
require(c >= a, "SafeMath: addition overflow");
34+
35+
return c;
36+
}
37+
38+
/**
39+
* @dev Returns the subtraction of two unsigned integers, reverting on
40+
* overflow (when the result is negative).
41+
*
42+
* Counterpart to Solidity's `-` operator.
43+
*
44+
* Requirements:
45+
*
46+
* - Subtraction cannot overflow.
47+
*/
48+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
49+
return sub(a, b, "SafeMath: subtraction overflow");
50+
}
51+
52+
/**
53+
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
54+
* overflow (when the result is negative).
55+
*
56+
* Counterpart to Solidity's `-` operator.
57+
*
58+
* Requirements:
59+
*
60+
* - Subtraction cannot overflow.
61+
*/
62+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
63+
require(b <= a, errorMessage);
64+
uint256 c = a - b;
65+
66+
return c;
67+
}
68+
69+
/**
70+
* @dev Returns the multiplication of two unsigned integers, reverting on
71+
* overflow.
72+
*
73+
* Counterpart to Solidity's `*` operator.
74+
*
75+
* Requirements:
76+
*
77+
* - Multiplication cannot overflow.
78+
*/
79+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
80+
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
81+
// benefit is lost if 'b' is also tested.
82+
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
83+
if (a == 0) {
84+
return 0;
85+
}
86+
87+
uint256 c = a * b;
88+
require(c / a == b, "SafeMath: multiplication overflow");
89+
90+
return c;
91+
}
92+
93+
/**
94+
* @dev Returns the integer division of two unsigned integers. Reverts on
95+
* division by zero. The result is rounded towards zero.
96+
*
97+
* Counterpart to Solidity's `/` operator. Note: this function uses a
98+
* `revert` opcode (which leaves remaining gas untouched) while Solidity
99+
* uses an invalid opcode to revert (consuming all remaining gas).
100+
*
101+
* Requirements:
102+
*
103+
* - The divisor cannot be zero.
104+
*/
105+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
106+
return div(a, b, "SafeMath: division by zero");
107+
}
108+
109+
/**
110+
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
111+
* division by zero. The result is rounded towards zero.
112+
*
113+
* Counterpart to Solidity's `/` operator. Note: this function uses a
114+
* `revert` opcode (which leaves remaining gas untouched) while Solidity
115+
* uses an invalid opcode to revert (consuming all remaining gas).
116+
*
117+
* Requirements:
118+
*
119+
* - The divisor cannot be zero.
120+
*/
121+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
122+
require(b > 0, errorMessage);
123+
uint256 c = a / b;
124+
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
125+
126+
return c;
127+
}
128+
129+
/**
130+
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
131+
* Reverts when dividing by zero.
132+
*
133+
* Counterpart to Solidity's `%` operator. This function uses a `revert`
134+
* opcode (which leaves remaining gas untouched) while Solidity uses an
135+
* invalid opcode to revert (consuming all remaining gas).
136+
*
137+
* Requirements:
138+
*
139+
* - The divisor cannot be zero.
140+
*/
141+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
142+
return mod(a, b, "SafeMath: modulo by zero");
143+
}
144+
145+
/**
146+
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
147+
* Reverts with custom message when dividing by zero.
148+
*
149+
* Counterpart to Solidity's `%` operator. This function uses a `revert`
150+
* opcode (which leaves remaining gas untouched) while Solidity uses an
151+
* invalid opcode to revert (consuming all remaining gas).
152+
*
153+
* Requirements:
154+
*
155+
* - The divisor cannot be zero.
156+
*/
157+
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
158+
require(b != 0, errorMessage);
159+
return a % b;
160+
}
161+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
pragma solidity ^0.6.0;
3+
4+
/**
5+
* @dev Interface of the ERC20 standard as defined in the EIP.
6+
*/
7+
interface IERC20 {
8+
/**
9+
* @dev Returns the amount of tokens in existence.
10+
*/
11+
function totalSupply() external view returns (uint256);
12+
13+
/**
14+
* @dev Returns the amount of tokens owned by `account`.
15+
*/
16+
function balanceOf(address account) external view returns (uint256);
17+
18+
/**
19+
* @dev Moves `amount` tokens from the caller's account to `recipient`.
20+
*
21+
* Returns a boolean value indicating whether the operation succeeded.
22+
*
23+
* Emits a {Transfer} event.
24+
*/
25+
function transfer(address recipient, uint256 amount) external returns (bool);
26+
27+
/**
28+
* @dev Returns the remaining number of tokens that `spender` will be
29+
* allowed to spend on behalf of `owner` through {transferFrom}. This is
30+
* zero by default.
31+
*
32+
* This value changes when {approve} or {transferFrom} are called.
33+
*/
34+
function allowance(address owner, address spender) external view returns (uint256);
35+
36+
/**
37+
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
38+
*
39+
* Returns a boolean value indicating whether the operation succeeded.
40+
*
41+
* IMPORTANT: Beware that changing an allowance with this method brings the risk
42+
* that someone may use both the old and the new allowance by unfortunate
43+
* transaction ordering. One possible solution to mitigate this race
44+
* condition is to first reduce the spender's allowance to 0 and set the
45+
* desired value afterwards:
46+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
47+
*
48+
* Emits an {Approval} event.
49+
*/
50+
function approve(address spender, uint256 amount) external returns (bool);
51+
52+
/**
53+
* @dev Moves `amount` tokens from `sender` to `recipient` using the
54+
* allowance mechanism. `amount` is then deducted from the caller's
55+
* allowance.
56+
*
57+
* Returns a boolean value indicating whether the operation succeeded.
58+
*
59+
* Emits a {Transfer} event.
60+
*/
61+
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
62+
63+
/**
64+
* @dev Emitted when `value` tokens are moved from one account (`from`) to
65+
* another (`to`).
66+
*
67+
* Note that `value` may be zero.
68+
*/
69+
event Transfer(address indexed from, address indexed to, uint256 value);
70+
71+
/**
72+
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
73+
* a call to {approve}. `value` is the new allowance.
74+
*/
75+
event Approval(address indexed owner, address indexed spender, uint256 value);
76+
}

0 commit comments

Comments
 (0)