Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Transfer/Moving tokens option in Token Manager #1134

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/token-manager/arapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
"Token amount"
]
},
{
"name": "Move tokens",
"id": "TRANSFER_FROM_TO_ROLE",
"params": [
"Holder",
"Receiver",
"Token amount"
]
},
{
"name": "Revoke vesting",
"id": "REVOKE_VESTINGS_ROLE",
Expand Down
16 changes: 16 additions & 0 deletions apps/token-manager/contracts/TokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ contract TokenManager is ITokenController, IForwarder, AragonApp {
bytes32 public constant MINT_ROLE = keccak256("MINT_ROLE");
bytes32 public constant ISSUE_ROLE = keccak256("ISSUE_ROLE");
bytes32 public constant ASSIGN_ROLE = keccak256("ASSIGN_ROLE");
bytes32 public constant TRANSFER_FROM_TO_ROLE = keccak256("TRANSFER_FROM_TO_ROLE");
bytes32 public constant REVOKE_VESTINGS_ROLE = keccak256("REVOKE_VESTINGS_ROLE");
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");

Expand Down Expand Up @@ -133,6 +134,16 @@ contract TokenManager is ITokenController, IForwarder, AragonApp {
token.destroyTokens(_holder, _amount);
}

/**
* @notice Transfer `@tokenAmount(self.token(): address, _amount, false)` tokens from `_holder` to `_receiver`
* @param _holder Holder of tokens being transferred
* @param _receiver The address receiving the tokens
* @param _amount Number of tokens transferred
*/
function transfer_from_to(address _holder, address _receiver, uint256 _amount) external authP(TRANSFER_FROM_TO_ROLE, arr(_holder, _receiver, _amount)) {
_transfer_from_to(_holder, _receiver, _amount);
}

/**
* @notice Assign `@tokenAmount(self.token(): address, _amount, false)` tokens to `_receiver` from the Token Manager's holdings with a `_revokable : 'revokable' : ''` vesting starting at `@formatDate(_start)`, cliff at `@formatDate(_cliff)` (first portion of tokens transferable), and completed vesting at `@formatDate(_vested)` (all tokens transferable)
* @param _receiver The address receiving the tokens, cannot be Token Manager itself
Expand Down Expand Up @@ -323,6 +334,11 @@ contract TokenManager is ITokenController, IForwarder, AragonApp {
token.generateTokens(_receiver, _amount); // minime.generateTokens() never returns false
}

function _transfer_from_to(address _holder, address _receiver, uint256 _amount) internal {
require(_isBalanceIncreaseAllowed(_holder, _receiver, _amount), ERROR_BALANCE_INCREASE_NOT_ALLOWED);
require(token.transferFrom(_holder, _receiver, _amount), ERROR_ASSIGN_TRANSFER_FROM_REVERTED);
}

function _isBalanceIncreaseAllowed(address _receiver, uint256 _inc) internal view returns (bool) {
// Max balance doesn't apply to the token manager itself
if (_receiver == address(this)) {
Expand Down