-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: added a "common" package to share code between packages #151
Conversation
package.json
Outdated
"@aws-sdk/client-apigatewaymanagementapi": "3.540.0", | ||
"@aws-sdk/client-lambda": "3.540.0", | ||
"@aws-sdk/client-sqs": "3.540.0", | ||
"@hathor/wallet-lib": "0.39.0", | ||
"bip32": "^4.0.0", | ||
"bitcoinjs-lib": "^6.1.5", | ||
"bitcoinjs-message": "^2.2.0", | ||
"tiny-secp256k1": "^2.2.3", | ||
"winston": "^3.13.0" |
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.
Added those dependencies here so the projects can use peerDependencies
and share the dependency
e66536d
to
81d2a6d
Compare
deb36e6
to
8da7285
Compare
@@ -28,9 +28,9 @@ export const addAlert = async ( | |||
title: string, | |||
message: string, | |||
severity: Severity, | |||
metadata?: unknown, | |||
metadata: unknown = null, |
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.
Why did you set this default value? Shouldn't we have the optional parameters in the end of the method?
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.
Added a comment in this line: a410a8c
I'll refactor the logger
to be shared between projects, so logger
will stop being a parameter there, so this default to null is temporary until then
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 still don't understand the default null
. We use default values for parameters in the end of the list of parameters, which is not the case.
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.
Removed the null default in cae81ac
packages/wallet-service/src/types.ts
Outdated
WARNING = 'warning', | ||
INFO = 'info', | ||
} | ||
export { Severity, Transaction, TxInput, TxOutput, DecodedOutput }; |
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.
Why do you need to export the imported types?
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.
We don't, this was done initially because I was only planning to move the types on the next PR
But refactored the code to import from the common project, can you please check again?
1d73093
to
49a3744
Compare
@@ -4,7 +4,8 @@ import eventTemplate from '@events/eventTemplate.json'; | |||
import { loadWallet, loadWalletFailed } from '@src/api/wallet'; | |||
import { createWallet, getMinersList } from '@src/db'; | |||
import * as txProcessor from '@src/txProcessor'; | |||
import { Transaction, WalletStatus, TxInput, Severity } from '@src/types'; | |||
import { WalletStatus } from '@src/types'; |
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.
style: Lint fix
import { WalletStatus } from '@src/types'; | |
import { WalletStatus } from '@src/types'; |
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.
Done in 408d995
@@ -6,7 +6,8 @@ import { sendMulticastMock, messaging, initFirebaseAdminMock } from '@tests/util | |||
import { logger } from '@tests/winston.mock'; | |||
import { PushNotificationUtils, PushNotificationError, buildFunctionName, FunctionName } from '@src/utils/pushnotification.utils'; | |||
import * as pushnotificationUtils from '@src/utils/pushnotification.utils'; | |||
import { SendNotificationToDevice, Severity } from '@src/types'; | |||
import { SendNotificationToDevice } from '@src/types'; | |||
import { Severity } from '@wallet-service/common/src/types'; |
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.
style: Lint fix
import { Severity } from '@wallet-service/common/src/types'; | |
import { Severity } from '@wallet-service/common/src/types'; |
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.
Done in 408d995
"peerDependencies": { | ||
"@aws-sdk/client-lambda": "3.540.0", | ||
"@hathor/wallet-lib": "0.39.0", | ||
"winston": "^3.13.0" |
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.
question(non-blocking): Here we have a mix of version definitions. Some are pinned to an exact value and some are with a flexible caret range.
Should we decide for one approach or another? Or can we leave this mixed as it currently is?
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'll fix all versions in a future PR
package.json
Outdated
"packages/daemon", | ||
"packages/wallet-service" | ||
"packages/wallet-service", | ||
"packages/common" |
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.
suggestion: Order this alphabetically, as it will probably be automatically fixed at some point in the future
"packages/common",
"packages/daemon",
"packages/wallet-service"
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.
Done in 408d995
6506f1f
to
8604db6
Compare
16ba61f
to
9d84734
Compare
…methods in wallet-service package
* feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor
9d84734
to
25261a1
Compare
* refactor: logger is now a required param in addAlert, refactored all methods in wallet-service package * chore: changed module resolution and several package locks * chore: added common library to externals whitelist and whitelisted it in tsloader * chore: wallet-service common package moved from direct path to workspace * chore: added common as a peer dependency and restored peer dependencies * chore: removed peer dependencies as they were not working with serverless-monorepo * chore: added comment on hoisting limits * chore: added comment explaining externals in webpack
Motivation
We should have a
common
package so that the wallet-service and the daemon can share code between them.This PR does not attempt to refactor both projects, but only to create the common project and include the bare minimum changes to enable code sharing of the nft util
Acceptance Criteria
addAlert
from the daemon's package to the common package and use it on both the wallet-service and the daemonChecklist
master
, confirm this code is production-ready and can be included in future releases as soon as it gets merged