Skip to content

Solidity API

PropsFeesInternal

Internal contract containing the core logic for PropsFees

This contract uses the PropsFeesStorage library for managing fee-related data

_upsertFee

solidity
function _upsertFee(string _feeType, uint256[] _feeAmounts, address[] _feeRecipients, enum PropsFeesStorage.FeeType _feeTypeEnum, enum PropsFeesStorage.FeeApplication _feeApplication, uint256 _tokenId) internal

Internal function to upsert (insert or update) a fee

This function filters out zero fee amounts and their corresponding recipients

Parameters

NameTypeDescription
_feeTypestringThe type of fee to upsert
_feeAmountsuint256[]The fee amounts to set
_feeRecipientsaddress[]The fee recipients to set
_feeTypeEnumenum PropsFeesStorage.FeeTypeThe fee type to set (from PropsFeesStorage.FeeType enum)
_feeApplicationenum PropsFeesStorage.FeeApplicationThe fee application to set (from PropsFeesStorage.FeeApplication enum)
_tokenIduint256The token ID associated with this fee

_getFee

solidity
function _getFee(string _feeType) internal view returns (struct PropsFeesStorage.Fee)

Internal function to get a fee value for a given fee type

Retrieves the fee from the feeCatalog mapping in storage

Parameters

NameTypeDescription
_feeTypestringThe type of fee to retrieve

Return Values

NameTypeDescription
[0]struct PropsFeesStorage.FeePropsFeesStorage.Fee The fee structure containing amounts, recipients, and other details

_getAllFees

solidity
function _getAllFees() internal view returns (string[], struct PropsFeesStorage.Fee[])

Internal function to get all fees

Retrieves all fee keys and their corresponding fee structures from storage

Return Values

NameTypeDescription
[0]string[]string[] An array of fee keys (fee types)
[1]struct PropsFeesStorage.Fee[]PropsFeesStorage.Fee[] An array of fee structures corresponding to the fee keys

_removeFee

solidity
function _removeFee(string _feeType) internal

Internal function to remove a fee

Removes the fee from the feeCatalog and updates the feeKeys array

Parameters

NameTypeDescription
_feeTypestringThe type of fee to remove

_mergeFees

solidity
function _mergeFees(address[] recipients1, uint256[] amounts1, address[] recipients2, uint256[] amounts2) internal pure returns (address[] mergedRecipients, uint256[] mergedAmounts)

Merges two sets of fee recipients and amounts

Combines and deduplicates recipients, summing amounts for duplicate addresses

Parameters

NameTypeDescription
recipients1address[]First array of recipient addresses
amounts1uint256[]First array of fee amounts
recipients2address[]Second array of recipient addresses
amounts2uint256[]Second array of fee amounts

Return Values

NameTypeDescription
mergedRecipientsaddress[]Combined array of unique recipient addresses
mergedAmountsuint256[]Combined array of fee amounts corresponding to mergedRecipients

_addOrUpdateRecipient

solidity
function _addOrUpdateRecipient(address[] recipients, uint256[] amounts, uint256 count, address newRecipient, uint256 newAmount) internal pure returns (address[], uint256[], uint256)

Helper function to add or update a recipient in the fee arrays

If the recipient already exists, updates the amount; otherwise, adds a new entry

Parameters

NameTypeDescription
recipientsaddress[]Array of recipient addresses
amountsuint256[]Array of fee amounts
countuint256Current count of unique recipients
newRecipientaddressAddress of the recipient to add or update
newAmountuint256Amount to add for the recipient

Return Values

NameTypeDescription
[0]address[]Updated recipients array, amounts array, and new count of unique recipients
[1]uint256[]
[2]uint256

_adjustAndMergeFees

solidity
function _adjustAndMergeFees(address[] regularRecipients, uint256[] regularAmounts, uint256 regularCount, address[] splitRecipients, uint256[] splitAmounts) internal pure returns (address[], uint256[], uint256)

Adjusts regular fees based on split fees and merges them

Reduces regular fees proportionally to accommodate split fees, then combines all fees

Parameters

NameTypeDescription
regularRecipientsaddress[]Array of regular fee recipients
regularAmountsuint256[]Array of regular fee amounts
regularCountuint256Number of regular fees
splitRecipientsaddress[]Array of split fee recipients
splitAmountsuint256[]Array of split fee amounts

Return Values

NameTypeDescription
[0]address[]Merged array of all recipients, merged array of adjusted amounts, and total fee amount
[1]uint256[]
[2]uint256

_calculateFees

solidity
function _calculateFees(uint256 _tokenId, uint256 _quantity, string[] _prefixes) internal view returns (uint256 totalFee, address[] feeRecipients, uint256[] feeAmounts)

Calculates the fees for a given quantity of tokens

Parameters

NameTypeDescription
_tokenIduint256
_quantityuint256The number of tokens to calculate fees for
_prefixesstring[]The prefixes to match against fee keys

Return Values

NameTypeDescription
totalFeeuint256The total fee calculated
feeRecipientsaddress[]The addresses of the fee recipients
feeAmountsuint256[]The amounts to be paid to each recipient

_countFeesAndCalculatePrice

solidity
function _countFeesAndCalculatePrice(uint256 _tokenId, string[] feeKeys, struct PropsFeesStorage.Fee[] fees, string[] _prefixes) internal pure returns (uint256 feeCount, uint256 pricePerToken)

Counts the number of fees and calculates the price per token

Parameters

