@algorandfoundation/algokit-utils 7.0.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.js
CHANGED
|
@@ -1,199 +1,79 @@
|
|
|
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
10
|
var modelsv2 = algosdk.modelsv2;
|
|
13
11
|
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
14
|
-
var SourceMap = algosdk.SourceMap;
|
|
15
12
|
/**
|
|
13
|
+
* @deprecated Use `algorand.send.appCreate()` / `algorand.createTransaction.appCreate()` / `algorand.send.appCreateMethodCall()`
|
|
14
|
+
* / `algorand.createTransaction.appCreateMethodCall()` instead
|
|
15
|
+
*
|
|
16
16
|
* Creates a smart contract app, returns the details of the created app.
|
|
17
17
|
* @param create The parameters to create the app with
|
|
18
18
|
* @param algod An algod client
|
|
19
19
|
* @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
|
|
20
20
|
*/
|
|
21
21
|
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
|
-
}
|
|
22
|
+
const onComplete = getAppOnCompleteAction(create.onCompleteAction);
|
|
23
|
+
if (onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
|
|
24
|
+
throw new Error('Cannot create an app with on-complete action of ClearState');
|
|
123
25
|
}
|
|
26
|
+
const result = create.args?.method
|
|
27
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
28
|
+
sender: transaction.getSenderAddress(create.from),
|
|
29
|
+
onComplete,
|
|
30
|
+
approvalProgram: create.approvalProgram,
|
|
31
|
+
clearStateProgram: create.clearStateProgram,
|
|
32
|
+
method: create.args.method instanceof ABIMethod ? create.args.method : new ABIMethod(create.args.method),
|
|
33
|
+
extraProgramPages: create.schema.extraPages,
|
|
34
|
+
schema: create.schema,
|
|
35
|
+
}, (c) => c.appCreateMethodCall, (c) => c.appCreateMethodCall)
|
|
36
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
37
|
+
sender: transaction.getSenderAddress(create.from),
|
|
38
|
+
onComplete,
|
|
39
|
+
approvalProgram: create.approvalProgram,
|
|
40
|
+
clearStateProgram: create.clearStateProgram,
|
|
41
|
+
extraProgramPages: create.schema.extraPages,
|
|
42
|
+
schema: create.schema,
|
|
43
|
+
}, (c) => c.appCreate, (c) => c.appCreate);
|
|
44
|
+
return { ...result, appId: 'appId' in result ? Number(result.appId) : 0, appAddress: 'appAddress' in result ? result.appAddress : '' };
|
|
124
45
|
}
|
|
125
46
|
/**
|
|
47
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
48
|
+
* / `algorand.createTransaction.appUpdateMethodCall()` instead
|
|
49
|
+
*
|
|
126
50
|
* Updates a smart contract app.
|
|
127
51
|
* @param update The parameters to update the app with
|
|
128
52
|
* @param algod An algod client
|
|
129
53
|
* @returns The transaction send result and the compilation result
|
|
130
54
|
*/
|
|
131
55
|
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
|
-
}
|
|
56
|
+
return update.args?.method
|
|
57
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
58
|
+
appId: BigInt(update.appId),
|
|
59
|
+
sender: transaction.getSenderAddress(update.from),
|
|
60
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
61
|
+
approvalProgram: update.approvalProgram,
|
|
62
|
+
clearStateProgram: update.clearStateProgram,
|
|
63
|
+
method: update.args.method instanceof ABIMethod ? update.args.method : new ABIMethod(update.args.method),
|
|
64
|
+
}, (c) => c.appUpdateMethodCall, (c) => c.appUpdateMethodCall)
|
|
65
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
66
|
+
appId: BigInt(update.appId),
|
|
67
|
+
sender: transaction.getSenderAddress(update.from),
|
|
68
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
69
|
+
approvalProgram: update.approvalProgram,
|
|
70
|
+
clearStateProgram: update.clearStateProgram,
|
|
71
|
+
}, (c) => c.appUpdate, (c) => c.appUpdate);
|
|
188
72
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
sendParams.atc = sendParams.atc ?? new AtomicTransactionComposer();
|
|
194
|
-
return sendParams.atc;
|
|
195
|
-
}
|
|
196
|
-
/** Returns an `algosdk.OnApplicationComplete` for the given onCompleteAction.
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use `algosdk.OnApplicationComplete` directly instead.
|
|
75
|
+
*
|
|
76
|
+
* Returns a `algosdk.OnApplicationComplete` for the given onCompleteAction.
|
|
197
77
|
*
|
|
198
78
|
* If given `undefined` will return `OnApplicationComplete.NoOpOC`.
|
|
199
79
|
*
|
|
@@ -226,77 +106,39 @@ function getAppOnCompleteAction(onCompletionAction) {
|
|
|
226
106
|
}
|
|
227
107
|
}
|
|
228
108
|
/**
|
|
109
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.createTransaction.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
110
|
+
* / `algorand.createTransaction.appUpdateMethodCall()` instead
|
|
111
|
+
*
|
|
229
112
|
* Issues a call to a given app.
|
|
230
113
|
* @param call The call details.
|
|
231
114
|
* @param algod An algod client
|
|
232
115
|
* @returns The result of the call
|
|
233
116
|
*/
|
|
234
117
|
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
|
-
};
|
|
118
|
+
const onComplete = getAppOnCompleteAction(call.callType);
|
|
119
|
+
if (onComplete === algosdk.OnApplicationComplete.UpdateApplicationOC) {
|
|
120
|
+
throw new Error('Cannot execute an app call with on-complete action of Update');
|
|
262
121
|
}
|
|
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}`);
|
|
122
|
+
if (call.args?.method && onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
|
|
123
|
+
throw new Error('Cannot execute an ABI method call with on-complete action of ClearState');
|
|
290
124
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
125
|
+
return call.args?.method
|
|
126
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
127
|
+
appId: BigInt(call.appId),
|
|
128
|
+
sender: transaction.getSenderAddress(call.from),
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
onComplete: onComplete,
|
|
131
|
+
method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method),
|
|
132
|
+
}, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall)
|
|
133
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
134
|
+
appId: BigInt(call.appId),
|
|
135
|
+
sender: transaction.getSenderAddress(call.from),
|
|
136
|
+
onComplete,
|
|
137
|
+
}, (c) => c.appCall, (c) => c.appCall);
|
|
298
138
|
}
|
|
299
139
|
/**
|
|
140
|
+
* @deprecated Use `AppManager.getABIReturn` instead.
|
|
141
|
+
*
|
|
300
142
|
* Returns any ABI return values for the given app call arguments and transaction confirmation.
|
|
301
143
|
* @param args The arguments that were used for the call
|
|
302
144
|
* @param confirmation The transaction confirmation from algod
|
|
@@ -307,43 +149,22 @@ function getABIReturn(args, confirmation) {
|
|
|
307
149
|
return undefined;
|
|
308
150
|
}
|
|
309
151
|
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;
|
|
152
|
+
return types_appManager.AppManager.getABIReturn(confirmation, method);
|
|
332
153
|
}
|
|
333
154
|
/**
|
|
155
|
+
* @deprecated Use `algorand.app.getGlobalState` instead.
|
|
156
|
+
*
|
|
334
157
|
* Returns the current global state values for the given app ID
|
|
335
158
|
* @param appId The ID of the app return global state for
|
|
336
159
|
* @param algod An algod client instance
|
|
337
160
|
* @returns The current global state
|
|
338
161
|
*/
|
|
339
162
|
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);
|
|
163
|
+
return await new types_appManager.AppManager(algod).getGlobalState(BigInt(appId));
|
|
345
164
|
}
|
|
346
165
|
/**
|
|
166
|
+
* @deprecated Use `algorand.app.getLocalState` instead.
|
|
167
|
+
*
|
|
347
168
|
* Returns the current global state values for the given app ID and account
|
|
348
169
|
* @param appId The ID of the app return global state for
|
|
349
170
|
* @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 +172,20 @@ async function getAppGlobalState(appId, algod) {
|
|
|
351
172
|
* @returns The current local state for the given (app, account) combination
|
|
352
173
|
*/
|
|
353
174
|
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);
|
|
175
|
+
return new types_appManager.AppManager(algod).getLocalState(BigInt(appId), transaction.getSenderAddress(account));
|
|
360
176
|
}
|
|
361
177
|
/**
|
|
178
|
+
* @deprecated Use `algorand.app.getBoxNames` instead.
|
|
362
179
|
* Returns the names of the boxes for the given app.
|
|
363
180
|
* @param appId The ID of the app return box names for
|
|
364
181
|
* @param algod An algod client instance
|
|
365
182
|
* @returns The current box names
|
|
366
183
|
*/
|
|
367
184
|
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
|
-
});
|
|
185
|
+
return new types_appManager.AppManager(algod).getBoxNames(BigInt(appId));
|
|
376
186
|
}
|
|
377
187
|
/**
|
|
188
|
+
* @deprecated Use `algorand.app.getBoxValue` instead.
|
|
378
189
|
* Returns the value of the given box name for the given app.
|
|
379
190
|
* @param appId The ID of the app return box names for
|
|
380
191
|
* @param boxName The name of the box to return either as a string, binary array or `BoxName`
|
|
@@ -382,11 +193,10 @@ async function getAppBoxNames(appId, algod) {
|
|
|
382
193
|
* @returns The current box value as a byte array
|
|
383
194
|
*/
|
|
384
195
|
async function getAppBoxValue(appId, boxName, algod) {
|
|
385
|
-
|
|
386
|
-
const boxResult = await algod.getApplicationBoxByName(util.toNumber(appId), name).do();
|
|
387
|
-
return boxResult.value;
|
|
196
|
+
return new types_appManager.AppManager(algod).getBoxValue(BigInt(appId), typeof boxName !== 'string' && 'name' in boxName ? boxName.nameRaw : boxName);
|
|
388
197
|
}
|
|
389
198
|
/**
|
|
199
|
+
* @deprecated Use `algorand.app.getBoxValues` instead.
|
|
390
200
|
* Returns the value of the given box names for the given app.
|
|
391
201
|
* @param appId The ID of the app return box names for
|
|
392
202
|
* @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
|
|
@@ -394,74 +204,50 @@ async function getAppBoxValue(appId, boxName, algod) {
|
|
|
394
204
|
* @returns The current box values as a byte array in the same order as the passed in box names
|
|
395
205
|
*/
|
|
396
206
|
async function getAppBoxValues(appId, boxNames, algod) {
|
|
397
|
-
return
|
|
207
|
+
return new types_appManager.AppManager(algod).getBoxValues(BigInt(appId), boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)));
|
|
398
208
|
}
|
|
399
209
|
/**
|
|
210
|
+
* @deprecated Use `algorand.app.getBoxValueFromABIType` instead.
|
|
400
211
|
* Returns the value of the given box name for the given app decoded based on the given ABI type.
|
|
401
212
|
* @param request The parameters for the box value request
|
|
402
213
|
* @param algod An algod client instance
|
|
403
214
|
* @returns The current box value as an ABI value
|
|
404
215
|
*/
|
|
405
216
|
async function getAppBoxValueFromABIType(request, algod) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
217
|
+
return new types_appManager.AppManager(algod).getBoxValueFromABIType({
|
|
218
|
+
appId: BigInt(request.appId),
|
|
219
|
+
boxName: typeof request.boxName !== 'string' && 'name' in request.boxName ? request.boxName.nameRaw : request.boxName,
|
|
220
|
+
type: request.type,
|
|
221
|
+
});
|
|
409
222
|
}
|
|
410
223
|
/**
|
|
224
|
+
* @deprecated Use `algorand.app.getBoxValuesFromABIType` instead.
|
|
411
225
|
* Returns the value of the given box names for the given app decoded based on the given ABI type.
|
|
412
226
|
* @param request The parameters for the box value request
|
|
413
227
|
* @param algod An algod client instance
|
|
414
228
|
* @returns The current box values as an ABI value in the same order as the passed in box names
|
|
415
229
|
*/
|
|
416
230
|
async function getAppBoxValuesFromABIType(request, algod) {
|
|
417
|
-
|
|
418
|
-
|
|
231
|
+
return new types_appManager.AppManager(algod).getBoxValuesFromABIType({
|
|
232
|
+
appId: BigInt(request.appId),
|
|
233
|
+
boxNames: request.boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)),
|
|
234
|
+
type: request.type,
|
|
235
|
+
});
|
|
419
236
|
}
|
|
420
237
|
/**
|
|
238
|
+
* @deprecated Use `AppManager.decodeAppState` instead.
|
|
239
|
+
*
|
|
421
240
|
* Converts an array of global/local state values from the algod api to a more friendly
|
|
422
241
|
* generic object keyed by the UTF-8 value of the key.
|
|
423
242
|
* @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`
|
|
424
243
|
* @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values
|
|
425
244
|
*/
|
|
426
245
|
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;
|
|
246
|
+
return types_appManager.AppManager.decodeAppState(state);
|
|
463
247
|
}
|
|
464
248
|
/**
|
|
249
|
+
* @deprecated Use `AlgoKitComposer` methods to construct transactions instead.
|
|
250
|
+
*
|
|
465
251
|
* Returns the app args ready to load onto an app `Transaction` object
|
|
466
252
|
* @param args The app call args
|
|
467
253
|
* @returns The args ready to load into a `Transaction`
|
|
@@ -480,68 +266,32 @@ function getAppArgsForTransaction(args) {
|
|
|
480
266
|
};
|
|
481
267
|
}
|
|
482
268
|
/**
|
|
269
|
+
* @deprecated Use `AlgoKitComposer` methods to construct transactions instead.
|
|
270
|
+
*
|
|
483
271
|
* Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer`
|
|
484
272
|
* @param args The ABI app call args
|
|
485
273
|
* @param from The transaction signer
|
|
486
274
|
* @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer
|
|
487
275
|
*/
|
|
488
276
|
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
|
-
};
|
|
277
|
+
return legacyBridge._getAppArgsForABICall(args, from);
|
|
520
278
|
}
|
|
521
279
|
/**
|
|
280
|
+
* @deprecated Use `AppManager.getBoxReference()` instead.
|
|
281
|
+
*
|
|
522
282
|
* Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.
|
|
523
283
|
* @param box The box to return a reference for
|
|
524
284
|
* @returns The box reference ready to pass into a `Transaction`
|
|
525
285
|
*/
|
|
526
286
|
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
|
-
};
|
|
287
|
+
return legacyBridge._getBoxReference(box);
|
|
540
288
|
}
|
|
541
289
|
function _getAccountAddress(account) {
|
|
542
290
|
return typeof account === 'string' ? account : algosdk.encodeAddress(account.publicKey);
|
|
543
291
|
}
|
|
544
292
|
/**
|
|
293
|
+
* @deprecated Use `algorand.app.getById` instead.
|
|
294
|
+
*
|
|
545
295
|
* Gets the current data for the given app from algod.
|
|
546
296
|
*
|
|
547
297
|
* @param appId The id of the app
|
|
@@ -552,6 +302,8 @@ async function getAppById(appId, algod) {
|
|
|
552
302
|
return modelsv2.Application.from_obj_for_encoding(await algod.getApplicationByID(util.toNumber(appId)).do());
|
|
553
303
|
}
|
|
554
304
|
/**
|
|
305
|
+
* @deprecated Use `algorand.app.compileTeal` instead.
|
|
306
|
+
*
|
|
555
307
|
* Compiles the given TEAL using algod and returns the result, including source map.
|
|
556
308
|
*
|
|
557
309
|
* @param algod An algod client
|
|
@@ -559,16 +311,11 @@ async function getAppById(appId, algod) {
|
|
|
559
311
|
* @returns The information about the compiled file
|
|
560
312
|
*/
|
|
561
313
|
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
|
-
};
|
|
314
|
+
return await new types_appManager.AppManager(algod).compileTeal(tealCode);
|
|
570
315
|
}
|
|
571
316
|
/**
|
|
317
|
+
* @deprecated Use `abiMethod.getSignature()` or `new ABIMethod(abiMethodParams).getSignature()` instead.
|
|
318
|
+
*
|
|
572
319
|
* Returns the encoded ABI spec for a given ABI Method
|
|
573
320
|
* @param method The method to return a signature for
|
|
574
321
|
* @returns The encoded ABI method spec e.g. `method_name(uint64,string)string`
|