-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: transaction checker app (#2) #8
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Michał Walczak <[email protected]>
networkUrl: process.env.NETWORK_URL || '127.0.0.1:50211', | ||
networkAccount: process.env.NETWORK_ACCOUNT || '3', | ||
operatorAccount: process.env.OPERATOR_ACCOUNT || '2', | ||
operatorAccountKey: process.env.OPERATOR_ACCOUNT_KEY || '302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This default private key comes from Hedera's documentation
/* Visit https://aka.ms/tsconfig to read more about this file */ | ||
|
||
/* Projects */ | ||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ | ||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ | ||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ | ||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ | ||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ | ||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove commented config, we can always set something when needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: 414c48c
await sendAndLogToFile(payload, status.toString(), null); | ||
} catch (error) { | ||
mirrorQueue.push(payload); | ||
console.log(`Hedera Worker ${id} failed to get receipt of transaction ${payload.transactionId}, sent to mirror queue. Error was: ${error}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets change it to console.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: 74c890f
|
||
await sendAndLogToFile(payload, status, null); | ||
} catch (error) { | ||
console.log(`Mirror Worker ${id} failed to get the status of transaction ${payload.transactionId}: ${error}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets change it to console.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: 74c890f
} // Log to file if enabled in environment variables. | ||
|
||
const logEntry = `${new Date().toISOString()} - ${jsonString}\n`; | ||
const logFilePath = path.resolve(__dirname, `../../${env.logFilePath}${env.logFileName}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const logFilePath = path.resolve(__dirname, `../../${env.logFilePath}${env.logFileName}`); | |
const logFilePath = path.resolve(__dirname, `..`, `..`, env.logFilePath, env.logFileName); |
This will make it a bit better as we are not going to get double slash by accident. Also, assuming:
logFilePath = 'logs',
logFileName = 'app.log'
__dirname = '/user/project/src';
The output would be: /user/logs/app.log
whereas with using .join()
we would get /user/project/logs/app.log
.
Is the first output desired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: a155a8b
export const env = { | ||
port: parseInt(process.env.PORT || '8081'), | ||
logToFile: process.env.LOG_TO_FILE || 'false', | ||
logFilePath: process.env.LOG_FILE_PATH || 'logs/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets remove trailing slash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: a155a8b
Create a ```.env``` file in the root of project and add all variables as in ```.env.example```. Api key for ```OPERATOR_PRIVATE``` should be added from the shadowing | ||
|
||
- ``PORT``- port which app will be running on - default is 8081 | ||
- ``LOG_TO_FILE``- directory to store logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description looks like a mishap, in the code it is used to decide whether to log or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: a155a8b
console.log(`Status of transaction ${payload.transactionId} is: ${status}`); | ||
|
||
await sendAndLogToFile(payload, status, null); | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make any error repeated if something inside constantly fails, is this desired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code does not lead to an infinite loop because the payload is removed from the mirrorQueue using shift() and is not reprocessed in case of an error. However, when the Mirror Node is unavailable and returns an error, we lose such a payload. Addressing this was not part of this task, but I will add a TODO comment to the code - ae80e71
…onfiguration options (#2) Signed-off-by: Michał Walczak <[email protected]>
…rror messages (#2) Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
Signed-off-by: Michał Walczak <[email protected]>
Description:
Rewrite transaction checker project from .go into node version using typescript.
Related issue(s):
Fixes #2