Skip to content

Commit 875bd4b

Browse files
authored
Merge pull request #11 from singnet/token/updates
Token/updates
2 parents ddc0d79 + d102abb commit 875bd4b

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

contracts/tokens/SingularityNetToken.sol

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ import "zeppelin-solidity/contracts/token/BurnableToken.sol";
2323
*/
2424
contract SingularityNetToken is PausableToken, BurnableToken {
2525

26-
string public constant NAME = "SingularityNET Token";
27-
string public constant SYMBOL = "AGI";
28-
uint8 public constant DECIMALS = 8;
29-
uint256 public constant INITIAL_SUPPLY = 1000000000 * 10**uint256(DECIMALS);
30-
uint256 public constant PRIVATE_SUPPLY = 100000000 * 10**uint256(DECIMALS);
31-
uint256 public constant FOUNDER_SUPPLY = 500000000 * 10**uint256(DECIMALS);
32-
uint256 public constant PUBLIC_SUPPLY = 400000000 * 10**uint256(DECIMALS);
26+
string public constant name = "SingularityNET Token";
27+
string public constant symbol = "AGI";
28+
uint8 public constant decimals = 8;
29+
uint256 public constant INITIAL_SUPPLY = 1000000000 * 10**uint256(decimals);
30+
uint256 public constant PRIVATE_SUPPLY = 350000000 * 10**uint256(decimals);
31+
uint256 public constant FOUNDER_SUPPLY = 500000000 * 10**uint256(decimals);
32+
uint256 public constant PUBLIC_SUPPLY = 150000000 * 10**uint256(decimals);
3333

3434
/**
3535
* @dev SingularityNetToken Constructor
@@ -40,17 +40,6 @@ contract SingularityNetToken is PausableToken, BurnableToken {
4040
balances[msg.sender] = INITIAL_SUPPLY;
4141
}
4242

43-
function setOwnership(address _owner) onlyOwner {
44-
require(_owner != owner);
45-
require(address(_owner) != address(0));
46-
pause();
47-
//assign to current owner
48-
balances[owner] = INITIAL_SUPPLY.sub(PUBLIC_SUPPLY);
49-
transferOwnership(_owner);
50-
require(_owner == owner);
51-
balances[owner] = PUBLIC_SUPPLY;
52-
}
53-
5443
function transferTokens(address beneficiary, uint256 amount) onlyOwner returns (bool) {
5544
require(amount > 0);
5645

test/TestAgiCrowdsale.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const Crowdsale = artifacts.require('./helpers/AgiCrowdsale.sol')
22
const AGIToken = artifacts.require('SingularityNetToken.sol')
33
const Vault = artifacts.require('RefundVault.sol')
4+
const PUBLIC_SUPPLY = new web3.BigNumber(150000000 * Math.pow(10, 8))
45

56
const { latestTime, duration } = require('./helpers/latestTime')
67
const { increaseTimeTo } = require('./helpers/increaseTime')
@@ -22,7 +23,9 @@ contract('AgiCrowdsale', async ([miner, firstContributor, secondContributor, whi
2223
this.token = await AGIToken.new({ from: miner })
2324
this.agiCrowdsale = await Crowdsale.new(this.token.address, wallet, startTime, endTime, rate, cap, firstDayCap, goal, { from: miner })
2425

25-
await this.token.setOwnership(this.agiCrowdsale.address)
26+
await this.token.transfer(this.agiCrowdsale.address, PUBLIC_SUPPLY, {from:miner})
27+
await this.token.pause()
28+
await this.token.transferOwnership(this.agiCrowdsale.address)
2629
await this.agiCrowdsale.updateWhitelist([firstContributor, secondContributor], true)
2730
})
2831

@@ -62,8 +65,8 @@ contract('AgiCrowdsale', async ([miner, firstContributor, secondContributor, whi
6265
})
6366

6467
it('check the balances just after deploy and after crowdsale initialization', async () => {
65-
assert.equal((await this.token.balanceOf(miner)).toNumber(), 600000000 * 10**8, "The miner should hold 600mil")
66-
assert.equal((await this.token.balanceOf(this.agiCrowdsale.address)).toNumber(), 400000000 * 10**8, "The Crowdsale should hold 400mil")
68+
assert.equal((await this.token.balanceOf(miner)).toNumber(), 850000000 * 10**8, "The miner should hold 600mil")
69+
assert.equal((await this.token.balanceOf(this.agiCrowdsale.address)).toNumber(), 150000000 * 10**8, "The Crowdsale should hold 400mil")
6770
})
6871

6972
})
@@ -271,6 +274,8 @@ contract('AgiCrowdsale', async ([miner, firstContributor, secondContributor, whi
271274
await increaseTimeTo(latestTime() + duration.weeks(2))
272275

273276
await this.agiCrowdsale.finalize()
277+
await this.agiCrowdsale.transferOwnership(miner)
278+
274279

275280
assert.isTrue(await this.agiCrowdsale.isFinalized.call())
276281

@@ -291,6 +296,7 @@ contract('AgiCrowdsale', async ([miner, firstContributor, secondContributor, whi
291296

292297
await increaseTimeTo(latestTime() + duration.weeks(2))
293298
await this.agiCrowdsale.finalize()
299+
await this.agiCrowdsale.transferOwnership(miner)
294300

295301
const before = web3.fromWei(web3.eth.getBalance(firstContributor), 'ether')
296302

@@ -304,6 +310,8 @@ contract('AgiCrowdsale', async ([miner, firstContributor, secondContributor, whi
304310
await increaseTimeTo(latestTime() + duration.weeks(2))
305311

306312
await this.agiCrowdsale.finalize()
313+
await this.agiCrowdsale.transferOwnership(miner)
314+
307315

308316
const initialSupply = await this.token.balanceOf(this.agiCrowdsale.address)
309317
const balanceBeforeClaim = await this.token.balanceOf(miner)
@@ -327,6 +335,7 @@ contract('AgiCrowdsale', async ([miner, firstContributor, secondContributor, whi
327335
await increaseTimeTo(latestTime() + duration.weeks(2))
328336

329337
await this.agiCrowdsale.finalize()
338+
await this.agiCrowdsale.transferOwnership(miner)
330339

331340
assert.isFalse(await this.token.paused.call(), 'token should be unpaused')
332341
})

test/TestSingularityNetToken.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const SingularityNetToken = artifacts.require('./helpers/SingularityNetToken.sol')
22
const Crowdsale = artifacts.require('./helpers/AgiCrowdsale.sol')
3+
const PUBLIC_SUPPLY = new web3.BigNumber(150000000 * Math.pow(10, 8))
4+
35

46
const assertFail = require('./helpers/assertFail.js')
57
const { increaseTimeTo } = require('./helpers/increaseTime')
@@ -12,15 +14,15 @@ contract('SingularityNetToken', (accounts) => {
1214
})
1315

1416
it('should have the name Singularity Network Token', async () => {
15-
assert.equal(await this.token.NAME.call(), 'SingularityNET Token', "Singularity Network Token wasn't the name")
17+
assert.equal(await this.token.name.call(), 'SingularityNET Token', "Singularity Network Token wasn't the name")
1618
})
1719

1820
it('should have the symbol AGI', async () => {
19-
assert.equal(await this.token.SYMBOL.call(), 'AGI', "AGI wasn't the symbol")
21+
assert.equal(await this.token.symbol.call(), 'AGI', "AGI wasn't the symbol")
2022
})
2123

2224
it('should have decimals set to 8', async () => {
23-
assert.equal(await this.token.DECIMALS.call(), 8, "8 wasn't the value of decimals")
25+
assert.equal(await this.token.decimals.call(), 8, "8 wasn't the value of decimals")
2426
})
2527

2628
it('should have INITIAL_SUPPLY set to 1e17 cogs', async () => {
@@ -46,12 +48,12 @@ contract('SingularityNetToken', (accounts) => {
4648
await increaseTimeTo(startTime + duration.days(1))
4749

4850
//should be the new owner and start the sale
49-
await this.token.setOwnership(agiCrowdsale.address)
51+
await this.token.transfer(agiCrowdsale.address, PUBLIC_SUPPLY, {from:accounts[0]})
52+
await this.token.pause()
53+
await this.token.transferOwnership(agiCrowdsale.address)
5054
//Check the new token owner
5155
assert.equal(await this.token.owner.call(), agiCrowdsale.address, 'Crowdsale is not the owner of the token')
52-
//Check the balances
53-
const balanceAfter = await this.token.balanceOf(miner)
54-
const balanceOfCrowdsale = await this.token.balanceOf(agiCrowdsale.address)
56+
5557
})
5658

5759

@@ -104,10 +106,10 @@ contract('SingularityNetToken', (accounts) => {
104106
await increaseTimeTo(startTime + duration.days(1))
105107

106108
// First time should be ok
107-
await this.token.setOwnership(agiCrowdsale.address)
109+
await this.token.transferOwnership(agiCrowdsale.address)
108110

109111
// Callisg anthoer time, not
110-
await assertFail(async () => await this.token.setOwnership(agiCrowdsale.address), 'should have thrown before')
112+
await assertFail(async () => await this.token.transferOwnership(agiCrowdsale.address), 'should have thrown before')
111113
})
112114

113115
it('should transfer tokens to someone if owner', async () => {

0 commit comments

Comments
 (0)