From 5dcec096dfbfee962e711051b493d57057609968 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Fri, 5 Jul 2024 21:23:55 +0530 Subject: [PATCH 1/8] updated the Proposal --- .env.example | 1 + CRIP/CRIP-2.md | 81 +++++++++++++++++++++++++++++++ package.json | 4 +- src/services/monkeyTypeService.js | 43 ++++++++++++++++ src/services/reclaimService.js | 6 ++- src/utils/constants.js | 2 + 6 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 CRIP/CRIP-2.md create mode 100644 src/services/monkeyTypeService.js diff --git a/.env.example b/.env.example index 2494daa..31e047c 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ TWITTER_ANALYTICS_VIEWS_SECRET=your-twitter-secret GITHUB_ACCOUNT_VERIFICATION_SECRET=your-github-secret RECLAIM_GITHUB_TOKEN=your-github-token +MONKEY_TYPE_SPEED_SECRET=0xc0459182660cc9427c584de29b50162a337f6d1d053b1ee355c5ba123061ae6d \ No newline at end of file diff --git a/CRIP/CRIP-2.md b/CRIP/CRIP-2.md new file mode 100644 index 0000000..08a21bb --- /dev/null +++ b/CRIP/CRIP-2.md @@ -0,0 +1,81 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 15 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-05 | | + +## Title + +Monkeytype Integration + +## 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 top typing speed data of 15 seconds from monkeytype, such as WPM,Accuracy and Time of achivement, to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 15 sec data +- **Hash Value**: 0x604f5228860b144b6e63ff47e541c1419b38d119cc3828a917dd9966dc7bb3a1 + +## 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/githubService.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // TODO: Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm15s + const acc= JSON.parse(proof[0].claimData.context).extractedParameters.acc + const completionTime = JSON.parse(proof[0].claimData.context).extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters.username + +const date = new Date(Number(completionTime)) +console.log(date); +// Options for formatting timestamp +const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', +} + +// Format the date and time +const formattedDate = date.toLocaleString('en-US', options) + const ProcessedData = { + wpm, + acc, + formattedDate, + username, + } + console.log("formated data ",ProcessedData); + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // TODO: Create a ReclaimServiceResponse object with the processed data + // Adjust the parameters and processing logic based on the actual data structure + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} + +``` diff --git a/package.json b/package.json index ac9ddd6..bade4b3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CRIP is an open source project to receieve community proposals for catoff challenges which are based on reclaim integration", "main": "index.js", "scripts": { - "start": "node index.js", + "start": "node --env-file=.env index.js ", "lint": "eslint '**/*.js'", "lint:fix": "eslint '**/*.js' --fix", "format": "prettier --write '**/*.js'" @@ -32,4 +32,4 @@ "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5" } -} +} \ No newline at end of file diff --git a/src/services/monkeyTypeService.js b/src/services/monkeyTypeService.js new file mode 100644 index 0000000..27083b7 --- /dev/null +++ b/src/services/monkeyTypeService.js @@ -0,0 +1,43 @@ +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // TODO: Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm15s + const acc= JSON.parse(proof[0].claimData.context).extractedParameters.acc + const completionTime = JSON.parse(proof[0].claimData.context).extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters.username + +const date = new Date(Number(completionTime)) +console.log(date); +// Options for formatting timestamp +const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', +} + +// Format the date and time +const formattedDate = date.toLocaleString('en-US', options) + const ProcessedData = { + wpm, + acc, + formattedDate, + username, + } + console.log("formated data ",ProcessedData); + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // TODO: Create a ReclaimServiceResponse object with the processed data + // Adjust the parameters and processing logic based on the actual data structure + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index b33006f..02372ac 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -3,12 +3,12 @@ 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 { processMonkeyTypeData } = require('./monkeyTypeService') exports.signWithProviderID = async (userId, providerId) => { const providerName = RECLAIM_PROVIDER_ID[providerId] const reclaimAppID = RECLAIM_APP_ID[providerName] const reclaimAppSecret = process.env[`${providerName}_SECRET`] - console.log( `Sending signature request to Reclaim for userId: ${userId} with providerName: ${providerName}` ) @@ -34,6 +34,7 @@ exports.signWithProviderID = async (userId, providerId) => { } const handleReclaimSession = async (userId, reclaimClient, providerName) => { + await reclaimClient.startSession({ onSuccessCallback: async proof => { console.log( @@ -49,6 +50,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'GITHUB_ACCOUNT_VERIFICATION': processedData = await processGitHubData(proof, providerName) break + case 'MONKEY_TYPE_SPEED_15S': + processedData = await processMonkeyTypeData(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..bc2ed94 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', + '835bdf89-86ad-4272-8126-34200c32f1a8': 'MONKEY_TYPE_SPEED_15S', } exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', + MONKEY_TYPE_SPEED_15S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', } From f9e38e61419022c88231fade0bfd1de1fa9fd430 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Fri, 5 Jul 2024 21:32:46 +0530 Subject: [PATCH 2/8] feat:monkeytype integration --- src/services/monkeyTypeService.js | 40 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/services/monkeyTypeService.js b/src/services/monkeyTypeService.js index 27083b7..ff197bc 100644 --- a/src/services/monkeyTypeService.js +++ b/src/services/monkeyTypeService.js @@ -3,32 +3,34 @@ const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') exports.processMonkeyTypeData = async (proof, providerName) => { // TODO: Extract relevant data from the proof const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm15s - const acc= JSON.parse(proof[0].claimData.context).extractedParameters.acc - const completionTime = JSON.parse(proof[0].claimData.context).extractedParameters.completionTime - const username = JSON.parse(proof[0].claimData.context).extractedParameters.username - -const date = new Date(Number(completionTime)) -console.log(date); -// Options for formatting timestamp -const options = { - year: 'numeric', - month: 'long', - day: 'numeric', - hour: '2-digit', - minute: '2-digit', - second: '2-digit', - timeZoneName: 'short', -} + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const completionTime = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(completionTime)) + console.log(date) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } -// Format the date and time -const formattedDate = date.toLocaleString('en-US', options) + // Format the date and time + const formattedDate = date.toLocaleString('en-US', options) const ProcessedData = { wpm, acc, formattedDate, username, } - console.log("formated data ",ProcessedData); + console.log('formated data ', ProcessedData) const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) // TODO: Create a ReclaimServiceResponse object with the processed data From c358d369fdb53c2abdf70209b743bdf6b8e261ff Mon Sep 17 00:00:00 2001 From: Ashwin Date: Fri, 5 Jul 2024 21:44:44 +0530 Subject: [PATCH 3/8] fix:Remove unwanted codes --- .env.example | 3 +-- CRIP/CRIP-2.md | 2 +- src/services/monkeyTypeService.js | 7 ++----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 31e047c..12622fe 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,3 @@ TWITTER_ANALYTICS_VIEWS_SECRET=your-twitter-secret GITHUB_ACCOUNT_VERIFICATION_SECRET=your-github-secret -RECLAIM_GITHUB_TOKEN=your-github-token -MONKEY_TYPE_SPEED_SECRET=0xc0459182660cc9427c584de29b50162a337f6d1d053b1ee355c5ba123061ae6d \ No newline at end of file +RECLAIM_GITHUB_TOKEN=your-github-token \ No newline at end of file diff --git a/CRIP/CRIP-2.md b/CRIP/CRIP-2.md index 08a21bb..06bff55 100644 --- a/CRIP/CRIP-2.md +++ b/CRIP/CRIP-2.md @@ -8,7 +8,7 @@ Monkeytype Integration ## 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 top typing speed data of 15 seconds from monkeytype, such as WPM,Accuracy and Time of achivement, to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. +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 top typing speed data of 15 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. ## External APIs Needed diff --git a/src/services/monkeyTypeService.js b/src/services/monkeyTypeService.js index ff197bc..3c2aba8 100644 --- a/src/services/monkeyTypeService.js +++ b/src/services/monkeyTypeService.js @@ -1,7 +1,7 @@ const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') exports.processMonkeyTypeData = async (proof, providerName) => { - // TODO: Extract relevant data from the proof + // Extract relevant data from the proof const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm15s const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc const completionTime = JSON.parse(proof[0].claimData.context) @@ -10,7 +10,6 @@ exports.processMonkeyTypeData = async (proof, providerName) => { .username const date = new Date(Number(completionTime)) - console.log(date) // Options for formatting timestamp const options = { year: 'numeric', @@ -30,11 +29,9 @@ exports.processMonkeyTypeData = async (proof, providerName) => { formattedDate, username, } - console.log('formated data ', ProcessedData) const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) - // TODO: Create a ReclaimServiceResponse object with the processed data - // Adjust the parameters and processing logic based on the actual data structure + // Create a ReclaimServiceResponse object with the processed data return new ReclaimServiceResponse( providerName, lastUpdateTimeStamp, From 6ad6561c5c5c0026316090a0f9470b501bd58d80 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Sun, 7 Jul 2024 15:54:08 +0530 Subject: [PATCH 4/8] feat:MonkeyType 30s data integration integrated 30s for monkeytype updated the proposal --- CRIP/{CRIP-2.md => CRIP-MonkeyType_15s.md} | 56 ++++++++------- CRIP/CRIP-MonkeyType_30s.md | 83 ++++++++++++++++++++++ src/services/monkeyTypeService.js | 14 ++-- src/services/reclaimService.js | 3 + src/utils/constants.js | 2 + 5 files changed, 125 insertions(+), 33 deletions(-) rename CRIP/{CRIP-2.md => CRIP-MonkeyType_15s.md} (74%) create mode 100644 CRIP/CRIP-MonkeyType_30s.md diff --git a/CRIP/CRIP-2.md b/CRIP/CRIP-MonkeyType_15s.md similarity index 74% rename from CRIP/CRIP-2.md rename to CRIP/CRIP-MonkeyType_15s.md index 06bff55..97035da 100644 --- a/CRIP/CRIP-2.md +++ b/CRIP/CRIP-MonkeyType_15s.md @@ -4,7 +4,7 @@ ## Title -Monkeytype Integration +Monkeytype Integration 15s ## Introduction @@ -31,44 +31,45 @@ This proposal outlines the integration of monkeytype as a data provider for the Below is a code snippet that demonstrates the key parts of the GitHub integration. The full implementation should follow the service file template. -**`services/githubService.js`** +**`services/monkeyTypeService.js`** ```javascript const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') exports.processMonkeyTypeData = async (proof, providerName) => { - // TODO: Extract relevant data from the proof - const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm15s - const acc= JSON.parse(proof[0].claimData.context).extractedParameters.acc - const completionTime = JSON.parse(proof[0].claimData.context).extractedParameters.completionTime - const username = JSON.parse(proof[0].claimData.context).extractedParameters.username - -const date = new Date(Number(completionTime)) -console.log(date); -// Options for formatting timestamp -const options = { - year: 'numeric', - month: 'long', - day: 'numeric', - hour: '2-digit', - minute: '2-digit', - second: '2-digit', - timeZoneName: 'short', -} + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } -// Format the date and time -const formattedDate = date.toLocaleString('en-US', options) - const ProcessedData = { + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, wpm, acc, - formattedDate, + completionTime, username, } - console.log("formated data ",ProcessedData); const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) - // TODO: Create a ReclaimServiceResponse object with the processed data - // Adjust the parameters and processing logic based on the actual data structure + // Create a ReclaimServiceResponse object with the processed data return new ReclaimServiceResponse( providerName, lastUpdateTimeStamp, @@ -78,4 +79,5 @@ const formattedDate = date.toLocaleString('en-US', options) ) } + ``` diff --git a/CRIP/CRIP-MonkeyType_30s.md b/CRIP/CRIP-MonkeyType_30s.md new file mode 100644 index 0000000..40e6bfb --- /dev/null +++ b/CRIP/CRIP-MonkeyType_30s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 30 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Monkeytype Integration 30s + +## 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 top typing speed data of 30 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 30 sec data +- **Hash Value**: 0x604f5228860b144b6e63ff47e541c1419b38d119cc3828a917dd9966dc7bb3a1 + +## 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.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + 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.js b/src/services/monkeyTypeService.js index 3c2aba8..c54666b 100644 --- a/src/services/monkeyTypeService.js +++ b/src/services/monkeyTypeService.js @@ -2,14 +2,14 @@ const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') exports.processMonkeyTypeData = async (proof, providerName) => { // Extract relevant data from the proof - const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm15s + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc - const completionTime = JSON.parse(proof[0].claimData.context) + const timeStamp = JSON.parse(proof[0].claimData.context) .extractedParameters.completionTime const username = JSON.parse(proof[0].claimData.context).extractedParameters .username - const date = new Date(Number(completionTime)) + const date = new Date(Number(timeStamp)) // Options for formatting timestamp const options = { year: 'numeric', @@ -22,11 +22,13 @@ exports.processMonkeyTypeData = async (proof, providerName) => { } // Format the date and time - const formattedDate = date.toLocaleString('en-US', options) - const ProcessedData = { + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, wpm, acc, - formattedDate, + completionTime, username, } const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index 02372ac..7703e09 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -53,6 +53,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'MONKEY_TYPE_SPEED_15S': processedData = await processMonkeyTypeData(proof, providerName) break + case 'MONKEY_TYPE_SPEED_30S': + processedData = await processMonkeyTypeData(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 bc2ed94..c32d5fc 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -2,10 +2,12 @@ exports.RECLAIM_PROVIDER_ID = { twitter: 'TWITTER_ANALYTICS_VIEWS', github: 'GITHUB_ACCOUNT_VERIFICATION', '835bdf89-86ad-4272-8126-34200c32f1a8': 'MONKEY_TYPE_SPEED_15S', + 'c87918fb-6b25-4ac3-9843-7c595b9a2baf': 'MONKEY_TYPE_SPEED_30S', } exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', MONKEY_TYPE_SPEED_15S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + MONKEY_TYPE_SPEED_30S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', } From e44e49b1a3d680da86530cd40bf204dd595f45a3 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Sun, 7 Jul 2024 21:58:52 +0530 Subject: [PATCH 5/8] feat:MonkeyType 60s data provider integration --- src/services/reclaimService.js | 3 +++ src/utils/constants.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index 7703e09..dd3f9f0 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -56,6 +56,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'MONKEY_TYPE_SPEED_30S': processedData = await processMonkeyTypeData(proof, providerName) break + case 'MONKEY_TYPE_SPEED_60S': + processedData = await processMonkeyTypeData(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 c32d5fc..c86eace 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -3,6 +3,8 @@ exports.RECLAIM_PROVIDER_ID = { github: 'GITHUB_ACCOUNT_VERIFICATION', '835bdf89-86ad-4272-8126-34200c32f1a8': 'MONKEY_TYPE_SPEED_15S', 'c87918fb-6b25-4ac3-9843-7c595b9a2baf': 'MONKEY_TYPE_SPEED_30S', + 'c9e3c386-a110-4c9c-b124-cf2f9def116f': 'MONKEY_TYPE_SPEED_60S', + // 'a350bcef-58f4-49ca-aecd-d15bd1d8e312': 'MONKEY_TYPE_SPEED_120S', } exports.RECLAIM_APP_ID = { @@ -10,4 +12,6 @@ exports.RECLAIM_APP_ID = { GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', MONKEY_TYPE_SPEED_15S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', MONKEY_TYPE_SPEED_30S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + MONKEY_TYPE_SPEED_60S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + // MONKEY_TYPE_SPEED_120S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', } From 4db9fc0d9baf69bfe8b889ed66109376acb4343c Mon Sep 17 00:00:00 2001 From: Ashwin Date: Sun, 7 Jul 2024 22:03:46 +0530 Subject: [PATCH 6/8] update new CRIP --- CRIP/CRIP-MonkeyType_60s.md | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 CRIP/CRIP-MonkeyType_60s.md diff --git a/CRIP/CRIP-MonkeyType_60s.md b/CRIP/CRIP-MonkeyType_60s.md new file mode 100644 index 0000000..b897adf --- /dev/null +++ b/CRIP/CRIP-MonkeyType_60s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 60 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Monkeytype Integration 60s + +## 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 top typing speed data of 60 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 60 sec data +- **Hash Value**: 0x604f5228860b144b6e63ff47e541c1419b38d119cc3828a917dd9966dc7bb3a1 + +## 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.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + 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] + ) +} + + +``` From c7206f8a0d817db823eb90b03ee018fb24627d63 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Sun, 7 Jul 2024 22:12:03 +0530 Subject: [PATCH 7/8] feat:MonkeyType 120s data provider integration integrated 120 sec test data updated CRIP --- CRIP/CRIP-MonkeyType_120s.md | 83 ++++++++++++++++++++++++++++++++++ CRIP/CRIP-MonkeyType_30s.md | 2 +- CRIP/CRIP-MonkeyType_60s.md | 2 +- src/services/reclaimService.js | 3 ++ src/utils/constants.js | 4 +- 5 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 CRIP/CRIP-MonkeyType_120s.md diff --git a/CRIP/CRIP-MonkeyType_120s.md b/CRIP/CRIP-MonkeyType_120s.md new file mode 100644 index 0000000..3e1ed35 --- /dev/null +++ b/CRIP/CRIP-MonkeyType_120s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 120 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Monkeytype Integration 60s + +## 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 top typing speed data of 120 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 120 sec data +- **Hash Value**: 0x059fe3942bf736c935700846a1b71ca91b93bdaaa65b37ea0d06834c90ee16b3 + +## 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.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + 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/CRIP/CRIP-MonkeyType_30s.md b/CRIP/CRIP-MonkeyType_30s.md index 40e6bfb..536f501 100644 --- a/CRIP/CRIP-MonkeyType_30s.md +++ b/CRIP/CRIP-MonkeyType_30s.md @@ -25,7 +25,7 @@ This proposal outlines the integration of monkeytype as a data provider for the ## Data Provider - **Name**: Monkeytype 30 sec data -- **Hash Value**: 0x604f5228860b144b6e63ff47e541c1419b38d119cc3828a917dd9966dc7bb3a1 +- **Hash Value**: 0x12bfd8a194c63765e7dc5aa47d74114f812f26652bf8cae1b0677d2ad471815e ## Code Snippet diff --git a/CRIP/CRIP-MonkeyType_60s.md b/CRIP/CRIP-MonkeyType_60s.md index b897adf..3196c6c 100644 --- a/CRIP/CRIP-MonkeyType_60s.md +++ b/CRIP/CRIP-MonkeyType_60s.md @@ -25,7 +25,7 @@ This proposal outlines the integration of monkeytype as a data provider for the ## Data Provider - **Name**: Monkeytype 60 sec data -- **Hash Value**: 0x604f5228860b144b6e63ff47e541c1419b38d119cc3828a917dd9966dc7bb3a1 +- **Hash Value**: 0x3904d64f3f1ce330bcd893fbaf9cf6ab94e58e3b22a200099f73a156bad646b7 ## Code Snippet diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index dd3f9f0..c2c061a 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -59,6 +59,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'MONKEY_TYPE_SPEED_60S': processedData = await processMonkeyTypeData(proof, providerName) break + case 'MONKEY_TYPE_SPEED_120S': + processedData = await processMonkeyTypeData(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 c86eace..6a51368 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -4,7 +4,7 @@ exports.RECLAIM_PROVIDER_ID = { '835bdf89-86ad-4272-8126-34200c32f1a8': 'MONKEY_TYPE_SPEED_15S', 'c87918fb-6b25-4ac3-9843-7c595b9a2baf': 'MONKEY_TYPE_SPEED_30S', 'c9e3c386-a110-4c9c-b124-cf2f9def116f': 'MONKEY_TYPE_SPEED_60S', - // 'a350bcef-58f4-49ca-aecd-d15bd1d8e312': 'MONKEY_TYPE_SPEED_120S', + 'a350bcef-58f4-49ca-aecd-d15bd1d8e312': 'MONKEY_TYPE_SPEED_120S', } exports.RECLAIM_APP_ID = { @@ -13,5 +13,5 @@ exports.RECLAIM_APP_ID = { MONKEY_TYPE_SPEED_15S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', MONKEY_TYPE_SPEED_30S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', MONKEY_TYPE_SPEED_60S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', - // MONKEY_TYPE_SPEED_120S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + MONKEY_TYPE_SPEED_120S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', } From f0cd5a0625f644aa4e748b41f9851f5caac95915 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Mon, 8 Jul 2024 12:08:17 +0530 Subject: [PATCH 8/8] refactor:Added more comments to the code --- src/services/monkeyTypeService.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/monkeyTypeService.js b/src/services/monkeyTypeService.js index c54666b..c99b3e1 100644 --- a/src/services/monkeyTypeService.js +++ b/src/services/monkeyTypeService.js @@ -2,12 +2,12 @@ const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') exports.processMonkeyTypeData = async (proof, providerName) => { // Extract relevant data from the proof - const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm - const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm // word per minutes speed of the test + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc // accuracy for the test const timeStamp = JSON.parse(proof[0].claimData.context) - .extractedParameters.completionTime + .extractedParameters.completionTime // completion time of the test const username = JSON.parse(proof[0].claimData.context).extractedParameters - .username + .username //username of the proof const date = new Date(Number(timeStamp)) // Options for formatting timestamp