NameTypeDescription
_tokenIduint256
feeKeysstring[]The keys of the fees
feesstruct PropsFeesStorage.Fee[]The fee structures
_prefixesstring[]The prefixes to match against fee keys

Return Values

NameTypeDescription
feeCountuint256The total number of fees
pricePerTokenuint256The calculated price per token

_calculateFeeForKey

solidity
function _calculateFeeForKey(struct PropsFeesStorage.Fee fee, enum PropsFeesStorage.FeeType feeType, enum PropsFeesStorage.FeeApplication feeApplication, uint256 _quantity, uint256 pricePerToken, uint256 subtotal) internal pure returns (uint256[] amounts, address[] addrs)

Calculates the fee for a specific fee key

Parameters

NameTypeDescription
feestruct PropsFeesStorage.FeeThe fee structure
feeTypeenum PropsFeesStorage.FeeType
feeApplicationenum PropsFeesStorage.FeeApplication
_quantityuint256The number of tokens
pricePerTokenuint256The price per token
subtotaluint256The subtotal for the transaction

Return Values

NameTypeDescription
amountsuint256[]The calculated fee amounts
addrsaddress[]The addresses of the fee recipients

_processFeeType

solidity
function _processFeeType(struct IPropsFees.ProcessFeeTypeInput input, string[] _prefixes) internal pure returns (struct IPropsFees.ProcessFeeTypeInput)

Processes fees of a specific type and application

Iterates through all fees, applying those matching the specified type and application

Parameters

NameTypeDescription
inputstruct IPropsFees.ProcessFeeTypeInputStruct containing all necessary input data for fee processing
_prefixesstring[]Array of prefixes to filter applicable fees

Return Values

NameTypeDescription
[0]struct IPropsFees.ProcessFeeTypeInputUpdated input struct with processed fees

_applyFeeToRecipientsAndAmounts

solidity
function _applyFeeToRecipientsAndAmounts(uint256[] amounts, address[] addrs, uint256[] tempAmounts, address[] tempRecipients, uint256 uniqueRecipientCount) internal pure returns (uint256[], address[], uint256)

Applies calculated fees to the running totals

Updates or adds new entries to the temporary fee arrays

Parameters

NameTypeDescription
amountsuint256[]Array of fee amounts to apply
addrsaddress[]Array of recipient addresses corresponding to the amounts
tempAmountsuint256[]Running total of fee amounts
tempRecipientsaddress[]Running list of unique recipients
uniqueRecipientCountuint256Current count of unique recipients

Return Values

NameTypeDescription
[0]uint256[]Updated tempAmounts, tempRecipients, and new uniqueRecipientCount
[1]address[]
[2]uint256

_hasMatchingPrefix

solidity
function _hasMatchingPrefix(string _str, string[] _prefixes) internal pure returns (bool)

Checks if a string has a matching prefix from a list of prefixes

Parameters

NameTypeDescription
_strstringThe string to check
_prefixesstring[]The list of prefixes to match against

Return Values

NameTypeDescription
[0]boolbool True if a matching prefix is found, false otherwise

_startsWith

solidity
function _startsWith(string _str, string _prefix) internal pure returns (bool)

Checks if a string starts with a given prefix

Parameters

NameTypeDescription
_strstringThe string to check
_prefixstringThe prefix to match

Return Values

NameTypeDescription
[0]boolbool True if the string starts with the prefix, false otherwise

_sumFeeAmounts

solidity
function _sumFeeAmounts(uint256[] feeAmounts) internal pure returns (uint256)

Sums up an array of fee amounts

Parameters

NameTypeDescription
feeAmountsuint256[]The array of fee amounts to sum

Return Values

NameTypeDescription
[0]uint256uint256 The total sum of the fee amounts

_convertCSVToUintArray

solidity
function _convertCSVToUintArray(string _csv) internal pure returns (uint256[])

Converts a comma-separated string of numbers to an array of uint256

Splits the string and converts each element to a uint256

Parameters

NameTypeDescription
_csvstringThe comma-separated string of numbers

Return Values

NameTypeDescription
[0]uint256[]uint256[] The array of uint256 values

_stringToUint

solidity
function _stringToUint(string s) internal pure returns (uint256)

Converts a string to a uint256

Parses the string as a decimal number

Parameters

NameTypeDescription
sstringThe string to convert

Return Values

NameTypeDescription
[0]uint256uint256 The converted uint256 value

_split

solidity
function _split(string _base, string _value) internal pure returns (string[])

Splits a string into an array of substrings based on a delimiter

Splits the base string into an array of substrings using the specified delimiter

Parameters

NameTypeDescription
_basestringThe base string to split
_valuestringThe delimiter to use for splitting

Return Values

NameTypeDescription
[0]string[]string[] The array of substrings

_indexOf

solidity
function _indexOf(string _base, string _value, uint256 _offset) internal pure returns (int256)

Finds the index of a substring within a base string

Searches for the first occurrence of the value substring within the base string

Parameters

NameTypeDescription
_basestringThe base string to search within
_valuestringThe substring to search for
_offsetuint256The starting index for the search

Return Values

NameTypeDescription
[0]int256int256 The index of the first occurrence, or -1 if not found

_distributeFees

solidity
function _distributeFees(address[] recipients, uint256[] amounts) internal

Distributes fees to recipients

Transfers the specified amounts to the corresponding recipients

Parameters

NameTypeDescription
recipientsaddress[]The array of recipient addresses
amountsuint256[]The array of fee amounts to transfer