From d61bc98abc9f91e8b80ae68af374f26c12595c98 Mon Sep 17 00:00:00 2001 From: "juraj.bacovcin" Date: Tue, 9 Apr 2024 17:21:39 +0200 Subject: [PATCH 1/2] ALL-5690 Fix AddressTransaction type in non-breaking way --- CHANGELOG.md | 6 ++++ package.json | 2 +- src/service/address/address.dto.ts | 48 ++++++++++++++++++++---------- src/service/address/address.ts | 7 +++-- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f0b7dcba..82a7ddbad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [4.2.22] - 2024.4.9 + +### Fixed + +- Fixed types for `getTransactions` method in `address` module. + ## [4.2.21] - 2024.4.4 ### Added diff --git a/package.json b/package.json index 4c7cbafc0..d42964ffa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatumio/tatum", - "version": "4.2.21", + "version": "4.2.22", "description": "Tatum JS SDK", "author": "Tatum", "repository": "https://github.com/tatumio/tatum-js", diff --git a/src/service/address/address.dto.ts b/src/service/address/address.dto.ts index 718c4b046..921a6a60f 100644 --- a/src/service/address/address.dto.ts +++ b/src/service/address/address.dto.ts @@ -109,50 +109,68 @@ export interface GetAddressTransactionsQueryTezos { cursor?: string } -export interface AddressTransaction { +export interface AddrTxCommon { /** * Blockchain network */ chain: string - /** - * Block number - */ - blockNumber: number /** * Transaction hash */ hash: string /** - * Transaction type + * Address, on which transaction occurred. This is receiver address for incoming transactions and sender address for outgoing transactions. */ - transactionType: 'incoming' | 'outgoing' | 'zero-transfer' + address: string + /** + * Block number + */ + blockNumber: number + /** + * Amount transferred. For outgoing transactions, it's a negative number. For zero-transfer transactions, it's always 0. For incoming transactions, it's a positive number. + */ + amount: string /** * Index of the transaction in the block */ transactionIndex?: number + /** + * Transaction subtype (only relevant for non-UTXO chains, for UTXO chains this exists as transactionType) + */ + transactionSubtype?: 'incoming' | 'outgoing' | 'zero-transfer' /** * Address of the token collection, if the transaction is related to a token (ERC-20, ERC-721, ERC-1155) */ tokenAddress?: string /** - * Token ID, if the transaction is related to a NFT (ERC-721) or MutiToken (ERC-1155) + * Token ID, if the transaction is related to an NFT (ERC-721) or MutiToken (ERC-1155) */ tokenId?: string /** - * Amount transferred. For outgoing transactions, it's a negative number. For zero-transfer transactions, it's always 0. For incoming transactions, it's a positive number. + * Counter address of the transaction. This is sender address for incoming transactions on `address` and receiver address for outgoing transactions on `address`. + * Not all blockchain networks can identify the counter address (e.g. UTXO chains like Bitcoin e.g., where there is multiple senders or recipients). In this case, the counter address is not returned. */ - amount: string + counterAddress?: string +} + +export interface AddressTransaction extends AddrTxCommon { /** * Transaction timestamp - UTC millis */ timestamp: number /** - * Address, on which transaction occurred. This is receiver address for incoming transactions and sender address for outgoing transactions. + * Transaction type */ - address: string + transactionType: 'fungible' | 'nft' | 'multitoken' | 'native' | 'internal' +} + +export interface AddressTransactionUTXO extends AddrTxCommon { /** - * Counter address of the transaction. This is sender address for incoming transactions on `address` and receiver address for outgoing transactions on `address`. - * Not all blockchain networks can identify the counter address (UTXO chains like Bitcoin e.g., where there is multiple senders or recipients). In this case, the counter address is not returned. + * Transaction timestamp - UTC seconds */ - counterAddress?: string + timestamp: number + /** + * Transaction type + */ + transactionType: 'incoming' | 'outgoing' | 'zero-transfer' } diff --git a/src/service/address/address.ts b/src/service/address/address.ts index b1f4c8665..5d7d9ead2 100644 --- a/src/service/address/address.ts +++ b/src/service/address/address.ts @@ -20,6 +20,7 @@ import { AddressBalance, AddressBalanceDataApi, AddressTransaction, + AddressTransactionUTXO, GetAddressTransactionsQuery, GetAddressTransactionsQueryTezos, } from './address.dto' @@ -286,7 +287,7 @@ export class Address { pageSize = 10, page = 0, tokenAddress, - }: GetAddressTransactionsQuery): Promise> { + }: GetAddressTransactionsQuery): Promise> { const chain = this.config.network return ErrorUtils.tryFail(async () => { if (isDataApiEnabledNetwork(chain)) { @@ -402,9 +403,9 @@ export class Address { }, }) .then((r) => { - const result: AddressTransaction[] = [] + const result: AddressTransactionUTXO[] = [] for (const tx of r) { - const item: AddressTransaction = { + const item: AddressTransactionUTXO = { chain, blockNumber: tx.blockNumber, timestamp: tx.time, From e344186afa7e5f004c85f75bd284f865b82698f6 Mon Sep 17 00:00:00 2001 From: "juraj.bacovcin" Date: Tue, 9 Apr 2024 17:33:55 +0200 Subject: [PATCH 2/2] ALL-5690 Update undici to get rid of vulnerability --- CHANGELOG.md | 3 ++- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82a7ddbad..7aa824023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ -## [4.2.22] - 2024.4.9 +## [4.2.22] - 2024.4.10 ### Fixed - Fixed types for `getTransactions` method in `address` module. +- Updated undici dependency. ## [4.2.21] - 2024.4.4 diff --git a/package.json b/package.json index d42964ffa..cc8679296 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,6 @@ "ts-node": "^10.7.0", "tslib": "^2.5.0", "typescript": "^5.0.4", - "undici": "^5.21.0" + "undici": "^5.28.3" } } diff --git a/yarn.lock b/yarn.lock index 5d0202eae..6db75970a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2855,10 +2855,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici@^5.21.0: - version "5.28.2" - resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.2.tgz#fea200eac65fc7ecaff80a023d1a0543423b4c91" - integrity sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w== +undici@^5.28.3: + version "5.28.4" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" + integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== dependencies: "@fastify/busboy" "^2.0.0"