Git Source

Inherits: IInputErrors, IERC721Errors, IRuleProcessorErrors, ITagRuleErrors, IMaxTagLimitError

Author: @ShaneDuncan602 @oscarsernarosero @TJ-Everett

Implements Non-Fungible Token Checks on Tagged Accounts.

This contract implements rules to be checked by a Token Handler.

State Variables

BLANK_TAG

bytes32 constant BLANK_TAG = bytes32("");

Functions

checkMinMaxAccountBalanceERC721

If the rule applies to all users, it checks blank tag only. Otherwise loop through tags and check for specific application. This was done in a minimal way to allow for modifications later while not duplicating rule check logic.

Check the minMaxAccoutBalance rule. This rule ensures accounts cannot exceed or drop below specified account balances via account tags.

function checkMinMaxAccountBalanceERC721(
    uint32 ruleId,
    uint256 balanceFrom,
    uint256 balanceTo,
    bytes32[] memory toTags,
    bytes32[] memory fromTags
) public view;

Parameters

NameTypeDescription
ruleIduint32Uint value of the ruleId storage pointer for applicable rule.
balanceFromuint256Token balance of the sender address
balanceTouint256Token balance of the recipient address
toTagsbytes32[]tags applied via App Manager to recipient address
fromTagsbytes32[]tags applied via App Manager to sender address

minAccountBalanceERC721

most restrictive tag will be enforced.

Check if tagged account passes minAccountBalanceERC721 rule

function minAccountBalanceERC721(uint256 balanceFrom, bytes32[] memory fromTags, uint32 ruleId) internal view;

Parameters

NameTypeDescription
balanceFromuint256Number of tokens held by sender address
fromTagsbytes32[]Account tags applied to sender via App Manager
ruleIduint32Rule identifier for rule arguments

maxAccountBalanceERC721

Check if tagged account passes maxAccountBalanceERC721 rule

function maxAccountBalanceERC721(uint256 balanceTo, bytes32[] memory toTags, uint32 ruleId) internal view;

Parameters

NameTypeDescription
balanceTouint256Number of tokens held by recipient address
toTagsbytes32[]Account tags applied to recipient via App Manager
ruleIduint32Rule identifier for rule arguments

getAccountMinMaxTokenBalanceERC721

Function get the Account Min Max Token Balance ERC721 rule in the rule set that belongs to a specific tag.

function getAccountMinMaxTokenBalanceERC721(uint32 _index, bytes32 _nftTag)
    public
    view
    returns (TaggedRules.AccountMinMaxTokenBalance memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array
_nftTagbytes32nft tag for rule application

Returns

NameTypeDescription
<none>TaggedRules.AccountMinMaxTokenBalanceAccountMinMaxTokenBalance at index location in array

getTotalAccountMinMaxTokenBalancesERC721

Function gets total Account Min Max Token Balance ERC721 rules

function getTotalAccountMinMaxTokenBalancesERC721() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array

checkTokenMaxDailyTrades

If the rule applies to all users, it checks blank tag only. Otherwise loop through tags and check for specific application. This was done in a minimal way to allow for modifications later while not duplicating rule check logic.

This function receives a rule id, which it uses to get the Token Max Daily Trades rule to check if the transfer is valid.

function checkTokenMaxDailyTrades(
    uint32 ruleId,
    uint256 transfersWithinPeriod,
    bytes32[] memory nftTags,
    uint64 lastTransferTime
) public view returns (uint256);

Parameters

NameTypeDescription
ruleIduint32Rule identifier for rule arguments
transfersWithinPerioduint256Number of transfers within the time period
nftTagsbytes32[]NFT tags
lastTransferTimeuint64block.timestamp of most recent transaction from sender.

getTokenMaxDailyTrades

Function get the Token Max Daily Trades rule in the rule set that belongs to an NFT type

function getTokenMaxDailyTrades(uint32 _index, bytes32 _nftType)
    public
    view
    returns (TaggedRules.TokenMaxDailyTrades memory);

Parameters

NameTypeDescription
_indexuint32position of rule in array
_nftTypebytes32Type of NFT

Returns

NameTypeDescription
<none>TaggedRules.TokenMaxDailyTradesTokenMaxDailyTrades at index location in array

getTotalTokenMaxDailyTrades

Function gets total Token Max Daily Trades rules

function getTotalTokenMaxDailyTrades() public view returns (uint32);

Returns

NameTypeDescription
<none>uint32Total length of array