Skip to content

Commit

Permalink
final test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyamSB committed Jan 9, 2019
1 parent c020217 commit aa985b1
Show file tree
Hide file tree
Showing 2 changed files with 328 additions and 6 deletions.
15 changes: 14 additions & 1 deletion contracts/ERC1410/ERC1410Standard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,25 @@ contract ERC1410Standard is IERC1410, ERC1410Operator, Ownable {
require(_validPartition(_partition, _from), "Invalid partition");
uint256 index = partitionToIndex[_from][_partition] - 1;
require(partitions[_from][index].amount >= _value, "Insufficient value");
partitions[_from][index].amount = partitions[_from][index].amount.sub(_value);
if (partitions[_from][index].amount == _value) {
_deletePartitionForHolder(_from, _partition, index);
} else {
partitions[_from][index].amount = partitions[_from][index].amount.sub(_value);
}
balances[_from] = balances[_from].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit RedeemedByPartition(_partition, _operator, _from, _value, _data, _operatorData);
}

function _deletePartitionForHolder(address _holder, bytes32 _partition, uint256 index) internal {
if (index != partitions[_holder].length -1) {
partitions[_holder][index] = partitions[_holder][partitions[_holder].length -1];
partitionToIndex[_holder][partitions[_holder][index].partition] = index + 1;
}
delete partitionToIndex[_holder][_partition];
partitions[_holder].length--;
}

function _validateParams(bytes32 _partition, uint256 _value) internal pure {
require(_value != uint256(0), "Zero value not allowed");
require(_partition != bytes32(0), "Invalid partition");
Expand Down
Loading

0 comments on commit aa985b1

Please sign in to comment.