Application Manager
Purpose
The Application Manager acts as a central hub for managing the application it is associated with.
It provides the ability to manage metadata for accounts associated with the application including:
- Roles
- Tags
- Risk Scores
- Access Levels
The Application Manager also provides the ability to check application level rules via its associated Application Handler.
Metadata
Roles
The Application Manager can be utilized for both updating and checking an account’s role in relation to the application. These capabilites are provided for the following roles:
- Super Admin
- App Admin
- Risk Admin
- Access Level Admin
- Rule Admin
- Treasury Account
The following functions are provided for each admin type (we’ll use the App Admin variant as an example here):
Checks whether or not the provided address is an App Admin for the application.
Adds the provided address as a new App Admin for the application. This function can only be called by the existing Super Admin.
A utility method to add multiple App Admins at the same time. Like the singular version this can only be called by the existing Super Admin.
Removes the senders role as an App Admin if the role argument is APP_ADMIN_ROLE
Super Admin Special Case
The functions are slightly different for a Super Admin. Because there can only be one super admin at a time we use a two-step process to set a new one. The following functions are used in place of the add function the other admin types employ:
The first part of the two-step process, to propose the new Super Admin address. This can only be called by the existing Super admin.
The second part of the two-step process, confirming renounces the role for the existing Super Admin and promotes the Proposed Super Admin to the role. This can only be called by the Proposed Super Admin.
Access Levels, Risk Scores and Tags
The AppManager contains the functionality used to manage the Access Levels, Risk Scores and Tags associated with accounts, with respect to the application it manages.
In order to manage these, the following functions have been provided for each (we’ll use the Risk Scores variant as an example here):
Applies the provided risk score to the provided address (of note that the Application Manager deploys the storage contracts for the Risk Scores, Access Levels and Tags associated with the application on its creation, these can be updated to point to external providers which we’ll cover in the next section). This can only be called by a Risk Admin.
Utility function to add a single Risk Score to multiple accounts. Like the singular function this can only be called by a Risk Admin.
Another Utility function that allows you to provide an array of scores to apply to an array of accounts (The arrays must be the same size). This function also can only be called by a Risk Admin.
Retrieves the Risk Score associated with the provided address.
Removes the Risk Score from the provided address. This function can only be called by a Risk Admin.
Changing Data Providers
In addition to using the functions outlined above to manually manage the qualifiers, each can be switched to an external provider. Of note the external provider must conform to the relevant interface definition: IRiskScores, IAccessLevels or ITags.
Changing data providers is a 2 step process. Since the same function API is used for each of the providers we’ll be using the Access Level Provider as an example:
The first step in the process is to propose the new provider. The provided address must conform to the IAccessLevel interface. Only App Admins can call the propose new provider functions.
After the new address is proposed it is confirmed by invoking a confirmation function in the new provider that in turn invokes the following function in the AppManager contract:
This function only succeeds if the msg sender is the proposed provider address. If it is, the provider is updated to be the proposed address and the process concludes.
Application Level Rules
The Application Manager provides a function that can be called from registered Token Handlers to check the Application Level Rules for a transaction.
The function actually calls to the registered Application Handler to check the rules. This can only be called by registered Token Handlers.
Associated Contracts
The Application Manager also contains the functionality to register, deregister and check various related contracts, including:
- The Application Handler
- Protocol Compliant Tokens
We’ll use the protocol token functions to demonstrate the API:
Registers the token address with the Application Manager. It can only be called by the Application Admin.
Update a registered token to the specified token type. ERC721 tokens that do not support ERC165 will be initially registered as an ERC20. This function will register the token as ERC721.
Token Types: ERC20 = 0, ERC721 = 1.
This function can only be called by the App Admin.
Deregisters the token address with the Application Manager. It can only be called by the App Admin.
Return the stored tag of the registered token.
Upgrading The Contract
When upgrading to a new Application Manager contract a two step process is provided to migrate the data contracts.
First the following function must be called on the original Application Manager:
The provided address should be the address of the new Application Manager contract. This function can only be called by the Application Admin.
In order to finalize the process the following function must be called in the new Application Manager:
This function can only be called by the App Admin.