Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bp 168 platform transfer #204

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions contracts/TalentLayerIdUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ import {TalentLayerID} from "./TalentLayerID.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

contract TalentLayerIdUtils is IERC721Receiver {

// =========================== Mappings & Variables ==============================

/**
* @notice Instance of TalentLayerID.sol
*/
TalentLayerID public talentLayerIdContract;


// =========================== Initializers ==============================

constructor(address _talentLayerIDAddress){
constructor(address _talentLayerIDAddress) {
talentLayerIdContract = TalentLayerID(_talentLayerIDAddress);
}

// =========================== User functions ==============================

function mintDelegateAndTransfer(address _to, address _delegateAddress, uint256 _platformId, string calldata _handle) external payable {
function mintDelegateAndTransfer(
address _to,
address _delegateAddress,
uint256 _platformId,
string calldata _handle
) external payable {
// Mint TLID token
uint256 tokenId = talentLayerIdContract.mint{value: msg.value}(_platformId, _handle);
// Add address as delegate
Expand All @@ -33,8 +36,12 @@ contract TalentLayerIdUtils is IERC721Receiver {

// =========================== Overrides ==============================

function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external pure override returns (bytes4) {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external pure override returns (bytes4) {
return this.onERC721Received.selector;
}

}
10 changes: 7 additions & 3 deletions contracts/TalentLayerPlatformID.sol
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,14 @@ contract TalentLayerPlatformID is ERC721Upgradeable, AccessControlUpgradeable, U
}

/**
* @dev Override to prevent token transfer.
* @dev Implementation of the {ERC721Upgradeable-transferFrom} function.
* @notice Only one Id allowed per account.
*/
function _transfer(address, address, uint256) internal virtual override(ERC721Upgradeable) {
revert("Token transfer is not allowed");
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
require(balanceOf(to) == 0, "Recipient already has a Platform ID");
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");

_transfer(from, to, tokenId);
}

/**
Expand Down
Loading
Loading