Purpose
There are several updates that need to take place in order to add a new token level rule. In this document we’ll be covering the steps required to update the assciated token asset diamond including: updating the code for the appropriate facets and upgrading the effected handler diamonds. This document will walk through the process step by step. (We will be using an existing rule, Token Minimum Transaction Size, as our example)Creating The Rule
Updating Diamond Storage
The first step is to update the diamond storage to account for the new rule. We’ll need to update StorageLib. For our example we would first add the following constant to the top of the contract to define the storage position for our Token Minimum Transaction Size rule:Facet Updates
The next step is to create the contract responsible for managing the rule. Insrc/client/token/handler/ruleContracts
you will see a contract for each existing rule that implements the following four functions: setRuleName, activateRuleName, getRuleNameId, isRuleNameActive (RuleName being replaced by the name of the specific rule instace the file is handling). For our example we’ll be looking at the HandlerTokenMinTxSize.sol
contract which implements the following four functions: setTokenMinTxSizeId
, activateMinTransactionSizeRule
, getTokenMinTxSizeId
, and isTokenMinTxSizeActive
.
The following function uses the ruleId we received when we created the instance of the rule to set the instance in the diamond and activate it for the list of passed in actions:
checkNonTaggedRules
function: