chore: upgrade wallet-lib to v1.14.1#216
Conversation
* feat: config modules * refactor: Use new config modules
|
|
||
| const hathorConfig = hathorLib.constants.HATHOR_TOKEN_CONFIG; | ||
| // XXX: get config from settings? | ||
| const hathorConfig = constants.DEFAULT_NATIVE_TOKEN_CONFIG; |
There was a problem hiding this comment.
This means that the daemon only supports Hathor as native token.
If we require support for side-dags we should add a nodeConfig module on the daemon (or common).
| expect(returnBody.details[0].message).toBe('Signatures are not valid'); | ||
| }); | ||
|
|
||
| test('PUT /wallet/auth should fail if we cannot confirm the firstAddress', async () => { |
There was a problem hiding this comment.
This test was created just to increase coverage to pass the CI
| expect(wallet.status).toStrictEqual(WalletStatus.ERROR); | ||
| }, 30000); | ||
|
|
||
| test('loadWalletFailed should create alert if xpubkey is missing', async () => { |
There was a problem hiding this comment.
This test was created just to increase coverage to pass the CI
| }); | ||
|
|
||
| // reload module | ||
| jest.resetModules(); |
There was a problem hiding this comment.
reset modules is required so that the import('@src/utils/pushnotification.utils') reimports the config and use the most recent values
| // get the first address | ||
| const xpubChangeDerivation = walletUtils.xpubDeriveChild(XPUBKEY, 0); | ||
| const firstAddress = walletUtils.getAddressAtIndex(xpubChangeDerivation, 0, process.env.NETWORK); | ||
| const firstAddressData = addressUtils.deriveAddressFromXPubP2PKH(xpubChangeDerivation, 0, process.env.NETWORK); |
There was a problem hiding this comment.
Use the config to get the network?
There was a problem hiding this comment.
Did not seem necessary to refactor the tests to also use the config.
What do you think?
There was a problem hiding this comment.
Maybe to guarantee that the config is being filled correctly?
…-lib-v1.14.1 * origin/master: fix: NFTs were not being properly processed (#219)
| // get the first address | ||
| const xpubChangeDerivation = walletUtils.xpubDeriveChild(XPUBKEY, 0); | ||
| const firstAddress = walletUtils.getAddressAtIndex(xpubChangeDerivation, 0, process.env.NETWORK); | ||
| const firstAddressData = addressUtils.deriveAddressFromXPubP2PKH(xpubChangeDerivation, 0, process.env.NETWORK); |
There was a problem hiding this comment.
Maybe to guarantee that the config is being filled correctly?
dfd52bb
Motivation
Wallet-lib is a core dependency but is currently 2 major versions outdated.
This PR is the first part upgrading and refactoring the codebase to work with
@hathor/wallet-lib@1.14.1Acceptance Criteria
Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets mergedDecisions
### Decision 1Code: DEC-0001Some constants are network configured and come from the/v1a/versionresponse of the fullnode.These constants were previously configured on the config module and updated by thehathorLib.version.checkApiVersion.This was replaced by having an ApiConfig instance on the storage to avoid having 1 config for all wallets connected.Currently we need to have a way to get these configured constants, we could go with one of the following:1. Use pre-configured hardcoded constants.2. Get from connected fullnode.~~ - The method
maybeRefreshWalletConstantsinpackages/wallet-service/src/commons.tscan be used to refresh constants based on a request to the fullnode.~~3. Get from wallet-service config.Current changes that may change after a decision is made:- Uses ofhathorLib.transaction.getMaxOutputsConstant()~~ - Temporarily fixed by using
constants.MAX_OUTPUTS = 255.~~- Call tohathorLib.version.checkApiVersion()to update variables does not exist~~ - Will use the version api directly so the data can be saved on the database.~~
~~ - Will not save the values until a decision is made.~~
### Decision 2Code: DEC-0002Some constants of the wallet-lib were deprecated, they are being used as sensible defaults but we need to check if we are still going to use these values.An example would be theDEFAULT_SERVERSandDEFAULT_SERVERconstants.We can either:- hardcode the values~~ - includes creating a constants file to keep these values.~~
- create a way to ensure some settings are configured~~ - This way we do not depend on sensible defaults~~
~~ - The deploy should fail if these are not configured~~
Currently the values are being hardcoded to avoid changing any behavior.Files
List of files that were changed:
String(process.env...)only in requiredEnvs to ensure typing asstringand notstring | undefined.Files that contain
@hathor/wallet-libgetConfig().NETWORKto be strictly a string.HATHOR_TOKEN_CONFIGwhich was deprecated, need to use a combination ofDEFAULT_NATIVE_TOKEN_CONFIGandNATIVE_TOKEN_UID.HATHOR_TOKEN_CONFIGwhich was deprecated, changed toNATIVE_TOKEN_UID.HATHOR_TOKEN_CONFIGwhich was deprecated, need to use a combination ofDEFAULT_NATIVE_TOKEN_CONFIGandNATIVE_TOKEN_UID.DEFAULT_SERVER.Tests files will be changed last since we need to change the methods first.
Package manager files are deferred since they should be updated automatically when upgrading.