diff --git a/CHANGELOG.md b/CHANGELOG.md index 17cc4564ff..74b27a6a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.5.11] - 2023.07.13 +### Changed +- Fix rpc calls without api key & Added haqq archive/non-archive calls + ## [1.5.10] - 2023.07.10 ### Changed - Selected Archive/Non-Archive node for Ethereum RPC calls based on method diff --git a/package.json b/package.json index 5d7c61967e..5a87cb8e4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatumcom/js", - "version": "1.5.10", + "version": "1.5.11", "description": "Tatum JS SDK", "author": "Tatum", "repository": "https://github.com/tatumio/tatum-js", diff --git a/src/dto/Network.ts b/src/dto/Network.ts index 2f1d2ba2d4..c19e654273 100644 --- a/src/dto/Network.ts +++ b/src/dto/Network.ts @@ -199,6 +199,8 @@ export const LOAD_BALANCER_NETWORKS = [...UTXO_LOAD_BALANCER_NETWORKS, ...EVM_LO export const EVM_ARCHIVE_NON_ARCHIVE_LOAD_BALANCER_NETWORKS = [ Network.ETHEREUM, Network.ETHEREUM_SEPOLIA, + Network.HAQQ, + Network.HAQQ_TESTNET, ] export const SOLANA_NETWORKS = [Network.SOLANA, Network.SOLANA_DEVNET] diff --git a/src/service/address/address.ts b/src/service/address/address.ts index 95755cf970..dfa4b90bea 100644 --- a/src/service/address/address.ts +++ b/src/service/address/address.ts @@ -235,7 +235,7 @@ export class Address { private async getNativeBalance(addresses: string[]): Promise { const network = this.config.network if (isEvmBasedNetwork(network)) { - const rpc = Utils.getRpc(this.id, network) + const rpc = Utils.getRpc(this.id, this.config) const result = await Promise.all( addresses.map((a, i) => rpc.rawRpcCall(Utils.prepareRpcCall('eth_getBalance', [a, 'pending'], i))), ) @@ -244,7 +244,7 @@ export class Address { 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(this.id, network) + const rpc = Utils.getRpc(this.id, this.config) return rpc .rawBatchRpcCall( addresses.map((a, i) => Utils.prepareRpcCall('getBalance', [a, { commitment: 'processed' }], i)), @@ -256,7 +256,7 @@ export class Address { if (addresses.length !== 1) { throw new Error(`UTXO based networks like ${network} support only one address per call.`) } - const rpc = Utils.getRpc(this.id, network) + const rpc = Utils.getRpc(this.id, this.config) return rpc .rawRpcCall( Utils.prepareRpcCall('account_info', [ diff --git a/src/service/rpc/evm/EvmArchiveLoadBalancerRpc.ts b/src/service/rpc/evm/EvmArchiveLoadBalancerRpc.ts index 1bec544c14..753aab82f4 100644 --- a/src/service/rpc/evm/EvmArchiveLoadBalancerRpc.ts +++ b/src/service/rpc/evm/EvmArchiveLoadBalancerRpc.ts @@ -60,6 +60,8 @@ export class EvmArchiveLoadBalancerRpc extends AbstractEvmRpc implements EvmBase } private isArchiveMethod(rpc: JsonRpcCall): boolean { + + const isArchiveMethod = ARCHIVE_METHODS.includes(rpc.method) if (isArchiveMethod) { return true diff --git a/src/service/tatum/tatum.ts b/src/service/tatum/tatum.ts index 0092f15a3f..851aed86dc 100644 --- a/src/service/tatum/tatum.ts +++ b/src/service/tatum/tatum.ts @@ -36,7 +36,7 @@ export abstract class BaseUtxoClass extends BaseTatumSdk { constructor(id: string) { super(id) - this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG).network) + this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG)) this.fee = Container.of(id).get(FeeUtxo) } } @@ -46,7 +46,7 @@ export abstract class BaseEvmClass extends BaseTatumSdk { constructor(id: string) { super(id) - this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG).network) + this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG)) } } @@ -91,21 +91,21 @@ export class Xrp extends BaseTatumSdk { rpc: XrpRpcSuite constructor(id: string) { super(id) - this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG).network) + this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG)) } } export class Solana extends BaseTatumSdk { rpc: SolanaRpcSuite constructor(id: string) { super(id) - this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG).network) + this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG)) } } export class Tron extends BaseTatumSdk { rpc: TronRpcSuite constructor(id: string) { super(id) - this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG).network) + this.rpc = Utils.getRpc(id, Container.of(id).get(CONFIG)) } } diff --git a/src/service/walletProvider/metaMask.ts b/src/service/walletProvider/metaMask.ts index aab9aa772c..a4678924a8 100644 --- a/src/service/walletProvider/metaMask.ts +++ b/src/service/walletProvider/metaMask.ts @@ -24,7 +24,7 @@ export class MetaMask { constructor(private readonly id: string) { this.config = Container.of(this.id).get(CONFIG) - this.rpc = Utils.getRpc(this.id, this.config.network) + this.rpc = Utils.getRpc(this.id, this.config) this.connector = Container.of(this.id).get(TatumConnector) } diff --git a/src/util/util.shared.ts b/src/util/util.shared.ts index 4f637a821a..7ff974f949 100644 --- a/src/util/util.shared.ts +++ b/src/util/util.shared.ts @@ -45,7 +45,7 @@ import { Palm, Polygon, Solana, - SolanaRpc, + SolanaRpc, TatumConfig, Tron, TronRpc, UtxoLoadBalancerRpc, @@ -59,12 +59,13 @@ import { CONFIG } from './di.tokens' import { EvmArchiveLoadBalancerRpc } from '../service/rpc/evm/EvmArchiveLoadBalancerRpc' export const Utils = { - getRpc: (id: string, network: Network): T => { + getRpc: (id: string, config: TatumConfig): T => { + const { network, apiKey } = config if (isUtxoLoadBalancerNetwork(network)) { return Container.of(id).get(UtxoLoadBalancerRpc) as T } - if (isEvmArchiveNonArchiveLoadBalancerNetwork(network)) { + if (isEvmArchiveNonArchiveLoadBalancerNetwork(network) && apiKey?.v2) { return Container.of(id).get(EvmArchiveLoadBalancerRpc) as T }