Skip to content

Commit

Permalink
ALL-1506 - Fix EVM tatum.address.spec.ts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel committed Jun 20, 2023
1 parent d1c9da6 commit d4eabf6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.5.2] - 2023.06.20
### Changed
- Fixed EVM tatum.address.spec.ts tests

## [1.5.1] - 2023.06.20
### Changed
- Fixed docs links to make it working in the /docs folder
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": "@tatumcom/js",
"version": "1.5.1",
"version": "1.5.2",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
5 changes: 2 additions & 3 deletions src/dto/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ export const EVM_LOAD_BALANCER_NETWORKS = [
Network.FLARE_SONGBIRD,
Network.HAQQ,
Network.HAQQ_TESTNET,
// TODO: uncomment once it will work
// Network.ETHEREUM,
// Network.ETHEREUM_SEPOLIA,
Network.ETHEREUM,
Network.ETHEREUM_SEPOLIA,
]

export const LOAD_BALANCER_NETWORKS = [
Expand Down
4 changes: 1 addition & 3 deletions src/e2e/e2e.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ export const e2eUtil = {
url,
address,
})
console.log(data)
console.log(error)

if (error) {
console.log(error)
throw new Error(error.message.join(','))
}

Expand Down
2 changes: 1 addition & 1 deletion src/e2e/rpc/tatum.rpc.ethereum.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Network } from '../../service'
import { EvmE2eUtils } from './evm.e2e.utils'

describe('Ethereum', () => {
describe.skip('Ethereum', () => {
describe('mainnet', () => {
EvmE2eUtils.e2e({ network: Network.ETHEREUM, chainId: 1 })
})
Expand Down
13 changes: 7 additions & 6 deletions src/service/address/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class Address {
addresses,
}: AddressBalanceDetails): Promise<ResponseDto<AddressBalance[]>> {
const chain = this.config.network
const address = await this.getNativeBalance(addresses)
console.log(address)
return ErrorUtils.tryFail(async () => {
const [nativeBalances, tokenBalances] = await Promise.all([
this.getNativeBalance(addresses),
Expand Down Expand Up @@ -232,15 +234,14 @@ export class Address {
})
}

private getNativeBalance(addresses: string[]): Promise<string[]> {
private async getNativeBalance(addresses: string[]): Promise<string[]> {
const network = this.config.network
if (isEvmBasedNetwork(network)) {
const rpc = Utils.getRpc<EvmBasedRpc>(this.id, network)
return rpc
.rawBatchRpcCall(addresses.map((a, i) => Utils.prepareRpcCall('eth_getBalance', [a, 'pending'], i)))
.then((r) =>
r.map((e) => new BigNumber(e.result).dividedBy(10 ** Constant.DECIMALS[network]).toString()),
)
const result = await Promise.all(addresses.map((a, i) => rpc.rawRpcCall(Utils.prepareRpcCall('eth_getBalance', [a, 'pending'], i))))
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return result.map((e) => new BigNumber(e.result).dividedBy(10 ** Constant.DECIMALS[network]).toString())
}
if ([Network.SOLANA, Network.SOLANA_DEVNET].includes(network)) {
const rpc = Utils.getRpc<GenericRpc>(this.id, network)
Expand Down

0 comments on commit d4eabf6

Please sign in to comment.