Skip to content

Commit

Permalink
Add filter tokenAddress to getTransactions (#1063)
Browse files Browse the repository at this point in the history
Co-authored-by: oliverjantar <[email protected]>
  • Loading branch information
oliverjantar and oliverjantar authored Feb 15, 2024
1 parent 765ccb3 commit df50c3d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [4.2.8] - 2024.2.15

### Updated

- Updated `address` module for EVM chains. Users can add parameter `tokenAddress` to `getTransactions` method to filter transactions by token address.

## [4.2.7] - 2024.2.12

### Updated
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "4.2.7",
"version": "4.2.8",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
14 changes: 14 additions & 0 deletions src/e2e/tatum.address.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,20 @@ describe.skip('Address', () => {
expect(page2.data).toHaveLength(1)
expect(page2.data[0].hash).not.toBe(page1.data[0].hash)
})

it('should get transactions for specific contract', async () => {
const tokenAddress = '0xdcF5D3E08c5007deCECDb34808C49331bD82a247'
const txs = await tatum.address.getTransactions({
tokenAddress,
address: '0x514D547c8aC8ccBEc29b5144810454BD7d3625CA',
})
expect(txs.status === Status.SUCCESS)
// at least one transaction
expect(txs.data).not.toHaveLength(0)
expect(
txs.data.forEach((tx) => expect(tx.tokenAddress?.toLowerCase()).toBe(tokenAddress.toLowerCase())),
)
})
})
describe('getTransactions BITCOIN', () => {
let tatum: Bitcoin
Expand Down
4 changes: 4 additions & 0 deletions src/service/address/address.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export interface GetAddressTransactionsQuery {
* Optional page number. If not specified, the first page is returned.
*/
page?: number
/**
* Optional token address. If specified, only transactions related to this token (smart contract) are returned.
*/
tokenAddress?: string
}

export interface GetAddressTransactionsQueryTezos {
Expand Down
2 changes: 2 additions & 0 deletions src/service/address/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export class Address {
toBlock,
pageSize = 10,
page = 0,
tokenAddress,
}: GetAddressTransactionsQuery): Promise<ResponseDto<AddressTransaction[]>> {
const chain = this.config.network
return ErrorUtils.tryFail(async () => {
Expand All @@ -301,6 +302,7 @@ export class Address {
blockTo: toBlock,
pageSize,
offset: page,
tokenAddress,
},
})
.then((r) => r.result)
Expand Down

0 comments on commit df50c3d

Please sign in to comment.