From 9f0f74a0042e1848d92d8f6d324277419ae8a45e Mon Sep 17 00:00:00 2001 From: "juraj.bacovcin" Date: Tue, 3 Dec 2024 18:49:06 +0100 Subject: [PATCH] ALL-9864 Add bitcoin testnet 4 support --- CHANGELOG.md | 6 ++++++ README.md | 1 + package.json | 2 +- src/api/api.dto.ts | 1 + src/dto/Currency.ts | 1 + src/dto/Network.ts | 27 ++++++++++++++++++--------- src/service/address/address.ts | 2 +- src/util/constant.ts | 3 +++ src/util/util.shared.ts | 21 ++++++++++++--------- 9 files changed, 44 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85566ada7..98b86c2de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [4.2.44] - 2024.12.4 + +### Added + +- Support for Bitcoin Testnet 4 + ## [4.2.43] - 2024.10.11 ### Fixed diff --git a/README.md b/README.md index d5614dfde..10520cc14 100644 --- a/README.md +++ b/README.md @@ -435,6 +435,7 @@ This section provides a list of various blockchain network status pages, powered |--------------------------------------------------------------------------------------------------------------| | [bitcoin-mainnet.status.tatum.io](https://bitcoin-mainnet.status.tatum.io) | | [bitcoin-testnet.status.tatum.io](https://bitcoin-testnet.status.tatum.io) | +| [bitcoin-testnet4.status.tatum.io](https://bitcoin-testnet4.status.tatum.io) | | [dogecoin-mainnet.status.tatum.io](https://dogecoin-mainnet.status.tatum.io) | | [dogecoin-testnet.status.tatum.io](https://dogecoin-testnet.status.tatum.io) | | [eos-mainnet-archive.status.tatum.io](https://eos-mainnet-archive.status.tatum.io) | diff --git a/package.json b/package.json index 80de8c801..d1df29cab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatumio/tatum", - "version": "4.2.43", + "version": "4.2.44", "description": "Tatum JS SDK", "author": "Tatum", "repository": "https://github.com/tatumio/tatum-js", diff --git a/src/api/api.dto.ts b/src/api/api.dto.ts index 901a42503..e929c1e0a 100644 --- a/src/api/api.dto.ts +++ b/src/api/api.dto.ts @@ -19,6 +19,7 @@ export type Chain = export type ChainUtxoEnum = | 'bitcoin' | 'bitcoin-testnet' + | 'bitcoin-testnet4' | 'litecoin' | 'litecoin-testnet' | 'doge' diff --git a/src/dto/Currency.ts b/src/dto/Currency.ts index 72207746c..b8036dcbc 100644 --- a/src/dto/Currency.ts +++ b/src/dto/Currency.ts @@ -63,6 +63,7 @@ export function networkToCurrency(network: Network): Currency { return Currency.ETH case Network.BITCOIN: case Network.BITCOIN_TESTNET: + case Network.BITCOIN_TESTNET_4: return Currency.BTC case Network.DOGECOIN: case Network.DOGECOIN_TESTNET: diff --git a/src/dto/Network.ts b/src/dto/Network.ts index 2a530e611..1011871b3 100644 --- a/src/dto/Network.ts +++ b/src/dto/Network.ts @@ -59,7 +59,6 @@ export enum Network { TON = 'ton-mainnet', ZK_SYNC = 'zksync-mainnet', - // Testnets ALGORAND_ALGOD_TESTNET = 'algorand-testnet-algod', ALGORAND_INDEXER_TESTNET = 'algorand-testnet-indexer', @@ -71,6 +70,7 @@ export enum Network { BASE_SEPOLIA = 'base-sepolia', BINANCE_SMART_CHAIN_TESTNET = 'bsc-testnet', BITCOIN_TESTNET = 'bitcoin-testnet', + BITCOIN_TESTNET_4 = 'bitcoin-testnet4', BITCOIN_CASH_TESTNET = 'bch-testnet', CARDANO_ROSETTA_PREPROD = 'cardano-preprod', CELO_ALFAJORES = 'celo-testnet', @@ -172,6 +172,7 @@ export const EVM_BASED_NETWORKS = [ export const UTXO_BASED_NETWORKS = [ Network.BITCOIN, Network.BITCOIN_TESTNET, + Network.BITCOIN_TESTNET_4, Network.BITCOIN_CASH, Network.BITCOIN_CASH_TESTNET, Network.LITECOIN, @@ -187,6 +188,7 @@ export const UTXO_ESTIMATE_FEE_NETWORKS = [Network.BITCOIN_CASH_TESTNET] export const DATA_API_UTXO_NETWORKS = [ Network.BITCOIN, Network.BITCOIN_TESTNET, + Network.BITCOIN_TESTNET_4, Network.LITECOIN, Network.LITECOIN_TESTNET, Network.CARDANO_ROSETTA, @@ -212,6 +214,7 @@ export const DATA_API_NETWORKS = [...DATA_API_EVM_NETWORKS, Network.TEZOS] export const UTXO_LOAD_BALANCER_NETWORKS = [ Network.BITCOIN, Network.BITCOIN_TESTNET, + Network.BITCOIN_TESTNET_4, Network.LITECOIN, Network.LITECOIN_TESTNET, Network.ZCASH, @@ -252,7 +255,6 @@ export const EVM_LOAD_BALANCER_NETWORKS = [ ...ZK_SYNC_LOAD_BALANCER_NETWORKS, ] - export const TRON_LOAD_BALANCER_NETWORKS = [Network.TRON] export const EOS_LOAD_BALANCER_NETWORKS = [Network.EOS] export const XRP_LOAD_BALANCER_NETWORKS = [Network.XRP, Network.XRP_TESTNET] @@ -267,12 +269,15 @@ export const CARDANO_NETWORKS = [ Network.CARDANO_ROSETTA_PREPROD, Network.COSMOS_ROSETTA, ] -export const COSMOS_NETWORKS = [ - Network.COSMOS_ROSETTA, -] +export const COSMOS_NETWORKS = [Network.COSMOS_ROSETTA] export const STELLAR_LOAD_BALANCER_NETWORKS = [Network.STELLAR] export const KADENA_LOAD_BALANCER_NETWORKS = [Network.KADENA, Network.KADENA_TESTNET] -export const ROSTRUM_LOAD_BALANCER_NETWORKS = [Network.ROSTRUM, Network.BITCOIN_ELECTRS, Network.ROSTRUM_TESTNET, Network.BITCOIN_ELECTRS_TESTNET] +export const ROSTRUM_LOAD_BALANCER_NETWORKS = [ + Network.ROSTRUM, + Network.BITCOIN_ELECTRS, + Network.ROSTRUM_TESTNET, + Network.BITCOIN_ELECTRS_TESTNET, +] export const IOTA_LOAD_BALANCER_NETWORKS = [Network.IOTA] export const BITCOIN_ELECTRS_NETWORKS = [Network.BITCOIN_ELECTRS, Network.BITCOIN_ELECTRS_TESTNET] export const IOTA_NETWORKS = [Network.IOTA, Network.IOTA_TESTNET] @@ -544,6 +549,10 @@ export const NETWORK_METADATA: Record = { testnet: true, defaultTestnet: true, }, + [Network.BITCOIN_TESTNET_4]: { + currency: Currency.BTC, + testnet: true, + }, [Network.LITECOIN]: { currency: Currency.LTC, testnet: false, @@ -982,16 +991,16 @@ export const NETWORK_METADATA: Record = { }, [Network.TON_TESTNET]: { currency: Currency.TON, - testnet: true + testnet: true, }, [Network.ZK_SYNC]: { currency: Currency.ZKS, testnet: false, - chainId: 324 + chainId: 324, }, [Network.ZK_SYNC_TESTNET]: { currency: Currency.ZKS, testnet: true, - chainId: 300 + chainId: 300, }, } diff --git a/src/service/address/address.ts b/src/service/address/address.ts index 3a6496d7b..a550c22f3 100644 --- a/src/service/address/address.ts +++ b/src/service/address/address.ts @@ -324,7 +324,7 @@ export class Address { .then((r) => r.result) } let path - if ([Network.BITCOIN, Network.BITCOIN_TESTNET].includes(chain)) { + if ([Network.BITCOIN, Network.BITCOIN_TESTNET, Network.BITCOIN_TESTNET_4].includes(chain)) { path = `bitcoin/transaction/address/${address}` } else if ([Network.LITECOIN, Network.LITECOIN_TESTNET].includes(chain)) { path = `litecoin/transaction/address/${address}` diff --git a/src/util/constant.ts b/src/util/constant.ts index c3cade2f0..cc30c99e7 100644 --- a/src/util/constant.ts +++ b/src/util/constant.ts @@ -24,6 +24,7 @@ export const Constant = { DECIMALS: { [Network.BITCOIN]: 8, [Network.BITCOIN_TESTNET]: 8, + [Network.BITCOIN_TESTNET_4]: 8, [Network.MULTIVERSX]: 18, [Network.MULTIVERSX_TESTNET]: 18, [Network.NEAR]: 24, @@ -135,6 +136,7 @@ export const Constant = { CURRENCY_NAMES: { [Network.BITCOIN]: 'BTC', [Network.BITCOIN_TESTNET]: 'BTC', + [Network.BITCOIN_TESTNET_4]: 'BTC', [Network.NEAR]: 'NEAR', [Network.NEAR_TESTNET]: 'NEAR', [Network.MULTIVERSX]: 'EGLD', @@ -297,6 +299,7 @@ export const Constant = { Network.AVALANCHE_X_TESTNET, Network.BINANCE_SMART_CHAIN_TESTNET, Network.BITCOIN_TESTNET, + Network.BITCOIN_TESTNET_4, Network.BITCOIN_CASH_TESTNET, Network.CARDANO_ROSETTA_PREPROD, Network.CELO_ALFAJORES, diff --git a/src/util/util.shared.ts b/src/util/util.shared.ts index 921d82fb2..de002bc6f 100644 --- a/src/util/util.shared.ts +++ b/src/util/util.shared.ts @@ -98,26 +98,32 @@ import { Vechain, XinFin, Xrp, - ZCash, ZkSync, + ZCash, + ZkSync, } from '../service' import { EvmArchiveLoadBalancerRpc } from '../service/rpc/evm/EvmArchiveLoadBalancerRpc' import { EvmBeaconArchiveLoadBalancerRpc } from '../service/rpc/evm/EvmBeaconArchiveLoadBalancerRpc' import { NativeEvmArchiveLoadBalancerRpc } from '../service/rpc/evm/NativeEvmArchiveLoadBalancerRpc' import { TronLoadBalancerRpc } from '../service/rpc/evm/TronLoadBalancerRpc' import { TronRpc } from '../service/rpc/evm/TronRpc' +import { ZkSyncLoadBalancerRpc } from '../service/rpc/evm/ZkSyncLoadBalancerRpc' import { AlgorandAlgodLoadBalancerRpc } from '../service/rpc/other/AlgorandAlgodLoadBalancerRpc' import { AlgorandIndexerLoadBalancerRpc } from '../service/rpc/other/AlgorandIndexerLoadBalancerRpc' import { BnbLoadBalancerRpc } from '../service/rpc/other/BnbLoadBalancerRpc' import { CardanoLoadBalancerRpc } from '../service/rpc/other/CardanoLoadBalancerRpc' +import { CasperLoadBalancerRpc } from '../service/rpc/other/CasperLoadBalancerRpc' +import { CosmosLoadBalancerRpc } from '../service/rpc/other/CosmosLoadBalancerRpc' import { EosLoadBalancerRpc } from '../service/rpc/other/EosLoadBalancerRpc' import { EosRpc } from '../service/rpc/other/EosRpc' import { IotaLoadBalancerRpc } from '../service/rpc/other/IotaLoadBalancerRpc' +import { IotaRpc } from '../service/rpc/other/IotaRpc' import { KadenaLoadBalancerRpc } from '../service/rpc/other/KadenaLoadBalancerRpc' import { RostrumLoadBalancerRpc } from '../service/rpc/other/RostrumLoadBalancerRpc' import { SolanaArchiveLoadBalancerRpc } from '../service/rpc/other/SolanaArchiveLoadBalancerRpc' import { StellarLoadBalancerRpc } from '../service/rpc/other/StellarLoadBalancerRpc' import { StellarRpc } from '../service/rpc/other/StellarRpc' import { TezosLoadBalancerRpc } from '../service/rpc/other/TezosLoadBalancerRpc' +import { TonRpc } from '../service/rpc/other/TonRpc' import { XrpLoadBalancerRpc } from '../service/rpc/other/XrpLoadBalancerRpc' import { DogeLoadBalancedRpc } from '../service/rpc/utxo/DogeLoadBalancedRpc' import { UtxoLoadBalancerRpc } from '../service/rpc/utxo/UtxoLoadBalancerRpc' @@ -125,24 +131,19 @@ import { UtxoLoadBalancerRpcEstimateFee } from '../service/rpc/utxo/UtxoLoadBala import { UtxoRpcEstimateFee } from '../service/rpc/utxo/UtxoRpcEstimateFee' import { Constant } from './constant' import { CONFIG, LOGGER } from './di.tokens' -import { IotaRpc } from '../service/rpc/other/IotaRpc' -import { CosmosLoadBalancerRpc } from '../service/rpc/other/CosmosLoadBalancerRpc' -import { CasperLoadBalancerRpc } from '../service/rpc/other/CasperLoadBalancerRpc' -import { TonRpc } from '../service/rpc/other/TonRpc' -import { ZkSyncLoadBalancerRpc } from '../service/rpc/evm/ZkSyncLoadBalancerRpc' export const Utils = { getRpc: (id: string, config: TatumConfig): T => { const { network } = config - if(isZkSyncNetwork(network)) { + if (isZkSyncNetwork(network)) { return Container.of(id).get(ZkSyncLoadBalancerRpc) as T } - if(isTonNetwork(network)) { + if (isTonNetwork(network)) { return Container.of(id).get(TonRpc) as T } - if(isCasperNetwork(network)) { + if (isCasperNetwork(network)) { return Container.of(id).get(CasperLoadBalancerRpc) as T } @@ -602,6 +603,7 @@ export const Utils = { switch (network) { case Network.BITCOIN: case Network.BITCOIN_TESTNET: + case Network.BITCOIN_TESTNET_4: return AddressEventNotificationChain.BTC case Network.BITCOIN_CASH: case Network.BITCOIN_CASH_TESTNET: @@ -787,6 +789,7 @@ export const Utils = { switch (network) { case Network.BITCOIN: case Network.BITCOIN_TESTNET: + case Network.BITCOIN_TESTNET_4: return new Bitcoin(id) as T case Network.LITECOIN: case Network.LITECOIN_TESTNET: