Skip to content

Commit

Permalink
Merge pull request #108 from oceanprotocol/feature/factory-getters
Browse files Browse the repository at this point in the history
Feature/factory getters
  • Loading branch information
Ahmed Ali committed Jun 11, 2020
2 parents af4d7ba + 53ea8f3 commit 1ba6c85
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
42 changes: 33 additions & 9 deletions contracts/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ contract Factory is Deployer, Converter {
string constant private TOKEN_NAME_PREFIX = 'DT';

event TokenCreated(
address newTokenAddress,
address templateAddress,
string tokenName
address indexed newTokenAddress,
address indexed templateAddress,
string indexed tokenName
);

event TokenRegistered(
address indexed tokenAddress,
string indexed tokenName,
string indexed tokenSymbol,
address tokenAddress,
string tokenName,
string tokenSymbol,
uint256 tokenCap,
address RegisteredBy,
uint256 RegisteredAt,
string blob
address indexed registeredBy,
uint256 indexed registeredAt,
string indexed blob
);

/**
Expand Down Expand Up @@ -115,4 +115,28 @@ contract Factory is Deployer, Converter {

currentTokenCount += 1;
}

/**
* @dev get the current token index.
* @return the current token count
*/
function getCurrentTokenIndex()
external
view
returns (uint256)
{
return currentTokenCount;
}

/**
* @dev get the token template address
* @return the template address
*/
function getTokenTemplate()
external
view
returns (address)
{
return tokenTemplate;
}
}
16 changes: 15 additions & 1 deletion docs/contracts/Factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,28 @@ Deploys new DataToken proxy contract.
Template contract address could not be a zero address.


### `getCurrentTokenIndex() → uint256` (external)



get the current token index.


### `getTokenTemplate() → address` (external)



get the token template address



### `TokenCreated(address newTokenAddress, address templateAddress, string tokenName)`





### `TokenRegistered(address tokenAddress, string tokenName, string tokenSymbol, uint256 tokenCap, address RegisteredBy, uint256 RegisteredAt, string blob)`
### `TokenRegistered(address tokenAddress, string tokenName, string tokenSymbol, uint256 tokenCap, address registeredBy, uint256 registeredAt, string blob)`



Expand Down
12 changes: 11 additions & 1 deletion test/unit/Factory.Test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env mocha */
/* global artifacts, contract, it, beforeEach */
/* global artifacts, contract, it, beforeEach, assert */

const Factory = artifacts.require('Factory')
const Template = artifacts.require('DataTokenTemplate')
Expand Down Expand Up @@ -52,4 +52,14 @@ contract('Factory test', async accounts => {
'DataTokenTemplate: Invalid minter, zero address'
)
})

it('should get the token count', async () => {
const currentTokenIndex = await factory.getCurrentTokenIndex()
assert.equal(currentTokenIndex.toNumber(), 1)
})

it('should get the token template', async () => {
const tokenTemplate = await factory.getTokenTemplate()
assert.equal(template.address, tokenTemplate)
})
})

0 comments on commit 1ba6c85

Please sign in to comment.