@algorandfoundation/algokit-utils 2.3.3-beta.3 → 2.3.3-beta.5
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/cjs/account.d.ts.map +1 -0
- package/cjs/account.js.map +1 -0
- package/cjs/amount.d.ts.map +1 -0
- package/cjs/amount.js.map +1 -0
- package/cjs/app-client.d.ts.map +1 -0
- package/cjs/app-client.js.map +1 -0
- package/cjs/app-deploy.d.ts.map +1 -0
- package/cjs/app-deploy.js.map +1 -0
- package/cjs/app.d.ts.map +1 -0
- package/cjs/app.js.map +1 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js.map +1 -0
- package/cjs/indexer-lookup.d.ts.map +1 -0
- package/cjs/indexer-lookup.js.map +1 -0
- package/cjs/localnet.d.ts.map +1 -0
- package/{localnet.js → cjs/localnet.js} +1 -1
- package/cjs/localnet.js.map +1 -0
- package/cjs/network-client.d.ts.map +1 -0
- package/cjs/network-client.js.map +1 -0
- package/cjs/testing/account.d.ts.map +1 -0
- package/cjs/testing/account.js.map +1 -0
- package/cjs/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/cjs/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/cjs/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/cjs/testing/fixtures/algorand-fixture.js.map +1 -0
- package/cjs/testing/fixtures/index.d.ts.map +1 -0
- package/cjs/testing/fixtures/index.js.map +1 -0
- package/cjs/testing/index.d.ts.map +1 -0
- package/cjs/testing/index.js.map +1 -0
- package/cjs/testing/indexer.d.ts.map +1 -0
- package/cjs/testing/indexer.js.map +1 -0
- package/cjs/testing/test-logger.d.ts.map +1 -0
- package/{testing → cjs/testing}/test-logger.js +2 -0
- package/cjs/testing/test-logger.js.map +1 -0
- package/cjs/testing/transaction-logger.d.ts.map +1 -0
- package/{testing → cjs/testing}/transaction-logger.js +2 -3
- package/cjs/testing/transaction-logger.js.map +1 -0
- package/cjs/transaction.d.ts.map +1 -0
- package/cjs/transaction.js.map +1 -0
- package/cjs/transfer.d.ts.map +1 -0
- package/cjs/transfer.js.map +1 -0
- package/cjs/types/account.d.ts +66 -0
- package/cjs/types/account.d.ts.map +1 -0
- package/{types → cjs/types}/account.js +7 -0
- package/cjs/types/account.js.map +1 -0
- package/cjs/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/{types → cjs/types}/algo-http-client-with-retry.js +16 -16
- package/cjs/types/algo-http-client-with-retry.js.map +1 -0
- package/cjs/types/amount.d.ts +24 -0
- package/cjs/types/amount.d.ts.map +1 -0
- package/{types → cjs/types}/amount.js +1 -0
- package/cjs/types/amount.js.map +1 -0
- package/cjs/types/app-client.d.ts +408 -0
- package/cjs/types/app-client.d.ts.map +1 -0
- package/{types → cjs/types}/app-client.js +13 -0
- package/cjs/types/app-client.js.map +1 -0
- package/cjs/types/app-spec.d.ts.map +1 -0
- package/{types → cjs/types}/app-spec.js.map +1 -1
- package/cjs/types/app.d.ts +308 -0
- package/cjs/types/app.d.ts.map +1 -0
- package/cjs/types/app.js.map +1 -0
- package/cjs/types/config.d.ts.map +1 -0
- package/{types → cjs/types}/config.js +1 -0
- package/cjs/types/config.js.map +1 -0
- package/cjs/types/indexer.d.ts.map +1 -0
- package/cjs/types/indexer.js.map +1 -0
- package/cjs/types/logging.d.ts.map +1 -0
- package/cjs/types/logging.js.map +1 -0
- package/cjs/types/logic-error.d.ts.map +1 -0
- package/{types → cjs/types}/logic-error.js +5 -2
- package/cjs/types/logic-error.js.map +1 -0
- package/cjs/types/network-client.d.ts +20 -0
- package/cjs/types/network-client.d.ts.map +1 -0
- package/cjs/types/network-client.js.map +1 -0
- package/cjs/types/testing.d.ts.map +1 -0
- package/{types → cjs/types}/testing.js.map +1 -1
- package/cjs/types/transaction.d.ts +111 -0
- package/cjs/types/transaction.d.ts.map +1 -0
- package/{types → cjs/types}/transaction.js.map +1 -1
- package/cjs/types/transfer.d.ts +32 -0
- package/cjs/types/transfer.d.ts.map +1 -0
- package/{types → cjs/types}/transfer.js.map +1 -1
- package/cjs/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/{types → cjs/types}/urlTokenBaseHTTPClient.js +4 -0
- package/cjs/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/cjs/util.d.ts.map +1 -0
- package/cjs/util.js.map +1 -0
- package/esm/account.js +170 -0
- package/esm/account.js.map +1 -0
- package/esm/amount.js +27 -0
- package/esm/amount.js.map +1 -0
- package/esm/app-client.js +76 -0
- package/esm/app-client.js.map +1 -0
- package/esm/app-deploy.js +446 -0
- package/esm/app-deploy.js.map +1 -0
- package/esm/app.js +572 -0
- package/esm/app.js.map +1 -0
- package/esm/index.js +14 -0
- package/esm/index.js.map +1 -0
- package/esm/indexer-lookup.js +98 -0
- package/esm/indexer-lookup.js.map +1 -0
- package/esm/localnet.js +111 -0
- package/esm/localnet.js.map +1 -0
- package/esm/network-client.js +179 -0
- package/esm/network-client.js.map +1 -0
- package/esm/testing/account.js +24 -0
- package/esm/testing/account.js.map +1 -0
- package/esm/testing/fixtures/algokit-log-capture-fixture.js +39 -0
- package/esm/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/esm/testing/fixtures/algorand-fixture.js +53 -0
- package/esm/testing/fixtures/algorand-fixture.js.map +1 -0
- package/esm/testing/fixtures/index.js +3 -0
- package/esm/testing/fixtures/index.js.map +1 -0
- package/esm/testing/index.js +6 -0
- package/esm/testing/index.js.map +1 -0
- package/esm/testing/indexer.js +36 -0
- package/esm/testing/indexer.js.map +1 -0
- package/esm/testing/test-logger.js +69 -0
- package/esm/testing/test-logger.js.map +1 -0
- package/esm/testing/transaction-logger.js +66 -0
- package/esm/testing/transaction-logger.js.map +1 -0
- package/esm/transaction.js +365 -0
- package/esm/transaction.js.map +1 -0
- package/esm/transfer.js +59 -0
- package/esm/transfer.js.map +1 -0
- package/esm/types/account.js +90 -0
- package/esm/types/account.js.map +1 -0
- package/esm/types/algo-http-client-with-retry.js +58 -0
- package/esm/types/algo-http-client-with-retry.js.map +1 -0
- package/esm/types/amount.js +35 -0
- package/esm/types/amount.js.map +1 -0
- package/esm/types/app-client.js +624 -0
- package/esm/types/app-client.js.map +1 -0
- package/esm/types/app-spec.js +2 -0
- package/esm/types/app-spec.js.map +1 -0
- package/esm/types/app.js +33 -0
- package/esm/types/app.js.map +1 -0
- package/esm/types/config.js +50 -0
- package/esm/types/config.js.map +1 -0
- package/esm/types/indexer.js +31 -0
- package/esm/types/indexer.js.map +1 -0
- package/esm/types/logging.js +24 -0
- package/esm/types/logging.js.map +1 -0
- package/esm/types/logic-error.js +49 -0
- package/esm/types/logic-error.js.map +1 -0
- package/esm/types/network-client.js +2 -0
- package/esm/types/network-client.js.map +1 -0
- package/esm/types/testing.js +2 -0
- package/esm/types/testing.js.map +1 -0
- package/esm/types/transaction.js +2 -0
- package/esm/types/transaction.js.map +1 -0
- package/esm/types/transfer.js +2 -0
- package/esm/types/transfer.js.map +1 -0
- package/esm/types/urlTokenBaseHTTPClient.js +151 -0
- package/esm/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/esm/util.js +20 -0
- package/esm/util.js.map +1 -0
- package/package.json +42 -6
- package/types/account.d.ts +125 -63
- package/types/account.d.ts.map +1 -1
- package/types/amount.d.ts +18 -22
- package/types/amount.d.ts.map +1 -1
- package/types/app-client.d.ts +70 -407
- package/types/app-client.d.ts.map +1 -1
- package/types/app-deploy.d.ts +101 -0
- package/types/app-deploy.d.ts.map +1 -0
- package/types/app.d.ts +145 -290
- package/types/app.d.ts.map +1 -1
- package/types/index.d.ts +14 -0
- package/types/index.d.ts.map +1 -0
- package/types/indexer-lookup.d.ts +38 -0
- package/types/indexer-lookup.d.ts.map +1 -0
- package/types/localnet.d.ts +54 -0
- package/types/localnet.d.ts.map +1 -0
- package/types/network-client.d.ts +96 -19
- package/types/network-client.d.ts.map +1 -1
- package/types/testing/account.d.ts +14 -0
- package/types/testing/account.d.ts.map +1 -0
- package/types/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
- package/types/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/types/testing/fixtures/algorand-fixture.d.ts +48 -0
- package/types/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/types/testing/fixtures/index.d.ts +3 -0
- package/types/testing/fixtures/index.d.ts.map +1 -0
- package/types/testing/index.d.ts +6 -0
- package/types/testing/index.d.ts.map +1 -0
- package/types/testing/indexer.d.ts +12 -0
- package/types/testing/indexer.d.ts.map +1 -0
- package/types/testing/test-logger.d.ts +41 -0
- package/types/testing/test-logger.d.ts.map +1 -0
- package/types/testing/transaction-logger.d.ts +29 -0
- package/types/testing/transaction-logger.d.ts.map +1 -0
- package/types/transaction.d.ts +133 -106
- package/types/transaction.d.ts.map +1 -1
- package/types/transfer.d.ts +21 -31
- package/types/transfer.d.ts.map +1 -1
- package/types/types/account.d.ts +66 -0
- package/types/types/account.d.ts.map +1 -0
- package/types/types/algo-http-client-with-retry.d.ts +14 -0
- package/types/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/types/types/amount.d.ts +24 -0
- package/types/types/amount.d.ts.map +1 -0
- package/types/types/app-client.d.ts +408 -0
- package/types/types/app-client.d.ts.map +1 -0
- package/types/types/app-spec.d.ts +154 -0
- package/types/types/app-spec.d.ts.map +1 -0
- package/types/types/app.d.ts +308 -0
- package/types/types/app.d.ts.map +1 -0
- package/types/types/config.d.ts +32 -0
- package/types/types/config.d.ts.map +1 -0
- package/types/types/indexer.d.ts +623 -0
- package/types/types/indexer.d.ts.map +1 -0
- package/types/types/logging.d.ts +13 -0
- package/types/types/logging.d.ts.map +1 -0
- package/types/types/logic-error.d.ts +37 -0
- package/types/types/logic-error.d.ts.map +1 -0
- package/types/types/network-client.d.ts +20 -0
- package/types/types/network-client.d.ts.map +1 -0
- package/types/types/testing.d.ts +89 -0
- package/types/types/testing.d.ts.map +1 -0
- package/types/types/transaction.d.ts +111 -0
- package/types/types/transaction.d.ts.map +1 -0
- package/types/types/transfer.d.ts +32 -0
- package/types/types/transfer.d.ts.map +1 -0
- package/types/types/urlTokenBaseHTTPClient.d.ts +41 -0
- package/types/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/types/util.d.ts +10 -0
- package/types/util.d.ts.map +1 -0
- package/account.d.ts.map +0 -1
- package/account.js.map +0 -1
- package/amount.d.ts.map +0 -1
- package/amount.js.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-client.js.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app-deploy.js.map +0 -1
- package/app.d.ts.map +0 -1
- package/app.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/indexer-lookup.js.map +0 -1
- package/localnet.d.ts.map +0 -1
- package/localnet.js.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/network-client.js.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/account.js.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.js.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/fixtures/index.js.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/index.js.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/indexer.js.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/test-logger.js.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/testing/transaction-logger.js.map +0 -1
- package/transaction.d.ts.map +0 -1
- package/transaction.js.map +0 -1
- package/transfer.d.ts.map +0 -1
- package/transfer.js.map +0 -1
- package/types/account.js.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.js.map +0 -1
- package/types/amount.js.map +0 -1
- package/types/app-client.js.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.js.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/config.js.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/indexer.js.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logging.js.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/logic-error.js.map +0 -1
- package/types/network-client.js.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/util.d.ts.map +0 -1
- package/util.js.map +0 -1
- /package/{account.d.ts → cjs/account.d.ts} +0 -0
- /package/{account.js → cjs/account.js} +0 -0
- /package/{amount.d.ts → cjs/amount.d.ts} +0 -0
- /package/{amount.js → cjs/amount.js} +0 -0
- /package/{app-client.d.ts → cjs/app-client.d.ts} +0 -0
- /package/{app-client.js → cjs/app-client.js} +0 -0
- /package/{app-deploy.d.ts → cjs/app-deploy.d.ts} +0 -0
- /package/{app-deploy.js → cjs/app-deploy.js} +0 -0
- /package/{app.d.ts → cjs/app.d.ts} +0 -0
- /package/{app.js → cjs/app.js} +0 -0
- /package/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/{index.js → cjs/index.js} +0 -0
- /package/{indexer-lookup.d.ts → cjs/indexer-lookup.d.ts} +0 -0
- /package/{indexer-lookup.js → cjs/indexer-lookup.js} +0 -0
- /package/{localnet.d.ts → cjs/localnet.d.ts} +0 -0
- /package/{network-client.d.ts → cjs/network-client.d.ts} +0 -0
- /package/{network-client.js → cjs/network-client.js} +0 -0
- /package/{testing → cjs/testing}/account.d.ts +0 -0
- /package/{testing → cjs/testing}/account.js +0 -0
- /package/{testing → cjs/testing}/fixtures/algokit-log-capture-fixture.d.ts +0 -0
- /package/{testing → cjs/testing}/fixtures/algokit-log-capture-fixture.js +0 -0
- /package/{testing → cjs/testing}/fixtures/algorand-fixture.d.ts +0 -0
- /package/{testing → cjs/testing}/fixtures/algorand-fixture.js +0 -0
- /package/{testing → cjs/testing}/fixtures/index.d.ts +0 -0
- /package/{testing → cjs/testing}/fixtures/index.js +0 -0
- /package/{testing → cjs/testing}/index.d.ts +0 -0
- /package/{testing → cjs/testing}/index.js +0 -0
- /package/{testing → cjs/testing}/indexer.d.ts +0 -0
- /package/{testing → cjs/testing}/indexer.js +0 -0
- /package/{testing → cjs/testing}/test-logger.d.ts +0 -0
- /package/{testing → cjs/testing}/transaction-logger.d.ts +0 -0
- /package/{transaction.d.ts → cjs/transaction.d.ts} +0 -0
- /package/{transaction.js → cjs/transaction.js} +0 -0
- /package/{transfer.d.ts → cjs/transfer.d.ts} +0 -0
- /package/{transfer.js → cjs/transfer.js} +0 -0
- /package/{types → cjs/types}/algo-http-client-with-retry.d.ts +0 -0
- /package/{types → cjs/types}/app-spec.d.ts +0 -0
- /package/{types → cjs/types}/app-spec.js +0 -0
- /package/{types → cjs/types}/app.js +0 -0
- /package/{types → cjs/types}/config.d.ts +0 -0
- /package/{types → cjs/types}/indexer.d.ts +0 -0
- /package/{types → cjs/types}/indexer.js +0 -0
- /package/{types → cjs/types}/logging.d.ts +0 -0
- /package/{types → cjs/types}/logging.js +0 -0
- /package/{types → cjs/types}/logic-error.d.ts +0 -0
- /package/{types → cjs/types}/network-client.js +0 -0
- /package/{types → cjs/types}/testing.d.ts +0 -0
- /package/{types → cjs/types}/testing.js +0 -0
- /package/{types → cjs/types}/transaction.js +0 -0
- /package/{types → cjs/types}/transfer.js +0 -0
- /package/{types → cjs/types}/urlTokenBaseHTTPClient.d.ts +0 -0
- /package/{util.d.ts → cjs/util.d.ts} +0 -0
- /package/{util.js → cjs/util.js} +0 -0
|
@@ -1,20 +1,97 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { Algodv2, Indexer, Kmd } from 'algosdk';
|
|
2
|
+
import { AlgoClientConfig, AlgoConfig } from './types/network-client';
|
|
3
|
+
/** Retrieve configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment not algod-side) */
|
|
4
|
+
export declare function getConfigFromEnvOrDefaults(): AlgoConfig;
|
|
5
|
+
/** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
6
|
+
export declare function getAlgodConfigFromEnvironment(): AlgoClientConfig;
|
|
7
|
+
/** Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
8
|
+
export declare function getIndexerConfigFromEnvironment(): AlgoClientConfig;
|
|
9
|
+
/** Returns the Algorand configuration to point to the AlgoNode service
|
|
10
|
+
*
|
|
11
|
+
* @param network Which network to connect to - TestNet or MainNet
|
|
12
|
+
* @param config Which algod config to return - Algod or Indexer
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAlgoNodeConfig(network: 'testnet' | 'mainnet', config: 'algod' | 'indexer'): AlgoClientConfig;
|
|
15
|
+
/** Returns the Algorand configuration to point to the default LocalNet
|
|
16
|
+
*
|
|
17
|
+
* @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexer' | 'kmd' | number): AlgoClientConfig;
|
|
20
|
+
/** Returns an algod SDK client that automatically retries on idempotent calls
|
|
21
|
+
*
|
|
22
|
+
* @param config The config if you want to override the default (getting config from process.env)
|
|
23
|
+
* @example Default (load from environment variables)
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
|
|
27
|
+
* // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
|
|
28
|
+
* const algod = getAlgoClient()
|
|
29
|
+
* await algod.healthCheck().do()
|
|
30
|
+
* ```
|
|
31
|
+
* @example AlgoNode (testnet)
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
|
|
34
|
+
* await algod.healthCheck().do()
|
|
35
|
+
* ```
|
|
36
|
+
* @example AlgoNode (mainnet)
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
|
|
39
|
+
* await algod.healthCheck().do()
|
|
40
|
+
* ```
|
|
41
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
44
|
+
* await algod.healthCheck().do()
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
|
|
48
|
+
/** Returns an indexer SDK client that automatically retries on idempotent calls
|
|
49
|
+
*
|
|
50
|
+
* @param config The config if you want to override the default (getting config from process.env)
|
|
51
|
+
* @example Default (load from environment variables)
|
|
52
|
+
*
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
|
|
55
|
+
* // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
|
|
56
|
+
* const indexer = getAlgoIndexerClient()
|
|
57
|
+
* await indexer.makeHealthCheck().do()
|
|
58
|
+
* ```
|
|
59
|
+
* @example AlgoNode (testnet)
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
|
|
62
|
+
* await indexer.makeHealthCheck().do()
|
|
63
|
+
* ```
|
|
64
|
+
* @example AlgoNode (mainnet)
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
|
|
67
|
+
* await indexer.makeHealthCheck().do()
|
|
68
|
+
* ```
|
|
69
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
72
|
+
* await indexer.makeHealthCheck().do()
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer;
|
|
76
|
+
/**
|
|
77
|
+
* Returns a KMD SDK client that automatically retries on idempotent calls
|
|
78
|
+
*
|
|
79
|
+
* KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
|
|
80
|
+
*
|
|
81
|
+
* @param config The config if you want to override the default (getting config from process.env)
|
|
82
|
+
* @example Default (load from environment variables)
|
|
83
|
+
*
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
|
|
86
|
+
* const kmd = getAlgoKmdClient()
|
|
87
|
+
* ```
|
|
88
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function getAlgoKmdClient(config?: AlgoClientConfig): Kmd;
|
|
94
|
+
export declare function isTestNet(algod: Algodv2): Promise<boolean>;
|
|
95
|
+
export declare function isMainNet(algod: Algodv2): Promise<boolean>;
|
|
96
|
+
export { isLocalNet } from './localnet';
|
|
20
97
|
//# sourceMappingURL=network-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../../src/
|
|
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,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAErE,uJAAuJ;AACvJ,wBAAgB,0BAA0B,IAAI,UAAU,CAwBvD;AAED,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,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhE;AACD,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhE;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -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
|
|
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
|
|
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,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,48 @@
|
|
|
1
|
+
import { AlgoConfig } from '../../types/network-client';
|
|
2
|
+
import { AlgorandFixture, AlgorandFixtureConfig } from '../../types/testing';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a test fixture for automated testing against Algorand.
|
|
5
|
+
* By default it tests against an environment variable specified client
|
|
6
|
+
* if the standard environment variables are specified, otherwise against
|
|
7
|
+
* a default LocalNet instance, but you can pass in an algod, indexer
|
|
8
|
+
* and/or kmd if you want to test against an explicitly defined network.
|
|
9
|
+
*
|
|
10
|
+
* @example ```typescript
|
|
11
|
+
* const algorand = algorandFixture()
|
|
12
|
+
*
|
|
13
|
+
* beforeEach(algorand.beforeEach, 10_000)
|
|
14
|
+
*
|
|
15
|
+
* test('My test', async () => {
|
|
16
|
+
* const {algod, indexer, testAccount, ...} = algorand.context
|
|
17
|
+
* // test things...
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param fixtureConfig The fixture configuration
|
|
22
|
+
* @returns The fixture
|
|
23
|
+
*/
|
|
24
|
+
export declare function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a test fixture for automated testing against Algorand.
|
|
27
|
+
* By default it tests against an environment variable specified client
|
|
28
|
+
* if the standard environment variables are specified, otherwise against
|
|
29
|
+
* a default LocalNet instance, but you can pass in an algod, indexer
|
|
30
|
+
* and/or kmd if you want to test against an explicitly defined network.
|
|
31
|
+
*
|
|
32
|
+
* @example ```typescript
|
|
33
|
+
* const algorand = algorandFixture(undefined, getConfigFromEnvOrDefaults())
|
|
34
|
+
*
|
|
35
|
+
* beforeEach(algorand.beforeEach, 10_000)
|
|
36
|
+
*
|
|
37
|
+
* test('My test', async () => {
|
|
38
|
+
* const {algod, indexer, testAccount, ...} = algorand.context
|
|
39
|
+
* // test things...
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param fixtureConfig The fixture configuration
|
|
44
|
+
* @param config The algo configuration
|
|
45
|
+
* @returns The fixture
|
|
46
|
+
*/
|
|
47
|
+
export declare function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture;
|
|
48
|
+
//# 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":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAuD,MAAM,qBAAqB,CAAA;AAEjI;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,aAAa,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,qBAAqB,GAAG,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,eAAe,CAAA"}
|
|
@@ -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 @@
|
|
|
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"}
|
|
@@ -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,CAuBjF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
*
|
|
23
|
+
* https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
|
|
24
|
+
*
|
|
25
|
+
* @example Jest Example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const logger = new TestLogger()
|
|
28
|
+
* ...
|
|
29
|
+
* expect(logger.getLogSnapshot()).toMatchSnapshot()
|
|
30
|
+
* ```
|
|
31
|
+
* @param config The snapshot configuration
|
|
32
|
+
* @returns The snapshotted logs.
|
|
33
|
+
*/
|
|
34
|
+
getLogSnapshot(config?: LogSnapshotConfig): string;
|
|
35
|
+
error(message: string, ...optionalParams: unknown[]): void;
|
|
36
|
+
warn(message: string, ...optionalParams: unknown[]): void;
|
|
37
|
+
info(message: string, ...optionalParams: unknown[]): void;
|
|
38
|
+
verbose(message: string, ...optionalParams: unknown[]): void;
|
|
39
|
+
debug(message: string, ...optionalParams: unknown[]): void;
|
|
40
|
+
}
|
|
41
|
+
//# 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;;;;;;;;;;;;;;;OAeG;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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Algodv2, Indexer } from 'algosdk';
|
|
2
|
+
/**
|
|
3
|
+
* Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.
|
|
4
|
+
* Useful for automated tests.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TransactionLogger {
|
|
7
|
+
private _sentTransactionIds;
|
|
8
|
+
/**
|
|
9
|
+
* The list of transaction IDs that has been logged thus far.
|
|
10
|
+
*/
|
|
11
|
+
get sentTransactionIds(): Readonly<string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Clear all logged IDs.
|
|
14
|
+
*/
|
|
15
|
+
clear(): void;
|
|
16
|
+
/**
|
|
17
|
+
* The method that captures raw transactions and stores the transaction IDs.
|
|
18
|
+
*/
|
|
19
|
+
logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]): void;
|
|
20
|
+
/** Return a proxy that wraps the given Algodv2 with this transaction logger.
|
|
21
|
+
*
|
|
22
|
+
* @param algod The `Algodv2` to wrap
|
|
23
|
+
* @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger
|
|
24
|
+
*/
|
|
25
|
+
capture(algod: Algodv2): Algodv2;
|
|
26
|
+
/** Wait until all logged transactions IDs appear in the given `Indexer`. */
|
|
27
|
+
waitForIndexer(indexer: Indexer): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=transaction-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-logger.d.ts","sourceRoot":"","sources":["../../../src/testing/transaction-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,OAAO,EAAE,MAAM,SAAS,CAAA;AAGnE;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,mBAAmB,CAAe;IAE1C;;OAEG;IACH,IAAI,kBAAkB,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAE3C;IAED;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,iBAAiB,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,EAAE;IAY/D;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIhC,4EAA4E;IACtE,cAAc,CAAC,OAAO,EAAE,OAAO;CAGtC"}
|
package/types/transaction.d.ts
CHANGED
|
@@ -1,111 +1,138 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
/** The transaction IDs that have been prepared and/or sent */
|
|
56
|
-
txIds: string[];
|
|
57
|
-
/** If ABI method(s) were called the processed return values */
|
|
58
|
-
returns?: ABIReturn[];
|
|
59
|
-
}
|
|
60
|
-
/** The result of sending and confirming a transaction */
|
|
61
|
-
export interface ConfirmedTransactionResult extends SendTransactionResult {
|
|
62
|
-
/** The response from sending and waiting for the transaction */
|
|
63
|
-
confirmation: modelsv2.PendingTransactionResponse;
|
|
64
|
-
}
|
|
65
|
-
/** The result of sending and confirming one or more transactions, but where there is a primary transaction of interest */
|
|
66
|
-
export interface ConfirmedTransactionResults extends SendTransactionResult, SendTransactionResults {
|
|
67
|
-
/** The response from sending and waiting for the primary transaction */
|
|
68
|
-
confirmation: modelsv2.PendingTransactionResponse;
|
|
69
|
-
/** The response from sending and waiting for the transactions */
|
|
70
|
-
confirmations: modelsv2.PendingTransactionResponse[];
|
|
71
|
-
}
|
|
72
|
-
/** Core account abstraction when signing/sending transactions
|
|
1
|
+
import algosdk, { Algodv2, AtomicTransactionComposer, modelsv2, SuggestedParams, Transaction, TransactionWithSigner } from 'algosdk';
|
|
2
|
+
import { AlgoAmount } from './types/amount';
|
|
3
|
+
import { AtomicTransactionComposerToSend, SendAtomicTransactionComposerResults, SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionGroupToSend, TransactionNote, TransactionToSign } from './types/transaction';
|
|
4
|
+
/** Encodes a transaction note into a byte array ready to be included in an Algorand transaction.
|
|
5
|
+
*
|
|
6
|
+
* @param note The transaction note
|
|
7
|
+
* @returns the transaction note ready for inclusion in a transaction
|
|
8
|
+
*
|
|
9
|
+
* Case on the value of `data` this either be:
|
|
10
|
+
* * `null` | `undefined`: `undefined`
|
|
11
|
+
* * `string`: The string value
|
|
12
|
+
* * Uint8Array: passthrough
|
|
13
|
+
* * Arc2TransactionNote object: ARC-0002 compatible transaction note
|
|
14
|
+
* * Else: The object/value converted into a JSON string representation
|
|
15
|
+
*/
|
|
16
|
+
export declare function encodeTransactionNote(note?: TransactionNote): Uint8Array | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the public address of the given transaction sender.
|
|
19
|
+
* @param sender A transaction sender
|
|
20
|
+
* @returns The public address
|
|
21
|
+
*/
|
|
22
|
+
export declare const getSenderAddress: (sender: SendTransactionFrom) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Given a transaction in a variety of supported formats, returns a TransactionWithSigner object ready to be passed to an
|
|
25
|
+
* AtomicTransactionComposer's addTransaction method.
|
|
26
|
+
* @param transaction One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the
|
|
27
|
+
* signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by
|
|
28
|
+
* one of algokit utils' helpers (signer is obtained from the defaultSender parameter)
|
|
29
|
+
* @param defaultSender The default sender to be used to obtain a signer where the object provided to the transaction parameter does not
|
|
30
|
+
* include a signer.
|
|
31
|
+
* @returns A TransactionWithSigner object.
|
|
32
|
+
*/
|
|
33
|
+
export declare const getTransactionWithSigner: (transaction: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom) => Promise<TransactionWithSigner>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns a `TransactionSigner` for the given transaction sender.
|
|
36
|
+
* This function has memoization, so will return the same transaction signer for a given sender.
|
|
37
|
+
* @param sender A transaction sender
|
|
38
|
+
* @returns A transaction signer
|
|
39
|
+
*/
|
|
40
|
+
export declare const getSenderTransactionSigner: (val: SendTransactionFrom) => algosdk.TransactionSigner;
|
|
41
|
+
/**
|
|
42
|
+
* Signs a single transaction by the given signer.
|
|
43
|
+
* @param transaction The transaction to sign
|
|
44
|
+
* @param signer The signer to sign
|
|
45
|
+
* @returns The signed transaction as a `Uint8Array`
|
|
46
|
+
*/
|
|
47
|
+
export declare const signTransaction: (transaction: Transaction, signer: SendTransactionFrom) => Promise<Uint8Array>;
|
|
48
|
+
/** Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.
|
|
49
|
+
*
|
|
50
|
+
* @param send The details for the transaction to prepare/send, including:
|
|
51
|
+
* * `transaction`: The unsigned transaction
|
|
52
|
+
* * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account
|
|
53
|
+
* * `config`: The sending configuration for this transaction
|
|
54
|
+
* @param algod An algod client
|
|
73
55
|
*
|
|
74
|
-
*
|
|
75
|
-
* many types of accounts, including:
|
|
76
|
-
* * `Account` - The in-built `algosdk.Account` type for mnemonic accounts
|
|
77
|
-
* * `SigningAccount` - An AlgoKit Utils class that wraps Account to provide support for rekeyed accounts
|
|
78
|
-
* * `LogicSigAccount` - The in-built `algosdk.LogicSigAccount` type for logic signatures
|
|
79
|
-
* * `MultisigAccount` - An AlgoKit Utils class that wraps a multisig account and provides mechanisms to get a multisig account
|
|
80
|
-
* * `TransactionSignerAccount` - An AlgoKitUtils class that wraps the in-built `algosdk.TransactionSigner` along with the sender address
|
|
56
|
+
* @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)
|
|
81
57
|
*/
|
|
82
|
-
export
|
|
83
|
-
/** Defines an unsigned transaction that will appear in a group of transactions along with its signing information */
|
|
84
|
-
export interface TransactionToSign {
|
|
85
|
-
/** The unsigned transaction to sign and send */
|
|
58
|
+
export declare const sendTransaction: (send: {
|
|
86
59
|
transaction: Transaction;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
60
|
+
from: SendTransactionFrom;
|
|
61
|
+
sendParams?: SendTransactionParams;
|
|
62
|
+
}, algod: Algodv2) => Promise<SendTransactionResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Signs and sends transactions that have been collected by an `AtomicTransactionComposer`.
|
|
65
|
+
* @param atcSend The parameters controlling the send, including:
|
|
66
|
+
* * `atc` The `AtomicTransactionComposer`
|
|
67
|
+
* * `sendParams` The parameters to control the send behaviour
|
|
68
|
+
* @param algod An algod client
|
|
69
|
+
* @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
|
|
70
|
+
*/
|
|
71
|
+
export declare const sendAtomicTransactionComposer: (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) => Promise<SendAtomicTransactionComposerResults>;
|
|
72
|
+
/**
|
|
73
|
+
* Performs a dry run of the transactions loaded into the given AtomicTransactionComposer`
|
|
74
|
+
* @param atc The AtomicTransactionComposer` with transaction(s) loaded
|
|
75
|
+
* @param algod An Algod client
|
|
76
|
+
* @returns The dryrun result
|
|
77
|
+
*/
|
|
78
|
+
export declare function performAtomicTransactionComposerDryrun(atc: AtomicTransactionComposer, algod: Algodv2): Promise<algosdk.DryrunResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain
|
|
81
|
+
*
|
|
82
|
+
* @param groupSend The group details to send, with:
|
|
83
|
+
* * `transactions`: The array of transactions to send along with their signing account
|
|
84
|
+
* * `sendParams`: The parameters to dictate how the group is sent
|
|
85
|
+
* @param algod An algod client
|
|
86
|
+
* @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
|
|
87
|
+
*/
|
|
88
|
+
export declare const sendGroupOfTransactions: (groupSend: TransactionGroupToSend, algod: Algodv2) => Promise<Omit<SendAtomicTransactionComposerResults, "returns">>;
|
|
89
|
+
/**
|
|
90
|
+
* Wait until the transaction is confirmed or rejected, or until `timeout`
|
|
91
|
+
* number of rounds have passed.
|
|
92
|
+
*
|
|
93
|
+
* @param algod An algod client
|
|
94
|
+
* @param transactionId The transaction ID to wait for
|
|
95
|
+
* @param maxRoundsToWait Maximum number of rounds to wait
|
|
96
|
+
*
|
|
97
|
+
* @return Pending transaction information
|
|
98
|
+
* @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds
|
|
99
|
+
*/
|
|
100
|
+
export declare const waitForConfirmation: (transactionId: string, maxRoundsToWait: number | bigint, algod: Algodv2) => Promise<modelsv2.PendingTransactionResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Limit the acceptable fee to a defined amount of µALGOs.
|
|
103
|
+
* This also sets the transaction to be flatFee to ensure the transaction only succeeds at
|
|
104
|
+
* the estimated rate.
|
|
105
|
+
* @param transaction The transaction to cap or suggested params object about to be used to create a transaction
|
|
106
|
+
* @param maxAcceptableFee The maximum acceptable fee to pay
|
|
107
|
+
*/
|
|
108
|
+
export declare function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount): void;
|
|
109
|
+
/**
|
|
110
|
+
* Allows for control of fees on a `Transaction` or `SuggestedParams` object
|
|
111
|
+
* @param transaction The transaction or suggested params
|
|
112
|
+
* @param feeControl The fee control parameters
|
|
113
|
+
*/
|
|
114
|
+
export declare function controlFees<T extends SuggestedParams | Transaction>(transaction: T, feeControl: {
|
|
115
|
+
fee?: AlgoAmount;
|
|
116
|
+
maxFee?: AlgoAmount;
|
|
117
|
+
}): T;
|
|
118
|
+
/**
|
|
119
|
+
* Returns suggested transaction parameters from algod unless some are already provided.
|
|
120
|
+
* @param params Optionally provide parameters to use
|
|
121
|
+
* @param algod Algod algod
|
|
122
|
+
* @returns The suggested transaction parameters
|
|
123
|
+
*/
|
|
124
|
+
export declare function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2): Promise<import("algosdk/dist/types/types/transactions/base").SuggestedParamsWithMinFee | {
|
|
125
|
+
flatFee?: boolean | undefined;
|
|
126
|
+
fee: number;
|
|
127
|
+
firstRound: number;
|
|
128
|
+
lastRound: number;
|
|
129
|
+
genesisID: string;
|
|
130
|
+
genesisHash: string;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the array of transactions currently present in the given `AtomicTransactionComposer`
|
|
134
|
+
* @param atc The atomic transaction composer
|
|
135
|
+
* @returns The array of transactions with signers
|
|
92
136
|
*/
|
|
93
|
-
export
|
|
94
|
-
/** Any parameters to control the semantics of the send to the network */
|
|
95
|
-
sendParams?: Omit<SendTransactionParams, 'fee' | 'maxFee' | 'skipSending' | 'atc'>;
|
|
96
|
-
/** The list of transactions to send, which can either be a raw transaction (in which case `signer` is required),
|
|
97
|
-
* the async result of an AlgoKit utils method that returns a `SendTransactionResult` (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is also required)
|
|
98
|
-
* or the transaction with its signer (`signer` is ignored)
|
|
99
|
-
**/
|
|
100
|
-
transactions: (TransactionToSign | Transaction | Promise<SendTransactionResult>)[];
|
|
101
|
-
/** Optional signer to pass in, required if at least one transaction provided is just the transaction, ignored otherwise */
|
|
102
|
-
signer?: SendTransactionFrom;
|
|
103
|
-
}
|
|
104
|
-
/** An `AtomicTransactionComposer` with transactions to send. */
|
|
105
|
-
export interface AtomicTransactionComposerToSend {
|
|
106
|
-
/** The `AtomicTransactionComposer` with transactions loaded to send */
|
|
107
|
-
atc: AtomicTransactionComposer;
|
|
108
|
-
/** Any parameters to control the semantics of the send to the network */
|
|
109
|
-
sendParams?: Omit<SendTransactionParams, 'fee' | 'maxFee' | 'skipSending' | 'atc'>;
|
|
110
|
-
}
|
|
137
|
+
export declare function getAtomicTransactionComposerTransactions(atc: AtomicTransactionComposer): algosdk.TransactionWithSigner[];
|
|
111
138
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EACd,OAAO,EACP,yBAAyB,EACzB,QAAQ,EACR,eAAe,EACf,WAAW,EAEX,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EACL,+BAA+B,EAC/B,oCAAoC,EACpC,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EAClB,MAAM,qBAAqB,CAAA;AAG5B;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,SAAS,CAcpF;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAqB,mBAAmB,WAEpE,CAAA;AAWD;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,gBACtB,qBAAqB,GAAG,iBAAiB,GAAG,WAAW,GAAG,QAAQ,qBAAqB,CAAC,kBACrF,mBAAmB,KAClC,QAAQ,qBAAqB,CAkB/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,yDAMrC,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,gBAAuB,WAAW,UAAU,mBAAmB,wBAQ1F,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,SACpB;IACJ,WAAW,EAAE,WAAW,CAAA;IACxB,IAAI,EAAE,mBAAmB,CAAA;IACzB,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC,SACM,OAAO,KACb,QAAQ,qBAAqB,CA2B/B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,YAA4B,+BAA+B,SAAS,OAAO,kDAgFpH,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,sCAAsC,CAAC,GAAG,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,iCAO1G;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,cAA8B,sBAAsB,SAAS,OAAO,mEAgCvG,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,kBACf,MAAM,mBACJ,MAAM,GAAG,MAAM,SACzB,OAAO,KACb,QAAQ,SAAS,0BAA0B,CA4C7C,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,GAAG,eAAe,EAAE,gBAAgB,EAAE,UAAU,QAgBjH;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,eAAe,GAAG,WAAW,EACjE,WAAW,EAAE,CAAC,EACd,UAAU,EAAE;IAAE,GAAG,CAAC,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,KAatD;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO;;;;;;;GAE7F;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,GAAG,EAAE,yBAAyB,mCAMtF"}
|