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(struct BosonTypes.Twin _twin)
- contractSupportsInterface(address _tokenAddress, bytes4 _interfaceId)
- isProtocolApproved(address _tokenAddress, address _operator, address _protocol)
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
Name | Type | Description |
---|---|---|
_twin | BosonTypes.Twin | the 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
Name | Type | Description |
---|---|---|
_tokenAddress | address | the address of the token to check |
_interfaceId | bytes4 | the 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
Name | Type | Description |
---|---|---|
_tokenAddress | address | the address of the seller's twin token contract |
_operator | address | the seller's operator address |
_protocol | address | the protocol address |
Returns
Name | Type | Description |
---|---|---|
_approved | bool | the approve status |