-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
There are a few things to address in the provided code snippet:
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. |
Feedback:File: package.json
File: src/config/channelsConfig.ts
File: src/sample_showrunners/aave/aaveChannel.ts
File: src/sample_showrunners/aave/aaveKeys.ts
File: src/sample_showrunners/aave/aaveSettings.ts
File: src/sample_showrunners/bank/bankChannel.ts
File: src/sample_showrunners/bank/bankKeys.ts
File: src/sample_showrunners/btcTicker/btcTickerChannel.ts
General:
All looks good. |
Pull Request Template
Description
Updated json to ts config files and package.json file