@algorandfoundation/algokit-utils 9.2.0 → 9.2.1-beta.1
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/_virtual/_rolldown/runtime.js +33 -0
- package/_virtual/_rolldown/runtime.mjs +13 -0
- package/account/account.d.ts +25 -30
- package/account/account.js +151 -146
- package/account/account.js.map +1 -1
- package/account/account.mjs +149 -144
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +7 -2
- package/account/get-account-config-from-environment.js +19 -21
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs +19 -19
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +14 -12
- package/account/get-account.js +56 -59
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +56 -57
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +9 -5
- package/account/get-dispenser-account.js +20 -18
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +20 -16
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.d.ts +7 -3
- package/account/mnemonic-account.js +17 -17
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +15 -15
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +40 -35
- package/amount.js +33 -34
- package/amount.js.map +1 -1
- package/amount.mjs +33 -32
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +10 -6
- package/app-client.js +91 -86
- package/app-client.js.map +1 -1
- package/app-client.mjs +91 -84
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +26 -24
- package/app-deploy.js +235 -253
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +233 -251
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +45 -46
- package/app.js +253 -271
- package/app.js.map +1 -1
- package/app.mjs +249 -267
- package/app.mjs.map +1 -1
- package/asset.d.ts +16 -12
- package/asset.js +116 -122
- package/asset.js.map +1 -1
- package/asset.mjs +116 -120
- package/asset.mjs.map +1 -1
- package/config.d.ts +7 -2
- package/config.js +5 -7
- package/config.js.map +1 -1
- package/config.mjs +5 -4
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +5 -1
- package/debugging/debugging.js +11 -11
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +11 -9
- package/debugging/debugging.mjs.map +1 -1
- package/dispenser-client.d.ts +7 -2
- package/dispenser-client.js +23 -24
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs +23 -22
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +27 -18
- package/index.js +140 -143
- package/index.mjs +27 -29
- package/indexer-lookup.d.ts +18 -11
- package/indexer-lookup.js +112 -120
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +105 -118
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +9 -7
- package/localnet/get-kmd-wallet-account.js +28 -26
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +28 -24
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +7 -5
- package/localnet/get-localnet-dispenser-account.js +17 -15
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +17 -13
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +10 -8
- package/localnet/get-or-create-kmd-wallet-account.js +28 -26
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +28 -24
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/is-localnet.d.ts +7 -3
- package/localnet/is-localnet.js +9 -10
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +9 -8
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +17 -15
- package/network-client.js +115 -116
- package/network-client.js.map +1 -1
- package/network-client.mjs +115 -114
- package/network-client.mjs.map +1 -1
- package/package.json +12 -3
- package/testing/account.d.ts +11 -9
- package/testing/account.js +31 -33
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +29 -31
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +7 -2
- package/testing/fixtures/algokit-log-capture-fixture.js +36 -41
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs +36 -39
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +9 -4
- package/testing/fixtures/algorand-fixture.js +67 -62
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +66 -59
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +7 -5
- package/testing/index.js +13 -18
- package/testing/index.mjs +7 -7
- package/testing/indexer.d.ts +5 -1
- package/testing/indexer.js +28 -37
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs +28 -35
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +41 -36
- package/testing/test-logger.js +71 -76
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +71 -74
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +30 -27
- package/testing/transaction-logger.js +77 -93
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs +74 -90
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/legacy-bridge.js +100 -111
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +97 -108
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +7 -5
- package/transaction/perform-atomic-transaction-composer-simulate.js +31 -36
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +28 -33
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +34 -35
- package/transaction/transaction.js +716 -914
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +713 -911
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.d.ts +9 -5
- package/transfer/transfer-algos.js +26 -27
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +26 -25
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +11 -8
- package/transfer/transfer.js +94 -100
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +94 -98
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +432 -429
- package/types/account-manager.js +591 -602
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +587 -599
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +192 -202
- package/types/account.js +91 -88
- package/types/account.js.map +1 -1
- package/types/account.mjs +88 -86
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +15 -10
- package/types/algo-http-client-with-retry.js +70 -92
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +69 -90
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +778 -771
- package/types/algorand-client-transaction-creator.js +733 -732
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +732 -730
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +1090 -1360
- package/types/algorand-client-transaction-sender.js +930 -961
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +927 -959
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +239 -236
- package/types/algorand-client.js +322 -320
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +321 -318
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +47 -43
- package/types/amount.js +66 -70
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +63 -68
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +235 -272
- package/types/app-arc56.js +124 -170
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs +121 -168
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +1128 -2009
- package/types/app-client.js +1633 -1791
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1624 -1783
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +139 -141
- package/types/app-deployer.js +344 -384
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +341 -382
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +762 -932
- package/types/app-factory.js +496 -488
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +491 -484
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +304 -310
- package/types/app-manager.js +422 -475
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +419 -473
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +118 -117
- package/types/app-spec.js +125 -135
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +121 -132
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +229 -241
- package/types/app.js +36 -28
- package/types/app.js.map +1 -1
- package/types/app.mjs +33 -26
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +204 -199
- package/types/asset-manager.js +165 -174
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +164 -172
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +95 -91
- package/types/asset.js +0 -3
- package/types/asset.mjs +0 -2
- package/types/async-event-emitter.d.ts +18 -13
- package/types/async-event-emitter.js +37 -49
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +36 -47
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +453 -451
- package/types/client-manager.js +602 -598
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +597 -594
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +1211 -1258
- package/types/composer.js +1436 -1498
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +1430 -1493
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +53 -48
- package/types/config.js +78 -77
- package/types/config.js.map +1 -1
- package/types/config.mjs +77 -75
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +25 -23
- package/types/debugging.js +9 -11
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +8 -9
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +57 -52
- package/types/dispenser-client.js +120 -141
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +119 -139
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +5 -3
- package/types/expand.js +0 -3
- package/types/expand.mjs +0 -2
- package/types/indexer.d.ts +104 -100
- package/types/indexer.js +36 -31
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +32 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +5 -3
- package/types/instance-of.js +0 -3
- package/types/instance-of.mjs +0 -2
- package/types/kmd-account-manager.d.ts +75 -70
- package/types/kmd-account-manager.js +150 -184
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +147 -182
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +13 -8
- package/types/lifecycle-events.js +10 -7
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +9 -7
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +15 -11
- package/types/logging.js +30 -31
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +29 -29
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +33 -29
- package/types/logic-error.js +50 -49
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +49 -47
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +32 -27
- package/types/network-client.js +10 -9
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +9 -7
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +131 -132
- package/types/testing.js +0 -3
- package/types/testing.mjs +0 -2
- package/types/transaction.d.ts +110 -110
- package/types/transaction.js +0 -3
- package/types/transaction.mjs +0 -2
- package/types/transfer.d.ts +70 -66
- package/types/transfer.js +0 -3
- package/types/transfer.mjs +0 -2
- package/util.js +73 -118
- package/util.js.map +1 -1
- package/util.mjs +73 -116
- package/util.mjs.map +1 -1
- package/account/index.d.ts +0 -5
- package/debugging/index.d.ts +0 -1
- package/index.js.map +0 -1
- package/index.mjs.map +0 -1
- package/localnet/index.d.ts +0 -4
- package/testing/_asset.d.ts +0 -3
- package/testing/fixtures/index.d.ts +0 -2
- package/testing/index.js.map +0 -1
- package/testing/index.mjs.map +0 -1
- package/transaction/index.d.ts +0 -2
- package/transaction/legacy-bridge.d.ts +0 -35
- package/transfer/index.d.ts +0 -2
- package/types/asset.js.map +0 -1
- package/types/asset.mjs.map +0 -1
- package/types/expand.js.map +0 -1
- package/types/expand.mjs.map +0 -1
- package/types/instance-of.js.map +0 -1
- package/types/instance-of.mjs.map +0 -1
- package/types/testing.js.map +0 -1
- package/types/testing.mjs.map +0 -1
- package/types/transaction.js.map +0 -1
- package/types/transaction.mjs.map +0 -1
- package/types/transfer.js.map +0 -1
- package/types/transfer.mjs.map +0 -1
- package/util.d.ts +0 -48
package/app.mjs
CHANGED
|
@@ -1,329 +1,311 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { toNumber } from "./util.mjs";
|
|
2
|
+
import { encodeLease, getSenderAddress } from "./transaction/transaction.mjs";
|
|
3
|
+
import { AppManager } from "./types/app-manager.mjs";
|
|
4
|
+
import { _getAppArgsForABICall, _getBoxReference, legacySendAppTransactionBridge } from "./transaction/legacy-bridge.mjs";
|
|
5
|
+
import algosdk from "algosdk";
|
|
6
|
+
//#region src/app.ts
|
|
7
7
|
var ABIMethod = algosdk.ABIMethod;
|
|
8
8
|
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
* @deprecated Use `algorand.send.appCreate()` / `algorand.createTransaction.appCreate()` / `algorand.send.appCreateMethodCall()`
|
|
11
|
+
* / `algorand.createTransaction.appCreateMethodCall()` instead
|
|
12
|
+
*
|
|
13
|
+
* Creates a smart contract app, returns the details of the created app.
|
|
14
|
+
* @param create The parameters to create the app with
|
|
15
|
+
* @param algod An algod client
|
|
16
|
+
* @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
|
|
17
|
+
*/
|
|
18
18
|
async function createApp(create, algod) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
...result,
|
|
43
|
-
appId: 'appId' in result ? Number(result.appId) : 0,
|
|
44
|
-
appAddress: 'appAddress' in result ? result.appAddress.toString() : '',
|
|
45
|
-
};
|
|
19
|
+
const onComplete = getAppOnCompleteAction(create.onCompleteAction);
|
|
20
|
+
if (onComplete === algosdk.OnApplicationComplete.ClearStateOC) throw new Error("Cannot create an app with on-complete action of ClearState");
|
|
21
|
+
const result = create.args?.method ? await legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
22
|
+
sender: getSenderAddress(create.from),
|
|
23
|
+
onComplete,
|
|
24
|
+
approvalProgram: create.approvalProgram,
|
|
25
|
+
clearStateProgram: create.clearStateProgram,
|
|
26
|
+
method: create.args.method instanceof ABIMethod ? create.args.method : new ABIMethod(create.args.method),
|
|
27
|
+
extraProgramPages: create.schema.extraPages,
|
|
28
|
+
schema: create.schema
|
|
29
|
+
}, (c) => c.appCreateMethodCall, (c) => c.appCreateMethodCall) : await legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
30
|
+
sender: getSenderAddress(create.from),
|
|
31
|
+
onComplete,
|
|
32
|
+
approvalProgram: create.approvalProgram,
|
|
33
|
+
clearStateProgram: create.clearStateProgram,
|
|
34
|
+
extraProgramPages: create.schema.extraPages,
|
|
35
|
+
schema: create.schema
|
|
36
|
+
}, (c) => c.appCreate, (c) => c.appCreate);
|
|
37
|
+
return {
|
|
38
|
+
...result,
|
|
39
|
+
appId: "appId" in result ? Number(result.appId) : 0,
|
|
40
|
+
appAddress: "appAddress" in result ? result.appAddress.toString() : ""
|
|
41
|
+
};
|
|
46
42
|
}
|
|
47
43
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
45
|
+
* / `algorand.createTransaction.appUpdateMethodCall()` instead
|
|
46
|
+
*
|
|
47
|
+
* Updates a smart contract app.
|
|
48
|
+
* @param update The parameters to update the app with
|
|
49
|
+
* @param algod An algod client
|
|
50
|
+
* @returns The transaction send result and the compilation result
|
|
51
|
+
*/
|
|
56
52
|
async function updateApp(update, algod) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
clearStateProgram: update.clearStateProgram,
|
|
72
|
-
}, (c) => c.appUpdate, (c) => c.appUpdate);
|
|
53
|
+
return update.args?.method ? await legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
54
|
+
appId: BigInt(update.appId),
|
|
55
|
+
sender: getSenderAddress(update.from),
|
|
56
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
57
|
+
approvalProgram: update.approvalProgram,
|
|
58
|
+
clearStateProgram: update.clearStateProgram,
|
|
59
|
+
method: update.args.method instanceof ABIMethod ? update.args.method : new ABIMethod(update.args.method)
|
|
60
|
+
}, (c) => c.appUpdateMethodCall, (c) => c.appUpdateMethodCall) : await legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
61
|
+
appId: BigInt(update.appId),
|
|
62
|
+
sender: getSenderAddress(update.from),
|
|
63
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
64
|
+
approvalProgram: update.approvalProgram,
|
|
65
|
+
clearStateProgram: update.clearStateProgram
|
|
66
|
+
}, (c) => c.appUpdate, (c) => c.appUpdate);
|
|
73
67
|
}
|
|
74
68
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
* @deprecated Use `algosdk.OnApplicationComplete` directly instead.
|
|
70
|
+
*
|
|
71
|
+
* Returns a `algosdk.OnApplicationComplete` for the given onCompleteAction.
|
|
72
|
+
*
|
|
73
|
+
* If given `undefined` will return `OnApplicationComplete.NoOpOC`.
|
|
74
|
+
*
|
|
75
|
+
* If given an `AppCallType` will convert the string enum to the correct underlying `algosdk.OnApplicationComplete`.
|
|
76
|
+
*
|
|
77
|
+
* @param onCompletionAction The on completion action
|
|
78
|
+
* @returns The `algosdk.OnApplicationComplete`
|
|
79
|
+
*/
|
|
86
80
|
function getAppOnCompleteAction(onCompletionAction) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
case OnApplicationComplete.UpdateApplicationOC:
|
|
103
|
-
return OnApplicationComplete.UpdateApplicationOC;
|
|
104
|
-
case 'delete_application':
|
|
105
|
-
case OnApplicationComplete.DeleteApplicationOC:
|
|
106
|
-
return OnApplicationComplete.DeleteApplicationOC;
|
|
107
|
-
}
|
|
81
|
+
switch (onCompletionAction) {
|
|
82
|
+
case void 0:
|
|
83
|
+
case "no_op":
|
|
84
|
+
case OnApplicationComplete.NoOpOC: return OnApplicationComplete.NoOpOC;
|
|
85
|
+
case "opt_in":
|
|
86
|
+
case OnApplicationComplete.OptInOC: return OnApplicationComplete.OptInOC;
|
|
87
|
+
case "close_out":
|
|
88
|
+
case OnApplicationComplete.CloseOutOC: return OnApplicationComplete.CloseOutOC;
|
|
89
|
+
case "clear_state":
|
|
90
|
+
case OnApplicationComplete.ClearStateOC: return OnApplicationComplete.ClearStateOC;
|
|
91
|
+
case "update_application":
|
|
92
|
+
case OnApplicationComplete.UpdateApplicationOC: return OnApplicationComplete.UpdateApplicationOC;
|
|
93
|
+
case "delete_application":
|
|
94
|
+
case OnApplicationComplete.DeleteApplicationOC: return OnApplicationComplete.DeleteApplicationOC;
|
|
95
|
+
}
|
|
108
96
|
}
|
|
109
97
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
98
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
99
|
+
* / `algorand.createTransaction.appUpdateMethodCall()` instead
|
|
100
|
+
*
|
|
101
|
+
* Issues a call to a given app.
|
|
102
|
+
* @param call The call details.
|
|
103
|
+
* @param algod An algod client
|
|
104
|
+
* @returns The result of the call
|
|
105
|
+
*/
|
|
118
106
|
async function callApp(call, algod) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method),
|
|
133
|
-
}, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall)
|
|
134
|
-
: await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
135
|
-
appId: BigInt(call.appId),
|
|
136
|
-
sender: getSenderAddress(call.from),
|
|
137
|
-
onComplete,
|
|
138
|
-
}, (c) => c.appCall, (c) => c.appCall);
|
|
107
|
+
const onComplete = getAppOnCompleteAction(call.callType);
|
|
108
|
+
if (onComplete === algosdk.OnApplicationComplete.UpdateApplicationOC) throw new Error("Cannot execute an app call with on-complete action of Update");
|
|
109
|
+
if (call.args?.method && onComplete === algosdk.OnApplicationComplete.ClearStateOC) throw new Error("Cannot execute an ABI method call with on-complete action of ClearState");
|
|
110
|
+
return call.args?.method ? await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
111
|
+
appId: BigInt(call.appId),
|
|
112
|
+
sender: getSenderAddress(call.from),
|
|
113
|
+
onComplete,
|
|
114
|
+
method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method)
|
|
115
|
+
}, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall) : await legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
116
|
+
appId: BigInt(call.appId),
|
|
117
|
+
sender: getSenderAddress(call.from),
|
|
118
|
+
onComplete
|
|
119
|
+
}, (c) => c.appCall, (c) => c.appCall);
|
|
139
120
|
}
|
|
140
121
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
122
|
+
* @deprecated Use `AppManager.getABIReturn` instead.
|
|
123
|
+
*
|
|
124
|
+
* Returns any ABI return values for the given app call arguments and transaction confirmation.
|
|
125
|
+
* @param args The arguments that were used for the call
|
|
126
|
+
* @param confirmation The transaction confirmation from algod
|
|
127
|
+
* @returns The return value for the method call
|
|
128
|
+
*/
|
|
148
129
|
function getABIReturn(args, confirmation) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const method = 'txnCount' in args.method ? args.method : new ABIMethod(args.method);
|
|
153
|
-
return AppManager.getABIReturn(confirmation, method);
|
|
130
|
+
if (!args || !args.method) return;
|
|
131
|
+
const method = "txnCount" in args.method ? args.method : new ABIMethod(args.method);
|
|
132
|
+
return AppManager.getABIReturn(confirmation, method);
|
|
154
133
|
}
|
|
155
134
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
135
|
+
* @deprecated Use `algorand.app.getGlobalState` instead.
|
|
136
|
+
*
|
|
137
|
+
* Returns the current global state values for the given app ID
|
|
138
|
+
* @param appId The ID of the app return global state for
|
|
139
|
+
* @param algod An algod client instance
|
|
140
|
+
* @returns The current global state
|
|
141
|
+
*/
|
|
163
142
|
async function getAppGlobalState(appId, algod) {
|
|
164
|
-
|
|
143
|
+
return await new AppManager(algod).getGlobalState(BigInt(appId));
|
|
165
144
|
}
|
|
166
145
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
146
|
+
* @deprecated Use `algorand.app.getLocalState` instead.
|
|
147
|
+
*
|
|
148
|
+
* Returns the current global state values for the given app ID and account
|
|
149
|
+
* @param appId The ID of the app return global state for
|
|
150
|
+
* @param account Either the string address of an account or an account object for the account to get local state for the given app
|
|
151
|
+
* @param algod An algod client instance
|
|
152
|
+
* @returns The current local state for the given (app, account) combination
|
|
153
|
+
*/
|
|
175
154
|
async function getAppLocalState(appId, account, algod) {
|
|
176
|
-
|
|
155
|
+
return new AppManager(algod).getLocalState(BigInt(appId), getSenderAddress(account));
|
|
177
156
|
}
|
|
178
157
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
158
|
+
* @deprecated Use `algorand.app.getBoxNames` instead.
|
|
159
|
+
* Returns the names of the boxes for the given app.
|
|
160
|
+
* @param appId The ID of the app return box names for
|
|
161
|
+
* @param algod An algod client instance
|
|
162
|
+
* @returns The current box names
|
|
163
|
+
*/
|
|
185
164
|
async function getAppBoxNames(appId, algod) {
|
|
186
|
-
|
|
165
|
+
return new AppManager(algod).getBoxNames(BigInt(appId));
|
|
187
166
|
}
|
|
188
167
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
168
|
+
* @deprecated Use `algorand.app.getBoxValue` instead.
|
|
169
|
+
* Returns the value of the given box name for the given app.
|
|
170
|
+
* @param appId The ID of the app return box names for
|
|
171
|
+
* @param boxName The name of the box to return either as a string, binary array or `BoxName`
|
|
172
|
+
* @param algod An algod client instance
|
|
173
|
+
* @returns The current box value as a byte array
|
|
174
|
+
*/
|
|
196
175
|
async function getAppBoxValue(appId, boxName, algod) {
|
|
197
|
-
|
|
176
|
+
return new AppManager(algod).getBoxValue(BigInt(appId), typeof boxName !== "string" && "name" in boxName ? boxName.nameRaw : boxName);
|
|
198
177
|
}
|
|
199
178
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
179
|
+
* @deprecated Use `algorand.app.getBoxValues` instead.
|
|
180
|
+
* Returns the value of the given box names for the given app.
|
|
181
|
+
* @param appId The ID of the app return box names for
|
|
182
|
+
* @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
|
|
183
|
+
* @param algod An algod client instance
|
|
184
|
+
* @returns The current box values as a byte array in the same order as the passed in box names
|
|
185
|
+
*/
|
|
207
186
|
async function getAppBoxValues(appId, boxNames, algod) {
|
|
208
|
-
|
|
187
|
+
return new AppManager(algod).getBoxValues(BigInt(appId), boxNames.map((b) => typeof b !== "string" && "name" in b ? b.nameRaw : b));
|
|
209
188
|
}
|
|
210
189
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
190
|
+
* @deprecated Use `algorand.app.getBoxValueFromABIType` instead.
|
|
191
|
+
* Returns the value of the given box name for the given app decoded based on the given ABI type.
|
|
192
|
+
* @param request The parameters for the box value request
|
|
193
|
+
* @param algod An algod client instance
|
|
194
|
+
* @returns The current box value as an ABI value
|
|
195
|
+
*/
|
|
217
196
|
async function getAppBoxValueFromABIType(request, algod) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
197
|
+
return new AppManager(algod).getBoxValueFromABIType({
|
|
198
|
+
appId: BigInt(request.appId),
|
|
199
|
+
boxName: typeof request.boxName !== "string" && "name" in request.boxName ? request.boxName.nameRaw : request.boxName,
|
|
200
|
+
type: request.type
|
|
201
|
+
});
|
|
223
202
|
}
|
|
224
203
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
204
|
+
* @deprecated Use `algorand.app.getBoxValuesFromABIType` instead.
|
|
205
|
+
* Returns the value of the given box names for the given app decoded based on the given ABI type.
|
|
206
|
+
* @param request The parameters for the box value request
|
|
207
|
+
* @param algod An algod client instance
|
|
208
|
+
* @returns The current box values as an ABI value in the same order as the passed in box names
|
|
209
|
+
*/
|
|
231
210
|
async function getAppBoxValuesFromABIType(request, algod) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
211
|
+
return new AppManager(algod).getBoxValuesFromABIType({
|
|
212
|
+
appId: BigInt(request.appId),
|
|
213
|
+
boxNames: request.boxNames.map((b) => typeof b !== "string" && "name" in b ? b.nameRaw : b),
|
|
214
|
+
type: request.type
|
|
215
|
+
});
|
|
237
216
|
}
|
|
238
217
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
218
|
+
* @deprecated Use `AppManager.decodeAppState` instead.
|
|
219
|
+
*
|
|
220
|
+
* Converts an array of global/local state values from the algod api to a more friendly
|
|
221
|
+
* generic object keyed by the UTF-8 value of the key.
|
|
222
|
+
* @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`
|
|
223
|
+
* @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values
|
|
224
|
+
*/
|
|
246
225
|
function decodeAppState(state) {
|
|
247
|
-
|
|
226
|
+
return AppManager.decodeAppState(state.map(({ key, value }) => ({
|
|
227
|
+
key: Buffer.from(key, "utf-8"),
|
|
228
|
+
value
|
|
229
|
+
})));
|
|
248
230
|
}
|
|
249
231
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
232
|
+
* @deprecated Use `TransactionComposer` methods to construct transactions instead.
|
|
233
|
+
*
|
|
234
|
+
* Returns the app args ready to load onto an app `Transaction` object
|
|
235
|
+
* @param args The app call args
|
|
236
|
+
* @returns The args ready to load into a `Transaction`
|
|
237
|
+
*/
|
|
256
238
|
function getAppArgsForTransaction(args) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
};
|
|
239
|
+
if (!args) return void 0;
|
|
240
|
+
const encoder = new TextEncoder();
|
|
241
|
+
return {
|
|
242
|
+
accounts: args?.accounts?.map(_getAccountAddress),
|
|
243
|
+
appArgs: args?.appArgs?.map((a) => typeof a === "string" ? encoder.encode(a) : a),
|
|
244
|
+
boxes: args.boxes?.map(getBoxReference),
|
|
245
|
+
foreignApps: args?.apps,
|
|
246
|
+
foreignAssets: args?.assets,
|
|
247
|
+
lease: encodeLease(args?.lease)
|
|
248
|
+
};
|
|
268
249
|
}
|
|
269
250
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
251
|
+
* @deprecated Use `TransactionComposer` methods to construct transactions instead.
|
|
252
|
+
*
|
|
253
|
+
* Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer`
|
|
254
|
+
* @param args The ABI app call args
|
|
255
|
+
* @param from The transaction signer
|
|
256
|
+
* @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer
|
|
257
|
+
*/
|
|
277
258
|
async function getAppArgsForABICall(args, from) {
|
|
278
|
-
|
|
259
|
+
return _getAppArgsForABICall(args, from);
|
|
279
260
|
}
|
|
280
261
|
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
262
|
+
* @deprecated Use `AppManager.getBoxReference()` instead.
|
|
263
|
+
*
|
|
264
|
+
* Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.
|
|
265
|
+
* @param box The box to return a reference for
|
|
266
|
+
* @returns The box reference ready to pass into a `Transaction`
|
|
267
|
+
*/
|
|
287
268
|
function getBoxReference(box) {
|
|
288
|
-
|
|
269
|
+
return _getBoxReference(box);
|
|
289
270
|
}
|
|
290
271
|
function _getAccountAddress(account) {
|
|
291
|
-
|
|
272
|
+
return typeof account === "string" ? account : algosdk.encodeAddress(account.publicKey);
|
|
292
273
|
}
|
|
293
274
|
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
275
|
+
* @deprecated Use `algorand.app.getById` instead.
|
|
276
|
+
*
|
|
277
|
+
* Gets the current data for the given app from algod.
|
|
278
|
+
*
|
|
279
|
+
* @param appId The id of the app
|
|
280
|
+
* @param algod An algod client
|
|
281
|
+
* @returns The data about the app
|
|
282
|
+
*/
|
|
302
283
|
async function getAppById(appId, algod) {
|
|
303
|
-
|
|
284
|
+
return await algod.getApplicationByID(toNumber(appId)).do();
|
|
304
285
|
}
|
|
305
286
|
/**
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
287
|
+
* @deprecated Use `algorand.app.compileTeal` instead.
|
|
288
|
+
*
|
|
289
|
+
* Compiles the given TEAL using algod and returns the result, including source map.
|
|
290
|
+
*
|
|
291
|
+
* @param algod An algod client
|
|
292
|
+
* @param tealCode The TEAL code
|
|
293
|
+
* @returns The information about the compiled file
|
|
294
|
+
*/
|
|
314
295
|
async function compileTeal(tealCode, algod) {
|
|
315
|
-
|
|
296
|
+
return await new AppManager(algod).compileTeal(tealCode);
|
|
316
297
|
}
|
|
317
298
|
/**
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
299
|
+
* @deprecated Use `abiMethod.getSignature()` or `new ABIMethod(abiMethodParams).getSignature()` instead.
|
|
300
|
+
*
|
|
301
|
+
* Returns the encoded ABI spec for a given ABI Method
|
|
302
|
+
* @param method The method to return a signature for
|
|
303
|
+
* @returns The encoded ABI method spec e.g. `method_name(uint64,string)string`
|
|
304
|
+
*/
|
|
324
305
|
const getABIMethodSignature = (method) => {
|
|
325
|
-
|
|
306
|
+
return "getSignature" in method ? method.getSignature() : new ABIMethod(method).getSignature();
|
|
326
307
|
};
|
|
327
|
-
|
|
308
|
+
//#endregion
|
|
328
309
|
export { callApp, compileTeal, createApp, decodeAppState, getABIMethodSignature, getABIReturn, getAppArgsForABICall, getAppArgsForTransaction, getAppBoxNames, getAppBoxValue, getAppBoxValueFromABIType, getAppBoxValues, getAppBoxValuesFromABIType, getAppById, getAppGlobalState, getAppLocalState, getAppOnCompleteAction, getBoxReference, updateApp };
|
|
329
|
-
|
|
310
|
+
|
|
311
|
+
//# sourceMappingURL=app.mjs.map
|