Skip to content
14 changes: 14 additions & 0 deletions src/testing/test-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ export class TestLogger implements Logger {
private originalLogger: Logger | undefined
private logs: string[]

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isTestLogger = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as TestLogger)._isTestLogger === true)
}

/**
* Create a new test logger that wraps the given logger if provided.
* @param originalLogger The optional original logger to wrap.
Expand Down
14 changes: 14 additions & 0 deletions src/types/account-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ export class AccountManager {
private _accounts: { [address: string]: TransactionSignerAccount } = {}
private _defaultSigner?: algosdk.TransactionSigner

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAccountManager = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AccountManager)._isAccountManager === true)
}

/**
* Create a new account manager.
* @param clientManager The ClientManager client to use for algod and kmd clients
Expand Down
28 changes: 28 additions & 0 deletions src/types/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ export class MultisigAccount {
_addr: Address
_signer: TransactionSigner

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isMultisigAccount = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as MultisigAccount)._isMultisigAccount === true)
}

/** The parameters for the multisig account */
get params(): Readonly<algosdk.MultisigMetadata> {
return this._params
Expand Down Expand Up @@ -81,6 +95,20 @@ export class SigningAccount implements Account {
private _signer: TransactionSigner
private _sender: Address

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isSigningAccount = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as SigningAccount)._isSigningAccount === true)
}

/**
* Algorand address of the sender
*/
Expand Down
14 changes: 14 additions & 0 deletions src/types/algo-http-client-with-retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ export class AlgoHttpClientWithRetry extends URLTokenBaseHTTPClient {
'EPROTO', // We get this intermittently with AlgoNode API
]

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAlgoHttpClientWithRetry = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AlgoHttpClientWithRetry)._isAlgoHttpClientWithRetry === true)
}

private async callWithRetry(func: () => Promise<BaseHTTPClientResponse>): Promise<BaseHTTPClientResponse> {
let response: BaseHTTPClientResponse | undefined
let numTries = 1
Expand Down
14 changes: 14 additions & 0 deletions src/types/algorand-client-transaction-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ import Transaction = algosdk.Transaction
export class AlgorandClientTransactionCreator {
private _newGroup: () => TransactionComposer

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAlgorandClientTransactionCreator = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AlgorandClientTransactionCreator)._isAlgorandClientTransactionCreator === true)
}

/**
* Creates a new `AlgorandClientTransactionCreator`
* @param newGroup A lambda that starts a new `TransactionComposer` transaction group
Expand Down
14 changes: 14 additions & 0 deletions src/types/algorand-client-transaction-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ export class AlgorandClientTransactionSender {
private _assetManager: AssetManager
private _appManager: AppManager

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAlgorandClientTransactionSender = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AlgorandClientTransactionSender)._isAlgorandClientTransactionSender === true)
}

/**
* Creates a new `AlgorandClientSender`
* @param newGroup A lambda that starts a new `TransactionComposer` transaction group
Expand Down
14 changes: 14 additions & 0 deletions src/types/algorand-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ export class AlgorandClient {
*/
private _errorTransformers: Set<ErrorTransformer> = new Set()

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAlgorandClient = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AlgorandClient)._isAlgorandClient === true)
}

private constructor(config: AlgoConfig | AlgoSdkClients) {
this._clientManager = new ClientManager(config, this)
this._accountManager = new AccountManager(this._clientManager)
Expand Down
14 changes: 14 additions & 0 deletions src/types/app-arc56.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ export class Arc56Method extends algosdk.ABIMethod {
override readonly args: Array<Arc56MethodArg>
override readonly returns: Arc56MethodReturnType

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isArc56Method = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as Arc56Method)._isArc56Method === true)
}

constructor(public method: Method) {
super(method)
this.args = method.args.map((arg) => ({
Expand Down
27 changes: 27 additions & 0 deletions src/types/app-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,20 @@ export class AppClient {
}
private _lastCompiled: { clear?: Uint8Array; approval?: Uint8Array }

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAppClient = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AppClient)._isAppClient === true)
}

/**
* Create a new app client.
* @param params The parameters to create the app client
Expand Down Expand Up @@ -1807,6 +1821,19 @@ export class ApplicationClient {

private _approvalSourceMap: SourceMap | undefined
private _clearSourceMap: SourceMap | undefined
/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isApplicationClient = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as ApplicationClient)._isApplicationClient === true)
}

/**
* @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById` or
Expand Down
14 changes: 14 additions & 0 deletions src/types/app-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ export class AppDeployer {
private _indexer?: algosdk.Indexer
private _appLookups = new Map<string, AppLookup>()

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAppDeployer = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AppDeployer)._isAppDeployer === true)
}

/**
* Creates an `AppManager`
* @param appManager An `AppManager` instance
Expand Down
14 changes: 14 additions & 0 deletions src/types/app-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ export class AppManager {
private _algod: algosdk.Algodv2
private _compilationResults: Record<string, CompiledTeal> = {}

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAppManager = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AppManager)._isAppManager === true)
}

/**
* Creates an `AppManager`
* @param algod An algod instance
Expand Down
14 changes: 14 additions & 0 deletions src/types/async-event-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ export class AsyncEventEmitter {
private listenerWrapperMap = new WeakMap<AsyncEventListener, AsyncEventListener>()
private listenerMap: Record<string | symbol, AsyncEventListener[]> = {}

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isAsyncEventEmitter = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as AsyncEventEmitter)._isAsyncEventEmitter === true)
}

async emitAsync<K extends EventType>(eventName: K, event: EventDataMap[K]): Promise<void>
async emitAsync(eventName: string | symbol, event: unknown): Promise<void>
async emitAsync(eventName: string | symbol, event: unknown): Promise<void> {
Expand Down
14 changes: 14 additions & 0 deletions src/types/client-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ export class ClientManager {
private _kmd?: algosdk.Kmd
private _algorand?: AlgorandClient

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isClientManager = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as ClientManager)._isClientManager === true)
}

/**
* algosdk clients or config for interacting with the official Algorand APIs.
* @param clientsOrConfig The clients or config to use
Expand Down
14 changes: 14 additions & 0 deletions src/types/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,20 @@ export class TransactionComposer {

private errorTransformers: ErrorTransformer[]

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isTransactionComposer = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as TransactionComposer)._isTransactionComposer === true)
}

private async transformError(originalError: unknown): Promise<unknown> {
// Transformers only work with Error instances, so immediately return anything else
if (!(originalError instanceof Error)) {
Expand Down
14 changes: 14 additions & 0 deletions src/types/dispenser-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ export class TestNetDispenserApiClient {
private _authToken: string
private _requestTimeout: number

/**
* Unique property marker for Symbol.hasInstance compatibility across module boundaries
*/
private readonly _isTestNetDispenserApiClient = true

/**
* Custom Symbol.hasInstance to handle dual package hazard
* @param instance - The instance to check
* @returns true if the instance is of the Type of the class, regardless of which module loaded it
*/
static [Symbol.hasInstance](instance: unknown): boolean {
return !!(instance && (instance as TestNetDispenserApiClient)._isTestNetDispenserApiClient === true)
}

constructor(params?: TestNetDispenserApiClientParams) {
const authTokenFromEnv = process?.env?.[DISPENSER_ACCESS_TOKEN_KEY]

Expand Down
Loading
Loading