Skip to content

Commit

Permalink
Removing Burn and Mint as they don't fit Hive Project token business …
Browse files Browse the repository at this point in the history
…needs
  • Loading branch information
Stanimir Savov committed Aug 29, 2017
1 parent 0d54699 commit 897f19e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 183 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ This is implementation of ERC20 HVN token.

Implementation supports also following protections:
- Freez and UnFreez transfers
- Burn and Mint
- Short address protection

## Implementation
Expand Down
2 changes: 1 addition & 1 deletion build/contracts/ERC20Interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@
"unlinked_binary": "0x",
"networks": {},
"schema_version": "0.0.5",
"updated_at": 1503670993747
"updated_at": 1504004902857
}
95 changes: 2 additions & 93 deletions build/contracts/HVNToken.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/contracts/Migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"type": "constructor"
}
],
"unlinked_binary": "0x6060604052341561000f57600080fd5b5b60008054600160a060020a03191633600160a060020a03161790555b5b6101e58061003c6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630900f010811461005e578063445df0ac1461007f5780638da5cb5b146100a4578063fdacd576146100d3575b600080fd5b341561006957600080fd5b61007d600160a060020a03600435166100eb565b005b341561008a57600080fd5b610092610182565b60405190815260200160405180910390f35b34156100af57600080fd5b6100b7610188565b604051600160a060020a03909116815260200160405180910390f35b34156100de57600080fd5b61007d600435610197565b005b6000805433600160a060020a039081169116141561017c5781905080600160a060020a031663fdacd5766001546040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401600060405180830381600087803b151561016757600080fd5b6102c65a03f1151561017857600080fd5b5050505b5b5b5050565b60015481565b600054600160a060020a031681565b60005433600160a060020a03908116911614156101b45760018190555b5b5b505600a165627a7a723058206873a763a442ca3432b80ad5d5c2b8b95f0e31abb79eacb7f22c4cf9b407b5340029",
"unlinked_binary": "0x6060604052341561000f57600080fd5b5b60008054600160a060020a03191633600160a060020a03161790555b5b6101e58061003c6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630900f010811461005e578063445df0ac1461007f5780638da5cb5b146100a4578063fdacd576146100d3575b600080fd5b341561006957600080fd5b61007d600160a060020a03600435166100eb565b005b341561008a57600080fd5b610092610182565b60405190815260200160405180910390f35b34156100af57600080fd5b6100b7610188565b604051600160a060020a03909116815260200160405180910390f35b34156100de57600080fd5b61007d600435610197565b005b6000805433600160a060020a039081169116141561017c5781905080600160a060020a031663fdacd5766001546040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281526004810191909152602401600060405180830381600087803b151561016757600080fd5b6102c65a03f1151561017857600080fd5b5050505b5b5b5050565b60015481565b600054600160a060020a031681565b60005433600160a060020a03908116911614156101b45760018190555b5b5b505600a165627a7a723058200bb07ff761a648a127c5fe21a929694b1b9d0198e26e0304df5f321c3a4c4ef20029",
"networks": {},
"schema_version": "0.0.5",
"updated_at": 1503328594898
"updated_at": 1504004902859
}
4 changes: 2 additions & 2 deletions build/contracts/Owned.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"type": "event"
}
],
"unlinked_binary": "0x6060604052341561000f57600080fd5b5b60008054600160a060020a03191633600160a060020a03161790555b5b6102448061003c6000396000f300606060405263ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166379ba5097811461005e5780638da5cb5b14610073578063d4ee1d90146100a2578063f2fde38b146100d1575b600080fd5b341561006957600080fd5b6100716100f2565b005b341561007e57600080fd5b61008661019a565b604051600160a060020a03909116815260200160405180910390f35b34156100ad57600080fd5b6100866101a9565b604051600160a060020a03909116815260200160405180910390f35b34156100dc57600080fd5b610071600160a060020a03600435166101b8565b005b60015433600160a060020a0390811691161461010d57600080fd5b6000546001547f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a91600160a060020a039081169116604051600160a060020a039283168152911660208201526040908101905180910390a1600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a038416179091551690555b565b600054600160a060020a031681565b600154600160a060020a031681565b60005433600160a060020a039081169116146101d057fe5b600054600160a060020a03828116911614156101eb57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b505600a165627a7a723058209bb90a255705dd9c5f2f7854104a7592d54dddebc2bca8b84b82855b24c721d00029",
"unlinked_binary": "0x6060604052341561000f57600080fd5b5b60008054600160a060020a03191633600160a060020a03161790555b5b6102448061003c6000396000f300606060405263ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166379ba5097811461005e5780638da5cb5b14610073578063d4ee1d90146100a2578063f2fde38b146100d1575b600080fd5b341561006957600080fd5b6100716100f2565b005b341561007e57600080fd5b61008661019a565b604051600160a060020a03909116815260200160405180910390f35b34156100ad57600080fd5b6100866101a9565b604051600160a060020a03909116815260200160405180910390f35b34156100dc57600080fd5b610071600160a060020a03600435166101b8565b005b60015433600160a060020a0390811691161461010d57600080fd5b6000546001547f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a91600160a060020a039081169116604051600160a060020a039283168152911660208201526040908101905180910390a1600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a038416179091551690555b565b600054600160a060020a031681565b600154600160a060020a031681565b60005433600160a060020a039081169116146101d057fe5b600054600160a060020a03828116911614156101eb57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b505600a165627a7a72305820e610335402518edb73c93bde92e15d24ee907189ef7f817be233d71c163426890029",
"networks": {},
"schema_version": "0.0.5",
"updated_at": 1503670993747
"updated_at": 1504004902859
}
4 changes: 2 additions & 2 deletions build/contracts/SafeMath.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"contract_name": "SafeMath",
"abi": [],
"unlinked_binary": "0x60606040523415600e57600080fd5b5b603680601c6000396000f30060606040525b600080fd00a165627a7a7230582006281bc3bed7da5179dd340728a5a241e0dd813ba85252ad3126e53af95708600029",
"unlinked_binary": "0x60606040523415600e57600080fd5b5b603680601c6000396000f30060606040525b600080fd00a165627a7a723058208791d327130cb3676441b15940d0160f8f6afc37747c3f170d22b5fc2c84c36e0029",
"networks": {},
"schema_version": "0.0.5",
"updated_at": 1503670993747
"updated_at": 1504004902859
}
2 changes: 1 addition & 1 deletion build/contracts/tokenRecipient.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
"unlinked_binary": "0x",
"networks": {},
"schema_version": "0.0.5",
"updated_at": 1503670993747
"updated_at": 1504004902859
}
47 changes: 3 additions & 44 deletions contracts/HVNToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract HVNToken is ERC20Interface, SafeMath, Owned {
string public constant name = "Hive Project Token";
string public constant symbol = "HVN";
uint8 public constant decimals = 8;
string public version = '0.0.1';
string public version = '0.0.2';

bool public transfersFrozen = false;

Expand All @@ -51,8 +51,8 @@ contract HVNToken is ERC20Interface, SafeMath, Owned {


function HVNToken() ownerOnly {
// send all tokens to the owner
mint(50000000000000000);
totalSupply = 50000000000000000;
balances[owner] = totalSupply;
}


Expand Down Expand Up @@ -133,45 +133,6 @@ contract HVNToken is ERC20Interface, SafeMath, Owned {
}


/**
* Approve and then communicate the approved contract in a single transaction
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) onlyPayloadSize(3) returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}


/**
* Minting functionality
*/
function mint(uint256 _amount) ownerOnly {
balances[owner] = add(balances[owner], _amount);
totalSupply = add(totalSupply, _amount);

Mint(owner, _amount);
Transfer(0x0, owner, _amount);
}


/**
* Burning functionality
*/
function burn(uint256 _amount) returns (bool) {
if (_amount > balances[msg.sender]) return false;

balances[msg.sender] = sub(balances[msg.sender], _amount);
totalSupply = sub(totalSupply, _amount);

Burn(msg.sender, _amount);
Transfer(msg.sender, 0x0, _amount);
return true;
}


/**
* Peterson's Law Protection
* Claim tokens
Expand All @@ -192,6 +153,4 @@ contract HVNToken is ERC20Interface, SafeMath, Owned {

event Freeze (address indexed owner);
event Unfreeze (address indexed owner);
event Mint(address indexed to, uint amount);
event Burn(address indexed from, uint amount);
}
Binary file modified docs/test-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 4 additions & 37 deletions test/HVNToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ const thousandTokens = 1000 * oneToken
const hundredTokens = 100 * oneToken
const fiftyTokens = 50 * oneToken

it("Current date is: " + new Date().toLocaleString("en-US", {timeZone: "UTC"}))
console.log("-".repeat(40))
console.log("\n", "Current date is:", new Date().toLocaleString("en-US", {timeZone: "UTC"}))
console.log("-".repeat(40))

contract('HNVToken', (accounts) => {
contract('HVNToken', (accounts) => {
it("should have total supply of 500,000,000.00000000 tokens", () => {
return HVNToken.deployed()
.then((token) => token.totalSupply())
Expand Down Expand Up @@ -134,39 +136,4 @@ contract('HNVToken', (accounts) => {
.catch((err) => assert(evmThrewError(err), err.message))
})
})

describe("Mint/Burn", () => {
it("should mint 10,000 tokens", () => {
return HVNToken.deployed()
.then((token) => {
return token.totalSupply()
.then(supplyBefore => {
return token.mint(tenThousandsTokens)
.then(() => token.totalSupply())
.then((supplyAfter) => assert.equal(supplyAfter.valueOf(), parseInt(supplyBefore.valueOf()) + tenThousandsTokens, "did not mint 10,000 tokens"))
})
})
})

it("not-owner should not be able to mint", () => {
let token = null
return HVNToken.deployed()
.then((t) => token = t)
.then(() => token.mint(tenThousandsTokens, { from: accounts[1] }))
.catch((err) => assert(evmThrewError(err), err.message))
})

it("anyone should be able to burn their tokens", () => {
let token = null
return HVNToken.deployed()
.then((token) => {
return token.totalSupply()
.then(supplyBefore => {
return token.burn(oneToken, { from: accounts[1] })
.then(() => token.totalSupply())
.then((supplyAfter) => assert.equal(supplyAfter.valueOf(), parseInt(supplyBefore.valueOf()) - oneToken, "did not burn 1 token"))
})
})
})
})
})

0 comments on commit 897f19e

Please sign in to comment.