@algorandfoundation/algokit-utils 9.2.1 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account/account.d.ts +28 -23
- package/account/get-account-config-from-environment.d.ts +2 -7
- package/account/get-account.d.ts +12 -14
- package/account/get-dispenser-account.d.ts +5 -9
- package/account/index.d.ts +5 -0
- package/account/mnemonic-account.d.ts +3 -7
- package/amount.d.ts +35 -40
- package/app-client.d.ts +6 -10
- package/app-deploy.d.ts +23 -25
- package/app.d.ts +46 -45
- package/asset.d.ts +12 -16
- package/config.d.ts +2 -7
- package/debugging/debugging.d.ts +1 -5
- package/debugging/index.d.ts +1 -0
- package/dispenser-client.d.ts +2 -7
- package/index.d.ts +18 -27
- package/indexer-lookup.d.ts +11 -18
- package/localnet/get-kmd-wallet-account.d.ts +7 -9
- package/localnet/get-localnet-dispenser-account.d.ts +5 -7
- package/localnet/get-or-create-kmd-wallet-account.d.ts +8 -10
- package/localnet/index.d.ts +4 -0
- package/localnet/is-localnet.d.ts +3 -7
- package/network-client.d.ts +15 -17
- package/package.json +1 -1
- package/testing/_asset.d.ts +3 -0
- package/testing/account.d.ts +9 -11
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +2 -7
- package/testing/fixtures/algorand-fixture.d.ts +4 -9
- package/testing/fixtures/index.d.ts +2 -0
- package/testing/index.d.ts +5 -7
- package/testing/indexer.d.ts +1 -5
- package/testing/test-logger.d.ts +36 -41
- package/testing/transaction-logger.d.ts +27 -30
- package/transaction/index.d.ts +2 -0
- package/transaction/legacy-bridge.d.ts +35 -0
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +5 -7
- package/transaction/resolve-signed-transactions.d.ts +16 -0
- package/transaction/transaction.d.ts +35 -34
- package/transfer/index.d.ts +2 -0
- package/transfer/transfer-algos.d.ts +5 -9
- package/transfer/transfer.d.ts +8 -11
- package/types/account-manager.d.ts +429 -432
- package/types/account.d.ts +202 -192
- package/types/algo-http-client-with-retry.d.ts +10 -15
- package/types/algorand-client-transaction-creator.d.ts +771 -778
- package/types/algorand-client-transaction-sender.d.ts +1085 -1090
- package/types/algorand-client.d.ts +236 -239
- package/types/amount.d.ts +43 -47
- package/types/app-arc56.d.ts +272 -235
- package/types/app-client.d.ts +1151 -1128
- package/types/app-deployer.d.ts +141 -139
- package/types/app-factory.d.ts +783 -762
- package/types/app-manager.d.ts +310 -304
- package/types/app-spec.d.ts +117 -118
- package/types/app.d.ts +241 -229
- package/types/asset-manager.d.ts +199 -204
- package/types/asset.d.ts +91 -95
- package/types/async-event-emitter.d.ts +13 -18
- package/types/client-manager.d.ts +451 -453
- package/types/composer.d.ts +1257 -1210
- package/types/config.d.ts +48 -53
- package/types/debugging.d.ts +23 -25
- package/types/dispenser-client.d.ts +52 -57
- package/types/expand.d.ts +3 -5
- package/types/indexer.d.ts +66 -70
- package/types/instance-of.d.ts +3 -5
- package/types/kmd-account-manager.d.ts +70 -75
- package/types/lifecycle-events.d.ts +8 -13
- package/types/logging.d.ts +11 -15
- package/types/logic-error.d.ts +29 -33
- package/types/network-client.d.ts +27 -32
- package/types/testing.d.ts +132 -131
- package/types/transaction.d.ts +110 -110
- package/types/transfer.d.ts +66 -70
- package/util.d.ts +48 -0
|
@@ -1,78 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SigningAccount, TransactionSignerAccount } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
//#region src/types/kmd-account-manager.d.ts
|
|
1
|
+
import algosdk, { Address } from 'algosdk';
|
|
2
|
+
import { SigningAccount, TransactionSignerAccount } from './account';
|
|
3
|
+
import { AlgoAmount } from './amount';
|
|
4
|
+
import { ClientManager } from './client-manager';
|
|
7
5
|
/** Provides abstractions over a [KMD](https://github.com/algorand/go-algorand/blob/master/daemon/kmd/README.md) instance
|
|
8
6
|
* that makes it easier to get and manage accounts using KMD. */
|
|
9
|
-
declare class KmdAccountManager {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
7
|
+
export declare class KmdAccountManager {
|
|
8
|
+
private _clientManager;
|
|
9
|
+
private _kmd?;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new KMD manager.
|
|
12
|
+
* @param clientManager A ClientManager client to use for algod and kmd clients
|
|
13
|
+
*/
|
|
14
|
+
constructor(clientManager: ClientManager);
|
|
15
|
+
kmd(): Promise<algosdk.Kmd>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns an Algorand signing account with private key loaded from the given KMD wallet (identified by name).
|
|
18
|
+
*
|
|
19
|
+
* @param walletName The name of the wallet to retrieve an account from
|
|
20
|
+
* @param predicate An optional filter to use to find the account (otherwise it will return a random account from the wallet)
|
|
21
|
+
* @param sender The optional sender address to use this signer for (aka a rekeyed account)
|
|
22
|
+
* @example Get default funded account in a LocalNet
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const defaultDispenserAccount = await kmdAccountManager.getWalletAccount(
|
|
26
|
+
* 'unencrypted-default-wallet',
|
|
27
|
+
* a => a.status !== 'Offline' && a.amount > 1_000_000_000
|
|
28
|
+
* )
|
|
29
|
+
* ```
|
|
30
|
+
* @returns The signing account (with private key loaded) or undefined if no matching wallet or account was found
|
|
31
|
+
*/
|
|
32
|
+
getWalletAccount(walletName: string, predicate?: (account: Record<string, any>) => boolean, sender?: string | Address): Promise<(TransactionSignerAccount & {
|
|
33
|
+
account: SigningAccount;
|
|
34
|
+
}) | undefined>;
|
|
35
|
+
private findWalletAccount;
|
|
36
|
+
/**
|
|
37
|
+
* Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.
|
|
38
|
+
*
|
|
39
|
+
* This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).
|
|
40
|
+
*
|
|
41
|
+
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh LocalNet.
|
|
42
|
+
*
|
|
43
|
+
* If this is used via `mnemonicAccountFromEnvironment`, then you can even use the same code that runs on production without changes for local development!
|
|
44
|
+
*
|
|
45
|
+
* @param name The name of the wallet to retrieve / create
|
|
46
|
+
* @param fundWith The number of Algo to fund the account with when it gets created, if not specified then 1000 ALGO will be funded from the dispenser account
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Idempotently get (if exists) or create (if it doesn't exist yet) an account by name using KMD
|
|
51
|
+
* // if creating it then fund it with 2 ALGO from the default dispenser account
|
|
52
|
+
* const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algo())
|
|
53
|
+
* // This will return the same account as above since the name matches
|
|
54
|
+
* const existingAccount = await kmdAccountManager.getOrCreateWalletAccount('account1')
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @returns An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you
|
|
58
|
+
*/
|
|
59
|
+
getOrCreateWalletAccount(name: string, fundWith?: AlgoAmount): Promise<TransactionSignerAccount & {
|
|
60
|
+
account: SigningAccount;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts).
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const dispenser = await kmdAccountManager.getLocalNetDispenserAccount()
|
|
67
|
+
* ```
|
|
68
|
+
* @returns The default LocalNet dispenser account
|
|
69
|
+
*/
|
|
70
|
+
getLocalNetDispenserAccount(): Promise<TransactionSignerAccount & {
|
|
71
|
+
account: SigningAccount;
|
|
72
|
+
}>;
|
|
75
73
|
}
|
|
76
|
-
//#endregion
|
|
77
|
-
export { KmdAccountManager };
|
|
78
|
-
//# sourceMappingURL=kmd-account-manager.d.ts.map
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { AVMTracesEventData, TealSourcesDebugEventData } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TxnGroupSimulated = "TxnGroupSimulated",
|
|
6
|
-
AppCompiled = "AppCompiled"
|
|
1
|
+
import { AVMTracesEventData, TealSourcesDebugEventData } from './debugging';
|
|
2
|
+
export declare enum EventType {
|
|
3
|
+
TxnGroupSimulated = "TxnGroupSimulated",
|
|
4
|
+
AppCompiled = "AppCompiled"
|
|
7
5
|
}
|
|
8
|
-
type EventDataMap = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export type EventDataMap = {
|
|
7
|
+
[EventType.TxnGroupSimulated]: AVMTracesEventData;
|
|
8
|
+
[EventType.AppCompiled]: TealSourcesDebugEventData;
|
|
9
|
+
[key: string]: unknown;
|
|
12
10
|
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { EventDataMap, EventType };
|
|
15
|
-
//# sourceMappingURL=lifecycle-events.d.ts.map
|
package/types/logging.d.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
//#region src/types/logging.d.ts
|
|
2
1
|
/** General purpose logger type, compatible with Winston and others. */
|
|
3
|
-
type Logger = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export type Logger = {
|
|
3
|
+
error(message: string, ...optionalParams: unknown[]): void;
|
|
4
|
+
warn(message: string, ...optionalParams: unknown[]): void;
|
|
5
|
+
info(message: string, ...optionalParams: unknown[]): void;
|
|
6
|
+
verbose(message: string, ...optionalParams: unknown[]): void;
|
|
7
|
+
debug(message: string, ...optionalParams: unknown[]): void;
|
|
9
8
|
};
|
|
10
9
|
/** A logger implementation that writes to console */
|
|
11
|
-
declare const consoleLogger: Logger;
|
|
12
|
-
declare const infoConsoleLogger: Logger;
|
|
13
|
-
declare const verboseConsoleLogger: Logger;
|
|
14
|
-
declare const warningConsoleLogger: Logger;
|
|
10
|
+
export declare const consoleLogger: Logger;
|
|
11
|
+
export declare const infoConsoleLogger: Logger;
|
|
12
|
+
export declare const verboseConsoleLogger: Logger;
|
|
13
|
+
export declare const warningConsoleLogger: Logger;
|
|
15
14
|
/** A logger implementation that does nothing */
|
|
16
|
-
declare const nullLogger: Logger;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { Logger, consoleLogger, infoConsoleLogger, nullLogger, verboseConsoleLogger, warningConsoleLogger };
|
|
19
|
-
//# sourceMappingURL=logging.d.ts.map
|
|
15
|
+
export declare const nullLogger: Logger;
|
package/types/logic-error.d.ts
CHANGED
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
//#region src/types/logic-error.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Details about a smart contract logic error
|
|
4
3
|
*/
|
|
5
|
-
interface LogicErrorDetails {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
export interface LogicErrorDetails {
|
|
5
|
+
/** The ID of the transaction with the logic error */
|
|
6
|
+
txId: string;
|
|
7
|
+
/** The program counter where the error was */
|
|
8
|
+
pc: number;
|
|
9
|
+
/** The error message */
|
|
10
|
+
msg: string;
|
|
11
|
+
/** The full error description */
|
|
12
|
+
desc: string;
|
|
13
|
+
/** Any trace information included in the error */
|
|
14
|
+
traces: Record<string, unknown>[];
|
|
16
15
|
}
|
|
17
16
|
/** Wraps key functionality around processing logic errors */
|
|
18
|
-
declare class LogicError extends Error {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
export declare class LogicError extends Error {
|
|
18
|
+
/** Takes an error message and parses out the details of any logic errors in there.
|
|
19
|
+
* @param error The error message to parse
|
|
20
|
+
* @returns The logic error details if any, or undefined
|
|
21
|
+
*/
|
|
22
|
+
static parseLogicError(error: any): LogicErrorDetails | undefined;
|
|
23
|
+
led: LogicErrorDetails;
|
|
24
|
+
program: string[];
|
|
25
|
+
lines: number;
|
|
26
|
+
teal_line: number;
|
|
27
|
+
stack?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new logic error object.
|
|
30
|
+
* @param errorDetails The details of the logic error
|
|
31
|
+
* @param program The TEAL source code, split by line
|
|
32
|
+
* @param getLineForPc The source map of the TEAL source code
|
|
33
|
+
*/
|
|
34
|
+
constructor(errorDetails: LogicErrorDetails, program: string[], getLineForPc: (pc: number) => number | undefined);
|
|
36
35
|
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { LogicError, LogicErrorDetails };
|
|
39
|
-
//# sourceMappingURL=logic-error.d.ts.map
|
|
@@ -1,43 +1,38 @@
|
|
|
1
|
-
import { TokenHeader } from
|
|
2
|
-
|
|
3
|
-
//#region src/types/network-client.d.ts
|
|
1
|
+
import { TokenHeader } from 'algosdk';
|
|
4
2
|
/** Config for an Algorand SDK client. */
|
|
5
|
-
interface AlgoClientConfig {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
export interface AlgoClientConfig {
|
|
4
|
+
/** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
|
|
5
|
+
server: string;
|
|
6
|
+
/** The port to use e.g. 4001, 443, etc. */
|
|
7
|
+
port?: string | number;
|
|
8
|
+
/** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
|
|
9
|
+
token?: string | TokenHeader;
|
|
12
10
|
}
|
|
13
11
|
/** Configuration for algod, indexer and kmd clients. */
|
|
14
|
-
interface AlgoConfig {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
export interface AlgoConfig {
|
|
13
|
+
/** Algod client configuration */
|
|
14
|
+
algodConfig: AlgoClientConfig;
|
|
15
|
+
/** Indexer client configuration */
|
|
16
|
+
indexerConfig?: AlgoClientConfig;
|
|
17
|
+
/** Kmd configuration */
|
|
18
|
+
kmdConfig?: AlgoClientConfig;
|
|
21
19
|
}
|
|
22
20
|
/** Details of the current network. */
|
|
23
|
-
interface NetworkDetails {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
export interface NetworkDetails {
|
|
22
|
+
/** Whether or not the network is TestNet. */
|
|
23
|
+
isTestNet: boolean;
|
|
24
|
+
/** Whether or not the network is MainNet. */
|
|
25
|
+
isMainNet: boolean;
|
|
26
|
+
/** Whether or not the network is LocalNet. */
|
|
27
|
+
isLocalNet: boolean;
|
|
28
|
+
/** The genesis ID of the current network. */
|
|
29
|
+
genesisId: string;
|
|
30
|
+
/** The base64 genesis hash of the current network. */
|
|
31
|
+
genesisHash: string;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* Returns true if the given network genesisId is associated with a LocalNet network.
|
|
37
35
|
* @param genesisId The network genesis ID
|
|
38
36
|
* @returns Whether the given genesis ID is associated with a LocalNet network
|
|
39
37
|
*/
|
|
40
|
-
declare function genesisIdIsLocalNet(genesisId: string): genesisId is "devnet-v1" | "sandnet-v1" | "dockernet-v1";
|
|
41
|
-
//#endregion
|
|
42
|
-
export { AlgoClientConfig, AlgoConfig, NetworkDetails, genesisIdIsLocalNet };
|
|
43
|
-
//# sourceMappingURL=network-client.d.ts.map
|
|
38
|
+
export declare function genesisIdIsLocalNet(genesisId: string): genesisId is "devnet-v1" | "sandnet-v1" | "dockernet-v1";
|
package/types/testing.d.ts
CHANGED
|
@@ -1,149 +1,150 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import algosdk, { Address } from 'algosdk';
|
|
2
|
+
import { TransactionLogger } from '../testing';
|
|
3
|
+
import { TestLogger } from '../testing/test-logger';
|
|
4
|
+
import { AlgoAmount } from '../types/amount';
|
|
5
|
+
import { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account';
|
|
6
|
+
import { AlgorandClient } from './algorand-client';
|
|
7
|
+
import { AlgoConfig } from './network-client';
|
|
8
|
+
import Account = algosdk.Account;
|
|
9
|
+
import Algodv2 = algosdk.Algodv2;
|
|
10
|
+
import Indexer = algosdk.Indexer;
|
|
11
|
+
import Kmd = algosdk.Kmd;
|
|
12
|
+
import LogicSigAccount = algosdk.LogicSigAccount;
|
|
13
|
+
import Transaction = algosdk.Transaction;
|
|
10
14
|
/**
|
|
11
15
|
* Test automation context.
|
|
12
16
|
*/
|
|
13
|
-
interface AlgorandTestAutomationContext {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
export interface AlgorandTestAutomationContext {
|
|
18
|
+
/** An AlgorandClient instance loaded with the current context, including testAccount and any generated accounts loaded as signers */
|
|
19
|
+
algorand: AlgorandClient;
|
|
20
|
+
/** Algod client instance that will log transactions in `transactionLogger` */
|
|
21
|
+
algod: Algodv2;
|
|
22
|
+
/** Indexer client instance */
|
|
23
|
+
indexer: Indexer;
|
|
24
|
+
/** KMD client instance */
|
|
25
|
+
kmd: Kmd;
|
|
26
|
+
/** Transaction logger that will log transaction IDs for all transactions issued by `algod` */
|
|
27
|
+
transactionLogger: TransactionLogger;
|
|
28
|
+
/** Default, funded test account that is ephemerally created */
|
|
29
|
+
testAccount: Address & TransactionSignerAccount & Account;
|
|
30
|
+
/** Generate and fund an additional ephemerally created account */
|
|
31
|
+
generateAccount: (params: GetTestAccountParams) => Promise<Address & Account & TransactionSignerAccount>;
|
|
32
|
+
/** Wait for the indexer to catch up with all transactions logged by `transactionLogger` */
|
|
33
|
+
waitForIndexer: () => Promise<void>;
|
|
34
|
+
/** Wait for the indexer to catch up with the given transaction ID */
|
|
35
|
+
waitForIndexerTransaction: (transactionId: string) => Promise<algosdk.indexerModels.TransactionResponse>;
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Parameters for the `getTestAccount` function.
|
|
35
39
|
*/
|
|
36
|
-
interface GetTestAccountParams {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
export interface GetTestAccountParams {
|
|
41
|
+
/** Initial funds to ensure the account has */
|
|
42
|
+
initialFunds: AlgoAmount;
|
|
43
|
+
/** Whether to suppress the log (which includes a mnemonic) or not (default: do not suppress the log) */
|
|
44
|
+
suppressLog?: boolean;
|
|
45
|
+
/** Optional override for how to get a test account; this allows you to retrieve accounts from a known or cached list of accounts. */
|
|
46
|
+
accountGetter?: (algorand: AlgorandClient) => Promise<Account>;
|
|
43
47
|
}
|
|
44
48
|
/** Configuration for creating an Algorand testing fixture. */
|
|
45
|
-
interface AlgorandFixtureConfig extends Partial<AlgoConfig> {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
export interface AlgorandFixtureConfig extends Partial<AlgoConfig> {
|
|
50
|
+
/** An optional algod client, if not specified then it will create one against `algodConfig` (if present) then environment variables defined network (if present) or default LocalNet. */
|
|
51
|
+
algod?: Algodv2;
|
|
52
|
+
/** An optional indexer client, if not specified then it will create one against `indexerConfig` (if present) then environment variables defined network (if present) or default LocalNet. */
|
|
53
|
+
indexer?: Indexer;
|
|
54
|
+
/** An optional kmd client, if not specified then it will create one against `kmdConfig` (if present) then environment variables defined network (if present) or default LocalNet. */
|
|
55
|
+
kmd?: Kmd;
|
|
56
|
+
/** The amount of funds to allocate to the default testing account, if not specified then it will get 10 ALGO. */
|
|
57
|
+
testAccountFunding?: AlgoAmount;
|
|
58
|
+
/** Optional override for how to get an account; this allows you to retrieve accounts from a known or cached list of accounts. */
|
|
59
|
+
accountGetter?: (algod: Algodv2, kmd?: Kmd) => Promise<Account>;
|
|
56
60
|
}
|
|
57
61
|
/** An Algorand automated testing fixture */
|
|
58
|
-
interface AlgorandFixture {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
62
|
+
export interface AlgorandFixture {
|
|
63
|
+
/**
|
|
64
|
+
* Retrieve the current context.
|
|
65
|
+
* Useful with destructuring.
|
|
66
|
+
*
|
|
67
|
+
* If you haven't called `newScope` then this will throw an error.
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* test('My test', () => {
|
|
71
|
+
* const {algod, indexer, testAccount, ...} = fixture.context
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
get context(): AlgorandTestAutomationContext;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve an `AlgorandClient` loaded with the current context, including testAccount and any generated accounts loaded as signers.
|
|
78
|
+
*/
|
|
79
|
+
get algorand(): AlgorandClient;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Use newScope instead.
|
|
82
|
+
* Testing framework agnostic handler method to run before each test to prepare the `context` for that test with per test isolation.
|
|
83
|
+
*/
|
|
84
|
+
beforeEach: () => Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new isolated fixture scope (clean transaction logger, AlgorandClient, testAccount, etc.).
|
|
87
|
+
*
|
|
88
|
+
* You can call this from any testing framework specific hook method to control when you want a new scope.
|
|
89
|
+
*
|
|
90
|
+
* @example Jest / vitest - per test isolation (beforeEach)
|
|
91
|
+
* ```typescript
|
|
92
|
+
* describe('MY MODULE', () => {
|
|
93
|
+
* const fixture = algorandFixture()
|
|
94
|
+
* beforeEach(fixture.newScope)
|
|
95
|
+
*
|
|
96
|
+
* test('MY TEST', async () => {
|
|
97
|
+
* const { algorand, testAccount } = fixture.context
|
|
98
|
+
*
|
|
99
|
+
* // Test stuff!
|
|
100
|
+
* })
|
|
101
|
+
* })
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @example Jest / vitest - test suite isolation (beforeAll)
|
|
105
|
+
* ```typescript
|
|
106
|
+
* describe('MY MODULE', () => {
|
|
107
|
+
* const fixture = algorandFixture()
|
|
108
|
+
* beforeAll(fixture.newScope)
|
|
109
|
+
*
|
|
110
|
+
* test('test1', async () => {
|
|
111
|
+
* const { algorand, testAccount } = fixture.context
|
|
112
|
+
*
|
|
113
|
+
* // Test stuff!
|
|
114
|
+
* })
|
|
115
|
+
* test('test2', async () => {
|
|
116
|
+
* const { algorand, testAccount } = fixture.context
|
|
117
|
+
* // algorand and testAccount are the same as in test1
|
|
118
|
+
* })
|
|
119
|
+
* })
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
newScope: () => Promise<void>;
|
|
120
124
|
}
|
|
121
125
|
/** Configuration for preparing a captured log snapshot.
|
|
122
126
|
* This helps ensure that the provided configuration items won't appear
|
|
123
127
|
* with random values in the log snapshot, but rather will get substituted with predictable ids.
|
|
124
128
|
*/
|
|
125
|
-
interface LogSnapshotConfig {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
export interface LogSnapshotConfig {
|
|
130
|
+
/** Any transaction IDs or transactions to replace the ID for predictably */
|
|
131
|
+
transactions?: (string | Transaction)[];
|
|
132
|
+
/** Any accounts/addresses to replace the address for predictably */
|
|
133
|
+
accounts?: (string | Address | Account | SigningAccount | LogicSigAccount | MultisigAccount | TransactionSignerAccount)[];
|
|
134
|
+
/** Any app IDs to replace predictably */
|
|
135
|
+
apps?: (string | number | bigint)[];
|
|
136
|
+
/** Optional filter predicate to filter out logs */
|
|
137
|
+
filterPredicate?: (log: string) => boolean;
|
|
134
138
|
}
|
|
135
|
-
interface AlgoKitLogCaptureFixture {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
export interface AlgoKitLogCaptureFixture {
|
|
140
|
+
/** The test logger instance for the current test */
|
|
141
|
+
get testLogger(): TestLogger;
|
|
142
|
+
/**
|
|
143
|
+
* Testing framework agnostic handler method to run before each test to prepare the `testLogger` for that test.
|
|
144
|
+
*/
|
|
145
|
+
beforeEach: () => void;
|
|
146
|
+
/**
|
|
147
|
+
* Testing framework agnostic handler method to run after each test to reset the logger.
|
|
148
|
+
*/
|
|
149
|
+
afterEach: () => void;
|
|
146
150
|
}
|
|
147
|
-
//#endregion
|
|
148
|
-
export { AlgoKitLogCaptureFixture, AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams, LogSnapshotConfig };
|
|
149
|
-
//# sourceMappingURL=testing.d.ts.map
|