diff --git a/CHANGELOG.md b/CHANGELOG.md index d7548bdc4..996f28597 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [4.2.32] - 2024.6.14 + +### Added + +- Support for Electrs & Rostrum testnet + ## [4.2.31] - 2024.6.3 ### Fixed diff --git a/package.json b/package.json index f47881aaf..003bcc46b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatumio/tatum", - "version": "4.2.31", + "version": "4.2.32", "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 e1d14948f..7ab1d18ae 100644 --- a/src/dto/Network.ts +++ b/src/dto/Network.ts @@ -107,6 +107,8 @@ export enum Network { ZCASH_TESTNET = 'zcash-testnet', ZILLIQA_TESTNET = 'zilliqa-testnet', IOTA_TESTNET = 'iota-testnet', + BITCOIN_ELECTRS_TESTNET = 'bitcoin-testnet-electrs', + ROSTRUM_TESTNET = 'bch-testnet-rostrum', } export const EVM_BASED_NETWORKS = [ @@ -256,9 +258,9 @@ export const CARDANO_NETWORKS = [ ] 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] +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] +export const BITCOIN_ELECTRS_NETWORKS = [Network.BITCOIN_ELECTRS, Network.BITCOIN_ELECTRS_TESTNET] export const IOTA_NETWORKS = [Network.IOTA, Network.IOTA_TESTNET] export const LOAD_BALANCER_NETWORKS = [ @@ -923,6 +925,10 @@ export const NETWORK_METADATA: Record = { currency: Currency.BCH, testnet: false, }, + [Network.ROSTRUM_TESTNET]: { + currency: Currency.BCH, + testnet: true, + }, [Network.IOTA]: { currency: Currency.IOTA, testnet: false, @@ -937,4 +943,8 @@ export const NETWORK_METADATA: Record = { currency: Currency.BTC, testnet: false, }, + [Network.BITCOIN_ELECTRS_TESTNET]: { + currency: Currency.BTC, + testnet: true, + }, } diff --git a/src/e2e/rpc/other/tatum.rpc.electrs.spec.ts b/src/e2e/rpc/other/tatum.rpc.electrs.spec.ts index e3582b800..c2d242ff5 100644 --- a/src/e2e/rpc/other/tatum.rpc.electrs.spec.ts +++ b/src/e2e/rpc/other/tatum.rpc.electrs.spec.ts @@ -1,12 +1,15 @@ import { Network, BitcoinElectrs, TatumSDK } from '../../../service' import { e2eUtil } from '../../e2e.util' -const getElectrsRpc = async () => await TatumSDK.init(e2eUtil.initConfig(Network.BITCOIN_ELECTRS)) +const getElectrsRpc = async (testnet: boolean) => await TatumSDK.init(e2eUtil.initConfig(testnet ? Network.BITCOIN_ELECTRS_TESTNET : Network.BITCOIN_ELECTRS)) -describe('Electrs', () => { +describe.each([ + [true], + [false] +])('Electrs (%s)', (testnet) => { it('blockchain.headers.subscribe', async () => { - const electrs = await getElectrsRpc() + const electrs = await getElectrsRpc(testnet) const result = await electrs.rpc.blockchainHeadersSubscribe() await electrs.destroy() expect(result.result?.hex).toBeDefined() @@ -14,7 +17,7 @@ describe('Electrs', () => { }) it('server.banner', async () => { - const electrs = await getElectrsRpc() + const electrs = await getElectrsRpc(testnet) const result = await electrs.rpc.serverBanner() await electrs.destroy() expect(result.result).toBeDefined() diff --git a/src/e2e/rpc/other/tatum.rpc.rostrum.spec.ts b/src/e2e/rpc/other/tatum.rpc.rostrum.spec.ts index ad095d855..0875f7ea1 100644 --- a/src/e2e/rpc/other/tatum.rpc.rostrum.spec.ts +++ b/src/e2e/rpc/other/tatum.rpc.rostrum.spec.ts @@ -1,11 +1,15 @@ import { Network, Rostrum, TatumSDK } from '../../../service' import { e2eUtil } from '../../e2e.util' -const getRostrumRpc = async () => await TatumSDK.init(e2eUtil.initConfig(Network.ROSTRUM)) +const getRostrumRpc = async (testnet: boolean) => await TatumSDK.init(e2eUtil.initConfig(testnet ? Network.ROSTRUM_TESTNET : Network.ROSTRUM)) + +// Testnet will be added later +describe.each([ + [false] +])('Rostrum (%s)', (testnet) => { -describe('Rostrum', () => { it('server.version', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.serverVersion({ client_name: '1.9.5', protocol_version: '0.6', @@ -16,7 +20,7 @@ describe('Rostrum', () => { }) it('blockchain.headers.tip', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainHeadersTip() await rostrum.destroy() expect(result.result?.hex).toBeDefined() @@ -24,7 +28,7 @@ describe('Rostrum', () => { }) it('blockchain.headers.subscribe', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainHeadersSubscribe() await rostrum.destroy() expect(result.result?.hex).toBeDefined() @@ -32,7 +36,7 @@ describe('Rostrum', () => { }) it('blockchain.address.get_balance', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainAddressGetBalance({ address: 'qrmfkegyf83zh5kauzwgygf82sdahd5a55x9wse7ve', }) @@ -42,7 +46,7 @@ describe('Rostrum', () => { }) it('blockchain.address.get_history', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainAddressGetHistory({ address: 'qrmfkegyf83zh5kauzwgygf82sdahd5a55x9wse7ve', }) @@ -51,21 +55,21 @@ describe('Rostrum', () => { }) it('blockchain.block.get', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainBlockGet(800000) await rostrum.destroy() expect(result.result).toBeDefined() }) it('blockchain.block.header', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainBlockHeader({ height: 800000 }) await rostrum.destroy() expect(result.result).toBeDefined() }) it('blockchain.transaction.get', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.blockchainTransactionGet({ tx_hash: '05ad7b2bd59e33df49827f2a62002b8f5cccb2a6dc5d96e87089bee9d2f705e2', }) @@ -74,7 +78,7 @@ describe('Rostrum', () => { }) it('server.banner', async () => { - const rostrum = await getRostrumRpc() + const rostrum = await getRostrumRpc(testnet) const result = await rostrum.rpc.serverBanner() await rostrum.destroy() expect(result.result).toBeDefined() diff --git a/src/util/constant.ts b/src/util/constant.ts index 0a23f9e76..40b28974f 100644 --- a/src/util/constant.ts +++ b/src/util/constant.ts @@ -123,7 +123,9 @@ export const Constant = { [Network.COSMONS_ROSETTA]: 18, [Network.IOTA]: 18, [Network.IOTA_TESTNET]: 18, - [Network.BITCOIN_ELECTRS]: 18 + [Network.BITCOIN_ELECTRS]: 18, + [Network.BITCOIN_ELECTRS_TESTNET]: 18, + [Network.ROSTRUM_TESTNET]: 18 }, CURRENCY_NAMES: { [Network.BITCOIN]: 'BTC', @@ -227,7 +229,9 @@ export const Constant = { [Network.COSMONS_ROSETTA]: 'ATOM', [Network.IOTA]: 'IOTA', [Network.IOTA_TESTNET]: 'IOTA', - [Network.BITCOIN_ELECTRS]: 'BTC' + [Network.BITCOIN_ELECTRS]: 'BTC', + [Network.BITCOIN_ELECTRS_TESTNET]: 'BTC', + [Network.ROSTRUM_TESTNET]: 'BCH' }, RPC: { MAINNETS: [ diff --git a/src/util/util.shared.ts b/src/util/util.shared.ts index c5dd33fe3..ab6b4e5a6 100644 --- a/src/util/util.shared.ts +++ b/src/util/util.shared.ts @@ -844,11 +844,13 @@ export const Utils = { case Network.KADENA_TESTNET: return new Kadena(id) as T case Network.ROSTRUM: + case Network.ROSTRUM_TESTNET: return new Rostrum(id) as T case Network.IOTA: case Network.IOTA_TESTNET: return new Iota(id) as T case Network.BITCOIN_ELECTRS: + case Network.BITCOIN_ELECTRS_TESTNET: return new BitcoinElectrs(id) as T default: return new FullSdk(id) as T