Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions CRIP/CRIP-MonkeyType-CompletedTest.md
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> | | 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]
)
}


```
25 changes: 25 additions & 0 deletions src/services/monkeyTypeService-completion.js
Original file line number Diff line number Diff line change
@@ -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]
)
}
7 changes: 7 additions & 0 deletions src/services/reclaimService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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}`)
}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -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
}