@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/app.js
CHANGED
|
@@ -1,199 +1,82 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var algosdk = require('algosdk');
|
|
4
|
-
var
|
|
5
|
-
var config = require('./config.js');
|
|
4
|
+
var legacyBridge = require('./transaction/legacy-bridge.js');
|
|
6
5
|
var transaction = require('./transaction/transaction.js');
|
|
7
|
-
var
|
|
6
|
+
var types_appManager = require('./types/app-manager.js');
|
|
8
7
|
var util = require('./util.js');
|
|
9
8
|
|
|
10
9
|
var ABIMethod = algosdk.ABIMethod;
|
|
11
|
-
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
12
|
-
var modelsv2 = algosdk.modelsv2;
|
|
13
10
|
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
14
|
-
var SourceMap = algosdk.SourceMap;
|
|
15
11
|
/**
|
|
12
|
+
* @deprecated Use `algorand.send.appCreate()` / `algorand.createTransaction.appCreate()` / `algorand.send.appCreateMethodCall()`
|
|
13
|
+
* / `algorand.createTransaction.appCreateMethodCall()` instead
|
|
14
|
+
*
|
|
16
15
|
* Creates a smart contract app, returns the details of the created app.
|
|
17
16
|
* @param create The parameters to create the app with
|
|
18
17
|
* @param algod An algod client
|
|
19
18
|
* @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
|
|
20
19
|
*/
|
|
21
20
|
async function createApp(create, algod) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined;
|
|
26
|
-
const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear;
|
|
27
|
-
if (args && args.method) {
|
|
28
|
-
const atc = attachATC(sendParams);
|
|
29
|
-
const before = transaction.getAtomicTransactionComposerTransactions(atc);
|
|
30
|
-
atc.addMethodCall({
|
|
31
|
-
appID: 0,
|
|
32
|
-
approvalProgram: approvalProgram,
|
|
33
|
-
clearProgram: clearProgram,
|
|
34
|
-
numLocalInts: schema.localInts,
|
|
35
|
-
numLocalByteSlices: schema.localByteSlices,
|
|
36
|
-
numGlobalInts: schema.globalInts,
|
|
37
|
-
numGlobalByteSlices: schema.globalByteSlices,
|
|
38
|
-
extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / types_app.APP_PAGE_MAX_SIZE),
|
|
39
|
-
onComplete: getAppOnCompleteAction(onCompleteAction),
|
|
40
|
-
suggestedParams: transaction.controlFees(await transaction.getTransactionParams(transactionParams, algod), sendParams),
|
|
41
|
-
note: transaction.encodeTransactionNote(note),
|
|
42
|
-
...(await getAppArgsForABICall(args, from)),
|
|
43
|
-
});
|
|
44
|
-
if (sendParams.skipSending) {
|
|
45
|
-
const after = atc.clone().buildGroup();
|
|
46
|
-
return {
|
|
47
|
-
transaction: after[after.length - 1].txn,
|
|
48
|
-
transactions: after.slice(before.length).map((t) => t.txn),
|
|
49
|
-
appId: 0,
|
|
50
|
-
appAddress: '',
|
|
51
|
-
compiledApproval,
|
|
52
|
-
compiledClear,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const result = await transaction.sendAtomicTransactionComposer({ atc, sendParams }, algod);
|
|
56
|
-
const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
|
|
57
|
-
if (confirmation) {
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
-
const appId = confirmation.applicationIndex;
|
|
60
|
-
config.Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${transaction.getSenderAddress(from)}`);
|
|
61
|
-
return {
|
|
62
|
-
transactions: result.transactions,
|
|
63
|
-
confirmations: result.confirmations,
|
|
64
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
65
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
66
|
-
confirmation: confirmation,
|
|
67
|
-
appId,
|
|
68
|
-
appAddress: algosdk.getApplicationAddress(appId),
|
|
69
|
-
compiledApproval,
|
|
70
|
-
compiledClear,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return {
|
|
75
|
-
transactions: result.transactions,
|
|
76
|
-
confirmations: result.confirmations,
|
|
77
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
78
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
79
|
-
confirmation: confirmation,
|
|
80
|
-
appId: 0,
|
|
81
|
-
appAddress: '',
|
|
82
|
-
compiledApproval,
|
|
83
|
-
compiledClear,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
const transaction$1 = algosdk.makeApplicationCreateTxnFromObject({
|
|
89
|
-
approvalProgram: approvalProgram,
|
|
90
|
-
clearProgram: clearProgram,
|
|
91
|
-
numLocalInts: schema.localInts,
|
|
92
|
-
numLocalByteSlices: schema.localByteSlices,
|
|
93
|
-
numGlobalInts: schema.globalInts,
|
|
94
|
-
numGlobalByteSlices: schema.globalByteSlices,
|
|
95
|
-
extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / types_app.APP_PAGE_MAX_SIZE),
|
|
96
|
-
onComplete: getAppOnCompleteAction(onCompleteAction),
|
|
97
|
-
suggestedParams: await transaction.getTransactionParams(transactionParams, algod),
|
|
98
|
-
from: transaction.getSenderAddress(from),
|
|
99
|
-
note: transaction.encodeTransactionNote(note),
|
|
100
|
-
...getAppArgsForTransaction(args),
|
|
101
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
102
|
-
});
|
|
103
|
-
const { confirmation } = await transaction.sendTransaction({ transaction: transaction$1, from, sendParams }, algod);
|
|
104
|
-
if (confirmation) {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
106
|
-
const appId = confirmation.applicationIndex;
|
|
107
|
-
config.Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${transaction.getSenderAddress(from)}`);
|
|
108
|
-
return {
|
|
109
|
-
transaction: transaction$1,
|
|
110
|
-
transactions: [transaction$1],
|
|
111
|
-
confirmation,
|
|
112
|
-
confirmations: confirmation ? [confirmation] : undefined,
|
|
113
|
-
appId,
|
|
114
|
-
appAddress: algosdk.getApplicationAddress(appId),
|
|
115
|
-
return: getABIReturn(args, confirmation),
|
|
116
|
-
compiledApproval,
|
|
117
|
-
compiledClear,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return { transaction: transaction$1, transactions: [transaction$1], appId: 0, appAddress: '', compiledApproval, compiledClear };
|
|
122
|
-
}
|
|
21
|
+
const onComplete = getAppOnCompleteAction(create.onCompleteAction);
|
|
22
|
+
if (onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
|
|
23
|
+
throw new Error('Cannot create an app with on-complete action of ClearState');
|
|
123
24
|
}
|
|
25
|
+
const result = create.args?.method
|
|
26
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
27
|
+
sender: transaction.getSenderAddress(create.from),
|
|
28
|
+
onComplete,
|
|
29
|
+
approvalProgram: create.approvalProgram,
|
|
30
|
+
clearStateProgram: create.clearStateProgram,
|
|
31
|
+
method: create.args.method instanceof ABIMethod ? create.args.method : new ABIMethod(create.args.method),
|
|
32
|
+
extraProgramPages: create.schema.extraPages,
|
|
33
|
+
schema: create.schema,
|
|
34
|
+
}, (c) => c.appCreateMethodCall, (c) => c.appCreateMethodCall)
|
|
35
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
36
|
+
sender: transaction.getSenderAddress(create.from),
|
|
37
|
+
onComplete,
|
|
38
|
+
approvalProgram: create.approvalProgram,
|
|
39
|
+
clearStateProgram: create.clearStateProgram,
|
|
40
|
+
extraProgramPages: create.schema.extraPages,
|
|
41
|
+
schema: create.schema,
|
|
42
|
+
}, (c) => c.appCreate, (c) => c.appCreate);
|
|
43
|
+
return {
|
|
44
|
+
...result,
|
|
45
|
+
appId: 'appId' in result ? Number(result.appId) : 0,
|
|
46
|
+
appAddress: 'appAddress' in result ? result.appAddress.toString() : '',
|
|
47
|
+
};
|
|
124
48
|
}
|
|
125
49
|
/**
|
|
50
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
51
|
+
* / `algorand.createTransaction.appUpdateMethodCall()` instead
|
|
52
|
+
*
|
|
126
53
|
* Updates a smart contract app.
|
|
127
54
|
* @param update The parameters to update the app with
|
|
128
55
|
* @param algod An algod client
|
|
129
56
|
* @returns The transaction send result and the compilation result
|
|
130
57
|
*/
|
|
131
58
|
async function updateApp(update, algod) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...(await getAppArgsForABICall(args, from)),
|
|
149
|
-
});
|
|
150
|
-
if (sendParams.skipSending) {
|
|
151
|
-
const after = atc.clone().buildGroup();
|
|
152
|
-
return {
|
|
153
|
-
transaction: after[after.length - 1].txn,
|
|
154
|
-
transactions: after.slice(before.length).map((t) => t.txn),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const result = await transaction.sendAtomicTransactionComposer({ atc, sendParams }, algod);
|
|
158
|
-
const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
|
|
159
|
-
return {
|
|
160
|
-
transactions: result.transactions,
|
|
161
|
-
confirmations: result.confirmations,
|
|
162
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
163
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
164
|
-
confirmation: confirmation,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
const transaction$1 = algosdk.makeApplicationUpdateTxnFromObject({
|
|
169
|
-
appIndex: util.toNumber(appId),
|
|
170
|
-
approvalProgram: approvalProgram,
|
|
171
|
-
clearProgram: clearProgram,
|
|
172
|
-
suggestedParams: await transaction.getTransactionParams(transactionParams, algod),
|
|
173
|
-
from: transaction.getSenderAddress(from),
|
|
174
|
-
note: transaction.encodeTransactionNote(note),
|
|
175
|
-
...getAppArgsForTransaction(args),
|
|
176
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
177
|
-
});
|
|
178
|
-
const result = await transaction.sendTransaction({ transaction: transaction$1, from, sendParams }, algod);
|
|
179
|
-
return {
|
|
180
|
-
...result,
|
|
181
|
-
transactions: [result.transaction],
|
|
182
|
-
confirmations: result.confirmation ? [result.confirmation] : undefined,
|
|
183
|
-
return: getABIReturn(args, result.confirmation),
|
|
184
|
-
compiledApproval,
|
|
185
|
-
compiledClear,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function attachATC(sendParams) {
|
|
190
|
-
if (sendParams.atc) {
|
|
191
|
-
sendParams.skipSending = true;
|
|
192
|
-
}
|
|
193
|
-
sendParams.atc = sendParams.atc ?? new AtomicTransactionComposer();
|
|
194
|
-
return sendParams.atc;
|
|
59
|
+
return update.args?.method
|
|
60
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
61
|
+
appId: BigInt(update.appId),
|
|
62
|
+
sender: transaction.getSenderAddress(update.from),
|
|
63
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
64
|
+
approvalProgram: update.approvalProgram,
|
|
65
|
+
clearStateProgram: update.clearStateProgram,
|
|
66
|
+
method: update.args.method instanceof ABIMethod ? update.args.method : new ABIMethod(update.args.method),
|
|
67
|
+
}, (c) => c.appUpdateMethodCall, (c) => c.appUpdateMethodCall)
|
|
68
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
69
|
+
appId: BigInt(update.appId),
|
|
70
|
+
sender: transaction.getSenderAddress(update.from),
|
|
71
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
72
|
+
approvalProgram: update.approvalProgram,
|
|
73
|
+
clearStateProgram: update.clearStateProgram,
|
|
74
|
+
}, (c) => c.appUpdate, (c) => c.appUpdate);
|
|
195
75
|
}
|
|
196
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use `algosdk.OnApplicationComplete` directly instead.
|
|
78
|
+
*
|
|
79
|
+
* Returns a `algosdk.OnApplicationComplete` for the given onCompleteAction.
|
|
197
80
|
*
|
|
198
81
|
* If given `undefined` will return `OnApplicationComplete.NoOpOC`.
|
|
199
82
|
*
|
|
@@ -226,77 +109,39 @@ function getAppOnCompleteAction(onCompletionAction) {
|
|
|
226
109
|
}
|
|
227
110
|
}
|
|
228
111
|
/**
|
|
112
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
113
|
+
* / `algorand.createTransaction.appUpdateMethodCall()` instead
|
|
114
|
+
*
|
|
229
115
|
* Issues a call to a given app.
|
|
230
116
|
* @param call The call details.
|
|
231
117
|
* @param algod An algod client
|
|
232
118
|
* @returns The result of the call
|
|
233
119
|
*/
|
|
234
120
|
async function callApp(call, algod) {
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
const before = transaction.getAtomicTransactionComposerTransactions(atc);
|
|
239
|
-
atc.addMethodCall({
|
|
240
|
-
appID: util.toNumber(appId),
|
|
241
|
-
suggestedParams: transaction.controlFees(await transaction.getTransactionParams(transactionParams, algod), sendParams),
|
|
242
|
-
note: transaction.encodeTransactionNote(note),
|
|
243
|
-
onComplete: getAppOnCompleteAction(callType),
|
|
244
|
-
...(await getAppArgsForABICall(args, from)),
|
|
245
|
-
});
|
|
246
|
-
if (sendParams.skipSending) {
|
|
247
|
-
const after = atc.clone().buildGroup();
|
|
248
|
-
return {
|
|
249
|
-
transaction: after[after.length - 1].txn,
|
|
250
|
-
transactions: after.slice(before.length).map((t) => t.txn),
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
const result = await transaction.sendAtomicTransactionComposer({ atc, sendParams }, algod);
|
|
254
|
-
const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
|
|
255
|
-
return {
|
|
256
|
-
transactions: result.transactions,
|
|
257
|
-
confirmations: result.confirmations,
|
|
258
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
259
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
260
|
-
confirmation: confirmation,
|
|
261
|
-
};
|
|
121
|
+
const onComplete = getAppOnCompleteAction(call.callType);
|
|
122
|
+
if (onComplete === algosdk.OnApplicationComplete.UpdateApplicationOC) {
|
|
123
|
+
throw new Error('Cannot execute an app call with on-complete action of Update');
|
|
262
124
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
from: transaction.getSenderAddress(from),
|
|
266
|
-
suggestedParams: await transaction.getTransactionParams(transactionParams, algod),
|
|
267
|
-
...getAppArgsForTransaction(args),
|
|
268
|
-
note: transaction.encodeTransactionNote(note),
|
|
269
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
270
|
-
};
|
|
271
|
-
let transaction$1;
|
|
272
|
-
switch (getAppOnCompleteAction(callType)) {
|
|
273
|
-
case OnApplicationComplete.OptInOC:
|
|
274
|
-
transaction$1 = algosdk.makeApplicationOptInTxnFromObject(appCallParams);
|
|
275
|
-
break;
|
|
276
|
-
case OnApplicationComplete.ClearStateOC:
|
|
277
|
-
transaction$1 = algosdk.makeApplicationClearStateTxnFromObject(appCallParams);
|
|
278
|
-
break;
|
|
279
|
-
case OnApplicationComplete.CloseOutOC:
|
|
280
|
-
transaction$1 = algosdk.makeApplicationCloseOutTxnFromObject(appCallParams);
|
|
281
|
-
break;
|
|
282
|
-
case OnApplicationComplete.DeleteApplicationOC:
|
|
283
|
-
transaction$1 = algosdk.makeApplicationDeleteTxnFromObject(appCallParams);
|
|
284
|
-
break;
|
|
285
|
-
case OnApplicationComplete.NoOpOC:
|
|
286
|
-
transaction$1 = algosdk.makeApplicationNoOpTxnFromObject(appCallParams);
|
|
287
|
-
break;
|
|
288
|
-
default:
|
|
289
|
-
throw new Error(`Received unexpected call type ${callType}`);
|
|
125
|
+
if (call.args?.method && onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
|
|
126
|
+
throw new Error('Cannot execute an ABI method call with on-complete action of ClearState');
|
|
290
127
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
128
|
+
return call.args?.method
|
|
129
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
130
|
+
appId: BigInt(call.appId),
|
|
131
|
+
sender: transaction.getSenderAddress(call.from),
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
onComplete: onComplete,
|
|
134
|
+
method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method),
|
|
135
|
+
}, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall)
|
|
136
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
137
|
+
appId: BigInt(call.appId),
|
|
138
|
+
sender: transaction.getSenderAddress(call.from),
|
|
139
|
+
onComplete,
|
|
140
|
+
}, (c) => c.appCall, (c) => c.appCall);
|
|
298
141
|
}
|
|
299
142
|
/**
|
|
143
|
+
* @deprecated Use `AppManager.getABIReturn` instead.
|
|
144
|
+
*
|
|
300
145
|
* Returns any ABI return values for the given app call arguments and transaction confirmation.
|
|
301
146
|
* @param args The arguments that were used for the call
|
|
302
147
|
* @param confirmation The transaction confirmation from algod
|
|
@@ -307,43 +152,22 @@ function getABIReturn(args, confirmation) {
|
|
|
307
152
|
return undefined;
|
|
308
153
|
}
|
|
309
154
|
const method = 'txnCount' in args.method ? args.method : new ABIMethod(args.method);
|
|
310
|
-
|
|
311
|
-
// The parseMethodResponse method mutates the second parameter :(
|
|
312
|
-
const resultDummy = {
|
|
313
|
-
txID: '',
|
|
314
|
-
method,
|
|
315
|
-
rawReturnValue: new Uint8Array(),
|
|
316
|
-
};
|
|
317
|
-
const response = AtomicTransactionComposer.parseMethodResponse(method, resultDummy, confirmation);
|
|
318
|
-
return !response.decodeError
|
|
319
|
-
? {
|
|
320
|
-
rawReturnValue: response.rawReturnValue,
|
|
321
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
322
|
-
returnValue: response.returnValue,
|
|
323
|
-
decodeError: undefined,
|
|
324
|
-
}
|
|
325
|
-
: {
|
|
326
|
-
rawReturnValue: undefined,
|
|
327
|
-
returnValue: undefined,
|
|
328
|
-
decodeError: response.decodeError,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
return undefined;
|
|
155
|
+
return types_appManager.AppManager.getABIReturn(confirmation, method);
|
|
332
156
|
}
|
|
333
157
|
/**
|
|
158
|
+
* @deprecated Use `algorand.app.getGlobalState` instead.
|
|
159
|
+
*
|
|
334
160
|
* Returns the current global state values for the given app ID
|
|
335
161
|
* @param appId The ID of the app return global state for
|
|
336
162
|
* @param algod An algod client instance
|
|
337
163
|
* @returns The current global state
|
|
338
164
|
*/
|
|
339
165
|
async function getAppGlobalState(appId, algod) {
|
|
340
|
-
|
|
341
|
-
if (!appInfo.params || !appInfo.params.globalState) {
|
|
342
|
-
throw new Error("Couldn't find global state");
|
|
343
|
-
}
|
|
344
|
-
return decodeAppState(appInfo.params.globalState);
|
|
166
|
+
return await new types_appManager.AppManager(algod).getGlobalState(BigInt(appId));
|
|
345
167
|
}
|
|
346
168
|
/**
|
|
169
|
+
* @deprecated Use `algorand.app.getLocalState` instead.
|
|
170
|
+
*
|
|
347
171
|
* Returns the current global state values for the given app ID and account
|
|
348
172
|
* @param appId The ID of the app return global state for
|
|
349
173
|
* @param account Either the string address of an account or an account object for the account to get local state for the given app
|
|
@@ -351,30 +175,20 @@ async function getAppGlobalState(appId, algod) {
|
|
|
351
175
|
* @returns The current local state for the given (app, account) combination
|
|
352
176
|
*/
|
|
353
177
|
async function getAppLocalState(appId, account, algod) {
|
|
354
|
-
|
|
355
|
-
const appInfo = modelsv2.AccountApplicationResponse.from_obj_for_encoding(await algod.accountApplicationInformation(accountAddress, util.toNumber(appId)).do());
|
|
356
|
-
if (!appInfo.appLocalState?.keyValue) {
|
|
357
|
-
throw new Error("Couldn't find local state");
|
|
358
|
-
}
|
|
359
|
-
return decodeAppState(appInfo.appLocalState.keyValue);
|
|
178
|
+
return new types_appManager.AppManager(algod).getLocalState(BigInt(appId), transaction.getSenderAddress(account));
|
|
360
179
|
}
|
|
361
180
|
/**
|
|
181
|
+
* @deprecated Use `algorand.app.getBoxNames` instead.
|
|
362
182
|
* Returns the names of the boxes for the given app.
|
|
363
183
|
* @param appId The ID of the app return box names for
|
|
364
184
|
* @param algod An algod client instance
|
|
365
185
|
* @returns The current box names
|
|
366
186
|
*/
|
|
367
187
|
async function getAppBoxNames(appId, algod) {
|
|
368
|
-
|
|
369
|
-
return boxResult.boxes.map((b) => {
|
|
370
|
-
return {
|
|
371
|
-
nameRaw: b.name,
|
|
372
|
-
nameBase64: buffer.Buffer.from(b.name).toString('base64'),
|
|
373
|
-
name: buffer.Buffer.from(b.name).toString('utf-8'),
|
|
374
|
-
};
|
|
375
|
-
});
|
|
188
|
+
return new types_appManager.AppManager(algod).getBoxNames(BigInt(appId));
|
|
376
189
|
}
|
|
377
190
|
/**
|
|
191
|
+
* @deprecated Use `algorand.app.getBoxValue` instead.
|
|
378
192
|
* Returns the value of the given box name for the given app.
|
|
379
193
|
* @param appId The ID of the app return box names for
|
|
380
194
|
* @param boxName The name of the box to return either as a string, binary array or `BoxName`
|
|
@@ -382,11 +196,10 @@ async function getAppBoxNames(appId, algod) {
|
|
|
382
196
|
* @returns The current box value as a byte array
|
|
383
197
|
*/
|
|
384
198
|
async function getAppBoxValue(appId, boxName, algod) {
|
|
385
|
-
|
|
386
|
-
const boxResult = await algod.getApplicationBoxByName(util.toNumber(appId), name).do();
|
|
387
|
-
return boxResult.value;
|
|
199
|
+
return new types_appManager.AppManager(algod).getBoxValue(BigInt(appId), typeof boxName !== 'string' && 'name' in boxName ? boxName.nameRaw : boxName);
|
|
388
200
|
}
|
|
389
201
|
/**
|
|
202
|
+
* @deprecated Use `algorand.app.getBoxValues` instead.
|
|
390
203
|
* Returns the value of the given box names for the given app.
|
|
391
204
|
* @param appId The ID of the app return box names for
|
|
392
205
|
* @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
|
|
@@ -394,74 +207,50 @@ async function getAppBoxValue(appId, boxName, algod) {
|
|
|
394
207
|
* @returns The current box values as a byte array in the same order as the passed in box names
|
|
395
208
|
*/
|
|
396
209
|
async function getAppBoxValues(appId, boxNames, algod) {
|
|
397
|
-
return
|
|
210
|
+
return new types_appManager.AppManager(algod).getBoxValues(BigInt(appId), boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)));
|
|
398
211
|
}
|
|
399
212
|
/**
|
|
213
|
+
* @deprecated Use `algorand.app.getBoxValueFromABIType` instead.
|
|
400
214
|
* Returns the value of the given box name for the given app decoded based on the given ABI type.
|
|
401
215
|
* @param request The parameters for the box value request
|
|
402
216
|
* @param algod An algod client instance
|
|
403
217
|
* @returns The current box value as an ABI value
|
|
404
218
|
*/
|
|
405
219
|
async function getAppBoxValueFromABIType(request, algod) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
220
|
+
return new types_appManager.AppManager(algod).getBoxValueFromABIType({
|
|
221
|
+
appId: BigInt(request.appId),
|
|
222
|
+
boxName: typeof request.boxName !== 'string' && 'name' in request.boxName ? request.boxName.nameRaw : request.boxName,
|
|
223
|
+
type: request.type,
|
|
224
|
+
});
|
|
409
225
|
}
|
|
410
226
|
/**
|
|
227
|
+
* @deprecated Use `algorand.app.getBoxValuesFromABIType` instead.
|
|
411
228
|
* Returns the value of the given box names for the given app decoded based on the given ABI type.
|
|
412
229
|
* @param request The parameters for the box value request
|
|
413
230
|
* @param algod An algod client instance
|
|
414
231
|
* @returns The current box values as an ABI value in the same order as the passed in box names
|
|
415
232
|
*/
|
|
416
233
|
async function getAppBoxValuesFromABIType(request, algod) {
|
|
417
|
-
|
|
418
|
-
|
|
234
|
+
return new types_appManager.AppManager(algod).getBoxValuesFromABIType({
|
|
235
|
+
appId: BigInt(request.appId),
|
|
236
|
+
boxNames: request.boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)),
|
|
237
|
+
type: request.type,
|
|
238
|
+
});
|
|
419
239
|
}
|
|
420
240
|
/**
|
|
241
|
+
* @deprecated Use `AppManager.decodeAppState` instead.
|
|
242
|
+
*
|
|
421
243
|
* Converts an array of global/local state values from the algod api to a more friendly
|
|
422
244
|
* generic object keyed by the UTF-8 value of the key.
|
|
423
245
|
* @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`
|
|
424
246
|
* @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values
|
|
425
247
|
*/
|
|
426
248
|
function decodeAppState(state) {
|
|
427
|
-
|
|
428
|
-
// Start with empty set
|
|
429
|
-
for (const stateVal of state) {
|
|
430
|
-
const keyBase64 = stateVal.key;
|
|
431
|
-
const keyRaw = buffer.Buffer.from(keyBase64, 'base64');
|
|
432
|
-
const key = keyRaw.toString('utf-8');
|
|
433
|
-
const tealValue = stateVal.value;
|
|
434
|
-
const dataTypeFlag = 'action' in tealValue ? tealValue.action : tealValue.type;
|
|
435
|
-
let valueBase64;
|
|
436
|
-
let valueRaw;
|
|
437
|
-
switch (dataTypeFlag) {
|
|
438
|
-
case 1:
|
|
439
|
-
valueBase64 = tealValue.bytes ?? '';
|
|
440
|
-
valueRaw = buffer.Buffer.from(valueBase64, 'base64');
|
|
441
|
-
stateValues[key] = {
|
|
442
|
-
keyRaw,
|
|
443
|
-
keyBase64,
|
|
444
|
-
valueRaw: new Uint8Array(valueRaw),
|
|
445
|
-
valueBase64: valueBase64,
|
|
446
|
-
value: valueRaw.toString('utf-8'),
|
|
447
|
-
};
|
|
448
|
-
break;
|
|
449
|
-
case 2: {
|
|
450
|
-
const value = tealValue.uint ?? 0;
|
|
451
|
-
stateValues[key] = {
|
|
452
|
-
keyRaw,
|
|
453
|
-
keyBase64,
|
|
454
|
-
value,
|
|
455
|
-
};
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
default:
|
|
459
|
-
throw new Error(`Received unknown state data type of ${dataTypeFlag}`);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return stateValues;
|
|
249
|
+
return types_appManager.AppManager.decodeAppState(state.map(({ key, value }) => ({ key: Buffer.from(key, 'utf-8'), value })));
|
|
463
250
|
}
|
|
464
251
|
/**
|
|
252
|
+
* @deprecated Use `TransactionComposer` methods to construct transactions instead.
|
|
253
|
+
*
|
|
465
254
|
* Returns the app args ready to load onto an app `Transaction` object
|
|
466
255
|
* @param args The app call args
|
|
467
256
|
* @returns The args ready to load into a `Transaction`
|
|
@@ -480,68 +269,32 @@ function getAppArgsForTransaction(args) {
|
|
|
480
269
|
};
|
|
481
270
|
}
|
|
482
271
|
/**
|
|
272
|
+
* @deprecated Use `TransactionComposer` methods to construct transactions instead.
|
|
273
|
+
*
|
|
483
274
|
* Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer`
|
|
484
275
|
* @param args The ABI app call args
|
|
485
276
|
* @param from The transaction signer
|
|
486
277
|
* @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer
|
|
487
278
|
*/
|
|
488
279
|
async function getAppArgsForABICall(args, from) {
|
|
489
|
-
|
|
490
|
-
const methodArgs = await Promise.all(('methodArgs' in args ? args.methodArgs : args)?.map(async (a, index) => {
|
|
491
|
-
if (a === undefined) {
|
|
492
|
-
throw new Error(`Argument at position ${index} does not have a value`);
|
|
493
|
-
}
|
|
494
|
-
if (typeof a !== 'object') {
|
|
495
|
-
return a;
|
|
496
|
-
}
|
|
497
|
-
// Handle the various forms of transactions to wrangle them for ATC
|
|
498
|
-
return 'txn' in a
|
|
499
|
-
? a
|
|
500
|
-
: a instanceof Promise
|
|
501
|
-
? { txn: (await a).transaction, signer }
|
|
502
|
-
: 'transaction' in a
|
|
503
|
-
? { txn: a.transaction, signer: 'signer' in a ? transaction.getSenderTransactionSigner(a.signer) : signer }
|
|
504
|
-
: 'txID' in a
|
|
505
|
-
? { txn: a, signer }
|
|
506
|
-
: a;
|
|
507
|
-
}));
|
|
508
|
-
return {
|
|
509
|
-
method: 'txnCount' in args.method ? args.method : new ABIMethod(args.method),
|
|
510
|
-
sender: transaction.getSenderAddress(from),
|
|
511
|
-
signer: signer,
|
|
512
|
-
boxes: args.boxes?.map(getBoxReference),
|
|
513
|
-
lease: transaction.encodeLease(args.lease),
|
|
514
|
-
appForeignApps: args.apps,
|
|
515
|
-
appForeignAssets: args.assets,
|
|
516
|
-
appAccounts: args.accounts?.map(_getAccountAddress),
|
|
517
|
-
methodArgs: methodArgs,
|
|
518
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
519
|
-
};
|
|
280
|
+
return legacyBridge._getAppArgsForABICall(args, from);
|
|
520
281
|
}
|
|
521
282
|
/**
|
|
283
|
+
* @deprecated Use `AppManager.getBoxReference()` instead.
|
|
284
|
+
*
|
|
522
285
|
* Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.
|
|
523
286
|
* @param box The box to return a reference for
|
|
524
287
|
* @returns The box reference ready to pass into a `Transaction`
|
|
525
288
|
*/
|
|
526
289
|
function getBoxReference(box) {
|
|
527
|
-
|
|
528
|
-
if (typeof box === 'object' && 'appIndex' in box) {
|
|
529
|
-
return box;
|
|
530
|
-
}
|
|
531
|
-
const ref = typeof box === 'object' && 'appId' in box ? box : { appId: 0, name: box };
|
|
532
|
-
return {
|
|
533
|
-
appIndex: ref.appId,
|
|
534
|
-
name: typeof ref.name === 'string'
|
|
535
|
-
? encoder.encode(ref.name)
|
|
536
|
-
: 'length' in ref.name
|
|
537
|
-
? ref.name
|
|
538
|
-
: algosdk.decodeAddress(transaction.getSenderAddress(ref.name)).publicKey,
|
|
539
|
-
};
|
|
290
|
+
return legacyBridge._getBoxReference(box);
|
|
540
291
|
}
|
|
541
292
|
function _getAccountAddress(account) {
|
|
542
293
|
return typeof account === 'string' ? account : algosdk.encodeAddress(account.publicKey);
|
|
543
294
|
}
|
|
544
295
|
/**
|
|
296
|
+
* @deprecated Use `algorand.app.getById` instead.
|
|
297
|
+
*
|
|
545
298
|
* Gets the current data for the given app from algod.
|
|
546
299
|
*
|
|
547
300
|
* @param appId The id of the app
|
|
@@ -549,9 +302,11 @@ function _getAccountAddress(account) {
|
|
|
549
302
|
* @returns The data about the app
|
|
550
303
|
*/
|
|
551
304
|
async function getAppById(appId, algod) {
|
|
552
|
-
return
|
|
305
|
+
return await algod.getApplicationByID(util.toNumber(appId)).do();
|
|
553
306
|
}
|
|
554
307
|
/**
|
|
308
|
+
* @deprecated Use `algorand.app.compileTeal` instead.
|
|
309
|
+
*
|
|
555
310
|
* Compiles the given TEAL using algod and returns the result, including source map.
|
|
556
311
|
*
|
|
557
312
|
* @param algod An algod client
|
|
@@ -559,16 +314,11 @@ async function getAppById(appId, algod) {
|
|
|
559
314
|
* @returns The information about the compiled file
|
|
560
315
|
*/
|
|
561
316
|
async function compileTeal(tealCode, algod) {
|
|
562
|
-
|
|
563
|
-
return {
|
|
564
|
-
teal: tealCode,
|
|
565
|
-
compiled: compiled.result,
|
|
566
|
-
compiledHash: compiled.hash,
|
|
567
|
-
compiledBase64ToBytes: new Uint8Array(buffer.Buffer.from(compiled.result, 'base64')),
|
|
568
|
-
sourceMap: new SourceMap(compiled['sourcemap']),
|
|
569
|
-
};
|
|
317
|
+
return await new types_appManager.AppManager(algod).compileTeal(tealCode);
|
|
570
318
|
}
|
|
571
319
|
/**
|
|
320
|
+
* @deprecated Use `abiMethod.getSignature()` or `new ABIMethod(abiMethodParams).getSignature()` instead.
|
|
321
|
+
*
|
|
572
322
|
* Returns the encoded ABI spec for a given ABI Method
|
|
573
323
|
* @param method The method to return a signature for
|
|
574
324
|
* @returns The encoded ABI method spec e.g. `method_name(uint64,string)string`
|