Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
72029b68
Commit
72029b68
authored
Mar 14, 2017
by
Jorge Izquierdo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decouple transferable logic from VestedToken
parent
9c5975a7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
17 deletions
+25
-17
TransferableToken.sol
contracts/token/TransferableToken.sol
+22
-0
VestedToken.sol
contracts/token/VestedToken.sol
+3
-17
No files found.
contracts/token/TransferableToken.sol
0 → 100644
View file @
72029b68
pragma solidity ^0.4.8;
import "./ERC20.sol";
contract TransferableToken is ERC20 {
modifier canTransfer(address _sender, uint _value) {
if (_value > transferableTokens(_sender, uint64(now))) throw;
_;
}
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) returns (bool success) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return balanceOf(holder);
}
}
contracts/token/VestedToken.sol
View file @
72029b68
...
@@ -2,9 +2,9 @@ pragma solidity ^0.4.8;
...
@@ -2,9 +2,9 @@ pragma solidity ^0.4.8;
import "./StandardToken.sol";
import "./StandardToken.sol";
import "./TransferableToken.sol";
contract VestedToken is StandardToken, TransferableToken {
contract VestedToken is StandardToken {
struct TokenGrant {
struct TokenGrant {
address granter;
address granter;
uint256 value;
uint256 value;
...
@@ -15,19 +15,6 @@ contract VestedToken is StandardToken {
...
@@ -15,19 +15,6 @@ contract VestedToken is StandardToken {
mapping (address => TokenGrant[]) public grants;
mapping (address => TokenGrant[]) public grants;
modifier canTransfer(address _sender, uint _value) {
if (_value > transferableTokens(_sender, uint64(now))) throw;
_;
}
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) returns (bool success) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
function grantVestedTokens(
function grantVestedTokens(
address _to,
address _to,
uint256 _value,
uint256 _value,
...
@@ -133,11 +120,10 @@ contract VestedToken is StandardToken {
...
@@ -133,11 +120,10 @@ contract VestedToken is StandardToken {
function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) {
function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) {
uint256 grantIndex = grants[holder].length;
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = safeAdd(nonVested, nonVestedTokens(grants[holder][i], time));
nonVested = safeAdd(nonVested, nonVestedTokens(grants[holder][i], time));
}
}
return
safeSub(balances[holder], nonVested
);
return
min256(safeSub(balances[holder], nonVested), super.transferableTokens(holder, time)
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment