diff --git a/CRIP/CRIP-MonkeyType-CompletedTest.md b/CRIP/CRIP-MonkeyType-CompletedTest.md new file mode 100644 index 0000000..c19a75b --- /dev/null +++ b/CRIP/CRIP-MonkeyType-CompletedTest.md @@ -0,0 +1,62 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to retrive total tests completed | Ashwin KV | | Draft | Integration | CRIP | 2024-07-08 | | + +## Title + +Monkeytype Integration tests Completed + +## Introduction + +This proposal outlines the integration of monkeytype as a data provider for the Catoff-Reclaim integration project. The integration aims to retrieve and process user Total completed tests data from monkeytype, like username and Total Completed Tests to be used within the Catoff platform. This will enable users to validate their Test Completions and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing test completion to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Enable users to join typing challenges that require a minimum number of completed tests on Monkeytype. +3. **Leaderboard Ranking**: Create leaderboards based on the total number of typing tests completed by users on Monkeytype. + +## Data Provider + +- **Name**: Monkeytype tests completed +- **Hash Value**: 0x450f9b9c600724a6bf54fce10171a5a7bca1273617c799c308337646b70e9e89 + +## Code Snippet + +Below is a code snippet that demonstrates the key parts of the GitHub integration. The full implementation should follow the service file template. + +**`services/monkeyTypeService-completion.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeCompletionData = async (proof, providerName) => { + // Extract relevant data from the proof + const completedTests = JSON.parse(proof[0].claimData.context) + .extractedParameters.completedTests //Total completed test of the user + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username //user name of the proof + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + completedTests, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} + + +``` diff --git a/src/services/monkeyTypeService-completion.js b/src/services/monkeyTypeService-completion.js new file mode 100644 index 0000000..7892e8d --- /dev/null +++ b/src/services/monkeyTypeService-completion.js @@ -0,0 +1,25 @@ +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeCompletionData = async (proof, providerName) => { + // Extract relevant data from the proof + const completedTests = JSON.parse(proof[0].claimData.context) + .extractedParameters.completedTests //Total completed test of the user + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username //user name of the proof + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + completedTests, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index b33006f..c3018e9 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -3,6 +3,7 @@ const { Reclaim } = require('@reclaimprotocol/js-sdk') const { RECLAIM_PROVIDER_ID, RECLAIM_APP_ID } = require('../utils/constants') const { processTwitterData } = require('./twitterService') const { processGitHubData } = require('./githubService') +const { processMonkeyTypeCompletionData } = require('./monkeyTypeService-completion') exports.signWithProviderID = async (userId, providerId) => { const providerName = RECLAIM_PROVIDER_ID[providerId] @@ -49,6 +50,12 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'GITHUB_ACCOUNT_VERIFICATION': processedData = await processGitHubData(proof, providerName) break + case 'MONKEY_TYPE_COMPLETION': + processedData = await processMonkeyTypeCompletionData( + proof, + providerName + ) + break default: throw new Error(`No handler for provider: ${providerName}`) } diff --git a/src/utils/constants.js b/src/utils/constants.js index 1c58669..1296804 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -1,9 +1,11 @@ exports.RECLAIM_PROVIDER_ID = { twitter: 'TWITTER_ANALYTICS_VIEWS', github: 'GITHUB_ACCOUNT_VERIFICATION', + '1c505d43-af61-4133-bc40-b3e9da329c2d': 'MONKEY_TYPE_COMPLETION', } exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', + MONKEY_TYPE_COMPLETION: '0x834665927E43F05969ee3B65174cDE071c29Fb44', //your monkeyTYPE app ID }