This PR, which addresses issue #740, integrates the TRM Labs wallet screening service into the Threshold dashboard application. This integration enables an automated process to evaluate the risks associated with the user's connected wallet addresses, using data from the TRM API. This is essential for complying with regulatory standards and ensuring the integrity of our platform. The primary elements and tasks of this integration include:
[X] - Data Fetching and Risk Assessment: The core of this integration lies in the implementation of a logic structure for data retrieval from the TRM API. A POST request is made, sending the user's wallet address and the connected chain ID to the TRM wallet screening endpoint. This fetches the risk score and any associated risk indicators, which are crucial for the subsequent validation process.
[X] - State Management in Redux Toolkit: To efficiently manage the application state reflecting the TRM API's response, a new state object within accountSlice has been introduced. This object, trm, includes isBlocked, isFetching, and hasFetched properties. These properties are pivotal in tracking the status of TRM data fetching and the subsequent actions based on the risk assessment.
[X] - Reducers for State Updates: To manipulate the trm state effectively, multiple reducers have been created. The setTRM reducer updates the isBlocked state based on the payload received, and the other properties, isFetching to false and hasFetched to true. The fetchingTrm reducer sets the isFetching property to true. In case of an error, the setTrmError reducer is utilized to update the isFetching state to false and populate the error property with the relevant error details.
[X] - Effect Handler for Wallet Connection: Upon the event of a wallet connection (walletConnected being called), an effect handler, getTRMInfo, is triggered. This function takes the wallet address and chain ID from the payload and sends it to the TRM API. Based on the API response, it checks for Severe risk indicators or entities and accordingly dispatches the isBlocked state property.
[X] - UI Integration and User Feedback: For user awareness, specific components in the UI have been updated. When a wallet is flagged as Severe risk (isBlocked set to true), a notification alert message is displayed to the user, indicating that their wallet has been flagged and contract interactions are disabled. Furthermore, on pages where contract interactions are possible, the interaction buttons are conditionally disabled based on the isBlocked state, ensuring compliance with the risk assessment.
[X] - Adapted the Contract Interaction Points: Each page that allows users to interact with contract functions or that enables users to proceed interacting with contract functions has been updated. The integration ensures that if a user's wallet is blocked, contract interaction functionalities like minting, un-minting, and staking are disabled, thereby upholding our commitment to operational integrity and regulatory compliance.
Notice
[x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
Ref: #740
Description
This PR, which addresses issue #740, integrates the TRM Labs wallet screening service into the Threshold dashboard application. This integration enables an automated process to evaluate the risks associated with the user's connected wallet addresses, using data from the TRM API. This is essential for complying with regulatory standards and ensuring the integrity of our platform. The primary elements and tasks of this integration include:
accountSlice
has been introduced. This object,trm
, includesisBlocked
,isFetching
, andhasFetched
properties. These properties are pivotal in tracking the status of TRM data fetching and the subsequent actions based on the risk assessment.trm
state effectively, multiple reducers have been created. ThesetTRM
reducer updates theisBlocked
state based on the payload received, and the other properties,isFetching
tofalse
andhasFetched
totrue
. ThefetchingTrm
reducer sets theisFetching
property totrue
. In case of an error, thesetTrmError
reducer is utilized to update theisFetching
state tofalse
and populate the error property with the relevant error details.walletConnected
being called), an effect handler,getTRMInfo
, is triggered. This function takes the wallet address and chain ID from the payload and sends it to the TRM API. Based on the API response, it checks forSevere
risk indicators or entities and accordingly dispatches theisBlocked
state property.Severe
risk (isBlocked
set totrue
), a notification alert message is displayed to the user, indicating that their wallet has been flagged and contract interactions are disabled. Furthermore, on pages where contract interactions are possible, the interaction buttons are conditionally disabled based on theisBlocked
state, ensuring compliance with the risk assessment.Notice
Pull Request Type
Issue (if applicable)
Closes issue #740
Testing
Preview uploaded to https://preview.dashboard.test.threshold.network/implement-trm-wallet-screening-integration/index.html.
Screenshots (if applicable)
Blocked wallet (Red alert message and disabled button):
Smaller screens: