Skip to content

Commit

Permalink
fix: Removing circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Aug 27, 2024
1 parent a5b03dd commit 4d0cd30
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/types/client-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/types/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 9 additions & 0 deletions src/types/network-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

0 comments on commit 4d0cd30

Please sign in to comment.