Skip to content

Commit 706ee7d

Browse files
committed
chore: simplify accountGetter return type
1 parent 8a39796 commit 706ee7d

8 files changed

+43
-73
lines changed

docs/capabilities/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ When calling `algorandFixture()` you can optionally pass in some fixture configu
110110
- `indexer?: Indexer` - An optional indexer client, if not specified then it will create one against environment variables defined network (if present) or default LocalNet
111111
- `kmd?: Kmd` - An optional kmd client, if not specified then it will create one against environment variables defined network (if present) or default LocalNet
112112
- `testAccountFunding?: AlgoAmount` - The [amount](./amount.md) of funds to allocate to the default testing account, if not specified then it will get `10` ALGO
113-
- `accountGetter?: (algod: Algodv2, kmd?: Kmd) => Promise<Account>` - Optional override for how to get an account; this allows you to retrieve test accounts from a known or cached list of accounts.
113+
- `accountGetter?: (algod: Algodv2, kmd?: Kmd) => Promise<Address & AddressWithSigners>` - Optional override for how to get an account; this allows you to retrieve test accounts from a known or cached list of accounts.
114114

115115
### Using the fixture context
116116

@@ -121,8 +121,8 @@ The `fixture.context` property is of type [`AlgorandTestAutomationContext`](../c
121121
- `indexer: Indexer` - Indexer client instance
122122
- `kmd: Kmd` - KMD client instance
123123
- `transactionLogger: TransactionLogger` - Transaction logger that will log transaction IDs for all transactions issued by `algod`
124-
- `testAccount: Account` - Funded test account that is ephemerally created for each test
125-
- `generateAccount: (params: GetTestAccountParams) => Promise<Account>` - Generate and fund an additional ephemerally created account
124+
- `testAccount: Address & AddressWithSigners` - Funded test account that is ephemerally created for each test
125+
- `generateAccount: (params: GetTestAccountParams) => Promise<Address & AddressWithSigners>` - Generate and fund an additional ephemerally created account
126126
- `waitForIndexer()` - Waits for indexer to catch up with the latest transaction that has been captured by the `transactionLogger` in the Algorand fixture
127127
- `waitForIndexerTransaction: (transactionId: string) => Promise<TransactionLookupResult>` - Wait for the indexer to catch up with the given transaction ID
128128

docs/code/interfaces/types_testing.AlgoKitLogCaptureFixture.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Testing framework agnostic handler method to run after each test to reset the lo
3333

3434
#### Defined in
3535

36-
[src/types/testing.ts:190](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L190)
36+
[src/types/testing.ts:161](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L161)
3737

3838
___
3939

@@ -53,7 +53,7 @@ Testing framework agnostic handler method to run before each test to prepare the
5353

5454
#### Defined in
5555

56-
[src/types/testing.ts:186](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L186)
56+
[src/types/testing.ts:157](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L157)
5757

5858
## Accessors
5959

@@ -69,4 +69,4 @@ The test logger instance for the current test
6969

7070
#### Defined in
7171

72-
[src/types/testing.ts:182](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L182)
72+
[src/types/testing.ts:153](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L153)

docs/code/interfaces/types_testing.AlgorandFixture.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Testing framework agnostic handler method to run before each test to prepare the
3939

4040
#### Defined in
4141

42-
[src/types/testing.ts:122](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L122)
42+
[src/types/testing.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L93)
4343

4444
___
4545

@@ -95,7 +95,7 @@ describe('MY MODULE', () => {
9595

9696
#### Defined in
9797

98-
[src/types/testing.ts:162](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L162)
98+
[src/types/testing.ts:133](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L133)
9999

100100
## Accessors
101101

@@ -111,7 +111,7 @@ Retrieve an `AlgorandClient` loaded with the current context, including testAcco
111111

112112
#### Defined in
113113

114-
[src/types/testing.ts:116](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L116)
114+
[src/types/testing.ts:87](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L87)
115115

116116
___
117117

@@ -138,4 +138,4 @@ test('My test', () => {
138138

139139
#### Defined in
140140

141-
[src/types/testing.ts:111](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L111)
141+
[src/types/testing.ts:82](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L82)

docs/code/interfaces/types_testing.AlgorandFixtureConfig.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,27 @@ Configuration for creating an Algorand testing fixture.
2929

3030
### accountGetter
3131

32-
`Optional` **accountGetter**: (`algod`: `AlgodClient`, `kmd?`: `KmdClient`) => `Promise`\<[`Address`](../classes/index.Address.md) & `AddressWithTransactionSigner` & \{ `account`: \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` } }\>
32+
`Optional` **accountGetter**: (`algorand`: [`AlgorandClient`](../classes/types_algorand_client.AlgorandClient.md)) => `Promise`\<[`Address`](../classes/index.Address.md) & \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` }\>
3333

3434
Optional override for how to get an account; this allows you to retrieve accounts from a known or cached list of accounts.
3535

3636
#### Type declaration
3737

38-
▸ (`algod`, `kmd?`): `Promise`\<[`Address`](../classes/index.Address.md) & `AddressWithTransactionSigner` & \{ `account`: \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` } }\>
38+
▸ (`algorand`): `Promise`\<[`Address`](../classes/index.Address.md) & \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` }\>
3939

4040
##### Parameters
4141

4242
| Name | Type |
4343
| :------ | :------ |
44-
| `algod` | `AlgodClient` |
45-
| `kmd?` | `KmdClient` |
44+
| `algorand` | [`AlgorandClient`](../classes/types_algorand_client.AlgorandClient.md) |
4645

4746
##### Returns
4847

49-
`Promise`\<[`Address`](../classes/index.Address.md) & `AddressWithTransactionSigner` & \{ `account`: \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` } }\>
48+
`Promise`\<[`Address`](../classes/index.Address.md) & \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` }\>
5049

5150
#### Defined in
5251

53-
[src/types/testing.ts:80](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L80)
52+
[src/types/testing.ts:65](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L65)
5453

5554
___
5655

@@ -62,7 +61,7 @@ An optional algod client, if not specified then it will create one against `algo
6261

6362
#### Defined in
6463

65-
[src/types/testing.ts:72](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L72)
64+
[src/types/testing.ts:57](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L57)
6665

6766
___
6867

@@ -90,7 +89,7 @@ An optional indexer client, if not specified then it will create one against `in
9089

9190
#### Defined in
9291

93-
[src/types/testing.ts:74](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L74)
92+
[src/types/testing.ts:59](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L59)
9493

9594
___
9695

@@ -118,7 +117,7 @@ An optional kmd client, if not specified then it will create one against `kmdCon
118117

119118
#### Defined in
120119

121-
[src/types/testing.ts:76](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L76)
120+
[src/types/testing.ts:61](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L61)
122121

123122
___
124123

@@ -146,4 +145,4 @@ The amount of funds to allocate to the default testing account, if not specified
146145

147146
#### Defined in
148147

149-
[src/types/testing.ts:78](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L78)
148+
[src/types/testing.ts:63](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L63)

docs/code/interfaces/types_testing.AlgorandTestAutomationContext.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Algod client instance that will log transactions in `transactionLogger`
3030

3131
#### Defined in
3232

33-
[src/types/testing.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L29)
33+
[src/types/testing.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L25)
3434

3535
___
3636

@@ -42,7 +42,7 @@ An AlgorandClient instance loaded with the current context, including testAccoun
4242

4343
#### Defined in
4444

45-
[src/types/testing.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L27)
45+
[src/types/testing.ts:23](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L23)
4646

4747
___
4848

@@ -68,7 +68,7 @@ Generate and fund an additional ephemerally created account
6868

6969
#### Defined in
7070

71-
[src/types/testing.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L39)
71+
[src/types/testing.ts:35](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L35)
7272

7373
___
7474

@@ -80,7 +80,7 @@ Indexer client instance
8080

8181
#### Defined in
8282

83-
[src/types/testing.ts:31](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L31)
83+
[src/types/testing.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L27)
8484

8585
___
8686

@@ -92,7 +92,7 @@ KMD client instance
9292

9393
#### Defined in
9494

95-
[src/types/testing.ts:33](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L33)
95+
[src/types/testing.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L29)
9696

9797
___
9898

@@ -104,7 +104,7 @@ Default, funded test account that is ephemerally created
104104

105105
#### Defined in
106106

107-
[src/types/testing.ts:37](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L37)
107+
[src/types/testing.ts:33](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L33)
108108

109109
___
110110

@@ -116,7 +116,7 @@ Transaction logger that will log transaction IDs for all transactions issued by
116116

117117
#### Defined in
118118

119-
[src/types/testing.ts:35](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L35)
119+
[src/types/testing.ts:31](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L31)
120120

121121
___
122122

@@ -136,7 +136,7 @@ Wait for the indexer to catch up with all transactions logged by `transactionLog
136136

137137
#### Defined in
138138

139-
[src/types/testing.ts:41](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L41)
139+
[src/types/testing.ts:37](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L37)
140140

141141
___
142142

@@ -162,4 +162,4 @@ Wait for the indexer to catch up with the given transaction ID
162162

163163
#### Defined in
164164

165-
[src/types/testing.ts:43](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L43)
165+
[src/types/testing.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L39)

docs/code/interfaces/types_testing.GetTestAccountParams.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Parameters for the `getTestAccount` function.
1818

1919
### accountGetter
2020

21-
`Optional` **accountGetter**: (`algorand`: [`AlgorandClient`](../classes/types_algorand_client.AlgorandClient.md)) => `Promise`\<[`Address`](../classes/index.Address.md) & `AddressWithTransactionSigner` & \{ `account`: \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` } }\>
21+
`Optional` **accountGetter**: (`algorand`: [`AlgorandClient`](../classes/types_algorand_client.AlgorandClient.md)) => `Promise`\<[`Address`](../classes/index.Address.md) & \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` }\>
2222

2323
Optional override for how to get a test account; this allows you to retrieve accounts from a known or cached list of accounts.
2424

2525
#### Type declaration
2626

27-
▸ (`algorand`): `Promise`\<[`Address`](../classes/index.Address.md) & `AddressWithTransactionSigner` & \{ `account`: \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` } }\>
27+
▸ (`algorand`): `Promise`\<[`Address`](../classes/index.Address.md) & \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` }\>
2828

2929
##### Parameters
3030

@@ -34,11 +34,11 @@ Optional override for how to get a test account; this allows you to retrieve acc
3434

3535
##### Returns
3636

37-
`Promise`\<[`Address`](../classes/index.Address.md) & `AddressWithTransactionSigner` & \{ `account`: \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` } }\>
37+
`Promise`\<[`Address`](../classes/index.Address.md) & \{ `addr`: `Readonly`\<[`Address`](../classes/index.Address.md)\> ; `lsigSigner`: `DelegatedLsigSigner` ; `mxBytesSigner`: `MxBytesSigner` ; `programDataSigner`: `ProgramDataSigner` ; `signer`: `TransactionSigner` }\>
3838

3939
#### Defined in
4040

41-
[src/types/testing.ts:55](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L55)
41+
[src/types/testing.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L51)
4242

4343
___
4444

@@ -50,7 +50,7 @@ Initial funds to ensure the account has
5050

5151
#### Defined in
5252

53-
[src/types/testing.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L51)
53+
[src/types/testing.ts:47](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L47)
5454

5555
___
5656

@@ -62,4 +62,4 @@ Whether to suppress the log (which includes a mnemonic) or not (default: do not
6262

6363
#### Defined in
6464

65-
[src/types/testing.ts:53](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L53)
65+
[src/types/testing.ts:49](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L49)

docs/code/interfaces/types_testing.LogSnapshotConfig.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Any accounts/addresses to replace the address for predictably
2727

2828
#### Defined in
2929

30-
[src/types/testing.ts:173](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L173)
30+
[src/types/testing.ts:144](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L144)
3131

3232
___
3333

@@ -39,7 +39,7 @@ Any app IDs to replace predictably
3939

4040
#### Defined in
4141

42-
[src/types/testing.ts:175](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L175)
42+
[src/types/testing.ts:146](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L146)
4343

4444
___
4545

@@ -65,7 +65,7 @@ Optional filter predicate to filter out logs
6565

6666
#### Defined in
6767

68-
[src/types/testing.ts:177](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L177)
68+
[src/types/testing.ts:148](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L148)
6969

7070
___
7171

@@ -77,4 +77,4 @@ Any transaction IDs or transactions to replace the ID for predictably
7777

7878
#### Defined in
7979

80-
[src/types/testing.ts:171](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L171)
80+
[src/types/testing.ts:142](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/testing.ts#L142)

src/types/testing.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import { AlgodClient } from '@algorandfoundation/algokit-algod-client'
22
import { Address } from '@algorandfoundation/algokit-common'
3+
import { IndexerClient, TransactionResponse } from '@algorandfoundation/algokit-indexer-client'
4+
import { KmdClient } from '@algorandfoundation/algokit-kmd-client'
35
import {
46
AddressWithSigners,
57
AddressWithTransactionSigner,
6-
DelegatedLsigSigner,
78
LogicSigAccount,
8-
MxBytesSigner,
9-
ProgramDataSigner,
9+
MultisigAccount,
1010
Transaction,
11-
TransactionSigner,
1211
} from '@algorandfoundation/algokit-transact'
13-
import { MultisigAccount } from '@algorandfoundation/algokit-transact'
14-
import { IndexerClient, TransactionResponse } from '@algorandfoundation/algokit-indexer-client'
15-
import { KmdClient } from '@algorandfoundation/algokit-kmd-client'
1612
import { TransactionLogger } from '../testing'
1713
import { TestLogger } from '../testing/test-logger'
1814
import { AlgoAmount } from '../types/amount'
@@ -52,18 +48,7 @@ export interface GetTestAccountParams {
5248
/** Whether to suppress the log (which includes a mnemonic) or not (default: do not suppress the log) */
5349
suppressLog?: boolean
5450
/** Optional override for how to get a test account; this allows you to retrieve accounts from a known or cached list of accounts. */
55-
accountGetter?: (algorand: AlgorandClient) => Promise<
56-
Address &
57-
AddressWithTransactionSigner & {
58-
account: {
59-
addr: Readonly<Address>
60-
signer: TransactionSigner
61-
lsigSigner: DelegatedLsigSigner
62-
programDataSigner: ProgramDataSigner
63-
mxBytesSigner: MxBytesSigner
64-
}
65-
}
66-
>
51+
accountGetter?: (algorand: AlgorandClient) => Promise<Address & AddressWithSigners>
6752
}
6853

6954
/** Configuration for creating an Algorand testing fixture. */
@@ -77,21 +62,7 @@ export interface AlgorandFixtureConfig extends Partial<AlgoConfig> {
7762
/** The amount of funds to allocate to the default testing account, if not specified then it will get 10 ALGO. */
7863
testAccountFunding?: AlgoAmount
7964
/** Optional override for how to get an account; this allows you to retrieve accounts from a known or cached list of accounts. */
80-
accountGetter?: (
81-
algod: AlgodClient,
82-
kmd?: KmdClient,
83-
) => Promise<
84-
Address &
85-
AddressWithTransactionSigner & {
86-
account: {
87-
addr: Readonly<Address>
88-
signer: TransactionSigner
89-
lsigSigner: DelegatedLsigSigner
90-
programDataSigner: ProgramDataSigner
91-
mxBytesSigner: MxBytesSigner
92-
}
93-
}
94-
>
65+
accountGetter?: (algorand: AlgorandClient) => Promise<Address & AddressWithSigners>
9566
}
9667

9768
/** An Algorand automated testing fixture */

0 commit comments

Comments
 (0)