Appearance
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) internalInternal function to upsert (insert or update) a fee
This function filters out zero fee amounts and their corresponding recipients
Parameters
| Name | Type | Description |
|---|---|---|
| _feeType | string | The type of fee to upsert |
| _feeAmounts | uint256[] | The fee amounts to set |
| _feeRecipients | address[] | The fee recipients to set |
| _feeTypeEnum | enum PropsFeesStorage.FeeType | The fee type to set (from PropsFeesStorage.FeeType enum) |
| _feeApplication | enum PropsFeesStorage.FeeApplication | The fee application to set (from PropsFeesStorage.FeeApplication enum) |
| _tokenId | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| _feeType | string | The type of fee to retrieve |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | struct PropsFeesStorage.Fee | PropsFeesStorage.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
| Name | Type | Description |
|---|---|---|
| [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) internalInternal function to remove a fee
Removes the fee from the feeCatalog and updates the feeKeys array
Parameters
| Name | Type | Description |
|---|---|---|
| _feeType | string | The 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
| Name | Type | Description |
|---|---|---|
| recipients1 | address[] | First array of recipient addresses |
| amounts1 | uint256[] | First array of fee amounts |
| recipients2 | address[] | Second array of recipient addresses |
| amounts2 | uint256[] | Second array of fee amounts |
Return Values
| Name | Type | Description |
|---|---|---|
| mergedRecipients | address[] | Combined array of unique recipient addresses |
| mergedAmounts | uint256[] | 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
| Name | Type | Description |
|---|---|---|
| recipients | address[] | Array of recipient addresses |
| amounts | uint256[] | Array of fee amounts |
| count | uint256 | Current count of unique recipients |
| newRecipient | address | Address of the recipient to add or update |
| newAmount | uint256 | Amount to add for the recipient |
Return Values
| Name | Type | Description |
|---|---|---|
| [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
| Name | Type | Description |
|---|---|---|
| regularRecipients | address[] | Array of regular fee recipients |
| regularAmounts | uint256[] | Array of regular fee amounts |
| regularCount | uint256 | Number of regular fees |
| splitRecipients | address[] | Array of split fee recipients |
| splitAmounts | uint256[] | Array of split fee amounts |
Return Values
| Name | Type | Description |
|---|---|---|
| [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
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | |
| _quantity | uint256 | The number of tokens to calculate fees for |
| _prefixes | string[] | The prefixes to match against fee keys |
Return Values
| Name | Type | Description |
|---|---|---|
| totalFee | uint256 | The total fee calculated |
| feeRecipients | address[] | The addresses of the fee recipients |
| feeAmounts | uint256[] | 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
| Name | Type | Description |
|---|---|---|
| _tokenId | uint256 | |
| feeKeys | string[] | The keys of the fees |
| fees | struct PropsFeesStorage.Fee[] | The fee structures |
| _prefixes | string[] | The prefixes to match against fee keys |
Return Values
| Name | Type | Description |
|---|---|---|
| feeCount | uint256 | The total number of fees |
| pricePerToken | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| fee | struct PropsFeesStorage.Fee | The fee structure |
| feeType | enum PropsFeesStorage.FeeType | |
| feeApplication | enum PropsFeesStorage.FeeApplication | |
| _quantity | uint256 | The number of tokens |
| pricePerToken | uint256 | The price per token |
| subtotal | uint256 | The subtotal for the transaction |
Return Values
| Name | Type | Description |
|---|---|---|
| amounts | uint256[] | The calculated fee amounts |
| addrs | address[] | 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
| Name | Type | Description |
|---|---|---|
| input | struct IPropsFees.ProcessFeeTypeInput | Struct containing all necessary input data for fee processing |
| _prefixes | string[] | Array of prefixes to filter applicable fees |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | struct IPropsFees.ProcessFeeTypeInput | Updated 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
| Name | Type | Description |
|---|---|---|
| amounts | uint256[] | Array of fee amounts to apply |
| addrs | address[] | Array of recipient addresses corresponding to the amounts |
| tempAmounts | uint256[] | Running total of fee amounts |
| tempRecipients | address[] | Running list of unique recipients |
| uniqueRecipientCount | uint256 | Current count of unique recipients |
Return Values
| Name | Type | Description |
|---|---|---|
| [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
| Name | Type | Description |
|---|---|---|
| _str | string | The string to check |
| _prefixes | string[] | The list of prefixes to match against |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool 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
| Name | Type | Description |
|---|---|---|
| _str | string | The string to check |
| _prefix | string | The prefix to match |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool 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
| Name | Type | Description |
|---|---|---|
| feeAmounts | uint256[] | The array of fee amounts to sum |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | uint256 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
| Name | Type | Description |
|---|---|---|
| _csv | string | The comma-separated string of numbers |
Return Values
| Name | Type | Description |
|---|---|---|
| [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
| Name | Type | Description |
|---|---|---|
| s | string | The string to convert |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | uint256 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
| Name | Type | Description |
|---|---|---|
| _base | string | The base string to split |
| _value | string | The delimiter to use for splitting |
Return Values
| Name | Type | Description |
|---|---|---|
| [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
| Name | Type | Description |
|---|---|---|
| _base | string | The base string to search within |
| _value | string | The substring to search for |
| _offset | uint256 | The starting index for the search |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | int256 | int256 The index of the first occurrence, or -1 if not found |
_distributeFees
solidity
function _distributeFees(address[] recipients, uint256[] amounts) internalDistributes fees to recipients
Transfers the specified amounts to the corresponding recipients
Parameters
| Name | Type | Description |
|---|---|---|
| recipients | address[] | The array of recipient addresses |
| amounts | uint256[] | The array of fee amounts to transfer |