Skip to content

Commit

Permalink
ALL-9864 Add bitcoin testnet 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj.bacovcin committed Dec 3, 2024
1 parent 7ad7dec commit 9f0f74a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [4.2.44] - 2024.12.4

### Added

- Support for Bitcoin Testnet 4

## [4.2.43] - 2024.10.11

### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
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": "@tatumio/tatum",
"version": "4.2.43",
"version": "4.2.44",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
1 change: 1 addition & 0 deletions src/api/api.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type Chain =
export type ChainUtxoEnum =
| 'bitcoin'
| 'bitcoin-testnet'
| 'bitcoin-testnet4'
| 'litecoin'
| 'litecoin-testnet'
| 'doge'
Expand Down
1 change: 1 addition & 0 deletions src/dto/Currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 18 additions & 9 deletions src/dto/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -544,6 +549,10 @@ export const NETWORK_METADATA: Record<Network, NetworkMetadata> = {
testnet: true,
defaultTestnet: true,
},
[Network.BITCOIN_TESTNET_4]: {
currency: Currency.BTC,
testnet: true,
},
[Network.LITECOIN]: {
currency: Currency.LTC,
testnet: false,
Expand Down Expand Up @@ -982,16 +991,16 @@ export const NETWORK_METADATA: Record<Network, NetworkMetadata> = {
},
[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,
},
}
2 changes: 1 addition & 1 deletion src/service/address/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
3 changes: 3 additions & 0 deletions src/util/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 12 additions & 9 deletions src/util/util.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,51 +98,52 @@ 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'
import { UtxoLoadBalancerRpcEstimateFee } from '../service/rpc/utxo/UtxoLoadBalancerRpcEstimateFee'
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: <T>(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
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9f0f74a

Please sign in to comment.