@algorandfoundation/algokit-utils 6.3.0-beta.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +22 -26
- package/account/account.d.ts +12 -10
- package/account/account.js +17 -14
- package/account/account.js.map +1 -1
- package/account/account.mjs +18 -15
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +0 -1
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +2 -3
- package/account/get-account.js +1 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +2 -3
- package/account/get-dispenser-account.js +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/index.d.ts +0 -1
- package/account/mnemonic-account.d.ts +1 -2
- package/account/mnemonic-account.js +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +15 -5
- package/amount.js +9 -2
- package/amount.js.map +1 -1
- package/amount.mjs +9 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +19 -5
- package/app-client.js +19 -4
- package/app-client.js.map +1 -1
- package/app-client.mjs +19 -4
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +18 -2
- package/app-deploy.js +159 -342
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +163 -346
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +39 -3
- package/app.js +121 -371
- package/app.js.map +1 -1
- package/app.mjs +122 -372
- package/app.mjs.map +1 -1
- package/asset.d.ts +5 -6
- package/asset.js +5 -8
- package/asset.js.map +1 -1
- package/asset.mjs +5 -8
- package/asset.mjs.map +1 -1
- package/config.d.ts +0 -1
- package/config.js.map +1 -1
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +3 -5
- package/debugging/debugging.js +4 -128
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +4 -109
- package/debugging/debugging.mjs.map +1 -1
- package/debugging/index.d.ts +0 -2
- package/dispenser-client.d.ts +0 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +5 -4
- package/index.js +36 -26
- package/index.js.map +1 -1
- package/index.mjs +6 -5
- package/index.mjs.map +1 -1
- package/indexer-lookup.d.ts +10 -9
- package/indexer-lookup.js +14 -10
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +14 -10
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-kmd-wallet-account.js +1 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +1 -2
- package/localnet/get-localnet-dispenser-account.js +1 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-or-create-kmd-wallet-account.js +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/index.d.ts +0 -1
- package/localnet/is-localnet.d.ts +1 -2
- package/localnet/is-localnet.js +1 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +3 -10
- package/network-client.js +4 -11
- package/network-client.js.map +1 -1
- package/network-client.mjs +4 -11
- package/network-client.mjs.map +1 -1
- package/package.json +3 -4
- package/testing/_asset.d.ts +2 -2
- package/testing/account.d.ts +4 -4
- package/testing/account.js +8 -2
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +9 -3
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +0 -1
- package/testing/fixtures/algorand-fixture.js +13 -14
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +13 -14
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/fixtures/index.d.ts +0 -1
- package/testing/index.d.ts +0 -1
- package/testing/indexer.d.ts +0 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +0 -1
- package/testing/test-logger.js +7 -3
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +7 -3
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +0 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/index.d.ts +0 -1
- package/transaction/legacy-bridge.d.ts +31 -6
- package/transaction/legacy-bridge.js +101 -7
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +101 -10
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -2
- package/transaction/perform-atomic-transaction-composer-simulate.js +14 -9
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -10
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +38 -19
- package/transaction/transaction.js +217 -137
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +218 -138
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/index.d.ts +0 -1
- package/transfer/transfer-algos.d.ts +1 -2
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -2
- package/transfer/transfer.js +6 -4
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +6 -4
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +33 -25
- package/types/account-manager.js +54 -31
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +56 -33
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +17 -9
- package/types/account.js +2 -2
- package/types/account.js.map +1 -1
- package/types/account.mjs +3 -3
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +1 -3
- package/types/algo-http-client-with-retry.js +33 -3
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +32 -2
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +28 -0
- package/types/algorand-client-interface.js +3 -0
- package/types/algorand-client-interface.js.map +1 -0
- package/types/algorand-client-interface.mjs +2 -0
- package/types/algorand-client-interface.mjs.map +1 -0
- package/types/algorand-client-transaction-creator.d.ts +452 -23
- package/types/algorand-client-transaction-creator.js +407 -23
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +407 -23
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +772 -47
- package/types/algorand-client-transaction-sender.js +445 -15
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +445 -15
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +24 -17
- package/types/algorand-client.js +26 -16
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +28 -15
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +10 -11
- package/types/amount.js +7 -7
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +7 -7
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +359 -0
- package/types/app-arc56.js +184 -0
- package/types/app-arc56.js.map +1 -0
- package/types/app-arc56.mjs +175 -0
- package/types/app-arc56.mjs.map +1 -0
- package/types/app-client.d.ts +1508 -12
- package/types/app-client.js +1018 -29
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1020 -32
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +126 -0
- package/types/app-deployer.js +353 -0
- package/types/app-deployer.js.map +1 -0
- package/types/app-deployer.mjs +351 -0
- package/types/app-deployer.mjs.map +1 -0
- package/types/app-factory.d.ts +846 -0
- package/types/app-factory.js +410 -0
- package/types/app-factory.js.map +1 -0
- package/types/app-factory.mjs +408 -0
- package/types/app-factory.mjs.map +1 -0
- package/types/app-manager.d.ts +244 -0
- package/types/app-manager.js +423 -0
- package/types/app-manager.js.map +1 -0
- package/types/app-manager.mjs +421 -0
- package/types/app-manager.mjs.map +1 -0
- package/types/app-spec.d.ts +2 -1
- package/types/app-spec.js +127 -0
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +126 -0
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +57 -18
- package/types/app.js +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +10 -10
- package/types/asset-manager.js +13 -17
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +13 -17
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +0 -1
- package/types/async-event-emitter.d.ts +14 -0
- package/types/async-event-emitter.js +50 -0
- package/types/async-event-emitter.js.map +1 -0
- package/types/async-event-emitter.mjs +48 -0
- package/types/async-event-emitter.mjs.map +1 -0
- package/types/client-manager.d.ts +135 -60
- package/types/client-manager.js +158 -44
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +159 -45
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +271 -87
- package/types/composer.js +405 -125
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +407 -125
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +3 -6
- package/types/config.js +5 -44
- package/types/config.js.map +1 -1
- package/types/config.mjs +5 -27
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +29 -101
- package/types/debugging.js +16 -109
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -107
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +2 -2
- package/types/dispenser-client.js +10 -5
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +10 -5
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +7 -0
- package/types/expand.js +3 -0
- package/types/expand.js.map +1 -0
- package/types/expand.mjs +2 -0
- package/types/expand.mjs.map +1 -0
- package/types/indexer.d.ts +74 -756
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +2 -3
- package/types/kmd-account-manager.js +3 -3
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +4 -4
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.d.ts +0 -1
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -4
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +14 -2
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +8 -10
- package/types/transaction.d.ts +17 -4
- package/types/transfer.d.ts +0 -1
- package/util.d.ts +2 -2
- package/util.js +11 -10
- package/util.js.map +1 -1
- package/util.mjs +11 -10
- package/util.mjs.map +1 -1
- package/account/account.d.ts.map +0 -1
- package/account/get-account-config-from-environment.d.ts.map +0 -1
- package/account/get-account.d.ts.map +0 -1
- package/account/get-dispenser-account.d.ts.map +0 -1
- package/account/index.d.ts.map +0 -1
- package/account/mnemonic-account.d.ts.map +0 -1
- package/amount.d.ts.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app.d.ts.map +0 -1
- package/asset.d.ts.map +0 -1
- package/config.d.ts.map +0 -1
- package/debugging/debugging.d.ts.map +0 -1
- package/debugging/index.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.d.ts +0 -20
- package/debugging/simulate-and-persist-response.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.js +0 -108
- package/debugging/simulate-and-persist-response.js.map +0 -1
- package/debugging/simulate-and-persist-response.mjs +0 -89
- package/debugging/simulate-and-persist-response.mjs.map +0 -1
- package/dispenser-client.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/index.d.ts.map +0 -1
- package/localnet/is-localnet.d.ts.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/testing/_asset.d.ts.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/transaction/index.d.ts.map +0 -1
- package/transaction/legacy-bridge.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
- package/transaction/transaction.d.ts.map +0 -1
- package/transfer/index.d.ts.map +0 -1
- package/transfer/transfer-algos.d.ts.map +0 -1
- package/transfer/transfer.d.ts.map +0 -1
- package/types/account-manager.d.ts.map +0 -1
- package/types/account.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algorand-client-transaction-creator.d.ts.map +0 -1
- package/types/algorand-client-transaction-sender.d.ts.map +0 -1
- package/types/algorand-client.d.ts.map +0 -1
- package/types/amount.d.ts.map +0 -1
- package/types/app-client.d.ts.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.d.ts.map +0 -1
- package/types/asset-manager.d.ts.map +0 -1
- package/types/asset.d.ts.map +0 -1
- package/types/client-manager.d.ts.map +0 -1
- package/types/composer.d.ts.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/debugging.d.ts.map +0 -1
- package/types/dispenser-client.d.ts.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/kmd-account-manager.d.ts.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/network-client.d.ts.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/transaction.d.ts.map +0 -1
- package/types/transfer.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -41
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.js +0 -153
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/types/urlTokenBaseHTTPClient.mjs +0 -151
- package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
- package/util.d.ts.map +0 -1
package/types/debugging.js
CHANGED
|
@@ -1,115 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* An asynchronous event listener
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
equals(other) {
|
|
17
|
-
return this.location === other.location && this.programHash === other.programHash;
|
|
18
|
-
}
|
|
19
|
-
toString() {
|
|
20
|
-
return JSON.stringify({ 'sourcemap-location': this.location, hash: this.programHash });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* AVM debugger source map class.
|
|
25
|
-
*/
|
|
26
|
-
class AVMDebuggerSourceMap {
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param txnGroupSources
|
|
30
|
-
*/
|
|
31
|
-
constructor(txnGroupSources) {
|
|
32
|
-
this.txnGroupSources = txnGroupSources;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Creates a source map from a dictionary of source map data.
|
|
36
|
-
* @param data The data
|
|
37
|
-
* @returns The source map
|
|
38
|
-
*/
|
|
39
|
-
static fromDict(data) {
|
|
40
|
-
return new AVMDebuggerSourceMap(data['txn-group-sources'].map((item) => new AVMDebuggerSourceMapEntry(item['sourcemap-location'], item['hash'])));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Converts the source map to a dictionary that can be passed around and then parsed back using `AVMDebuggerSourceMap.fromDict`.
|
|
44
|
-
* @returns The dictionary
|
|
45
|
-
*/
|
|
46
|
-
toDict() {
|
|
47
|
-
return { 'txn-group-sources': this.txnGroupSources.map((item) => JSON.parse(item.toString())) };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Class representing a debugger source maps input for persistence.
|
|
52
|
-
*
|
|
53
|
-
* Note: rawTeal and compiledTeal are mutually exclusive. Only one of them should be provided.
|
|
54
|
-
*/
|
|
55
|
-
class PersistSourceMapInput {
|
|
56
|
-
constructor(appName, fileName, rawTeal, compiledTeal) {
|
|
57
|
-
this.compiledTeal = compiledTeal;
|
|
58
|
-
this.appName = appName;
|
|
59
|
-
this._rawTeal = rawTeal;
|
|
60
|
-
this._fileName = this.stripTealExtension(fileName);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns debugger source maps input from raw TEAL code.
|
|
64
|
-
* @param rawTeal The raw TEAL code
|
|
65
|
-
* @param appName The name of the app
|
|
66
|
-
* @param fileName The name of the file to persist to
|
|
67
|
-
* @returns The persist source map input
|
|
68
|
-
*/
|
|
69
|
-
static fromRawTeal(rawTeal, appName, fileName) {
|
|
70
|
-
return new PersistSourceMapInput(appName, fileName, rawTeal);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Returns debugger source maps input from compiled TEAL code.
|
|
74
|
-
* @param compiledTeal The compiled TEAL code
|
|
75
|
-
* @param appName The name of the app
|
|
76
|
-
* @param fileName The name of the file to persist to
|
|
77
|
-
* @returns The persist source map input
|
|
78
|
-
*/
|
|
79
|
-
static fromCompiledTeal(compiledTeal, appName, fileName) {
|
|
80
|
-
return new PersistSourceMapInput(appName, fileName, undefined, compiledTeal);
|
|
81
|
-
}
|
|
82
|
-
/** Get the underlying raw teal */
|
|
83
|
-
get rawTeal() {
|
|
84
|
-
if (this._rawTeal) {
|
|
85
|
-
return this._rawTeal;
|
|
86
|
-
}
|
|
87
|
-
else if (this.compiledTeal) {
|
|
88
|
-
return this.compiledTeal.teal;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
throw new Error('No teal content found');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/** Get the file name */
|
|
95
|
-
get fileName() {
|
|
96
|
-
return this._fileName;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Strips the '.teal' extension from a filename, if present.
|
|
100
|
-
*
|
|
101
|
-
* @param fileName - The filename to strip the extension from.
|
|
102
|
-
* @returns The filename without the '.teal' extension.
|
|
103
|
-
*/
|
|
104
|
-
stripTealExtension(fileName) {
|
|
105
|
-
if (fileName.endsWith('.teal')) {
|
|
106
|
-
return fileName.slice(0, -5);
|
|
107
|
-
}
|
|
108
|
-
return fileName;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
6
|
+
/** The directory name for AlgoKit project related files */
|
|
7
|
+
const ALGOKIT_DIR = '.algokit';
|
|
8
|
+
/** The directory name for debug source files */
|
|
9
|
+
const SOURCES_DIR = 'sources';
|
|
10
|
+
/** The file extension for TEAL files */
|
|
11
|
+
const TEAL_FILE_EXT = '.teal';
|
|
12
|
+
/** The file extension for TEAL source map files */
|
|
13
|
+
const TEAL_SOURCEMAP_EXT = '.teal.map';
|
|
14
|
+
/** The default maximum search depth for file operations */
|
|
15
|
+
const DEFAULT_MAX_SEARCH_DEPTH = 10;
|
|
111
16
|
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
114
|
-
exports.
|
|
17
|
+
exports.ALGOKIT_DIR = ALGOKIT_DIR;
|
|
18
|
+
exports.DEFAULT_MAX_SEARCH_DEPTH = DEFAULT_MAX_SEARCH_DEPTH;
|
|
19
|
+
exports.SOURCES_DIR = SOURCES_DIR;
|
|
20
|
+
exports.TEAL_FILE_EXT = TEAL_FILE_EXT;
|
|
21
|
+
exports.TEAL_SOURCEMAP_EXT = TEAL_SOURCEMAP_EXT;
|
|
115
22
|
//# sourceMappingURL=debugging.js.map
|
package/types/debugging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugging.js","sources":["../../src/types/debugging.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"debugging.js","sources":["../../src/types/debugging.ts"],"sourcesContent":["/**\n * An asynchronous event listener\n */\n\nimport algosdk from 'algosdk'\nimport { CompiledTeal } from './app'\n\n/** The directory name for AlgoKit project related files */\nexport const ALGOKIT_DIR = '.algokit'\n\n/** The directory name for debug source files */\nexport const SOURCES_DIR = 'sources'\n\n/** The file extension for TEAL files */\nexport const TEAL_FILE_EXT = '.teal'\n\n/** The file extension for TEAL source map files */\nexport const TEAL_SOURCEMAP_EXT = '.teal.map'\n\n/** The default maximum search depth for file operations */\nexport const DEFAULT_MAX_SEARCH_DEPTH = 10\n\n/**\n * Represents the data for a single TEAL source\n */\nexport interface TealSourceDebugEventData {\n /** The name of the application */\n appName: string\n /** The name of the file */\n fileName: string\n /** The compiled TEAL code */\n compiledTeal: CompiledTeal\n}\n\n/**\n * Represents the data for multiple TEAL sources debug events emitted whenever an app is compiled as part of a deploy in debug mode\n */\nexport interface TealSourcesDebugEventData {\n /** An array of TEAL source debug event data */\n sources: TealSourceDebugEventData[]\n}\n\n/**\n * Represents the data for AVM traces debug events emitted whenever a transaction is simulated in debug mode\n */\nexport interface AVMTracesEventData {\n /** The simulation response from Algod */\n simulateResponse: algosdk.modelsv2.SimulateResponse\n}\n"],"names":[],"mappings":";;AAAA;;AAEG;AAKH;AACO,MAAM,WAAW,GAAG,WAAU;AAErC;AACO,MAAM,WAAW,GAAG,UAAS;AAEpC;AACO,MAAM,aAAa,GAAG,QAAO;AAEpC;AACO,MAAM,kBAAkB,GAAG,YAAW;AAE7C;AACO,MAAM,wBAAwB,GAAG;;;;;;;;"}
|
package/types/debugging.mjs
CHANGED
|
@@ -1,111 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* An asynchronous event listener
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
equals(other) {
|
|
15
|
-
return this.location === other.location && this.programHash === other.programHash;
|
|
16
|
-
}
|
|
17
|
-
toString() {
|
|
18
|
-
return JSON.stringify({ 'sourcemap-location': this.location, hash: this.programHash });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* AVM debugger source map class.
|
|
23
|
-
*/
|
|
24
|
-
class AVMDebuggerSourceMap {
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param txnGroupSources
|
|
28
|
-
*/
|
|
29
|
-
constructor(txnGroupSources) {
|
|
30
|
-
this.txnGroupSources = txnGroupSources;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates a source map from a dictionary of source map data.
|
|
34
|
-
* @param data The data
|
|
35
|
-
* @returns The source map
|
|
36
|
-
*/
|
|
37
|
-
static fromDict(data) {
|
|
38
|
-
return new AVMDebuggerSourceMap(data['txn-group-sources'].map((item) => new AVMDebuggerSourceMapEntry(item['sourcemap-location'], item['hash'])));
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Converts the source map to a dictionary that can be passed around and then parsed back using `AVMDebuggerSourceMap.fromDict`.
|
|
42
|
-
* @returns The dictionary
|
|
43
|
-
*/
|
|
44
|
-
toDict() {
|
|
45
|
-
return { 'txn-group-sources': this.txnGroupSources.map((item) => JSON.parse(item.toString())) };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Class representing a debugger source maps input for persistence.
|
|
50
|
-
*
|
|
51
|
-
* Note: rawTeal and compiledTeal are mutually exclusive. Only one of them should be provided.
|
|
52
|
-
*/
|
|
53
|
-
class PersistSourceMapInput {
|
|
54
|
-
constructor(appName, fileName, rawTeal, compiledTeal) {
|
|
55
|
-
this.compiledTeal = compiledTeal;
|
|
56
|
-
this.appName = appName;
|
|
57
|
-
this._rawTeal = rawTeal;
|
|
58
|
-
this._fileName = this.stripTealExtension(fileName);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Returns debugger source maps input from raw TEAL code.
|
|
62
|
-
* @param rawTeal The raw TEAL code
|
|
63
|
-
* @param appName The name of the app
|
|
64
|
-
* @param fileName The name of the file to persist to
|
|
65
|
-
* @returns The persist source map input
|
|
66
|
-
*/
|
|
67
|
-
static fromRawTeal(rawTeal, appName, fileName) {
|
|
68
|
-
return new PersistSourceMapInput(appName, fileName, rawTeal);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Returns debugger source maps input from compiled TEAL code.
|
|
72
|
-
* @param compiledTeal The compiled TEAL code
|
|
73
|
-
* @param appName The name of the app
|
|
74
|
-
* @param fileName The name of the file to persist to
|
|
75
|
-
* @returns The persist source map input
|
|
76
|
-
*/
|
|
77
|
-
static fromCompiledTeal(compiledTeal, appName, fileName) {
|
|
78
|
-
return new PersistSourceMapInput(appName, fileName, undefined, compiledTeal);
|
|
79
|
-
}
|
|
80
|
-
/** Get the underlying raw teal */
|
|
81
|
-
get rawTeal() {
|
|
82
|
-
if (this._rawTeal) {
|
|
83
|
-
return this._rawTeal;
|
|
84
|
-
}
|
|
85
|
-
else if (this.compiledTeal) {
|
|
86
|
-
return this.compiledTeal.teal;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw new Error('No teal content found');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/** Get the file name */
|
|
93
|
-
get fileName() {
|
|
94
|
-
return this._fileName;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Strips the '.teal' extension from a filename, if present.
|
|
98
|
-
*
|
|
99
|
-
* @param fileName - The filename to strip the extension from.
|
|
100
|
-
* @returns The filename without the '.teal' extension.
|
|
101
|
-
*/
|
|
102
|
-
stripTealExtension(fileName) {
|
|
103
|
-
if (fileName.endsWith('.teal')) {
|
|
104
|
-
return fileName.slice(0, -5);
|
|
105
|
-
}
|
|
106
|
-
return fileName;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
4
|
+
/** The directory name for AlgoKit project related files */
|
|
5
|
+
const ALGOKIT_DIR = '.algokit';
|
|
6
|
+
/** The directory name for debug source files */
|
|
7
|
+
const SOURCES_DIR = 'sources';
|
|
8
|
+
/** The file extension for TEAL files */
|
|
9
|
+
const TEAL_FILE_EXT = '.teal';
|
|
10
|
+
/** The file extension for TEAL source map files */
|
|
11
|
+
const TEAL_SOURCEMAP_EXT = '.teal.map';
|
|
12
|
+
/** The default maximum search depth for file operations */
|
|
13
|
+
const DEFAULT_MAX_SEARCH_DEPTH = 10;
|
|
109
14
|
|
|
110
|
-
export {
|
|
15
|
+
export { ALGOKIT_DIR, DEFAULT_MAX_SEARCH_DEPTH, SOURCES_DIR, TEAL_FILE_EXT, TEAL_SOURCEMAP_EXT };
|
|
111
16
|
//# sourceMappingURL=debugging.mjs.map
|
package/types/debugging.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugging.mjs","sources":["../../src/types/debugging.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"debugging.mjs","sources":["../../src/types/debugging.ts"],"sourcesContent":["/**\n * An asynchronous event listener\n */\n\nimport algosdk from 'algosdk'\nimport { CompiledTeal } from './app'\n\n/** The directory name for AlgoKit project related files */\nexport const ALGOKIT_DIR = '.algokit'\n\n/** The directory name for debug source files */\nexport const SOURCES_DIR = 'sources'\n\n/** The file extension for TEAL files */\nexport const TEAL_FILE_EXT = '.teal'\n\n/** The file extension for TEAL source map files */\nexport const TEAL_SOURCEMAP_EXT = '.teal.map'\n\n/** The default maximum search depth for file operations */\nexport const DEFAULT_MAX_SEARCH_DEPTH = 10\n\n/**\n * Represents the data for a single TEAL source\n */\nexport interface TealSourceDebugEventData {\n /** The name of the application */\n appName: string\n /** The name of the file */\n fileName: string\n /** The compiled TEAL code */\n compiledTeal: CompiledTeal\n}\n\n/**\n * Represents the data for multiple TEAL sources debug events emitted whenever an app is compiled as part of a deploy in debug mode\n */\nexport interface TealSourcesDebugEventData {\n /** An array of TEAL source debug event data */\n sources: TealSourceDebugEventData[]\n}\n\n/**\n * Represents the data for AVM traces debug events emitted whenever a transaction is simulated in debug mode\n */\nexport interface AVMTracesEventData {\n /** The simulation response from Algod */\n simulateResponse: algosdk.modelsv2.SimulateResponse\n}\n"],"names":[],"mappings":"AAAA;;AAEG;AAKH;AACO,MAAM,WAAW,GAAG,WAAU;AAErC;AACO,MAAM,WAAW,GAAG,UAAS;AAEpC;AACO,MAAM,aAAa,GAAG,QAAO;AAEpC;AACO,MAAM,kBAAkB,GAAG,YAAW;AAE7C;AACO,MAAM,wBAAwB,GAAG;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Address } from 'algosdk';
|
|
1
2
|
/** The TestNet Dispenser API response when funding. */
|
|
2
3
|
export interface DispenserFundResponse {
|
|
3
4
|
/** The ID of the transaction that was issued to fund the account. */
|
|
@@ -68,7 +69,7 @@ export declare class TestNetDispenserApiClient {
|
|
|
68
69
|
*
|
|
69
70
|
* @returns DispenserFundResponse: An object containing the transaction ID and funded amount.
|
|
70
71
|
*/
|
|
71
|
-
fund(address: string, amount: number): Promise<DispenserFundResponse>;
|
|
72
|
+
fund(address: string | Address, amount: number | bigint): Promise<DispenserFundResponse>;
|
|
72
73
|
/**
|
|
73
74
|
* Sends a refund request to the dispenser API for the specified refundTxnId.
|
|
74
75
|
*
|
|
@@ -82,4 +83,3 @@ export declare class TestNetDispenserApiClient {
|
|
|
82
83
|
*/
|
|
83
84
|
getLimit(): Promise<DispenserLimitResponse>;
|
|
84
85
|
}
|
|
85
|
-
//# sourceMappingURL=dispenser-client.d.ts.map
|
|
@@ -87,14 +87,15 @@ class TestNetDispenserApiClient {
|
|
|
87
87
|
try {
|
|
88
88
|
error_response = await response.json();
|
|
89
89
|
}
|
|
90
|
-
catch
|
|
90
|
+
catch {
|
|
91
91
|
// suppress exception
|
|
92
92
|
}
|
|
93
93
|
if (error_response && error_response.code) {
|
|
94
94
|
error_message = error_response.code;
|
|
95
95
|
}
|
|
96
96
|
else if (response.status === 400) {
|
|
97
|
-
|
|
97
|
+
const errorResponse = (await response.json());
|
|
98
|
+
error_message = errorResponse.message;
|
|
98
99
|
}
|
|
99
100
|
throw new Error(error_message);
|
|
100
101
|
}
|
|
@@ -109,8 +110,12 @@ class TestNetDispenserApiClient {
|
|
|
109
110
|
* @returns DispenserFundResponse: An object containing the transaction ID and funded amount.
|
|
110
111
|
*/
|
|
111
112
|
async fund(address, amount) {
|
|
112
|
-
const response = await this.processDispenserRequest(this.authToken, `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}`, {
|
|
113
|
-
|
|
113
|
+
const response = await this.processDispenserRequest(this.authToken, `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}`, {
|
|
114
|
+
receiver: typeof address === 'string' ? address : address.toString(),
|
|
115
|
+
amount: Number(amount),
|
|
116
|
+
assetID: dispenserAssets[DispenserAssetName.Algo].assetId,
|
|
117
|
+
}, 'POST');
|
|
118
|
+
const content = (await response.json());
|
|
114
119
|
return { txId: content.txID, amount: content.amount };
|
|
115
120
|
}
|
|
116
121
|
/**
|
|
@@ -128,7 +133,7 @@ class TestNetDispenserApiClient {
|
|
|
128
133
|
*/
|
|
129
134
|
async getLimit() {
|
|
130
135
|
const response = await this.processDispenserRequest(this.authToken, `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}/limit`, null, 'GET');
|
|
131
|
-
const content = await response.json();
|
|
136
|
+
const content = (await response.json());
|
|
132
137
|
return { amount: content.amount };
|
|
133
138
|
}
|
|
134
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispenser-client.js","sources":["../../src/types/dispenser-client.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA,MAAM,kBAAkB,GAAG,gDAAgD,CAAA;AAC3E,MAAM,iCAAiC,GAAG,EAAE,CAAA;AAC5C,MAAM,0BAA0B,GAAG,gCAAgC,CAAA;AAEnE,IAAK,kBAEJ,CAAA;AAFD,CAAA,UAAK,kBAAkB,EAAA;AACrB,IAAA,kBAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACV,CAAC,EAFI,kBAAkB,KAAlB,kBAAkB,GAEtB,EAAA,CAAA,CAAA,CAAA;AAED,MAAM,eAAe,GAAG;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ACP,CAAA;AAED,QAAA,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AACrC,QAAA,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;KACtD;AAED;;;;AAIG;IACH,MAAM,MAAM,CAAC,WAAmB,EAAA;AAC9B,QAAA,MAAM,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,mBAAmB,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,CAAA;KAC3G;AAED;;;;AAIG;AACH,IAAA,MAAM,QAAQ,GAAA;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,uBAAuB,CACjD,IAAI,CAAC,SAAS,EACd,CAAQ,KAAA,EAAA,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAQ,MAAA,CAAA,EAChE,IAAI,EACJ,KAAK,CACN,CAAA;AACD,QAAA,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AAErC,QAAA,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;KAClC;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"dispenser-client.js","sources":["../../src/types/dispenser-client.ts"],"sourcesContent":["import { Address } from 'algosdk'\n\nconst DISPENSER_BASE_URL = 'https://api.dispenser.algorandfoundation.tools'\nconst DEFAULT_DISPENSER_REQUEST_TIMEOUT = 15\nconst DISPENSER_ACCESS_TOKEN_KEY = 'ALGOKIT_DISPENSER_ACCESS_TOKEN'\n\ninterface ErrorResponse {\n code?: string\n}\n\nenum DispenserAssetName {\n Algo = 0,\n}\n\nconst dispenserAssets = {\n [DispenserAssetName.Algo]: {\n assetId: 0,\n decimals: 6,\n description: 'Algo',\n },\n}\n\n/** The TestNet Dispenser API response when funding. */\nexport interface DispenserFundResponse {\n /** The ID of the transaction that was issued to fund the account. */\n txId: string\n /** The number of µAlgo that was funded. */\n amount: number\n}\n\n/** The TestNet Dispenser API response when getting the current limit. */\nexport interface DispenserLimitResponse {\n /** The limit, in µAlgo, that you can currently fund. */\n amount: number\n}\n\n/** The parameters to construct a TestNet Dispenser API client. */\nexport interface TestNetDispenserApiClientParams {\n /** The API auth token */\n authToken: string\n /** The request timeout in seconds */\n requestTimeout?: number\n}\n\n/**\n * `TestNetDispenserApiClient` is a class that provides methods to interact with the [Algorand TestNet Dispenser API](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md).\n * It allows you to fund an address with Algo, refund a transaction, and get the funding limit for the Algo asset.\n *\n * The class requires an authentication token and a request timeout to be initialized. The authentication token can be provided\n * either directly as a parameter or through an `ALGOKIT_DISPENSER_ACCESS_TOKEN` environment variable. If neither is provided, an error is thrown.\n *\n * The request timeout can be provided as a parameter. If not provided, a default value is used.\n *\n * @property {string} authToken - The authentication token used for API requests.\n * @property {number} requestTimeout - The timeout for API requests, in seconds.\n *\n * @method fund - Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.\n * @method refund - Sends a refund request to the dispenser API for the specified refundTxnId.\n * @method limit - Sends a request to the dispenser API to get the funding limit for the Algo asset.\n *\n * @example\n * ```typescript\n * const client = new TestNetDispenserApiClient({ authToken: 'your_auth_token', requestTimeout: 30 });\n * const fundResponse = await client.fund('your_address', 100);\n * const limitResponse = await client.getLimit();\n * await client.refund('your_transaction_id');\n * ```\n *\n * @throws {Error} If neither the environment variable 'ALGOKIT_DISPENSER_ACCESS_TOKEN' nor the authToken parameter were provided.\n */\nexport class TestNetDispenserApiClient {\n private _authToken: string\n private _requestTimeout: number\n\n constructor(params?: TestNetDispenserApiClientParams) {\n const authTokenFromEnv = process?.env?.[DISPENSER_ACCESS_TOKEN_KEY]\n\n if (params?.authToken) {\n this._authToken = params.authToken\n } else if (authTokenFromEnv) {\n this._authToken = authTokenFromEnv\n } else {\n throw new Error(\n `Can't init AlgoKit TestNet Dispenser API client because neither environment variable ${DISPENSER_ACCESS_TOKEN_KEY} or the authToken were provided.`,\n )\n }\n\n this._requestTimeout = params?.requestTimeout || DEFAULT_DISPENSER_REQUEST_TIMEOUT\n }\n\n get authToken(): string {\n return this._authToken\n }\n\n get requestTimeout(): number {\n return this._requestTimeout\n }\n\n /**\n * Processes a dispenser API request.\n *\n * @param authToken - The authentication token.\n * @param urlSuffix - The URL suffix for the API request.\n * @param body - The request body.\n * @param method - The HTTP method.\n *\n * @returns The API response.\n */\n private async processDispenserRequest(\n authToken: string,\n urlSuffix: string,\n body: Record<string, string | number> | null = null,\n method = 'POST',\n ): Promise<Response> {\n const headers = { Authorization: `Bearer ${authToken}` }\n\n const requestArgs: RequestInit = {\n method: method,\n headers: headers,\n signal: AbortSignal.timeout(this.requestTimeout * 1000),\n }\n\n if (body) {\n requestArgs.body = JSON.stringify(body)\n }\n\n const response = await fetch(`${DISPENSER_BASE_URL}/${urlSuffix}`, requestArgs)\n if (!response.ok) {\n let error_message = `Error processing dispenser API request: ${response.status}`\n let error_response = null\n try {\n error_response = await response.json()\n } catch {\n // suppress exception\n }\n\n if (error_response && (error_response as ErrorResponse).code) {\n error_message = (error_response as ErrorResponse).code!\n } else if (response.status === 400) {\n const errorResponse = (await response.json()) as { message: string }\n error_message = errorResponse.message\n }\n\n throw new Error(error_message)\n }\n return response\n }\n\n /**\n * Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.\n *\n * @param address - The address to fund.\n * @param amount - The amount of µAlgo to fund.\n *\n * @returns DispenserFundResponse: An object containing the transaction ID and funded amount.\n */\n async fund(address: string | Address, amount: number | bigint): Promise<DispenserFundResponse> {\n const response = await this.processDispenserRequest(\n this.authToken,\n `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}`,\n {\n receiver: typeof address === 'string' ? address : address.toString(),\n amount: Number(amount),\n assetID: dispenserAssets[DispenserAssetName.Algo].assetId,\n },\n 'POST',\n )\n\n const content = (await response.json()) as { txID: string; amount: number }\n return { txId: content.txID, amount: content.amount }\n }\n\n /**\n * Sends a refund request to the dispenser API for the specified refundTxnId.\n *\n * @param refundTxnId - The transaction ID to refund.\n */\n async refund(refundTxnId: string): Promise<void> {\n await this.processDispenserRequest(this.authToken, 'refund', { refundTransactionID: refundTxnId }, 'POST')\n }\n\n /**\n * Sends a request to the dispenser API to get the funding limit for the Algo asset.\n *\n * @returns DispenserLimitResponse: An object containing the funding limit amount.\n */\n async getLimit(): Promise<DispenserLimitResponse> {\n const response = await this.processDispenserRequest(\n this.authToken,\n `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}/limit`,\n null,\n 'GET',\n )\n const content = (await response.json()) as { amount: number }\n\n return { amount: content.amount }\n }\n}\n"],"names":[],"mappings":";;AAEA,MAAM,kBAAkB,GAAG,gDAAgD,CAAA;AAC3E,MAAM,iCAAiC,GAAG,EAAE,CAAA;AAC5C,MAAM,0BAA0B,GAAG,gCAAgC,CAAA;AAMnE,IAAK,kBAEJ,CAAA;AAFD,CAAA,UAAK,kBAAkB,EAAA;AACrB,IAAA,kBAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACV,CAAC,EAFI,kBAAkB,KAAlB,kBAAkB,GAEtB,EAAA,CAAA,CAAA,CAAA;AAED,MAAM,eAAe,GAAG;AACtB,IAAA,CAAC,kBAAkB,CAAC,IAAI,GAAG;AACzB,QAAA,OAAO,EAAE,CAAC;AACV,QAAA,QAAQ,EAAE,CAAC;AACX,QAAA,WAAW,EAAE,MAAM;AACpB,KAAA;CACF,CAAA;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;MACU,yBAAyB,CAAA;AAIpC,IAAA,WAAA,CAAY,MAAwC,EAAA;QAClD,MAAM,gBAAgB,GAAG,OAAO,EAAE,GAAG,GAAG,0BAA0B,CAAC,CAAA;AAEnE,QAAA,IAAI,MAAM,EAAE,SAAS,EAAE;AACrB,YAAA,IAAI,CAAC,UAAU,GAAG,MAAM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,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,mBAAmB,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,CAAA;KAC3G;AAED;;;;AAIG;AACH,IAAA,MAAM,QAAQ,GAAA;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,uBAAuB,CACjD,IAAI,CAAC,SAAS,EACd,CAAQ,KAAA,EAAA,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAQ,MAAA,CAAA,EAChE,IAAI,EACJ,KAAK,CACN,CAAA;QACD,MAAM,OAAO,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAuB,CAAA;AAE7D,QAAA,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;KAClC;AACF;;;;"}
|
|
@@ -85,14 +85,15 @@ class TestNetDispenserApiClient {
|
|
|
85
85
|
try {
|
|
86
86
|
error_response = await response.json();
|
|
87
87
|
}
|
|
88
|
-
catch
|
|
88
|
+
catch {
|
|
89
89
|
// suppress exception
|
|
90
90
|
}
|
|
91
91
|
if (error_response && error_response.code) {
|
|
92
92
|
error_message = error_response.code;
|
|
93
93
|
}
|
|
94
94
|
else if (response.status === 400) {
|
|
95
|
-
|
|
95
|
+
const errorResponse = (await response.json());
|
|
96
|
+
error_message = errorResponse.message;
|
|
96
97
|
}
|
|
97
98
|
throw new Error(error_message);
|
|
98
99
|
}
|
|
@@ -107,8 +108,12 @@ class TestNetDispenserApiClient {
|
|
|
107
108
|
* @returns DispenserFundResponse: An object containing the transaction ID and funded amount.
|
|
108
109
|
*/
|
|
109
110
|
async fund(address, amount) {
|
|
110
|
-
const response = await this.processDispenserRequest(this.authToken, `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}`, {
|
|
111
|
-
|
|
111
|
+
const response = await this.processDispenserRequest(this.authToken, `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}`, {
|
|
112
|
+
receiver: typeof address === 'string' ? address : address.toString(),
|
|
113
|
+
amount: Number(amount),
|
|
114
|
+
assetID: dispenserAssets[DispenserAssetName.Algo].assetId,
|
|
115
|
+
}, 'POST');
|
|
116
|
+
const content = (await response.json());
|
|
112
117
|
return { txId: content.txID, amount: content.amount };
|
|
113
118
|
}
|
|
114
119
|
/**
|
|
@@ -126,7 +131,7 @@ class TestNetDispenserApiClient {
|
|
|
126
131
|
*/
|
|
127
132
|
async getLimit() {
|
|
128
133
|
const response = await this.processDispenserRequest(this.authToken, `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}/limit`, null, 'GET');
|
|
129
|
-
const content = await response.json();
|
|
134
|
+
const content = (await response.json());
|
|
130
135
|
return { amount: content.amount };
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispenser-client.mjs","sources":["../../src/types/dispenser-client.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,gDAAgD,CAAA;AAC3E,MAAM,iCAAiC,GAAG,EAAE,CAAA;AAC5C,MAAM,0BAA0B,GAAG,gCAAgC,CAAA;AAEnE,IAAK,kBAEJ,CAAA;AAFD,CAAA,UAAK,kBAAkB,EAAA;AACrB,IAAA,kBAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACV,CAAC,EAFI,kBAAkB,KAAlB,kBAAkB,GAEtB,EAAA,CAAA,CAAA,CAAA;AAED,MAAM,eAAe,GAAG;AACtB,IAAA,CAAC,kBAAkB,CAAC,IAAI,GAAG;AACzB,QAAA,OAAO,EAAE,CAAC;AACV,QAAA,QAAQ,EAAE,CAAC;AACX,QAAA,WAAW,EAAE,MAAM;AACpB,KAAA;CACF,CAAA;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;MACU,yBAAyB,CAAA;AAIpC,IAAA,WAAA,CAAY,MAAwC,EAAA;QAClD,MAAM,gBAAgB,GAAG,OAAO,EAAE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AS,EAAE,QAAQ,EAAE,EAAE,mBAAmB,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,CAAA;KAC3G;AAED;;;;AAIG;AACH,IAAA,MAAM,QAAQ,GAAA;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,uBAAuB,CACjD,IAAI,CAAC,SAAS,EACd,CAAQ,KAAA,EAAA,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAQ,MAAA,CAAA,EAChE,IAAI,EACJ,KAAK,CACN,CAAA;AACD,QAAA,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AAErC,QAAA,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;KAClC;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"dispenser-client.mjs","sources":["../../src/types/dispenser-client.ts"],"sourcesContent":["import { Address } from 'algosdk'\n\nconst DISPENSER_BASE_URL = 'https://api.dispenser.algorandfoundation.tools'\nconst DEFAULT_DISPENSER_REQUEST_TIMEOUT = 15\nconst DISPENSER_ACCESS_TOKEN_KEY = 'ALGOKIT_DISPENSER_ACCESS_TOKEN'\n\ninterface ErrorResponse {\n code?: string\n}\n\nenum DispenserAssetName {\n Algo = 0,\n}\n\nconst dispenserAssets = {\n [DispenserAssetName.Algo]: {\n assetId: 0,\n decimals: 6,\n description: 'Algo',\n },\n}\n\n/** The TestNet Dispenser API response when funding. */\nexport interface DispenserFundResponse {\n /** The ID of the transaction that was issued to fund the account. */\n txId: string\n /** The number of µAlgo that was funded. */\n amount: number\n}\n\n/** The TestNet Dispenser API response when getting the current limit. */\nexport interface DispenserLimitResponse {\n /** The limit, in µAlgo, that you can currently fund. */\n amount: number\n}\n\n/** The parameters to construct a TestNet Dispenser API client. */\nexport interface TestNetDispenserApiClientParams {\n /** The API auth token */\n authToken: string\n /** The request timeout in seconds */\n requestTimeout?: number\n}\n\n/**\n * `TestNetDispenserApiClient` is a class that provides methods to interact with the [Algorand TestNet Dispenser API](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md).\n * It allows you to fund an address with Algo, refund a transaction, and get the funding limit for the Algo asset.\n *\n * The class requires an authentication token and a request timeout to be initialized. The authentication token can be provided\n * either directly as a parameter or through an `ALGOKIT_DISPENSER_ACCESS_TOKEN` environment variable. If neither is provided, an error is thrown.\n *\n * The request timeout can be provided as a parameter. If not provided, a default value is used.\n *\n * @property {string} authToken - The authentication token used for API requests.\n * @property {number} requestTimeout - The timeout for API requests, in seconds.\n *\n * @method fund - Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.\n * @method refund - Sends a refund request to the dispenser API for the specified refundTxnId.\n * @method limit - Sends a request to the dispenser API to get the funding limit for the Algo asset.\n *\n * @example\n * ```typescript\n * const client = new TestNetDispenserApiClient({ authToken: 'your_auth_token', requestTimeout: 30 });\n * const fundResponse = await client.fund('your_address', 100);\n * const limitResponse = await client.getLimit();\n * await client.refund('your_transaction_id');\n * ```\n *\n * @throws {Error} If neither the environment variable 'ALGOKIT_DISPENSER_ACCESS_TOKEN' nor the authToken parameter were provided.\n */\nexport class TestNetDispenserApiClient {\n private _authToken: string\n private _requestTimeout: number\n\n constructor(params?: TestNetDispenserApiClientParams) {\n const authTokenFromEnv = process?.env?.[DISPENSER_ACCESS_TOKEN_KEY]\n\n if (params?.authToken) {\n this._authToken = params.authToken\n } else if (authTokenFromEnv) {\n this._authToken = authTokenFromEnv\n } else {\n throw new Error(\n `Can't init AlgoKit TestNet Dispenser API client because neither environment variable ${DISPENSER_ACCESS_TOKEN_KEY} or the authToken were provided.`,\n )\n }\n\n this._requestTimeout = params?.requestTimeout || DEFAULT_DISPENSER_REQUEST_TIMEOUT\n }\n\n get authToken(): string {\n return this._authToken\n }\n\n get requestTimeout(): number {\n return this._requestTimeout\n }\n\n /**\n * Processes a dispenser API request.\n *\n * @param authToken - The authentication token.\n * @param urlSuffix - The URL suffix for the API request.\n * @param body - The request body.\n * @param method - The HTTP method.\n *\n * @returns The API response.\n */\n private async processDispenserRequest(\n authToken: string,\n urlSuffix: string,\n body: Record<string, string | number> | null = null,\n method = 'POST',\n ): Promise<Response> {\n const headers = { Authorization: `Bearer ${authToken}` }\n\n const requestArgs: RequestInit = {\n method: method,\n headers: headers,\n signal: AbortSignal.timeout(this.requestTimeout * 1000),\n }\n\n if (body) {\n requestArgs.body = JSON.stringify(body)\n }\n\n const response = await fetch(`${DISPENSER_BASE_URL}/${urlSuffix}`, requestArgs)\n if (!response.ok) {\n let error_message = `Error processing dispenser API request: ${response.status}`\n let error_response = null\n try {\n error_response = await response.json()\n } catch {\n // suppress exception\n }\n\n if (error_response && (error_response as ErrorResponse).code) {\n error_message = (error_response as ErrorResponse).code!\n } else if (response.status === 400) {\n const errorResponse = (await response.json()) as { message: string }\n error_message = errorResponse.message\n }\n\n throw new Error(error_message)\n }\n return response\n }\n\n /**\n * Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.\n *\n * @param address - The address to fund.\n * @param amount - The amount of µAlgo to fund.\n *\n * @returns DispenserFundResponse: An object containing the transaction ID and funded amount.\n */\n async fund(address: string | Address, amount: number | bigint): Promise<DispenserFundResponse> {\n const response = await this.processDispenserRequest(\n this.authToken,\n `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}`,\n {\n receiver: typeof address === 'string' ? address : address.toString(),\n amount: Number(amount),\n assetID: dispenserAssets[DispenserAssetName.Algo].assetId,\n },\n 'POST',\n )\n\n const content = (await response.json()) as { txID: string; amount: number }\n return { txId: content.txID, amount: content.amount }\n }\n\n /**\n * Sends a refund request to the dispenser API for the specified refundTxnId.\n *\n * @param refundTxnId - The transaction ID to refund.\n */\n async refund(refundTxnId: string): Promise<void> {\n await this.processDispenserRequest(this.authToken, 'refund', { refundTransactionID: refundTxnId }, 'POST')\n }\n\n /**\n * Sends a request to the dispenser API to get the funding limit for the Algo asset.\n *\n * @returns DispenserLimitResponse: An object containing the funding limit amount.\n */\n async getLimit(): Promise<DispenserLimitResponse> {\n const response = await this.processDispenserRequest(\n this.authToken,\n `fund/${dispenserAssets[DispenserAssetName.Algo].assetId}/limit`,\n null,\n 'GET',\n )\n const content = (await response.json()) as { amount: number }\n\n return { amount: content.amount }\n }\n}\n"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAG,gDAAgD,CAAA;AAC3E,MAAM,iCAAiC,GAAG,EAAE,CAAA;AAC5C,MAAM,0BAA0B,GAAG,gCAAgC,CAAA;AAMnE,IAAK,kBAEJ,CAAA;AAFD,CAAA,UAAK,kBAAkB,EAAA;AACrB,IAAA,kBAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACV,CAAC,EAFI,kBAAkB,KAAlB,kBAAkB,GAEtB,EAAA,CAAA,CAAA,CAAA;AAED,MAAM,eAAe,GAAG;AACtB,IAAA,CAAC,kBAAkB,CAAC,IAAI,GAAG;AACzB,QAAA,OAAO,EAAE,CAAC;AACV,QAAA,QAAQ,EAAE,CAAC;AACX,QAAA,WAAW,EAAE,MAAM;AACpB,KAAA;CACF,CAAA;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;MACU,yBAAyB,CAAA;AAIpC,IAAA,WAAA,CAAY,MAAwC,EAAA;QAClD,MAAM,gBAAgB,GAAG,OAAO,EAAE,GAAG,GAAG,0BAA0B,CAAC,CAAA;AAEnE,QAAA,IAAI,MAAM,EAAE,SAAS,EAAE;AACrB,YAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAA;SACnC;aAAM,IAAI,gBAAgB,EAAE;AAC3B,YAAA,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAA;SACnC;aAAM;AACL,YAAA,MAAM,IAAI,KAAK,CACb,wFAAwF,0BAA0B,CAAA,gCAAA,CAAkC,CACrJ,CAAA;SACF;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,EAAE,cAAc,IAAI,iCAAiC,CAAA;KACnF;AAED,IAAA,IAAI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AC,OAAO,CAAQ,MAAA,CAAA,EAChE,IAAI,EACJ,KAAK,CACN,CAAA;QACD,MAAM,OAAO,IAAI,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAuB,CAAA;AAE7D,QAAA,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;KAClC;AACF;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expands types for IntelliSense so they are more human readable
|
|
3
|
+
* See https://stackoverflow.com/a/69288824
|
|
4
|
+
*/
|
|
5
|
+
export type Expand<T> = T extends (...args: infer A) => infer R ? (...args: Expand<A>) => Expand<R> : T extends infer O ? {
|
|
6
|
+
[K in keyof O]: O[K];
|
|
7
|
+
} : never;
|
package/types/expand.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expand.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/types/expand.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expand.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|