@algorandfoundation/algokit-utils 1.0.0-beta.9 → 1.0.0
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.d.ts +35 -31
- package/account.d.ts.map +1 -1
- package/account.js +53 -39
- package/account.js.map +1 -1
- package/amount.d.ts +8 -0
- package/amount.d.ts.map +1 -0
- package/amount.js +24 -0
- package/amount.js.map +1 -0
- package/app.d.ts +64 -145
- package/app.d.ts.map +1 -1
- package/app.js +197 -39
- package/app.js.map +1 -1
- package/application-client.d.ts +9 -112
- package/application-client.d.ts.map +1 -1
- package/application-client.js +11 -254
- package/application-client.js.map +1 -1
- package/deploy-app.d.ts +20 -91
- package/deploy-app.d.ts.map +1 -1
- package/deploy-app.js +84 -93
- package/deploy-app.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +5 -2
- package/index.js.map +1 -1
- package/localnet.d.ts +4 -4
- package/localnet.d.ts.map +1 -1
- package/localnet.js +10 -10
- package/localnet.js.map +1 -1
- package/network-client.d.ts +11 -20
- package/network-client.d.ts.map +1 -1
- package/network-client.js +11 -11
- package/network-client.js.map +1 -1
- package/package.json +2 -2
- package/testing/account.d.ts +14 -0
- package/testing/account.d.ts.map +1 -0
- package/testing/account.js +31 -0
- package/testing/account.js.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/testing/fixtures/algorand-fixture.d.ts +20 -0
- package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/testing/fixtures/algorand-fixture.js +49 -0
- package/testing/fixtures/algorand-fixture.js.map +1 -0
- package/testing/fixtures/index.d.ts +3 -0
- package/testing/fixtures/index.d.ts.map +1 -0
- package/testing/fixtures/index.js +19 -0
- package/testing/fixtures/index.js.map +1 -0
- package/testing/index.d.ts +6 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +22 -0
- package/testing/index.js.map +1 -0
- package/testing/indexer.d.ts +12 -0
- package/testing/indexer.d.ts.map +1 -0
- package/testing/indexer.js +39 -0
- package/testing/indexer.js.map +1 -0
- package/testing/test-logger.d.ts +39 -0
- package/testing/test-logger.d.ts.map +1 -0
- package/testing/test-logger.js +69 -0
- package/testing/test-logger.js.map +1 -0
- package/testing/transaction-logger.d.ts +29 -0
- package/testing/transaction-logger.d.ts.map +1 -0
- package/testing/transaction-logger.js +71 -0
- package/testing/transaction-logger.js.map +1 -0
- package/transaction.d.ts +4 -81
- package/transaction.d.ts.map +1 -1
- package/transaction.js +39 -89
- package/transaction.js.map +1 -1
- package/transfer.d.ts +13 -16
- package/transfer.d.ts.map +1 -1
- package/transfer.js +35 -3
- package/transfer.js.map +1 -1
- package/types/account.d.ts +52 -0
- package/types/account.d.ts.map +1 -0
- package/types/account.js +86 -0
- package/types/account.js.map +1 -0
- package/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/{algo-http-client-with-retry.js → types/algo-http-client-with-retry.js} +2 -2
- package/types/algo-http-client-with-retry.js.map +1 -0
- package/types/algod.d.ts +22 -9
- package/types/algod.d.ts.map +1 -1
- package/{algo-amount.d.ts → types/amount.d.ts} +3 -1
- package/types/amount.d.ts.map +1 -0
- package/{algo-amount.js → types/amount.js} +7 -1
- package/types/amount.js.map +1 -0
- package/types/app.d.ts +279 -0
- package/types/app.d.ts.map +1 -0
- package/types/app.js +32 -0
- package/types/app.js.map +1 -0
- package/types/application-client.d.ts +229 -0
- package/types/application-client.d.ts.map +1 -0
- package/types/application-client.js +470 -0
- package/types/application-client.js.map +1 -0
- package/types/appspec.d.ts +1 -2
- package/types/appspec.d.ts.map +1 -1
- package/types/appspec.js.map +1 -1
- package/types/config.d.ts +15 -0
- package/types/config.d.ts.map +1 -0
- package/types/config.js +27 -0
- package/types/config.js.map +1 -0
- package/types/indexer.d.ts +8 -9
- package/types/indexer.d.ts.map +1 -1
- package/{config.d.ts → types/logging.d.ts} +2 -16
- package/types/logging.d.ts.map +1 -0
- package/{config.js → types/logging.js} +5 -24
- package/types/logging.js.map +1 -0
- package/types/logic-error.d.ts +33 -0
- package/types/logic-error.d.ts.map +1 -0
- package/types/logic-error.js +46 -0
- package/types/logic-error.js.map +1 -0
- package/types/network-client.d.ts +11 -0
- package/types/network-client.d.ts.map +1 -0
- package/types/network-client.js +3 -0
- package/types/network-client.js.map +1 -0
- package/types/testing.d.ts +89 -0
- package/types/testing.d.ts.map +1 -0
- package/types/testing.js +3 -0
- package/types/testing.js.map +1 -0
- package/types/transaction.d.ts +67 -0
- package/types/transaction.d.ts.map +1 -0
- package/types/transaction.js +3 -0
- package/types/transaction.js.map +1 -0
- package/types/transfer.d.ts +32 -0
- package/types/transfer.d.ts.map +1 -0
- package/types/transfer.js +3 -0
- package/types/transfer.js.map +1 -0
- package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/algo-amount.d.ts.map +0 -1
- package/algo-amount.js.map +0 -1
- package/algo-http-client-with-retry.d.ts.map +0 -1
- package/algo-http-client-with-retry.js.map +0 -1
- package/config.d.ts.map +0 -1
- package/config.js.map +0 -1
- package/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/urlTokenBaseHTTPClient.js.map +0 -1
- /package/{algo-http-client-with-retry.d.ts → types/algo-http-client-with-retry.d.ts} +0 -0
- /package/{urlTokenBaseHTTPClient.d.ts → types/urlTokenBaseHTTPClient.d.ts} +0 -0
- /package/{urlTokenBaseHTTPClient.js → types/urlTokenBaseHTTPClient.js} +0 -0
package/network-client.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Algodv2, Indexer, Kmd } from 'algosdk';
|
|
2
|
-
import {
|
|
3
|
-
/** Config for an Algorand SDK client */
|
|
4
|
-
export interface AlgoClientConfig {
|
|
5
|
-
/** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
|
|
6
|
-
server: string;
|
|
7
|
-
/** The port to use e.g. 4001, 443, etc. */
|
|
8
|
-
port?: string | number;
|
|
9
|
-
/** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
|
|
10
|
-
token?: string | TokenHeader;
|
|
11
|
-
}
|
|
2
|
+
import { AlgoClientConfig } from './types/network-client';
|
|
12
3
|
/** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
13
4
|
export declare function getAlgodConfigFromEnvironment(): AlgoClientConfig;
|
|
14
5
|
/** Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
@@ -29,24 +20,24 @@ export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexe
|
|
|
29
20
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
30
21
|
* @example Default (load from environment variables)
|
|
31
22
|
*
|
|
32
|
-
* ```
|
|
23
|
+
* ```typescript
|
|
33
24
|
* // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
|
|
34
25
|
* // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
|
|
35
26
|
* const algod = getAlgoClient()
|
|
36
27
|
* await algod.healthCheck().do()
|
|
37
28
|
* ```
|
|
38
29
|
* @example AlgoNode (testnet)
|
|
39
|
-
* ```
|
|
30
|
+
* ```typescript
|
|
40
31
|
* const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
|
|
41
32
|
* await algod.healthCheck().do()
|
|
42
33
|
* ```
|
|
43
34
|
* @example AlgoNode (mainnet)
|
|
44
|
-
* ```
|
|
35
|
+
* ```typescript
|
|
45
36
|
* const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
|
|
46
37
|
* await algod.healthCheck().do()
|
|
47
38
|
* ```
|
|
48
39
|
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
49
|
-
* ```
|
|
40
|
+
* ```typescript
|
|
50
41
|
* const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
51
42
|
* await algod.healthCheck().do()
|
|
52
43
|
* ```
|
|
@@ -57,24 +48,24 @@ export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
|
|
|
57
48
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
58
49
|
* @example Default (load from environment variables)
|
|
59
50
|
*
|
|
60
|
-
* ```
|
|
51
|
+
* ```typescript
|
|
61
52
|
* // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
|
|
62
53
|
* // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
|
|
63
54
|
* const indexer = getAlgoIndexerClient()
|
|
64
55
|
* await indexer.makeHealthCheck().do()
|
|
65
56
|
* ```
|
|
66
57
|
* @example AlgoNode (testnet)
|
|
67
|
-
* ```
|
|
58
|
+
* ```typescript
|
|
68
59
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
|
|
69
60
|
* await indexer.makeHealthCheck().do()
|
|
70
61
|
* ```
|
|
71
62
|
* @example AlgoNode (mainnet)
|
|
72
|
-
* ```
|
|
63
|
+
* ```typescript
|
|
73
64
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
|
|
74
65
|
* await indexer.makeHealthCheck().do()
|
|
75
66
|
* ```
|
|
76
67
|
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
77
|
-
* ```
|
|
68
|
+
* ```typescript
|
|
78
69
|
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
79
70
|
* await indexer.makeHealthCheck().do()
|
|
80
71
|
* ```
|
|
@@ -88,12 +79,12 @@ export declare function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer
|
|
|
88
79
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
89
80
|
* @example Default (load from environment variables)
|
|
90
81
|
*
|
|
91
|
-
* ```
|
|
82
|
+
* ```typescript
|
|
92
83
|
* // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
|
|
93
84
|
* const kmd = getAlgoKmdClient()
|
|
94
85
|
* ```
|
|
95
86
|
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
96
|
-
* ```
|
|
87
|
+
* ```typescript
|
|
97
88
|
* const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
98
89
|
* ```
|
|
99
90
|
*/
|
package/network-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,mIAAmI;AACnI,wBAAgB,6BAA6B,IAAI,gBAAgB,CAchE;AAED,qIAAqI;AACrI,wBAAgB,+BAA+B,IAAI,gBAAgB,CAclE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAK/G;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,gBAAgB,CAM7G;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,GAAG,CAK/D;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
package/network-client.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.isLocalNet = exports.getAlgoKmdClient = exports.getAlgoIndexerClient = exports.getAlgoClient = exports.getDefaultLocalNetConfig = exports.getAlgoNodeConfig = exports.getIndexerConfigFromEnvironment = exports.getAlgodConfigFromEnvironment = void 0;
|
|
27
27
|
const algosdk_1 = __importStar(require("algosdk"));
|
|
28
|
-
const algo_http_client_with_retry_1 = require("./algo-http-client-with-retry");
|
|
28
|
+
const algo_http_client_with_retry_1 = require("./types/algo-http-client-with-retry");
|
|
29
29
|
/** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
30
30
|
function getAlgodConfigFromEnvironment() {
|
|
31
31
|
if (!process || !process.env) {
|
|
@@ -92,24 +92,24 @@ function getAlgoTokenHeader(server, token, defaultHeader) {
|
|
|
92
92
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
93
93
|
* @example Default (load from environment variables)
|
|
94
94
|
*
|
|
95
|
-
* ```
|
|
95
|
+
* ```typescript
|
|
96
96
|
* // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
|
|
97
97
|
* // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
|
|
98
98
|
* const algod = getAlgoClient()
|
|
99
99
|
* await algod.healthCheck().do()
|
|
100
100
|
* ```
|
|
101
101
|
* @example AlgoNode (testnet)
|
|
102
|
-
* ```
|
|
102
|
+
* ```typescript
|
|
103
103
|
* const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
|
|
104
104
|
* await algod.healthCheck().do()
|
|
105
105
|
* ```
|
|
106
106
|
* @example AlgoNode (mainnet)
|
|
107
|
-
* ```
|
|
107
|
+
* ```typescript
|
|
108
108
|
* const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
|
|
109
109
|
* await algod.healthCheck().do()
|
|
110
110
|
* ```
|
|
111
111
|
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
112
|
-
* ```
|
|
112
|
+
* ```typescript
|
|
113
113
|
* const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
114
114
|
* await algod.healthCheck().do()
|
|
115
115
|
* ```
|
|
@@ -125,24 +125,24 @@ exports.getAlgoClient = getAlgoClient;
|
|
|
125
125
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
126
126
|
* @example Default (load from environment variables)
|
|
127
127
|
*
|
|
128
|
-
* ```
|
|
128
|
+
* ```typescript
|
|
129
129
|
* // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
|
|
130
130
|
* // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
|
|
131
131
|
* const indexer = getAlgoIndexerClient()
|
|
132
132
|
* await indexer.makeHealthCheck().do()
|
|
133
133
|
* ```
|
|
134
134
|
* @example AlgoNode (testnet)
|
|
135
|
-
* ```
|
|
135
|
+
* ```typescript
|
|
136
136
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
|
|
137
137
|
* await indexer.makeHealthCheck().do()
|
|
138
138
|
* ```
|
|
139
139
|
* @example AlgoNode (mainnet)
|
|
140
|
-
* ```
|
|
140
|
+
* ```typescript
|
|
141
141
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
|
|
142
142
|
* await indexer.makeHealthCheck().do()
|
|
143
143
|
* ```
|
|
144
144
|
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
145
|
-
* ```
|
|
145
|
+
* ```typescript
|
|
146
146
|
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
147
147
|
* await indexer.makeHealthCheck().do()
|
|
148
148
|
* ```
|
|
@@ -161,12 +161,12 @@ exports.getAlgoIndexerClient = getAlgoIndexerClient;
|
|
|
161
161
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
162
162
|
* @example Default (load from environment variables)
|
|
163
163
|
*
|
|
164
|
-
* ```
|
|
164
|
+
* ```typescript
|
|
165
165
|
* // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
|
|
166
166
|
* const kmd = getAlgoKmdClient()
|
|
167
167
|
* ```
|
|
168
168
|
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
169
|
-
* ```
|
|
169
|
+
* ```typescript
|
|
170
170
|
* const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
171
171
|
* ```
|
|
172
172
|
*/
|
package/network-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.js","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwD;AAExD
|
|
1
|
+
{"version":3,"file":"network-client.js","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwD;AAExD,qFAA6E;AAG7E,mIAAmI;AACnI,SAAgB,6BAA6B;IAC3C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAA;KACpH;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,yGAAyG,CAAC,CAAA;KAC3H;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAChC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;QAC5B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;KAC/B,CAAA;AACH,CAAC;AAdD,sEAcC;AAED,qIAAqI;AACrI,SAAgB,+BAA+B;IAC7C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,oGAAoG,CAAC,CAAA;KACtH;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,6GAA6G,CAAC,CAAA;KAC/H;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QAClC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;QAC9B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;KACjC,CAAA;AACH,CAAC;AAdD,0EAcC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,OAA8B,EAAE,MAA2B;IAC3F,OAAO;QACL,MAAM,EAAE,WAAW,OAAO,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,kBAAkB;QAClF,IAAI,EAAE,GAAG;KACV,CAAA;AACH,CAAC;AALD,8CAKC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,YAAkD;IACzF,OAAO;QACL,MAAM,EAAE,kBAAkB;QAC1B,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY;QACxH,KAAK,EAAE,kEAAkE;KAC1E,CAAA;AACH,CAAC;AAND,4DAMC;AAED,SAAS,kBAAkB,CAAC,MAAc,EAAE,KAA4B,EAAE,aAAsB;IAC9F,sEAAsE;IACtE,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAA;IAE/F,6IAA6I;IAC7I,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,IAAI,kBAAkB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAA;AACnG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,aAAa,CAAC,MAAyB;IACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,6BAA6B,EAAE,CAAA;IACzE,MAAM,mBAAmB,GAAG,IAAI,qDAAuB,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IACxG,OAAO,IAAI,iBAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;AACzD,CAAC;AAJD,sCAIC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,oBAAoB,CAAC,MAAyB;IAC5D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,+BAA+B,EAAE,CAAA;IAC3E,MAAM,mBAAmB,GAAG,IAAI,qDAAuB,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,qBAAqB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IAC/H,OAAO,IAAI,iBAAO,CAAC,mBAAmB,CAAC,CAAA;AACzC,CAAC;AAJD,oDAIC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,gBAAgB,CAAC,MAAyB;IACxD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,6BAA6B,EAAE,CAAA;IACnE,+FAA+F;IAC/F,iEAAiE;IACjE,OAAO,IAAI,aAAG,CAAC,KAAe,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAA;AAC3E,CAAC;AALD,4CAKC;AAED,uCAAuC;AAA9B,sGAAA,UAAU,OAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"main": "index.js",
|
|
3
3
|
"types": "index.d.ts",
|
|
4
4
|
"name": "@algorandfoundation/algokit-utils",
|
|
5
|
-
"version": "1.0.0
|
|
5
|
+
"version": "1.0.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
8
8
|
"author": "Algorand Foundation",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"**/*"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"algosdk": "^2.
|
|
17
|
+
"algosdk": "^2.2.0",
|
|
18
18
|
"buffer": "^6.0.3"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Account, Algodv2, Kmd } from 'algosdk';
|
|
2
|
+
import { GetTestAccountParams } from '../types/testing';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an ephemeral Algorand account for the purposes of testing.
|
|
5
|
+
* Returns a newly created random test account that is funded from the dispenser @see {getDispenserAccount}
|
|
6
|
+
* DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
|
|
7
|
+
* Note: By default this will log the mnemonic of the account.
|
|
8
|
+
* @param param0 The config for the test account to generate
|
|
9
|
+
* @param algod An algod client
|
|
10
|
+
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
11
|
+
* @returns The account, with private key loaded
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTestAccount({ suppressLog, initialFunds }: GetTestAccountParams, algod: Algodv2, kmd?: Kmd): Promise<Account>;
|
|
14
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/testing/account.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrI"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTestAccount = void 0;
|
|
7
|
+
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
const __1 = require("../");
|
|
9
|
+
const account_1 = require("../account");
|
|
10
|
+
const transfer_1 = require("../transfer");
|
|
11
|
+
/**
|
|
12
|
+
* Creates an ephemeral Algorand account for the purposes of testing.
|
|
13
|
+
* Returns a newly created random test account that is funded from the dispenser @see {getDispenserAccount}
|
|
14
|
+
* DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
|
|
15
|
+
* Note: By default this will log the mnemonic of the account.
|
|
16
|
+
* @param param0 The config for the test account to generate
|
|
17
|
+
* @param algod An algod client
|
|
18
|
+
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
19
|
+
* @returns The account, with private key loaded
|
|
20
|
+
*/
|
|
21
|
+
async function getTestAccount({ suppressLog, initialFunds }, algod, kmd) {
|
|
22
|
+
const account = algosdk_1.default.generateAccount();
|
|
23
|
+
__1.Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}' and mnemonic '${algosdk_1.default.secretKeyToMnemonic(account.sk)}'.`);
|
|
24
|
+
const dispenser = await (0, account_1.getDispenserAccount)(algod, kmd);
|
|
25
|
+
await (0, transfer_1.transferAlgos)({ from: dispenser, to: account.addr, amount: initialFunds, note: 'Funding test account', suppressLog }, algod);
|
|
26
|
+
const accountInfo = await algod.accountInformation(account.addr).do();
|
|
27
|
+
__1.Config.getLogger(suppressLog).info('Test account funded; account balance: %d µAlgos', accountInfo.amount);
|
|
28
|
+
return account;
|
|
29
|
+
}
|
|
30
|
+
exports.getTestAccount = getTestAccount;
|
|
31
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/testing/account.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwD;AACxD,2BAA4B;AAC5B,wCAAgD;AAChD,0CAA2C;AAG3C;;;;;;;;;GASG;AACI,KAAK,UAAU,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAwB,EAAE,KAAc,EAAE,GAAS;IACjH,MAAM,OAAO,GAAG,iBAAO,CAAC,eAAe,EAAE,CAAA;IAEzC,UAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAChC,0CAA0C,OAAO,CAAC,IAAI,mBAAmB,iBAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CACrH,CAAA;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAmB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAEvD,MAAM,IAAA,wBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC,CAAA;IAElI,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAA;IAErE,UAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,iDAAiD,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAEzG,OAAO,OAAO,CAAA;AAChB,CAAC;AAhBD,wCAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AlgoKitLogCaptureFixture } from '../../types/testing';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a test fixture for capturing AlgoKit logs.
|
|
4
|
+
*
|
|
5
|
+
* @example ```typescript
|
|
6
|
+
* const logs = algoKitLogCaptureFixture()
|
|
7
|
+
*
|
|
8
|
+
* beforeEach(logs.beforeEach)
|
|
9
|
+
* afterEach(logs.afterEach)
|
|
10
|
+
*
|
|
11
|
+
* test('My test', () => {
|
|
12
|
+
* const capturedLogs = logs.testLogger.capturedLogs
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns The fixture
|
|
17
|
+
*/
|
|
18
|
+
export declare const algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture;
|
|
19
|
+
//# sourceMappingURL=algokit-log-capture-fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algokit-log-capture-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAG9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,wBAqB5C,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.algoKitLogCaptureFixture = void 0;
|
|
4
|
+
const __1 = require("../../");
|
|
5
|
+
const test_logger_1 = require("../test-logger");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a test fixture for capturing AlgoKit logs.
|
|
8
|
+
*
|
|
9
|
+
* @example ```typescript
|
|
10
|
+
* const logs = algoKitLogCaptureFixture()
|
|
11
|
+
*
|
|
12
|
+
* beforeEach(logs.beforeEach)
|
|
13
|
+
* afterEach(logs.afterEach)
|
|
14
|
+
*
|
|
15
|
+
* test('My test', () => {
|
|
16
|
+
* const capturedLogs = logs.testLogger.capturedLogs
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @returns The fixture
|
|
21
|
+
*/
|
|
22
|
+
const algoKitLogCaptureFixture = () => {
|
|
23
|
+
const originalLogger = __1.Config.logger;
|
|
24
|
+
let hybridLogger;
|
|
25
|
+
return {
|
|
26
|
+
get testLogger() {
|
|
27
|
+
return hybridLogger;
|
|
28
|
+
},
|
|
29
|
+
beforeEach: () => {
|
|
30
|
+
hybridLogger = new test_logger_1.TestLogger(originalLogger);
|
|
31
|
+
__1.Config.configure({
|
|
32
|
+
logger: hybridLogger,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
afterEach: () => {
|
|
36
|
+
__1.Config.configure({
|
|
37
|
+
logger: originalLogger,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.algoKitLogCaptureFixture = algoKitLogCaptureFixture;
|
|
43
|
+
//# sourceMappingURL=algokit-log-capture-fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algokit-log-capture-fixture.js","sourceRoot":"","sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":";;;AAAA,8BAA+B;AAE/B,gDAA2C;AAE3C;;;;;;;;;;;;;;;GAeG;AACI,MAAM,wBAAwB,GAAmC,GAAG,EAAE;IAC3E,MAAM,cAAc,GAAG,UAAM,CAAC,MAAM,CAAA;IAEpC,IAAI,YAAwB,CAAA;IAE5B,OAAO;QACL,IAAI,UAAU;YACZ,OAAO,YAAY,CAAA;QACrB,CAAC;QACD,UAAU,EAAE,GAAG,EAAE;YACf,YAAY,GAAG,IAAI,wBAAU,CAAC,cAAc,CAAC,CAAA;YAC7C,UAAM,CAAC,SAAS,CAAC;gBACf,MAAM,EAAE,YAAY;aACrB,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,UAAM,CAAC,SAAS,CAAC;gBACf,MAAM,EAAE,cAAc;aACvB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AArBY,QAAA,wBAAwB,4BAqBpC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AlgorandFixture, AlgorandFixtureConfig } from '../../types/testing';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a test fixture for automated testing against Algorand.
|
|
4
|
+
* By default it tests against a default LocalNet instance, but you can pass in an algod and indexer if you want to test against, say, TestNet.
|
|
5
|
+
*
|
|
6
|
+
* @example ```typescript
|
|
7
|
+
* const algorand = algorandFixture()
|
|
8
|
+
*
|
|
9
|
+
* beforeEach(algorand.beforeEach, 10_000)
|
|
10
|
+
*
|
|
11
|
+
* test('My test', () => {
|
|
12
|
+
* const {algod, indexer, testAccount, ...} = algorand.context
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param fixtureConfig The fixture configuration
|
|
17
|
+
* @returns The fixture
|
|
18
|
+
*/
|
|
19
|
+
export declare const algorandFixture: (fixtureConfig?: AlgorandFixtureConfig) => AlgorandFixture;
|
|
20
|
+
//# sourceMappingURL=algorand-fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algorand-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAuD,MAAM,qBAAqB,CAAA;AAEjI;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,mBAAoB,qBAAqB,KAAG,eA0BvE,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.algorandFixture = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
5
|
+
const __2 = require("../../");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a test fixture for automated testing against Algorand.
|
|
8
|
+
* By default it tests against a default LocalNet instance, but you can pass in an algod and indexer if you want to test against, say, TestNet.
|
|
9
|
+
*
|
|
10
|
+
* @example ```typescript
|
|
11
|
+
* const algorand = algorandFixture()
|
|
12
|
+
*
|
|
13
|
+
* beforeEach(algorand.beforeEach, 10_000)
|
|
14
|
+
*
|
|
15
|
+
* test('My test', () => {
|
|
16
|
+
* const {algod, indexer, testAccount, ...} = algorand.context
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param fixtureConfig The fixture configuration
|
|
21
|
+
* @returns The fixture
|
|
22
|
+
*/
|
|
23
|
+
const algorandFixture = (fixtureConfig) => {
|
|
24
|
+
const algod = fixtureConfig?.algod ?? (0, __2.getAlgoClient)((0, __2.getDefaultLocalNetConfig)('algod'));
|
|
25
|
+
const indexer = fixtureConfig?.indexer ?? (0, __2.getAlgoIndexerClient)((0, __2.getDefaultLocalNetConfig)('indexer'));
|
|
26
|
+
const kmd = fixtureConfig?.kmd ?? (0, __2.getAlgoKmdClient)((0, __2.getDefaultLocalNetConfig)('kmd'));
|
|
27
|
+
let context;
|
|
28
|
+
const beforeEach = async () => {
|
|
29
|
+
const transactionLogger = new __1.TransactionLogger();
|
|
30
|
+
context = {
|
|
31
|
+
algod: transactionLogger.capture(algod),
|
|
32
|
+
indexer: indexer,
|
|
33
|
+
kmd: kmd,
|
|
34
|
+
testAccount: await (0, __1.getTestAccount)({ initialFunds: fixtureConfig?.testAccountFunding ?? (0, __2.algos)(10), suppressLog: true }, algod, kmd),
|
|
35
|
+
generateAccount: (params) => (0, __1.getTestAccount)(params, algod, kmd),
|
|
36
|
+
transactionLogger: transactionLogger,
|
|
37
|
+
waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
|
|
38
|
+
waitForIndexerTransaction: (transactionId) => (0, __1.runWhenIndexerCaughtUp)(() => (0, __2.lookupTransactionById)(transactionId, indexer)),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
get context() {
|
|
43
|
+
return context;
|
|
44
|
+
},
|
|
45
|
+
beforeEach,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.algorandFixture = algorandFixture;
|
|
49
|
+
//# sourceMappingURL=algorand-fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algorand-fixture.js","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":";;;AAAA,2BAA+E;AAC/E,8BAAsI;AAGtI;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,eAAe,GAAG,CAAC,aAAqC,EAAmB,EAAE;IACxF,MAAM,KAAK,GAAG,aAAa,EAAE,KAAK,IAAI,IAAA,iBAAa,EAAC,IAAA,4BAAwB,EAAC,OAAO,CAAC,CAAC,CAAA;IACtF,MAAM,OAAO,GAAG,aAAa,EAAE,OAAO,IAAI,IAAA,wBAAoB,EAAC,IAAA,4BAAwB,EAAC,SAAS,CAAC,CAAC,CAAA;IACnG,MAAM,GAAG,GAAG,aAAa,EAAE,GAAG,IAAI,IAAA,oBAAgB,EAAC,IAAA,4BAAwB,EAAC,KAAK,CAAC,CAAC,CAAA;IACnF,IAAI,OAAsC,CAAA;IAE1C,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,MAAM,iBAAiB,GAAG,IAAI,qBAAiB,EAAE,CAAA;QACjD,OAAO,GAAG;YACR,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC;YACvC,OAAO,EAAE,OAAO;YAChB,GAAG,EAAE,GAAG;YACR,WAAW,EAAE,MAAM,IAAA,kBAAc,EAAC,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,IAAI,IAAA,SAAK,EAAC,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC;YAClI,eAAe,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,IAAA,kBAAc,EAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC;YACrF,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC;YAC/D,yBAAyB,EAAE,CAAC,aAAqB,EAAE,EAAE,CAAC,IAAA,0BAAsB,EAAC,GAAG,EAAE,CAAC,IAAA,yBAAqB,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SAClI,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,IAAI,OAAO;YACT,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AA1BY,QAAA,eAAe,mBA0B3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./algokit-log-capture-fixture"), exports);
|
|
18
|
+
__exportStar(require("./algorand-fixture"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/fixtures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C;AAC7C,qDAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
package/testing/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./account"), exports);
|
|
18
|
+
__exportStar(require("./fixtures"), exports);
|
|
19
|
+
__exportStar(require("./indexer"), exports);
|
|
20
|
+
__exportStar(require("./test-logger"), exports);
|
|
21
|
+
__exportStar(require("./transaction-logger"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,6CAA0B;AAC1B,4CAAyB;AACzB,gDAA6B;AAC7B,uDAAoC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the given indexer call until a 404 error is no longer returned.
|
|
3
|
+
* Tried every 200ms up to 20 times.
|
|
4
|
+
* Very rudimentary implementation designed for automated testing.
|
|
5
|
+
* @example ```typescript
|
|
6
|
+
* const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
|
|
7
|
+
* ```
|
|
8
|
+
* @param run The code to run
|
|
9
|
+
* @returns The result (as a promise), or throws if the indexer didn't catch up in time
|
|
10
|
+
*/
|
|
11
|
+
export declare function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T>;
|
|
12
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../src/testing/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsBjF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runWhenIndexerCaughtUp = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Runs the given indexer call until a 404 error is no longer returned.
|
|
6
|
+
* Tried every 200ms up to 20 times.
|
|
7
|
+
* Very rudimentary implementation designed for automated testing.
|
|
8
|
+
* @example ```typescript
|
|
9
|
+
* const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
|
|
10
|
+
* ```
|
|
11
|
+
* @param run The code to run
|
|
12
|
+
* @returns The result (as a promise), or throws if the indexer didn't catch up in time
|
|
13
|
+
*/
|
|
14
|
+
async function runWhenIndexerCaughtUp(run) {
|
|
15
|
+
let result = null;
|
|
16
|
+
let ok = false;
|
|
17
|
+
let tries = 0;
|
|
18
|
+
while (!ok) {
|
|
19
|
+
try {
|
|
20
|
+
result = await run();
|
|
21
|
+
ok = true;
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
if (e?.status === 404) {
|
|
25
|
+
tries++;
|
|
26
|
+
if (tries > 20) {
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
exports.runWhenIndexerCaughtUp = runWhenIndexerCaughtUp;
|
|
39
|
+
//# sourceMappingURL=indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/testing/indexer.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,KAAK,UAAU,sBAAsB,CAAI,GAAqB;IACnE,IAAI,MAAM,GAAa,IAAI,CAAA;IAC3B,IAAI,EAAE,GAAG,KAAK,CAAA;IACd,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,EAAE;QACV,IAAI;YACF,MAAM,GAAG,MAAM,GAAG,EAAE,CAAA;YACpB,EAAE,GAAG,IAAI,CAAA;SACV;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,EAAE;gBACrB,KAAK,EAAE,CAAA;gBACP,IAAI,KAAK,GAAG,EAAE,EAAE;oBACd,MAAM,CAAC,CAAA;iBACR;gBACD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;aAC/D;iBAAM;gBACL,MAAM,CAAC,CAAA;aACR;SACF;KACF;IAED,OAAO,MAAW,CAAA;AACpB,CAAC;AAtBD,wDAsBC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Logger } from '../types/logging';
|
|
2
|
+
import { LogSnapshotConfig } from '../types/testing';
|
|
3
|
+
/** Exposes an AlgoKit logger which captures log messages, while wrapping an original logger.
|
|
4
|
+
* This is useful for automated testing.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TestLogger implements Logger {
|
|
7
|
+
private originalLogger;
|
|
8
|
+
private logs;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new test logger that wraps the given logger if provided.
|
|
11
|
+
* @param originalLogger The optional original logger to wrap.
|
|
12
|
+
*/
|
|
13
|
+
constructor(originalLogger?: Logger);
|
|
14
|
+
/** Returns all logs captured thus far. */
|
|
15
|
+
get capturedLogs(): string[];
|
|
16
|
+
/** Clears all logs captured so far. */
|
|
17
|
+
clear(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a captured log snapshot.
|
|
20
|
+
* This helps ensure that the provided configuration items won't appear
|
|
21
|
+
* with random values in the log snapshot, but rather will get substituted with predictable ids.
|
|
22
|
+
* @see https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
|
|
23
|
+
* @example Jest Example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const logger = new TestLogger()
|
|
26
|
+
* ...
|
|
27
|
+
* expect(logger.getLogSnapshot()).toMatchSnapshot()
|
|
28
|
+
* ```
|
|
29
|
+
* @param config The snapshot configuration
|
|
30
|
+
* @returns The snapshotted logs.
|
|
31
|
+
*/
|
|
32
|
+
getLogSnapshot(config?: LogSnapshotConfig): string;
|
|
33
|
+
error(message: string, ...optionalParams: unknown[]): void;
|
|
34
|
+
warn(message: string, ...optionalParams: unknown[]): void;
|
|
35
|
+
info(message: string, ...optionalParams: unknown[]): void;
|
|
36
|
+
verbose(message: string, ...optionalParams: unknown[]): void;
|
|
37
|
+
debug(message: string, ...optionalParams: unknown[]): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=test-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-logger.d.ts","sourceRoot":"","sources":["../../src/testing/test-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,IAAI,CAAU;IAEtB;;;OAGG;gBACS,cAAc,CAAC,EAAE,MAAM;IAKnC,0CAA0C;IAC1C,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED,uCAAuC;IACvC,KAAK;IAIL;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,MAAM,CAAC,EAAE,iBAAiB;IAczC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAI1D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAIzD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAIzD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAI5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;CAI3D"}
|