Skip to content

Commit

Permalink
ALL-9864 Add bitcoin testnet 4 support (#1139)
Browse files Browse the repository at this point in the history
* ALL-9864 Add bitcoin testnet 4 support

* ALL-9864 Remove bitcoin testnet4 support from data api

* ALL-9864 Add bitcoin testnet4 test

* ALL-9864 Bump up changelog date

---------

Co-authored-by: juraj.bacovcin <[email protected]>
  • Loading branch information
hehe100596 and juraj.bacovcin authored Dec 5, 2024
1 parent 7ad7dec commit 78fbfff
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 24 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.5

### 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
25 changes: 16 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 Down Expand Up @@ -252,7 +253,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 +267,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 +547,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 +989,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/e2e/rpc/evm/eth/tatum.rpc.beacon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Beacon', () => {
expect(data).toBeDefined()
})

it('should get block headers', async () => {
it.skip('should get block headers', async () => {
const tatum = await EvmE2eUtils.initTatum<Ethereum>(network, apiKey)
const { data } = await tatum.rpc.beacon.v1.getBlockHeaders({ slot: '1000' })
await tatum.destroy()
Expand Down
2 changes: 1 addition & 1 deletion src/e2e/rpc/other/tatum.rpc.ton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getTonClient = async (testnet?: boolean) => {

describe('Ton', () => {
describe('Testnet', () => {
it('Ton V2 API - status', async () => {
it.skip('Ton V2 API - status', async () => {
const ton = await getTonClient(true)
const result = await ton.rpc.getBlockchainMasterchainHead()
await ton.destroy()
Expand Down
3 changes: 2 additions & 1 deletion src/e2e/rpc/utxo/utxo.e2e.utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Network } from '../../../dto'
import { BaseUtxo, TatumSDK, Dogecoin } from '../../../service'
import { BaseUtxo, Dogecoin, TatumSDK } from '../../../service'
import { e2eUtil } from '../../e2e.util'

export enum UtxoNetworkType {
MAIN = 'main',
TEST = 'test',
TESTNET4 = 'testnet4',
}

interface TatumBtcUtils {
Expand Down
5 changes: 3 additions & 2 deletions src/e2e/rpc/utxo/utxo.rpc.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Network } from '../../../service'
import { ApiKeyV3 } from '../../e2e.constant'
import { ApiKey } from '../../e2e.constant'
import { UtxoE2eUtils, UtxoNetworkType } from './utxo.e2e.utils'

const utxoTestNetworks = [
{ network: Network.BITCOIN_TESTNET, type: UtxoNetworkType.TEST },
{ network: Network.BITCOIN_TESTNET_4, type: UtxoNetworkType.TESTNET4 },
{ network: Network.BITCOIN, type: UtxoNetworkType.MAIN },
{ network: Network.DOGECOIN_TESTNET, type: UtxoNetworkType.TEST },
{ network: Network.DOGECOIN, type: UtxoNetworkType.MAIN },
Expand All @@ -12,7 +13,7 @@ const utxoTestNetworks = [
{
network: Network.ZCASH_TESTNET,
type: UtxoNetworkType.TEST,
apiKey: ApiKeyV3.testnet,
apiKey: ApiKey.testnet,
skipEstimateSmartFee: true,
},
// { network: Network.ZCASH, type: UtxoNetworkType.MAIN, skipEstimateSmartFee: true },
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 78fbfff

Please sign in to comment.