Skip to content

Commit d73011e

Browse files
committed
chore: installed shared dependencies on root project, using peerDependencies
1 parent 5f609a7 commit d73011e

File tree

8 files changed

+67
-33
lines changed

8 files changed

+67
-33
lines changed

packages/common/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "@wallet-service/common",
33
"packageManager": "[email protected]",
44
"peerDependencies": {
5-
"@aws-sdk/client-lambda": "3.465.0",
6-
"@hathor/wallet-lib": "1.4.1",
7-
"winston": "3.7.2"
5+
"@aws-sdk/client-lambda": "3.540.0",
6+
"@hathor/wallet-lib": "0.39.0",
7+
"winston": "^3.13.0"
88
},
99
"devDependencies": {
1010
"@types/node": "^20.11.30"

packages/common/src/types.ts

+30
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,33 @@ export interface Transaction {
2929
// eslint-disable-next-line camelcase
3030
token_symbol?: string;
3131
}
32+
33+
export interface TxInput {
34+
// eslint-disable-next-line camelcase
35+
tx_id: string;
36+
index: number;
37+
value: number;
38+
// eslint-disable-next-line camelcase
39+
token_data: number;
40+
script: string;
41+
token: string;
42+
decoded: DecodedOutput;
43+
}
44+
45+
export interface TxOutput {
46+
value: number;
47+
script: string;
48+
token: string;
49+
decoded: DecodedOutput;
50+
// eslint-disable-next-line camelcase
51+
spent_by: string | null;
52+
// eslint-disable-next-line camelcase
53+
token_data: number;
54+
locked?: boolean;
55+
}
56+
57+
export interface DecodedOutput {
58+
type: string;
59+
address: string;
60+
timelock: number | null;
61+
}

packages/common/src/utils/index.utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export const assertEnvVariablesExistence = (envVariables: string[]): void => {
88
const missingList = [];
99
for (const envVariable of envVariables) {
10-
if (!(envVariable in process.env) || process.env[envVariable].length === 0) {
10+
if (!(envVariable in process.env) || process.env[envVariable]?.length === 0) {
1111
missingList.push(envVariable);
1212
}
1313
}

packages/common/src/utils/nft.utils.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { LambdaClient, InvokeCommand, InvokeCommandOutput } from '@aws-sdk/client-lambda';
99
import { addAlert } from './alerting.utils';
1010
import { Transaction, Severity } from '../types';
11-
import hathorLib from '@hathor/wallet-lib';
11+
import { Network, constants, CreateTokenTransaction, helpersUtils } from '@hathor/wallet-lib';
1212
import createDefaultLogger from '../logger';
1313

1414
/**
@@ -25,7 +25,7 @@ export class NftUtils {
2525
* @param {string} network
2626
* @returns {boolean}
2727
*/
28-
static shouldInvokeNftHandlerForTx(tx: Transaction, network: string): boolean {
28+
static shouldInvokeNftHandlerForTx(tx: Transaction, network: Network): boolean {
2929
return isNftAutoReviewEnabled() && this.isTransactionNFTCreation(tx, network);
3030
}
3131

@@ -36,13 +36,13 @@ export class NftUtils {
3636
*
3737
* TODO: change tx type to HistoryTransaction
3838
*/
39-
static isTransactionNFTCreation(tx: any, network: string): boolean {
39+
static isTransactionNFTCreation(tx: any, network: Network): boolean {
4040
/*
4141
* To fully check if a transaction is a NFT creation, we need to instantiate a new Transaction object in the lib.
4242
* So first we do some very fast checks to filter the bulk of the requests for NFTs with minimum processing.
4343
*/
4444
if (
45-
tx.version !== hathorLib.constants.CREATE_TOKEN_TX_VERSION // Must be a token creation tx
45+
tx.version !== constants.CREATE_TOKEN_TX_VERSION // Must be a token creation tx
4646
|| !tx.token_name // Must have a token name
4747
|| !tx.token_symbol // Must have a token symbol
4848
) {
@@ -52,11 +52,11 @@ export class NftUtils {
5252
// Continue with a deeper validation
5353
const logger = createDefaultLogger();
5454
let isNftCreationTx: boolean;
55-
let libTx: hathorLib.CreateTokenTransaction;
55+
let libTx: CreateTokenTransaction;
5656

5757
// Transaction parsing failures should be alerted
5858
try {
59-
libTx = hathorLib.helpersUtils.createTxFromHistoryObject(tx) as hathorLib.CreateTokenTransaction;
59+
libTx = helpersUtils.createTxFromHistoryObject(tx) as CreateTokenTransaction;
6060
} catch (ex) {
6161
logger.error('[ALERT] Error when parsing transaction on isTransactionNFTCreation', {
6262
transaction: tx,
@@ -69,7 +69,7 @@ export class NftUtils {
6969

7070
// Validate the token: the validateNft will throw if the transaction is not a NFT Creation
7171
try {
72-
libTx.validateNft(new hathorLib.Network(network));
72+
libTx.validateNft(network);
7373
isNftCreationTx = true;
7474
} catch (ex) {
7575
isNftCreationTx = false;
@@ -124,15 +124,16 @@ export class NftUtils {
124124
/**
125125
* Identifies if the metadata for a NFT needs updating and, if it does, update it.
126126
* @param {string} nftUid
127+
* @param {number} maxRetries
127128
* @returns {Promise<void>} No data is returned after a successful update or skip
128129
*/
129-
static async createOrUpdateNftMetadata(nftUid: string): Promise<void> {
130+
static async createOrUpdateNftMetadata(nftUid: string, maxRetries: number): Promise<void> {
130131
// The explorer service automatically merges the metadata content if it already exists.
131132
const newMetadata = {
132133
id: nftUid,
133134
nft: true,
134135
};
135-
await NftUtils._updateMetadata(nftUid, newMetadata);
136+
await NftUtils._updateMetadata(nftUid, newMetadata, maxRetries);
136137
}
137138

138139
/**

packages/daemon/package.json

+11-10
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,25 @@
3232
"@types/mysql": "^2.15.21",
3333
"@types/node": "^17.0.45",
3434
"@types/ws": "^8.5.5",
35-
"@typescript-eslint/eslint-plugin": "^6.7.3",
36-
"@typescript-eslint/parser": "^6.7.3",
35+
"@typescript-eslint/eslint-plugin": "^7.4.0",
36+
"@typescript-eslint/parser": "^7.4.0",
37+
"eslint": "^8.57.0",
3738
"eslint-config-airbnb-base": "^15.0.0",
38-
"eslint-plugin-jest": "^27.4.0",
39+
"eslint-plugin-import": "^2.29.1",
40+
"eslint-plugin-jest": "^27.9.0",
3941
"jest": "^29.6.4",
4042
"sequelize-cli": "^6.6.1",
4143
"ts-jest": "^29.1.1",
4244
"tslib": "^2.1.0",
4345
"typescript": "^4.9.5"
4446
},
45-
"dependencies": {
46-
"@aws-sdk/client-lambda": "^3.474.0",
47-
"@aws-sdk/client-sqs": "^3.474.0",
47+
"peerDependencies": {
48+
"@aws-sdk/client-lambda": "3.540.0",
49+
"@aws-sdk/client-sqs": "3.540.0",
4850
"@hathor/wallet-lib": "0.39.0",
51+
"winston": "^3.13.0"
52+
},
53+
"dependencies": {
4954
"@wallet-service/common": "workspace:^",
5055
"assert": "^2.1.0",
5156
"aws-sdk": "^2.1454.0",
@@ -55,11 +60,7 @@
5560
"mysql2": "^3.5.2",
5661
"sequelize": "^6.33.0",
5762
"websocket": "^1.0.33",
58-
"winston": "^3.3.3",
5963
"ws": "^8.13.0",
6064
"xstate": "^4.38.2"
61-
},
62-
"resolutions": {
63-
"@hathor/wallet-lib": "0.39.0"
6465
}
6566
}

packages/daemon/src/db/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,6 @@ export const generateAddresses = async (mysql: MysqlConnection, xpubkey: string,
10481048
let lastUsedAddressIndex = -1;
10491049
do {
10501050
const { NETWORK } = getConfig();
1051-
console.debug('WALLET UTILS: ', walletUtils);
10521051
const addrMap = walletUtils.getAddresses(derivedXpub, highestCheckedIndex + 1, maxGap, NETWORK);
10531052
allAddresses.push(...Object.keys(addrMap));
10541053

packages/daemon/src/services/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// @ts-ignore
99
import hathorLib from '@hathor/wallet-lib';
10+
import { isNftAutoReviewEnabled } from '@wallet-service/common/src/utils/nft.utils';
1011
import axios from 'axios';
1112
import { get } from 'lodash';
1213
import {
@@ -72,6 +73,8 @@ export const METADATA_DIFF_EVENT_TYPES = {
7273
TX_FIRST_BLOCK: 'TX_FIRST_BLOCK',
7374
};
7475

76+
isNftAutoReviewEnabled();
77+
7578
export const metadataDiff = async (_context: Context, event: Event) => {
7679
const mysql = await getDbConnection();
7780

packages/wallet-service/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
"@types/aws-lambda": "^8.10.95",
4040
"@types/jest": "^27.0.24",
4141
"@types/node": "^18.0.4",
42-
"@typescript-eslint/eslint-plugin": "^6.7.4",
43-
"@typescript-eslint/parser": "^3.3.0",
42+
"@typescript-eslint/eslint-plugin": "^7.4.0",
43+
"@typescript-eslint/parser": "^7.4.0",
4444
"bitcore-lib": "8.25.10",
4545
"dotenv": "^10.0.0",
46-
"eslint": "^8.50.0",
47-
"eslint-config-airbnb-base": "^14.2.1",
46+
"eslint": "^8.57.0",
47+
"eslint-config-airbnb-base": "^15.0.0",
4848
"eslint-import-resolver-alias": "^1.1.2",
4949
"eslint-plugin-import": "^2.23.3",
50-
"eslint-plugin-jest": "^23.13.2",
50+
"eslint-plugin-jest": "^27.9.0",
5151
"eslint-plugin-module-resolver": "^0.16.0",
5252
"fork-ts-checker-webpack-plugin": "^9.0.0",
5353
"jest": "^29.7.0",
@@ -70,9 +70,9 @@
7070
"webpack-node-externals": "^3.0.0"
7171
},
7272
"peerDependencies": {
73-
"@aws-sdk/client-apigatewaymanagementapi": "3.465.0",
74-
"@aws-sdk/client-lambda": "3.465.0",
75-
"@aws-sdk/client-sqs": "3.465.0",
76-
"winston": "^3.7.2"
73+
"@aws-sdk/client-apigatewaymanagementapi": "3.540.0",
74+
"@aws-sdk/client-lambda": "3.540.0",
75+
"@aws-sdk/client-sqs": "3.540.0",
76+
"winston": "^3.13.0"
7777
}
7878
}

0 commit comments

Comments
 (0)