TwinHandlerFacet
View Source: contracts/protocol/facets/TwinHandlerFacet.sol
↗ Extends: IBosonTwinHandler, TwinBase
TwinHandlerFacet
Manages twin management requests and queries.
Functions
- initialize()
- createTwin(struct BosonTypes.Twin _twin)
- removeTwin(uint256 _twinId)
- getTwin(uint256 _twinId)
- getNextTwinId()
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
Name | Type | Description |
---|---|---|
_twin | BosonTypes.Twin | the 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
Name | Type | Description |
---|---|---|
_twinId | uint256 | the 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
Name | Type | Description |
---|---|---|
_twinId | uint256 | the id of the twin to check |
Returns
Name | Type | Description |
---|---|---|
exists | bool | the twin was found |
twin | BosonTypes.Twin | the twin details. See {BosonTypes.Twin} |
getNextTwinId
Gets the next twin id.Does not increment the counter.
function getNextTwinId()
public
view
returns(uint256 nextTwinId)
Returns
Name | Type | Description |
---|---|---|
nextTwinId | uint256 | the next twin id |