Skip to main content

TwinBase

View Source: contracts/protocol/bases/TwinBase.sol

↗ Extends: ProtocolBase, IBosonTwinEvents ↘ Derived Contracts: OrchestrationHandlerFacet, TwinHandlerFacet

TwinBase

Provides functions for twin creation that can be shared across facets

Functions

createTwinInternal

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 createTwinInternal(struct BosonTypes.Twin _twin) 
internal

Arguments

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

contractSupportsInterface

Checks if the contract supports the correct interface for the selected token type.

function contractSupportsInterface(address _tokenAddress,
bytes4 _interfaceId)
internal
view
returns(bool)

Arguments

NameTypeDescription
_tokenAddressaddressthe address of the token to check
_interfaceIdbytes4the interface to check for

Returns

bool

isProtocolApproved

Checks if protocol is approved to transfer the tokens.

function isProtocolApproved(address _tokenAddress,
address _operator,
address _protocol)
internal
view
returns(bool _approved)

Arguments

NameTypeDescription
_tokenAddressaddressthe address of the seller's twin token contract
_operatoraddressthe seller's operator address
_protocoladdressthe protocol address

Returns

NameTypeDescription
_approvedboolthe approve status