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