Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EthTracker notif settings implemented #33

Closed
wants to merge 2 commits into from

Conversation

Arunava-Barua
Copy link
Collaborator

This includes EthTicker channel with notif settings implemented that is triggered after a specific 1h percent change in Eth price.

Closes #32

@Arunava-Barua Arunava-Barua added the enhancement New feature or request label Dec 3, 2023
@Arunava-Barua Arunava-Barua self-assigned this Dec 3, 2023
Copy link

github-actions bot commented Dec 3, 2023

File: src/sample_showrunners/bank/bankChannel.ts

  • Line 57: There is a missing closing parenthesis after holidayNotif(userAlice, holiday, simulate);.

  • Lines 71-75: The commented out code block of the apyNotif function is not properly indented. Please fix the indentation.

  • Lines 77-95: The holidayNotif function is not properly indented. Please fix the indentation.

  • Line 80: The payload object is missing a closing curly brace.

  • Line 83: The payload object is missing a closing parenthesis.

  • Lines 87-91: The payload object is missing a closing parenthesis.

  • Line 89: The comment mentions "Boolean type" but the actual value should be holiday == true ? 'closed' : 'open'.

  • Lines 97-107: The sendThroughNotifSettings function is not properly indented. Please fix the indentation.

  • Line 98: The opening curly brace of the sendThroughNotifSettings function is missing a closing curly brace.

  • Line 116: The initializeUser function is missing a closing parenthesis.

  • Line 117: There is a missing semicolon at the end of the line.

  • Line 127: The closing parenthesis of await PushAPI.initialize(signer, { env: "staging" }) is missing.

File: src/sample_showrunners/ethTicker/ethTickerChannel.ts

  • Line 18: The comment block should start with /** and end with */.

  • Line 32: The import statement for ethers should be placed after the import statement for mongo.

  • Line 33: The import statement for mongo should be removed since it is not used.

  • Line 40: The ethTickerSettings require statement is not used. Please remove it.

  • Line 51: The closing parenthesis of the super function call is missing.

  • Line 58: There is a missing closing parenthesis after useOffChain: true.

  • Lines 131-162: There are missing closing curly braces for the sendMessageToContract, getNewPrice, and initializeUser functions.

  • Line 201: The promise executor function passed to new Promise is not properly indented. Please fix the indentation.

  • Line 217: There is a missing semicolon at the end of the line.

  • Line 234: The console.log statement is not properly indented. Please fix the indentation.

  • Line 256: The closing parenthesis of the getJSON function call is missing.

  • Line 262: The opening curly brace of the promise's then callback is missing a closing curly brace.

  • Line 281: The closing parenthesis of the new Date(Date.now()) is missing.

  • Line 291: The closing parenthesis of the new Date(Date.now()) is missing.

  • Line 310: The closing parenthesis of the new Date(Date.now()) is missing.

  • Line 365: The closing parenthesis of the logger.info function call is missing.

File: src/sample_showrunners/ethTicker/ethTickerKeys.json

  • Lines 2-7: The PRIVATE_KEY_NEW_STANDARD key has a nested PK object with an incorrect closing curly brace.

File: src/sample_showrunners/ethTicker/ethTickerModel.ts

  • Line 10: There is a missing closing curly brace for the ethTickerSchema.

  • Line 11: There is a missing semicolon at the end of the line.

File: src/sample_showrunners/ethTicker/ethTickerSettings.json

  • Line 2: The value of cmcEndpoint should be "https://pro-api.coinmarketcap.com/".

All looks good.


