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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TWITTER_ANALYTICS_VIEWS_SECRET=your-twitter-secret
GITHUB_ACCOUNT_VERIFICATION_SECRET=your-github-secret
RECLAIM_GITHUB_TOKEN=your-github-token
SPELLING_BEE_STATS_SECRET=your-spelling-bee-token
62 changes: 62 additions & 0 deletions CRIP/CRIP-Spelling-bee.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-Spelling-bee | Spelling Bee Integration | Integration with Spelling Bee to validate user stats | Raazi Muhammed <[email protected]> | | Draft | Integration | CRIP | 2024-07-07 | |

## Title

Spelling Bee Integration

## Introduction

This proposal outlines the integration of daily puzzles into the Catoff platform for the Catoff-Reclaim integration project. The integration aims to track and validate user progress on daily puzzles, including metrics such as total words found, pangrams discovered, longest word, and the center letter used. This data will be utilized to enhance user engagement and provide interactive challenges based on daily puzzle achievements.

## External APIs Needed

- None

## Use Cases

1. **Challenge Participation**: Enable users to participate in challenges that require proof of daily puzzle completion and achievements.
2. **Longest Word Challenge**: Users must find the longest possible word in the daily puzzle to complete the challenge, leveraging the center letter provided.
3. **Pangram Hunt**: Users are challenged to discover pangrams (words using every letter at least once) within the daily puzzle.

## Data Provider

- **Name**: Spelling Bee Stats
- **Hash Value**: 0x4a38917946919df457dab21b2b5cc927ea8a04dfb35c98833dce4c0a3b66eccb

## Code Snippet

Below is a code snippet that demonstrates the key parts of the Spelling Bee integration.

**`services/spellingBeeService.js`**

```javascript
const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse')

exports.processSpellingBeeData = async (proof, providerName) => {
const userStatsExtracted = JSON.parse(
proof[0].claimData.context
).extractedParameters

const userStats = {
longestWord: userStatsExtracted.longest_word,
puzzlesStarted: userStatsExtracted.puzzles_started,
totalPangrams: userStatsExtracted.total_pangrams,
totalWords: userStatsExtracted.total_words,
}

const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS)

// Spelling bee does not provider username
const username = userStatsExtracted.user_id

return new ReclaimServiceResponse(
providerName,
lastUpdateTimeStamp,
username,
userStats,
proof[0]
)
}
```
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const express = require('express')
const bodyParser = require('body-parser')
const reclaimController = require('./src/controllers/reclaimController')
require('dotenv').config()

const app = express()
app.use(bodyParser.json())
Expand Down
4 changes: 4 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 { processSpellingBeeData } = require('./spellingBeeService')

exports.signWithProviderID = async (userId, providerId) => {
const providerName = RECLAIM_PROVIDER_ID[providerId]
Expand Down Expand Up @@ -49,6 +50,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => {
case 'GITHUB_ACCOUNT_VERIFICATION':
processedData = await processGitHubData(proof, providerName)
break
case 'SPELLING_BEE_STATS':
processedData = await processSpellingBeeData(proof, providerName)
break
default:
throw new Error(`No handler for provider: ${providerName}`)
}
Expand Down
27 changes: 27 additions & 0 deletions src/services/spellingBeeService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse')

exports.processSpellingBeeData = async (proof, providerName) => {
const userStatsExtracted = JSON.parse(
proof[0].claimData.context
).extractedParameters

const userStats = {
longestWord: userStatsExtracted.longest_word,
puzzlesStarted: userStatsExtracted.puzzles_started,
totalPangrams: userStatsExtracted.total_pangrams,
totalWords: userStatsExtracted.total_words,
}

const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS)

// Spelling bee does not provider username
const username = userStatsExtracted.user_id

return new ReclaimServiceResponse(
providerName,
lastUpdateTimeStamp,
username,
userStats,
proof[0]
)
}
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',
'6ef3c828-dc69-4ea7-bdf3-7cca065306c8': 'SPELLING_BEE_STATS',
}

exports.RECLAIM_APP_ID = {
TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id',
GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id',
SPELLING_BEE_STATS: '0x6f1aC97bbFf12558f251A11A6623C146300bF56C',
}