Skip to content

Commit

Permalink
Merge pull request #28 from ConsenSys/feature/set_document
Browse files Browse the repository at this point in the history
feat(setDocument): Update access rights to setDocument function
  • Loading branch information
gauthierpetetin authored Jul 14, 2019
2 parents 34cab3b + a627ed3 commit 34991ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion contracts/ERC1400.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ contract ERC1400 is IERC1400, ERC1400Partition, MinterRole {
* @param uri Document content.
* @param documentHash Hash of the document [optional parameter].
*/
function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external onlyOwner {
function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external {
require(_isController[msg.sender]);
_documents[name] = Doc({
docURI: uri,
docHash: documentHash
Expand Down
10 changes: 5 additions & 5 deletions test/ERC1400.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,15 @@ contract('ERC1400', function ([owner, operator, controller, controller_alternati
});

describe('setDocument', function () {
describe('when sender is the contract owner', function () {
describe('when sender is a controller', function () {
it('attaches the document to the token', async function () {
await this.token.setDocument(documentName, documentURI, documentHash, { from: owner });
await this.token.setDocument(documentName, documentURI, documentHash, { from: controller });
const doc = await this.token.getDocument(documentName);
assert.equal(documentURI, doc[0]);
assert.equal(documentHash, doc[1]);
});
it('emits a docuemnt event', async function () {
const { logs } = await this.token.setDocument(documentName, documentURI, documentHash, { from: owner });
const { logs } = await this.token.setDocument(documentName, documentURI, documentHash, { from: controller });

assert.equal(logs.length, 1);
assert.equal(logs[0].event, 'Document');
Expand All @@ -611,7 +611,7 @@ contract('ERC1400', function ([owner, operator, controller, controller_alternati
assert.equal(logs[0].args.documentHash, documentHash);
});
});
describe('when sender is not the contract owner', function () {
describe('when sender is not a controller', function () {
it('reverts', async function () {
await shouldFail.reverting(this.token.setDocument(documentName, documentURI, documentHash, { from: unknown }));
});
Expand All @@ -620,7 +620,7 @@ contract('ERC1400', function ([owner, operator, controller, controller_alternati
describe('getDocument', function () {
describe('when docuemnt exists', function () {
it('returns the document', async function () {
await this.token.setDocument(documentName, documentURI, documentHash, { from: owner });
await this.token.setDocument(documentName, documentURI, documentHash, { from: controller });
const doc = await this.token.getDocument(documentName);
assert.equal(documentURI, doc[0]);
assert.equal(documentHash, doc[1]);
Expand Down

0 comments on commit 34991ae

Please sign in to comment.