// 1. Store prev price in MongoDB
// Store
await ethTickerModel.findByIdAndUpdate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can skip storing of % change if we directly get the data for 6h(current cron job) from the CMC API, I just checked it and it can be done.

}[timestamp: ${Math.floor(Date.now() / 1000)}]`;

const payload = {
type: 1, // Type of Notification
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type will be 3 here as we are sending Targetted notifications at line 54.

@@ -0,0 +1,8 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Private key values

@@ -0,0 +1,17 @@
/* eslint-disable prettier/prettier */
import { model, Schema } from 'mongoose';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file won't be needed.

Copy link
Member

@aeyshubh aeyshubh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do the necessary changes, other things looks good.

Copy link

github-actions bot commented Dec 3, 2023

File: src/sample_showrunners/bank/bankChannel.ts

  1. In the startEventListener function, there are missing curly braces at the end of the function after the closing parentheses of the contract.on("HolidayStatus") callback.

  2. The apyNotif function is commented out. If it is not needed, it should be removed to avoid confusion.

  3. In the investmentNotif function, there is a typo in the comment. Instead of "optted", it should be "opted".

  4. In the holidayNotif function, the body property in the payload object is duplicated. One of them should be removed.

  5. In the sendThroughNotifSettings function, there is a missing closing curly brace before the catch block.

  6. The initializeUser function is missing a closing curly brace at the end of the function.

Overall, the code seems to be correct with these minor issues.

File: src/sample_showrunners/ethTicker/ethTickerChannel.ts

  1. There is a missing import statement for EPNSChannel at the top of the file. It should be added.

  2. The commented out ethTickerSettings import statement is unnecessary and should be removed.

  3. There are unused import statements for the Service and Inject decorators from typedi. They can be removed.

  4. In the getNewPrice function, there is an unused const statement for bent. It can be removed.

  5. There is a typo in the comment in the sendMessageToContract function. Instead of "optted", it should be "opted".

  6. In the for loop in the sendMessageToContract function, there is an unnecessary ellipsis (...) after the sendNotification function call. It should be removed.

  7. There is an unnecessary return statement at the end of the getNewPrice function. It can be removed.

  8. In the userSettings.find function in the getNewPrice function, there is an unnecessary semicolon after the parentheses. It should be removed.

  9. In the if condition inside the userSettings.find callback, the strict equality operator (===) should be used instead of the loose equality operator (==).

  10. In the else block of the if condition inside the userSettings.find callback, the strict equality operator (===) should be used instead of the loose equality operator (==).

  11. In the getJSON promise chain, there is an unnecessary catch block. It can be removed since there is already a catch block at the end.

  12. The code seems to be missing a closing curly brace for the ethTickerChannel class declaration. It should be added.

File: src/sample_showrunners/ethTicker/ethTickerJobs.ts

  1. There is a missing import statement for Container from typedi. It should be added.

  2. The import statement for config is unnecessary and can be removed since it is already imported in the config.ts file.

  3. The import statement for logger is unnecessary and can be removed since it is already imported in the logger.ts file.

  4. The import statement for PushAPI is unnecessary and can be removed since it is not used in the file.

Other files:

  1. The file ethTickerRoutes.ts is empty and can be deleted.

  2. The ethTickerSettings.json file is empty and can be deleted.

Overall, the code seems to be correct with these minor issues.

All looks good.

const formattedPrice = Number(Number(price).toFixed(2)).toLocaleString();


const hourChange = Number(data.quote.USD.percent_change_1h);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you need to fetch the price percent change in 6 hour and then on the basis of that change, we will send notification.
please refer this : https://coinmarketcap.com/api/documentation/v1/#operation/getV3CryptocurrencyQuotesHistorical [Interval Options section].

Copy link
Member

@aeyshubh aeyshubh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick update.

let recipients: string[] = [];

// 2. Get the list of all the addresses opted in for the setting - /subscribers?category=2&setting=true
const { data: userData } = await axios(`https://backend-staging.epns.io/apis/v1/channels/eip155:${'11155111'}:${'0x9C2dA92ff312b630B67cEa1d2C234250c2d3410e'}/subscribers?category=${'2'}&setting=${'true'}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK has incorporated this API. So you can replace this with the SDK call

@aeyshubh
Copy link
Member

aeyshubh commented Mar 6, 2024

Closing this as btc tracker already exists

@aeyshubh aeyshubh closed this Mar 6, 2024
@aeyshubh aeyshubh deleted the eth-tracker-notif-settings branch August 27, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implemented Notif settings with EthTracker
3 participants