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

Updated json to ts and package.json #42

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

Arunava-Barua
Copy link
Collaborator

Pull Request Template

Description

Updated json to ts config files and package.json file

@Arunava-Barua Arunava-Barua added the enhancement New feature or request label Aug 27, 2024
@Arunava-Barua Arunava-Barua self-assigned this Aug 27, 2024
Copy link

There are a few things to address in the provided code snippet:

  1. The import statement for fs is missing import fs from 'fs';, you should include it at the beginning of the file.

  2. The import for cryptoHelper and utils should be adjusted to use relative paths, for example: import cryptoHelper from '../helpers/cryptoHelper'; and const utils = require('../helpers/utilsHelper');.

  3. There is a typo in the function name loadShowrunnersWallets, it should be function loadShowrunnersWallets() {.

  4. There is a typo in the variable name channlKeys which should be corrected to channelKeys.

  5. The end of the function channelWallets is missing, you need to close the function with };.

  6. You should replace template literals ${channel} with just channel since there is no need for template literals.

  7. You're using semicolons inconsistently, consider adding them consistently at the end of each statement.

  8. It's good practice to have descriptive comments for each part of the function to explain its purpose and the logic behind it.

import fs from 'fs';
import cryptoHelper from '../helpers/cryptoHelper';
import LoggerInstance from '../loaders/logger';
const utils = require('../helpers/utilsHelper');

function loadShowrunnersWallets() {
  LoggerInstance.info('    -- Checking and Loading Dynamic Channel Keys...');
  const channelFolderPath = `${__dirname}/../showrunners/`;
  const directories = utils.getDirectories(channelFolderPath);

  let channelKeys = {};
  let keys = {};

  if (directories.length === 0) {
    LoggerInstance.info('     ❌  showrunners don\'t have any channel folder in src/showrunners! Check docs.epns.io to see how to set up showrunners properly!');
    process.exit(1);
  }

  for (const channel of directories) {
    const absPath = `${channelFolderPath}${channel}/${channel}Keys.ts`;
    if (fs.existsSync(absPath)) {
      const object = require(absPath);
      let count = 1;

      channelKeys[channel] = {};

      for (const [key, value] of Object.entries(object.keys)) {
        const isOldStandard = typeof value === 'string' || value instanceof String;
        const newValue = value;
        const pkey = isOldStandard ? newValue : newValue.PK;

        const result = cryptoHelper.checkPrivateKeyValidity(pkey);

        if (result) {
          channelKeys[channel][`wallet${count}`] = value;
          count++;
        } else {
          LoggerInstance.info(`         ⚠️  ${key} -> ${value} is an invalid private key, skipped`);
        }
      }

      if (Object.keys(channelKeys[channel]).length) {
        LoggerInstance.info(`     ✔️  ${channel} Loaded ${Object.keys(channelKeys[channel]).length} Wallet(s)!`);
      } else {
        LoggerInstance.info(`     ❌  ${channel} has no wallets attached to them... aborting! Check ${channel}Keys.ts!!!`);
        process.exit(1);
      }
    } else {
      LoggerInstance.info(`     ❌  ${channel}Keys.ts does not exist, aborting! Create ${channel}Keys.ts and add one wallet to it!!!`);
      process.exit(1);
    }
  }

  return channelKeys;
}

export default loadShowrunnersWallets;

After addressing these points, the code should be more correct and readable.

Copy link

Feedback:

File: package.json

  1. Missing closing curly brace '}' after the "bugs" object.
  2. Missing closing curly brace '}' after the "devDependencies" object.

File: src/config/channelsConfig.ts

  1. In the channelWallets function, the for loop is missing a closing curly brace '}' before the return channelKeys;.

File: src/sample_showrunners/aave/aaveChannel.ts

  1. In the public async sendMessageToContract(simulate) method, the 'simulateAaveNetwork' variable is initialized but not used.

File: src/sample_showrunners/aave/aaveKeys.ts

  1. The file seems to be correctly declaring key objects.

File: src/sample_showrunners/aave/aaveSettings.ts

  1. The file seems to be correctly declaring Aave settings.

File: src/sample_showrunners/bank/bankChannel.ts

  1. In the async startEventListener(simulate) method, the ellipses '...' indicates more code that is cut off.

File: src/sample_showrunners/bank/bankKeys.ts

  1. The file seems to be correctly declaring key objects.

File: src/sample_showrunners/btcTicker/btcTickerChannel.ts

  1. In the public async getNewPrice(simulate) method, the 'logger' variable is used without declaration.

General:

  • Some parts of the code are truncated or not complete, which might affect the overall functionality or readability.
  • The codebase is complex, and it's recommended to have thorough testing in place.
  • Make sure to verify the logic in the files with the incomplete sections.

All looks good.

@pranshurastogi pranshurastogi merged commit faedf2b into main Aug 28, 2024
1 check passed
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.

2 participants