Skip to content

Commit

Permalink
Added ownable + test
Browse files Browse the repository at this point in the history
  • Loading branch information
quent043 committed Mar 30, 2024
1 parent 1dce85e commit f513e7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions contracts/TalentLayerIdUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand All @@ -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");
_;
Expand Down
6 changes: 6 additions & 0 deletions test/batch/talentLayerIdUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f513e7a

Please sign in to comment.