Skip to content

Commit

Permalink
ALL-1478 refactor AddressTron service
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverjantar committed Aug 16, 2023
1 parent 2a53d32 commit 90e2e54
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 113 deletions.
15 changes: 9 additions & 6 deletions src/dto/shared.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ export interface TokenIdContractAddress extends TokenAddress {
tokenId: string
}

export interface AddressBalanceDetails {
/**
* List of addresses to check.
*/
addresses: string[]
export interface AddressBalanceDetails extends AddressBalanceFilters {
/**
* Optional page size. If not specified, the default page size is used, which is 10.
*/
Expand All @@ -31,13 +27,20 @@ export interface AddressBalanceDetails {
page?: number
}

export interface AddressBalanceDetailsTezos {
export interface AddressBalanceFilters {
/**
* List of addresses to check.
*/
addresses: string[]
}

export interface AddressBalanceFiltersTron {
/**
* Addresses to check.
*/
address: string
}

export interface TokenDetails {
/**
* Name of the token
Expand Down
52 changes: 50 additions & 2 deletions src/e2e/tatum.address.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { Network } from '../dto'
import { BaseTatumSdk, Bitcoin, Dogecoin, Ethereum, Litecoin, Solana, TatumSDK, Tezos, Xrp } from '../service'
import {
ApiVersion,
BaseTatumSdk,
Bitcoin,
Dogecoin,
Ethereum,
Litecoin,
Solana,
TatumSDK,
Tezos,
Tron,
Xrp,
} from '../service'
import { Status } from '../util'

describe('Address', () => {
Expand Down Expand Up @@ -242,7 +254,6 @@ describe('Address', () => {
beforeEach(async () => {
tatum = await TatumSDK.init<Tezos>({
network: Network.TEZOS,
apiKey: { v2: process.env.V2_API_KEY },
})
})

Expand Down Expand Up @@ -281,6 +292,43 @@ describe('Address', () => {
})
})
})

describe('getBalance Tron', () => {
let tatum: Tron

beforeEach(async () => {
tatum = await TatumSDK.init<Tron>({
network: Network.TRON_SHASTA,
version: ApiVersion.V1,
})
})

afterEach(() => {
tatum.destroy()
})

it('should get balance with native and erc20 assets', async () => {
const { data } = await tatum.address.getBalance({
address: 'TBhC4DefkF79z1B8MBbXRjAhMsWk5r3VLf',
})
console.log(data)
expect(data.length).toBeGreaterThan(1)
expect(data[0]).toStrictEqual({
asset: 'TRX',
decimals: 6,
address: 'TBhC4DefkF79z1B8MBbXRjAhMsWk5r3VLf',
balance: expect.any(String),
type: 'native',
})
expect(data[1]).toStrictEqual({
asset: 'ANK',
decimals: 6,
address: 'TBhC4DefkF79z1B8MBbXRjAhMsWk5r3VLf',
balance: expect.any(String),
type: 'fungible',
})
})
})
})

describe('getTransactions', () => {
Expand Down
Loading

0 comments on commit 90e2e54

Please sign in to comment.