Skip to content

Commit

Permalink
chore: invert logic and add deprecation info
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell committed Jul 19, 2024
1 parent b7c96a0 commit f8d8f33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 11 additions & 7 deletions docs/code/modules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ ___

**getTestAccount**(`params`, `algod`, `kmd?`): `Promise`\<`Account`\>

Creates an ephemeral Algorand account for the purposes of testing.
Returns a newly created random test account that is funded from the dispenser
DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
Note: By default this will log the mnemonic of the account.

#### Parameters

| Name | Type | Description |
Expand All @@ -172,9 +167,18 @@ Note: By default this will log the mnemonic of the account.

The account, with private key loaded

**`Deprecated`**

Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.

Creates an ephemeral Algorand account for the purposes of testing.
Returns a newly created random test account that is funded from the dispenser
DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
Note: By default this will log the mnemonic of the account.

#### Defined in

[src/testing/account.ts:18](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/testing/account.ts#L18)
[src/testing/account.ts:20](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/testing/account.ts#L20)

**getTestAccount**(`params`, `algorand`): `Promise`\<`Account`\>

Expand All @@ -198,7 +202,7 @@ The account, with private key loaded

#### Defined in

[src/testing/account.ts:28](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/testing/account.ts#L28)
[src/testing/account.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/testing/account.ts#L30)

___

Expand Down
6 changes: 5 additions & 1 deletion src/testing/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Algodv2 = algosdk.Algodv2
import Kmd = algosdk.Kmd

/**
* @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.
*
* Creates an ephemeral Algorand account for the purposes of testing.
* Returns a newly created random test account that is funded from the dispenser
* DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
Expand All @@ -32,7 +34,9 @@ export async function getTestAccount(
kmd?: Kmd,
): Promise<Account> {
const algorand =
algodOrAlgorandClient instanceof Algodv2 ? AlgorandClient.fromClients({ algod: algodOrAlgorandClient, kmd }) : algodOrAlgorandClient
algodOrAlgorandClient instanceof AlgorandClient
? algodOrAlgorandClient
: AlgorandClient.fromClients({ algod: algodOrAlgorandClient, kmd })

const account = accountGetter ? await accountGetter(algorand) : algosdk.generateAccount()

Expand Down

0 comments on commit f8d8f33

Please sign in to comment.