Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALL-1506 - Fix EVM tatum.address.spec.ts tests #842

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion src/dto/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ 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,
]
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
13 changes: 7 additions & 6 deletions src/service/address/address.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from 'bignumber.js'
import { Container, Service } from 'typedi'

Check warning on line 2 in src/service/address/address.ts

View workflow job for this annotation

GitHub Actions / test

'Service' is defined but never used
import { ApiBalanceRequest } from '../../api/api.dto'
import { TatumConnector } from '../../connector/tatum.connector'
import {
Expand All @@ -20,7 +20,7 @@
},
transient: true,
})
export class Address {

Check warning on line 23 in src/service/address/address.ts

View workflow job for this annotation

GitHub Actions / test

'Address' is defined but never used
private readonly connector: TatumConnector
private readonly config: TatumConfig

Expand All @@ -39,6 +39,8 @@
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 @@
})
}

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
8 changes: 0 additions & 8 deletions src/service/notification/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ export class Subscribe {
): Promise<ResponseDto<AddressBasedNotification>> {
return ErrorUtils.tryFail(async () => {
const chain = Utils.mapNetworkToNotificationChain(this.config.network)
console.log({
type: type,
attr: {
chain,
address,
url,
},
})
const { id } = await this.connector.post<IdDto>({
path: 'subscription',
body: {
Expand Down
Loading