diff --git a/CRIP/CRIP-GrowwBalanceOnHold.md b/CRIP/CRIP-GrowwBalanceOnHold.md new file mode 100644 index 0000000..ceb8ac3 --- /dev/null +++ b/CRIP/CRIP-GrowwBalanceOnHold.md @@ -0,0 +1,56 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|-----------------------------|-----------------------------------------------------------|---------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-10 | Groww Balance On Hold | Integration with Groww to verify balance on hold | Ritik Bhatt | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Groww Balance On Hold Integration + +## Introduction + +This proposal outlines the integration of Groww as a data provider for the Catoff-Reclaim integration project. The integration aims to retrieve and process the balance on hold data from Groww, allowing users to validate their financial status on the Catoff platform. This will enable users to use their Groww balance on hold data for various challenges and verifications on Catoff. + +## External APIs Needed + +- Groww API: Groww doesn't have a public API, so the integration will use data extraction methods from the Groww app/web. + +## Use Cases + +1. **User Verification**: Verify the balance on hold on a user's Groww account. +2. **Challenge Participation**: Allow users to participate in challenges that require proof of their balance on hold on Groww. +3. **Financial Status**: Validate users' financial status based on their Groww balance on hold. + +## Data Provider + +- **Name**: Groww Balance On Hold +- **Hash Value**: 0x8bbe041be479e12ef2efee703fced2f4b605c4a6d69e9957d955bebb92ad30ed + +## Code Snippet + +Below is a code snippet that demonstrates the key parts of the Groww integration. The full implementation should follow the service file template. + +**`services/GrowwBalanceOnHoldService.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse'); + +exports.processGrowwAccountData = async (proof, providerName) => { + console.log("Proof is: ", proof[0]); + + const extractedParameters = JSON.parse(proof[0].claimData.context).extractedParameters; + + const lastUpdateTimeStamp = proof[0].claimData.timestampS; + const balanceOnHold = extractedParameters.balanceOnHold; + const balanceOnHoldForStocks = extractedParameters.balanceOnHoldForStocks; + + console.log("The Balance On Hold of your Groww account is:", balanceOnHold); + console.log("The Balance On Hold For Stocks of your Groww account is:", balanceOnHoldForStocks); + + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + 'ritikbhatt', + balanceOnHold, + proof[0] + ); +}; diff --git a/index.js b/index.js index df7fba0..bfbe55b 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,8 @@ 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()) diff --git a/package.json b/package.json index ac9ddd6..dfe69c7 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@reclaimprotocol/js-sdk": "^1.3.6", "axios": "^1.7.2", "body-parser": "^1.20.2", + "chess-web-api": "^1.2.0", "dotenv": "^16.4.5", "express": "^4.19.2" }, diff --git a/src/services/GrowwBalanceOnHoldService.js b/src/services/GrowwBalanceOnHoldService.js new file mode 100644 index 0000000..fe21d97 --- /dev/null +++ b/src/services/GrowwBalanceOnHoldService.js @@ -0,0 +1,22 @@ +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse'); + +exports.processGrowwAccountData = async (proof, providerName) => { + console.log("Proof is: ", proof[0]); + + const extractedParameters = JSON.parse(proof[0].claimData.context).extractedParameters; + + const lastUpdateTimeStamp = proof[0].claimData.timestampS; + const balanceOnHold = extractedParameters.balanceOnHold; + const balanceOnHoldForStocks = extractedParameters.balanceOnHoldForStocks; + + console.log("The Balance On Hold of your Groww account is:", balanceOnHold); + console.log("The Balance On Hold For Stocks of your Groww account is:", balanceOnHoldForStocks); + + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + 'ritikbhatt', + balanceOnHold, + proof[0] + ); +}; diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index b33006f..ff47517 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 { processGrowwAccountData } = require('./GrowwBalanceOnHoldService') exports.signWithProviderID = async (userId, providerId) => { const providerName = RECLAIM_PROVIDER_ID[providerId] @@ -13,11 +14,11 @@ exports.signWithProviderID = async (userId, providerId) => { `Sending signature request to Reclaim for userId: ${userId} with providerName: ${providerName}` ) - try { - const reclaimClient = new Reclaim.ProofRequest(reclaimAppID) - await reclaimClient.buildProofRequest(providerId) + try { + const reclaimClient = new Reclaim.ProofRequest('0x8DB7F57E462B89D5392A08dDFFa02cec430974B1') + await reclaimClient.buildProofRequest('3a73fdb0-7a52-4a3b-8df3-21e59bb5c481') reclaimClient.setSignature( - await reclaimClient.generateSignature(reclaimAppSecret) + await reclaimClient.generateSignature('0x2028acf98d4529c300cbdc1b7cb52de6e5d45ef48216711a6c3c3a7fe1feec56') ) const { requestUrl: signedUrl } = await reclaimClient.createVerificationRequest() @@ -34,6 +35,7 @@ exports.signWithProviderID = async (userId, providerId) => { } const handleReclaimSession = async (userId, reclaimClient, providerName) => { + console.log('Starting session') await reclaimClient.startSession({ onSuccessCallback: async proof => { console.log( @@ -49,6 +51,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'GITHUB_ACCOUNT_VERIFICATION': processedData = await processGitHubData(proof, providerName) break + case 'GROWW_ACCOUNT_VERIFICATION': + processedData = await processGrowwAccountData(proof, providerName); + break default: throw new Error(`No handler for provider: ${providerName}`) } @@ -65,4 +70,5 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { console.error(`Verification failed for userId: ${userId}`, error) }, }) -} + console.log('Ended session') +} \ No newline at end of file diff --git a/src/utils/constants.js b/src/utils/constants.js index 1c58669..8b68b1d 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -1,9 +1,17 @@ exports.RECLAIM_PROVIDER_ID = { twitter: 'TWITTER_ANALYTICS_VIEWS', github: 'GITHUB_ACCOUNT_VERIFICATION', + groww: 'GROWW_ACCOUNT_VERIFICATION' } exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', + GROWW_ACCOUNT_VERIFICATION: 'your-groww-app-id' } + +exports.PROVIDER_ID = { + twitter: 'twitter-provider-id', + github: 'github-provider-id', + groww: 'groww-provider-id' +} \ No newline at end of file