diff --git a/contracts/ERC1400.sol b/contracts/ERC1400.sol index 2fefb835..fc1e0783 100644 --- a/contracts/ERC1400.sol +++ b/contracts/ERC1400.sol @@ -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 diff --git a/test/ERC1400.test.js b/test/ERC1400.test.js index f96746f2..7c09b475 100644 --- a/test/ERC1400.test.js +++ b/test/ERC1400.test.js @@ -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'); @@ -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 })); }); @@ -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]);