diff --git a/src/app/features/add-network/network-form-fields.tsx b/src/app/features/add-network/network-form-fields.tsx index b69ee6c0147..1ae0d7111ae 100644 --- a/src/app/features/add-network/network-form-fields.tsx +++ b/src/app/features/add-network/network-form-fields.tsx @@ -6,7 +6,9 @@ import { HStack, styled } from 'leather-styles/jsx'; import { BITCOIN_API_BASE_URL_MAINNET, - BITCOIN_API_BASE_URL_TESTNET, + BITCOIN_API_BASE_URL_TESTNET3, + BITCOIN_API_BASE_URL_TESTNET4, + type BitcoinNetwork, type BitcoinNetworkModes, } from '@leather.io/models'; import { @@ -24,15 +26,19 @@ import { type AddNetworkFormValues } from './use-add-network'; const networks: { label: string; - value: BitcoinNetworkModes; + value: BitcoinNetwork; }[] = [ { label: 'Mainnet', value: 'mainnet', }, { - label: 'Testnet', - value: 'testnet', + label: 'Testnet3', + value: 'testnet3', + }, + { + label: 'Testnet4', + value: 'testnet4', }, { label: 'Signet', @@ -66,15 +72,20 @@ export function NetworkFormFields({ isEditNetworkMode }: NetworkFormFieldsProps) [setFieldValue] ); - function setNetworkUrls(value: BitcoinNetworkModes) { + function setNetworkUrls(value: BitcoinNetwork | BitcoinNetworkModes) { switch (value) { case 'mainnet': setStacksUrl('https://api.hiro.so'); setBitcoinUrl(BITCOIN_API_BASE_URL_MAINNET); break; case 'testnet': + case 'testnet3': + setStacksUrl('https://api.testnet.hiro.so'); + setBitcoinUrl(BITCOIN_API_BASE_URL_TESTNET3); + break; + case 'testnet4': setStacksUrl('https://api.testnet.hiro.so'); - setBitcoinUrl(BITCOIN_API_BASE_URL_TESTNET); + setBitcoinUrl(BITCOIN_API_BASE_URL_TESTNET4); break; case 'signet': setStacksUrl('https://api.testnet.hiro.so'); @@ -112,7 +123,7 @@ export function NetworkFormFields({ isEditNetworkMode }: NetworkFormFieldsProps) { + onValueChange={(value: BitcoinNetwork) => { setNetworkUrls(value); void setFieldValue('bitcoinNetwork', value); }} diff --git a/src/app/store/networks/networks.utils.ts b/src/app/store/networks/networks.utils.ts index 0ac60b138c7..691b5c8a3f6 100644 --- a/src/app/store/networks/networks.utils.ts +++ b/src/app/store/networks/networks.utils.ts @@ -2,7 +2,7 @@ import { ChainID } from '@stacks/transactions'; import { BITCOIN_API_BASE_URL_MAINNET, - BITCOIN_API_BASE_URL_TESTNET, + BITCOIN_API_BASE_URL_TESTNET3, type NetworkConfiguration, } from '@leather.io/models'; @@ -54,7 +54,7 @@ function checkBitcoinNetworkProperties( bitcoinUrl: network.chainId === ChainID.Mainnet ? BITCOIN_API_BASE_URL_MAINNET - : BITCOIN_API_BASE_URL_TESTNET, + : BITCOIN_API_BASE_URL_TESTNET3, }; } else { return network; @@ -86,7 +86,7 @@ export function transformNetworkStateToMultichainStucture( bitcoin: { blockchain: 'bitcoin', bitcoinNetwork: bitcoinNetwork ? bitcoinNetwork : 'testnet', - bitcoinUrl: bitcoinUrl ? bitcoinUrl : BITCOIN_API_BASE_URL_TESTNET, + bitcoinUrl: bitcoinUrl ? bitcoinUrl : BITCOIN_API_BASE_URL_TESTNET3, }, }, }, diff --git a/tests/mocks/mock-utxos.ts b/tests/mocks/mock-utxos.ts index 1a85499fc62..ef44bdb90c6 100644 --- a/tests/mocks/mock-utxos.ts +++ b/tests/mocks/mock-utxos.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test'; -import { BITCOIN_API_BASE_URL_TESTNET } from '@leather.io/models'; +import { BITCOIN_API_BASE_URL_TESTNET3 } from '@leather.io/models'; import { TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS } from './constants'; @@ -133,7 +133,7 @@ export async function mockMainnetTestAccountBitcoinRequests(page: Page) { } export async function mockTestnetTestAccountEmptyUtxosRequests(page: Page) { - await page.route(`${BITCOIN_API_BASE_URL_TESTNET}/address/**/utxo`, route => + await page.route(`${BITCOIN_API_BASE_URL_TESTNET3}/address/**/utxo`, route => route.fulfill({ json: [], }) diff --git a/tests/specs/network/add-network.spec.ts b/tests/specs/network/add-network.spec.ts index ff989ab4dbf..49fb2517bb8 100644 --- a/tests/specs/network/add-network.spec.ts +++ b/tests/specs/network/add-network.spec.ts @@ -1,7 +1,7 @@ import { NetworkSelectors } from '@tests/selectors/network.selectors'; import { SettingsSelectors } from '@tests/selectors/settings.selectors'; -import { BITCOIN_API_BASE_URL_TESTNET } from '@leather.io/models'; +import { BITCOIN_API_BASE_URL_TESTNET3 } from '@leather.io/models'; import { test } from '../../fixtures/fixtures'; @@ -23,7 +23,7 @@ test.describe('Networks tests', () => { const bitcoinUrl = page.getByTestId(NetworkSelectors.NetworkBitcoinAddress); - test.expect(await bitcoinUrl.inputValue()).toEqual(BITCOIN_API_BASE_URL_TESTNET); + test.expect(await bitcoinUrl.inputValue()).toEqual(BITCOIN_API_BASE_URL_TESTNET3); }); test('validation error when stacks api url is empty', async ({ networkPage }) => {