diff --git a/contracts/TalentLayerIdUtils.sol b/contracts/TalentLayerIdUtils.sol index 870f113c..28e0cffd 100644 --- a/contracts/TalentLayerIdUtils.sol +++ b/contracts/TalentLayerIdUtils.sol @@ -3,8 +3,11 @@ pragma solidity ^0.8.9; import {TalentLayerID} from "./TalentLayerID.sol"; import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -contract TalentLayerIdUtils is IERC721Receiver { +contract TalentLayerIdUtils is IERC721Receiver, Ownable { + + // =========================== Mappings & Variables ============================== /** * @notice Instance of TalentLayerID.sol @@ -16,13 +19,15 @@ contract TalentLayerIdUtils is IERC721Receiver { */ address private backendDelegate; - + // =========================== Initializers ============================== constructor(address _talentLayerIDAddress){ talentLayerIdContract = TalentLayerID(_talentLayerIDAddress); } - function setBackendDelegate(address _backendDelegate) external { + // =========================== User functions ============================== + + function setBackendDelegate(address _backendDelegate) external onlyOwner { backendDelegate = _backendDelegate; } @@ -37,10 +42,14 @@ contract TalentLayerIdUtils is IERC721Receiver { talentLayerIdContract.safeTransferFrom(address(this), _to, tokenId); } + // =========================== Overrides ============================== + function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external pure override returns (bytes4) { return this.onERC721Received.selector; } + // =========================== Modifiers ============================== + modifier onlyBackendDelegate() { require((msg.sender == backendDelegate), "Not delegate"); _; diff --git a/test/batch/talentLayerIdUtils.ts b/test/batch/talentLayerIdUtils.ts index b9bc26cd..1542b20a 100644 --- a/test/batch/talentLayerIdUtils.ts +++ b/test/batch/talentLayerIdUtils.ts @@ -59,6 +59,12 @@ describe.only('TalentLayerIdUtils', function () { await deployAndSetup() }) + it("should fail to setBackendDelegate if executed by non-owner", async function () { + await expect( + talentLayerIdUtils.connect(alice).setBackendDelegate(alice.address) + ).to.be.revertedWith("Ownable: caller is not the owner"); + }); + it('mintDelegateAndTransfer', async function () { const handle = "pipou"; const mintFee = talentLayerId.getHandlePrice(handle);