diff --git a/src/types/client-manager.ts b/src/types/client-manager.ts index 8c692f2e..80bf2300 100644 --- a/src/types/client-manager.ts +++ b/src/types/client-manager.ts @@ -11,7 +11,7 @@ import { ResolveAppByIdBase, } from './app-client' import { TestNetDispenserApiClient, TestNetDispenserApiClientParams } from './dispenser-client' -import { AlgoClientConfig, AlgoConfig } from './network-client' +import { AlgoClientConfig, AlgoConfig, genesisIdIsLocalNet } from './network-client' import Kmd = algosdk.Kmd import Indexer = algosdk.Indexer import Algodv2 = algosdk.Algodv2 @@ -129,7 +129,7 @@ export class ClientManager { * @returns Whether the given genesis ID is associated with a LocalNet network */ public static genesisIdIsLocalNet(genesisId: string) { - return genesisId === 'devnet-v1' || genesisId === 'sandnet-v1' || genesisId === 'dockernet-v1' + return genesisIdIsLocalNet(genesisId) } /** diff --git a/src/types/composer.ts b/src/types/composer.ts index e640c3ed..04cb0f99 100644 --- a/src/types/composer.ts +++ b/src/types/composer.ts @@ -2,7 +2,7 @@ import algosdk from 'algosdk' import { encodeLease, encodeTransactionNote, sendAtomicTransactionComposer } from '../transaction/transaction' import { TransactionSignerAccount } from './account' import { AlgoAmount } from './amount' -import { ClientManager } from './client-manager' +import { genesisIdIsLocalNet } from './network-client' import { SendAtomicTransactionComposerResults } from './transaction' import Transaction = algosdk.Transaction import TransactionWithSigner = algosdk.TransactionWithSigner @@ -601,9 +601,7 @@ export default class AlgoKitComposer { // LocalNet set a bigger window to avoid dead transactions const window = params.validityWindow ?? - (!this.defaultValidityWindowIsExplicit && ClientManager.genesisIdIsLocalNet(suggestedParams.genesisID) - ? 1000 - : this.defaultValidityWindow) + (!this.defaultValidityWindowIsExplicit && genesisIdIsLocalNet(suggestedParams.genesisID) ? 1000 : this.defaultValidityWindow) txn.lastRound = txn.firstRound + window } diff --git a/src/types/network-client.ts b/src/types/network-client.ts index 2b371d18..61a091d7 100644 --- a/src/types/network-client.ts +++ b/src/types/network-client.ts @@ -19,3 +19,12 @@ export interface AlgoConfig { /** Kmd configuration */ kmdConfig?: AlgoClientConfig } + +/** + * Returns true if the given network genesisId is associated with a LocalNet network. + * @param genesisId The network genesis ID + * @returns Whether the given genesis ID is associated with a LocalNet network + */ +export function genesisIdIsLocalNet(genesisId: string) { + return genesisId === 'devnet-v1' || genesisId === 'sandnet-v1' || genesisId === 'dockernet-v1' +}