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,