Skip to main content

TwinHandlerFacet

View Source: contracts/protocol/facets/TwinHandlerFacet.sol

↗ Extends: IBosonTwinHandler, TwinBase

TwinHandlerFacet

Manages twin management requests and queries.

Functions

initialize

Initializes facet.
This function is callable only once.

function initialize() 
public
onlyUnInitialized

createTwin

Creates a Twin.
Emits a TwinCreated event if successful.
Reverts if:
- Seller does not exist
- Protocol is not approved to transfer the seller's token
- Twin supplyAvailable is zero
- Twin is NonFungibleToken and amount was set
- Twin is NonFungibleToken and end of range would overflow
- Twin is NonFungibleToken with unlimited supply and starting token id is too high
- Twin is NonFungibleToken and range is already being used in another twin of the seller
- Twin is FungibleToken or MultiToken and amount was not set
- Twin is FungibleToken or MultiToken and amount is greater than supply available

function createTwin(struct BosonTypes.Twin _twin) 
external
twinsNotPaused nonReentrant

Arguments

NameTypeDescription
_twinBosonTypes.Twinthe fully populated struct with twin id set to 0x0

removeTwin

Removes a twin.
Emits a TwinDeleted event if successful.
Reverts if:
- The twins region of protocol is paused
- Caller is not the seller.
- Twin does not exist.
- Bundle for twin exists

function removeTwin(uint256 _twinId) 
external
twinsNotPaused nonReentrant

Arguments

NameTypeDescription
_twinIduint256the id of the twin to check

getTwin

Gets the details about a given twin.

function getTwin(uint256 _twinId) 
external
view
returns(bool exists, Twin memory twin)

Arguments

NameTypeDescription
_twinIduint256the id of the twin to check

Returns

NameTypeDescription
existsboolthe twin was found
twinBosonTypes.Twinthe twin details. See {BosonTypes.Twin}

getNextTwinId

Gets the next twin id.Does not increment the counter.

function getNextTwinId() 
public
view
returns(uint256 nextTwinId)

Returns

NameTypeDescription
nextTwinIduint256the next twin id