@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-deploy.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { getAppOnCompleteAction, compileTeal } from './app.mjs';
|
|
3
|
+
import { _getBoxReference, _getAppArgsForABICall } from './transaction/legacy-bridge.mjs';
|
|
4
|
+
import { getSenderAddress, getSenderTransactionSigner } from './transaction/transaction.mjs';
|
|
5
|
+
import { AlgorandClientTransactionSender } from './types/algorand-client-transaction-sender.mjs';
|
|
6
|
+
import { APP_DEPLOY_NOTE_DAPP } from './types/app.mjs';
|
|
7
|
+
import { AppDeployer } from './types/app-deployer.mjs';
|
|
8
|
+
import { AppManager } from './types/app-manager.mjs';
|
|
9
|
+
import { AssetManager } from './types/asset-manager.mjs';
|
|
10
|
+
import AlgoKitComposer from './types/composer.mjs';
|
|
7
11
|
|
|
8
|
-
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
9
|
-
var getApplicationAddress = algosdk.getApplicationAddress;
|
|
10
|
-
var modelsv2 = algosdk.modelsv2;
|
|
11
|
-
var TransactionType = algosdk.TransactionType;
|
|
12
12
|
/**
|
|
13
|
+
* @deprecated Use `algorand.appDeployer.deploy` instead.
|
|
14
|
+
*
|
|
13
15
|
* Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
|
|
14
16
|
*
|
|
15
17
|
* To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
|
|
@@ -25,230 +27,123 @@ var TransactionType = algosdk.TransactionType;
|
|
|
25
27
|
* @returns The app reference of the new/existing app
|
|
26
28
|
*/
|
|
27
29
|
async function deployApp(deployment, algod, indexer) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
Config.getLogger(appParams.suppressLog).info(`Idempotently deploying app "${metadata.name}" from creator ${getSenderAddress(appParams.from)} using ${appParams.approvalProgram.length} bytes of teal code and ${appParams.clearStateProgram.length} bytes of teal code`);
|
|
36
|
-
const compiledApproval = typeof appParams.approvalProgram === 'string'
|
|
37
|
-
? await performTemplateSubstitutionAndCompile(appParams.approvalProgram, algod, deployTimeParameters, metadata)
|
|
38
|
-
: undefined;
|
|
39
|
-
appParams.approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : appParams.approvalProgram;
|
|
40
|
-
const compiledClear = typeof appParams.clearStateProgram === 'string'
|
|
41
|
-
? await performTemplateSubstitutionAndCompile(appParams.clearStateProgram, algod, deployTimeParameters)
|
|
42
|
-
: undefined;
|
|
43
|
-
appParams.clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : appParams.clearStateProgram;
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
-
const apps = existingDeployments ?? (await getCreatorAppsByName(appParams.from, indexer));
|
|
46
|
-
const create = async (atc) => {
|
|
47
|
-
const result = await createApp({
|
|
48
|
-
...appParams,
|
|
49
|
-
onCompleteAction: createOnCompleteAction,
|
|
50
|
-
args: createArgs,
|
|
51
|
-
note: getAppDeploymentTransactionNote(metadata),
|
|
52
|
-
atc,
|
|
53
|
-
skipWaiting: false,
|
|
54
|
-
}, algod);
|
|
55
|
-
return {
|
|
56
|
-
transaction: result.transaction,
|
|
57
|
-
transactions: result.transactions,
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
-
confirmation: result.confirmation,
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
-
confirmations: result.confirmations,
|
|
62
|
-
return: result.return,
|
|
63
|
-
appId: result.appId,
|
|
64
|
-
appAddress: result.appAddress,
|
|
65
|
-
createdMetadata: metadata,
|
|
66
|
-
createdRound: Number(result.confirmation?.confirmedRound),
|
|
67
|
-
updatedRound: Number(result.confirmation?.confirmedRound),
|
|
68
|
-
...metadata,
|
|
69
|
-
deleted: false,
|
|
70
|
-
operationPerformed: 'create',
|
|
71
|
-
compiledApproval,
|
|
72
|
-
compiledClear,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
const existingApp = apps.apps[metadata.name];
|
|
76
|
-
if (!existingApp || existingApp.deleted) {
|
|
77
|
-
Config.getLogger(appParams.suppressLog).info(`App ${metadata.name} not found in apps created by ${getSenderAddress(appParams.from)}; deploying app with version ${metadata.version}.`);
|
|
78
|
-
return await create();
|
|
79
|
-
}
|
|
80
|
-
Config.getLogger(appParams.suppressLog).info(`Existing app ${metadata.name} found by creator ${getSenderAddress(appParams.from)}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
|
|
81
|
-
const existingAppRecord = await getAppById(existingApp.appId, algod);
|
|
82
|
-
const existingApproval = Buffer.from(existingAppRecord.params.approvalProgram).toString('base64');
|
|
83
|
-
const existingClear = Buffer.from(existingAppRecord.params.clearStateProgram).toString('base64');
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
85
|
-
const existingGlobalSchema = existingAppRecord.params.globalStateSchema;
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
87
|
-
const existingLocalSchema = existingAppRecord.params.localStateSchema;
|
|
88
|
-
const newGlobalSchema = new modelsv2.ApplicationStateSchema({
|
|
89
|
-
numByteSlice: appParams.schema.globalByteSlices,
|
|
90
|
-
numUint: appParams.schema.globalInts,
|
|
91
|
-
});
|
|
92
|
-
const newLocalSchema = new modelsv2.ApplicationStateSchema({
|
|
93
|
-
numByteSlice: appParams.schema.localByteSlices,
|
|
94
|
-
numUint: appParams.schema.localInts,
|
|
30
|
+
const appManager = new AppManager(algod);
|
|
31
|
+
const newGroup = () => new AlgoKitComposer({
|
|
32
|
+
algod,
|
|
33
|
+
getSigner: () => getSenderTransactionSigner(deployment.from),
|
|
34
|
+
getSuggestedParams: async () => deployment.transactionParams ? { ...deployment.transactionParams } : await algod.getTransactionParams().do(),
|
|
35
|
+
appManager,
|
|
95
36
|
});
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
suppressLog: appParams.suppressLog,
|
|
115
|
-
skipSending: true,
|
|
116
|
-
atc,
|
|
117
|
-
}, algod);
|
|
118
|
-
// Ensure create and delete happen atomically
|
|
119
|
-
const { transactions, confirmations, returns } = await sendAtomicTransactionComposer({
|
|
120
|
-
atc,
|
|
121
|
-
sendParams: {
|
|
122
|
-
maxRoundsToWaitForConfirmation: appParams.maxRoundsToWaitForConfirmation,
|
|
123
|
-
skipWaiting: false,
|
|
124
|
-
suppressLog: true,
|
|
125
|
-
},
|
|
126
|
-
}, algod);
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
128
|
-
const createConfirmation = confirmations[createTransactions.length - 1];
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
130
|
-
const deleteConfirmation = confirmations[confirmations.length - 1];
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
132
|
-
const newAppIndex = createConfirmation.applicationIndex;
|
|
133
|
-
Config.getLogger(appParams.suppressLog).warn(`Sent transactions ${createTransaction.txID()} to create app with id ${newAppIndex} and ${deleteTransaction.txID()} to delete app with id ${existingApp.appId} from ${getSenderAddress(appParams.from)} account.`);
|
|
134
|
-
return {
|
|
135
|
-
transaction: createTransaction,
|
|
136
|
-
transactions: transactions,
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
138
|
-
confirmation: createConfirmation,
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
140
|
-
confirmations: confirmations,
|
|
141
|
-
return: returns?.[0],
|
|
142
|
-
deleteReturn: returns?.[1],
|
|
143
|
-
appId: newAppIndex,
|
|
144
|
-
appAddress: getApplicationAddress(newAppIndex),
|
|
145
|
-
createdMetadata: metadata,
|
|
146
|
-
createdRound: Number(createConfirmation.confirmedRound),
|
|
147
|
-
updatedRound: Number(createConfirmation.confirmedRound),
|
|
148
|
-
...metadata,
|
|
149
|
-
deleted: false,
|
|
150
|
-
deleteResult: { transaction: deleteTransaction, confirmation: deleteConfirmation },
|
|
151
|
-
operationPerformed: 'replace',
|
|
152
|
-
compiledApproval,
|
|
153
|
-
compiledClear,
|
|
154
|
-
};
|
|
37
|
+
const deployer = new AppDeployer(appManager, new AlgorandClientTransactionSender(newGroup, new AssetManager(algod, newGroup), appManager), indexer);
|
|
38
|
+
const createParams = {
|
|
39
|
+
approvalProgram: deployment.approvalProgram,
|
|
40
|
+
clearStateProgram: deployment.clearStateProgram,
|
|
41
|
+
sender: getSenderAddress(deployment.from),
|
|
42
|
+
accountReferences: deployment.createArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk.encodeAddress(a.publicKey))),
|
|
43
|
+
appReferences: deployment.createArgs?.apps?.map((a) => BigInt(a)),
|
|
44
|
+
assetReferences: deployment.createArgs?.assets?.map((a) => BigInt(a)),
|
|
45
|
+
boxReferences: deployment.createArgs?.boxes
|
|
46
|
+
?.map(_getBoxReference)
|
|
47
|
+
?.map((r) => ({ appId: BigInt(r.appIndex), name: r.name })),
|
|
48
|
+
lease: deployment.createArgs?.lease,
|
|
49
|
+
rekeyTo: deployment.createArgs?.rekeyTo ? getSenderAddress(deployment.createArgs?.rekeyTo) : undefined,
|
|
50
|
+
staticFee: deployment.fee,
|
|
51
|
+
maxFee: deployment.maxFee,
|
|
52
|
+
extraProgramPages: deployment.schema.extraPages,
|
|
53
|
+
onComplete: getAppOnCompleteAction(deployment.createOnCompleteAction),
|
|
54
|
+
schema: deployment.schema,
|
|
155
55
|
};
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
transaction: result.transaction,
|
|
172
|
-
transactions: result.transactions,
|
|
173
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
174
|
-
confirmation: result.confirmation,
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
176
|
-
confirmations: result.confirmations,
|
|
177
|
-
return: result.return,
|
|
178
|
-
appId: existingApp.appId,
|
|
179
|
-
appAddress: existingApp.appAddress,
|
|
180
|
-
createdMetadata: existingApp.createdMetadata,
|
|
181
|
-
createdRound: existingApp.createdRound,
|
|
182
|
-
updatedRound: Number(result.confirmation?.confirmedRound),
|
|
183
|
-
...metadata,
|
|
184
|
-
deleted: false,
|
|
185
|
-
operationPerformed: 'update',
|
|
186
|
-
compiledApproval,
|
|
187
|
-
compiledClear,
|
|
188
|
-
};
|
|
56
|
+
const updateParams = {
|
|
57
|
+
approvalProgram: deployment.approvalProgram,
|
|
58
|
+
clearStateProgram: deployment.clearStateProgram,
|
|
59
|
+
sender: getSenderAddress(deployment.from),
|
|
60
|
+
accountReferences: deployment.updateArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk.encodeAddress(a.publicKey))),
|
|
61
|
+
appReferences: deployment.updateArgs?.apps?.map((a) => BigInt(a)),
|
|
62
|
+
assetReferences: deployment.updateArgs?.assets?.map((a) => BigInt(a)),
|
|
63
|
+
boxReferences: deployment.updateArgs?.boxes
|
|
64
|
+
?.map(_getBoxReference)
|
|
65
|
+
?.map((r) => ({ appId: BigInt(r.appIndex), name: r.name })),
|
|
66
|
+
lease: deployment.updateArgs?.lease,
|
|
67
|
+
rekeyTo: deployment.updateArgs?.rekeyTo ? getSenderAddress(deployment.updateArgs?.rekeyTo) : undefined,
|
|
68
|
+
staticFee: deployment.fee,
|
|
69
|
+
maxFee: deployment.maxFee,
|
|
70
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
189
71
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
72
|
+
const deleteParams = {
|
|
73
|
+
sender: getSenderAddress(deployment.from),
|
|
74
|
+
accountReferences: deployment.deleteArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk.encodeAddress(a.publicKey))),
|
|
75
|
+
appReferences: deployment.deleteArgs?.apps?.map((a) => BigInt(a)),
|
|
76
|
+
assetReferences: deployment.deleteArgs?.assets?.map((a) => BigInt(a)),
|
|
77
|
+
boxReferences: deployment.deleteArgs?.boxes
|
|
78
|
+
?.map(_getBoxReference)
|
|
79
|
+
?.map((r) => ({ appId: BigInt(r.appIndex), name: r.name })),
|
|
80
|
+
lease: deployment.deleteArgs?.lease,
|
|
81
|
+
rekeyTo: deployment.deleteArgs?.rekeyTo ? getSenderAddress(deployment.deleteArgs?.rekeyTo) : undefined,
|
|
82
|
+
staticFee: deployment.fee,
|
|
83
|
+
maxFee: deployment.maxFee,
|
|
84
|
+
onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
|
|
85
|
+
};
|
|
86
|
+
const encoder = new TextEncoder();
|
|
87
|
+
const result = await deployer.deploy({
|
|
88
|
+
createParams: deployment.createArgs?.method
|
|
89
|
+
? ({
|
|
90
|
+
...createParams,
|
|
91
|
+
method: 'txnCount' in deployment.createArgs.method ? deployment.createArgs.method : new algosdk.ABIMethod(deployment.createArgs.method),
|
|
92
|
+
args: (await _getAppArgsForABICall(deployment.createArgs, deployment.from)).methodArgs,
|
|
93
|
+
})
|
|
94
|
+
: ({
|
|
95
|
+
...createParams,
|
|
96
|
+
args: 'appArgs' in (deployment?.createArgs ?? {})
|
|
97
|
+
? deployment.createArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a))
|
|
98
|
+
: undefined,
|
|
99
|
+
}),
|
|
100
|
+
updateParams: deployment.updateArgs?.method
|
|
101
|
+
? ({
|
|
102
|
+
...updateParams,
|
|
103
|
+
method: 'txnCount' in deployment.updateArgs.method ? deployment.updateArgs.method : new algosdk.ABIMethod(deployment.updateArgs.method),
|
|
104
|
+
args: (await _getAppArgsForABICall(deployment.updateArgs, deployment.from)).methodArgs,
|
|
105
|
+
})
|
|
106
|
+
: ({
|
|
107
|
+
...updateParams,
|
|
108
|
+
args: 'appArgs' in (deployment?.updateArgs ?? {})
|
|
109
|
+
? deployment.updateArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a))
|
|
110
|
+
: undefined,
|
|
111
|
+
}),
|
|
112
|
+
deleteParams: deployment.deleteArgs?.method
|
|
113
|
+
? ({
|
|
114
|
+
...deleteParams,
|
|
115
|
+
method: 'txnCount' in deployment.deleteArgs.method ? deployment.deleteArgs.method : new algosdk.ABIMethod(deployment.deleteArgs.method),
|
|
116
|
+
args: (await _getAppArgsForABICall(deployment.deleteArgs, deployment.from)).methodArgs,
|
|
117
|
+
})
|
|
118
|
+
: ({
|
|
119
|
+
...deleteParams,
|
|
120
|
+
args: 'appArgs' in (deployment?.deleteArgs ?? {})
|
|
121
|
+
? deployment.deleteArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a))
|
|
122
|
+
: undefined,
|
|
123
|
+
}),
|
|
124
|
+
metadata: deployment.metadata,
|
|
125
|
+
deployTimeParams: deployment.deployTimeParams,
|
|
126
|
+
onSchemaBreak: deployment.onSchemaBreak,
|
|
127
|
+
onUpdate: deployment.onUpdate,
|
|
128
|
+
existingDeployments: deployment.existingDeployments
|
|
129
|
+
? {
|
|
130
|
+
creator: deployment.existingDeployments.creator,
|
|
131
|
+
apps: Object.fromEntries(Object.entries(deployment.existingDeployments.apps).map(([name, app]) => [
|
|
132
|
+
name,
|
|
133
|
+
{ ...app, appId: BigInt(app.appId), createdRound: BigInt(app.createdRound), updatedRound: BigInt(app.updatedRound) },
|
|
134
|
+
])),
|
|
244
135
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
136
|
+
: undefined,
|
|
137
|
+
maxRoundsToWaitForConfirmation: deployment.maxRoundsToWaitForConfirmation,
|
|
138
|
+
populateAppCallResources: deployment.populateAppCallResources,
|
|
139
|
+
suppressLog: deployment.suppressLog,
|
|
140
|
+
});
|
|
141
|
+
return { ...result, appId: Number(result.appId), createdRound: Number(result.createdRound), updatedRound: Number(result.updatedRound) };
|
|
250
142
|
}
|
|
251
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use `before.numByteSlice < after.numByteSlice || before.numUint < after.numUint` instead.
|
|
145
|
+
*
|
|
146
|
+
* Returns true is there is a breaking change in the application state schema from before to after.
|
|
252
147
|
* i.e. if the schema becomes larger, since applications can't ask for more schema after creation.
|
|
253
148
|
* Otherwise, there is no error, the app just doesn't store data in the extra schema :(
|
|
254
149
|
*
|
|
@@ -260,6 +155,8 @@ function isSchemaIsBroken(before, after) {
|
|
|
260
155
|
return before.numByteSlice < after.numByteSlice || before.numUint < after.numUint;
|
|
261
156
|
}
|
|
262
157
|
/**
|
|
158
|
+
* @deprecated Use `algorand.appDeployer.getCreatorAppsByName` instead.
|
|
159
|
+
*
|
|
263
160
|
* Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have an `AppDeployNote` in the transaction note of the creation transaction.
|
|
264
161
|
*
|
|
265
162
|
* **Note:** It's recommended this is only called once and then stored since it's a somewhat expensive operation (multiple indexer calls).
|
|
@@ -269,87 +166,18 @@ function isSchemaIsBroken(before, after) {
|
|
|
269
166
|
* @returns A name-based lookup of the app information (id, address)
|
|
270
167
|
*/
|
|
271
168
|
async function getCreatorAppsByName(creatorAccount, indexer) {
|
|
272
|
-
const
|
|
273
|
-
const creatorAddress = typeof creatorAccount !== 'string' ? getSenderAddress(creatorAccount) : creatorAccount;
|
|
274
|
-
// Extract all apps that account created
|
|
275
|
-
const createdApps = (await lookupAccountCreatedApplicationByAddress(indexer, creatorAddress))
|
|
276
|
-
.map((a) => {
|
|
277
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
278
|
-
return { id: a.id, createdAtRound: a['created-at-round'], deleted: a.deleted };
|
|
279
|
-
})
|
|
280
|
-
.sort((a, b) => a.createdAtRound - b.createdAtRound);
|
|
281
|
-
// For each app that account created (in parallel)...
|
|
282
|
-
const apps = await Promise.all(createdApps.map(async (createdApp) => {
|
|
283
|
-
// Find any app transactions for that app in the round it was created (should always just be a single creation transaction)
|
|
284
|
-
const appTransactions = await searchTransactions(indexer, (s) => s
|
|
285
|
-
.minRound(createdApp.createdAtRound)
|
|
286
|
-
.txType(TransactionType.appl)
|
|
287
|
-
.applicationID(createdApp.id)
|
|
288
|
-
.address(creatorAddress)
|
|
289
|
-
.addressRole('sender')
|
|
290
|
-
.notePrefix(Buffer.from(APP_DEPLOY_NOTE_DAPP).toString('base64')));
|
|
291
|
-
// Triple check the transaction is intact by filtering for the one we want:
|
|
292
|
-
// * application-id is 0 when the app is first created
|
|
293
|
-
// * also verify the sender to prevent a potential security risk
|
|
294
|
-
const appCreationTransaction = appTransactions.transactions.filter(
|
|
295
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
296
|
-
(t) => t['application-transaction']['application-id'] === 0 && t.sender === creatorAddress)[0];
|
|
297
|
-
const latestAppUpdateTransaction = appTransactions.transactions
|
|
298
|
-
.filter((t) => t.sender === creatorAddress)
|
|
299
|
-
.sort((a, b) => a['confirmed-round'] === b['confirmed-round']
|
|
300
|
-
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
301
|
-
(b['intra-round-offset'] - a['intra-round-offset']) / 10
|
|
302
|
-
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
303
|
-
b['confirmed-round'] - a['confirmed-round'])[0];
|
|
304
|
-
if (!appCreationTransaction?.note)
|
|
305
|
-
// No note; ignoring
|
|
306
|
-
return null;
|
|
307
|
-
return { createdApp, appCreationTransaction, latestAppUpdateTransaction };
|
|
308
|
-
}));
|
|
309
|
-
apps
|
|
310
|
-
.filter((a) => a !== null)
|
|
311
|
-
.forEach((a) => {
|
|
312
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
313
|
-
const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a;
|
|
314
|
-
const parseNote = (note) => {
|
|
315
|
-
if (!note) {
|
|
316
|
-
// No note; ignoring...
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const decoder = new TextDecoder();
|
|
320
|
-
const noteAsBase64 = decoder.decode(Buffer.from(note));
|
|
321
|
-
const noteAsString = Buffer.from(noteAsBase64, 'base64').toString('utf-8');
|
|
322
|
-
if (!noteAsString.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))
|
|
323
|
-
// Clearly not APP_DEPLOY JSON; ignoring...
|
|
324
|
-
return;
|
|
325
|
-
return JSON.parse(noteAsString.substring(APP_DEPLOY_NOTE_DAPP.length + 2));
|
|
326
|
-
};
|
|
327
|
-
try {
|
|
328
|
-
const creationNote = parseNote(appCreationTransaction.note);
|
|
329
|
-
const updateNote = parseNote(latestAppUpdateTransaction.note);
|
|
330
|
-
if (creationNote?.name) {
|
|
331
|
-
appLookup[creationNote.name] = {
|
|
332
|
-
appId: createdApp.id,
|
|
333
|
-
appAddress: getApplicationAddress(createdApp.id),
|
|
334
|
-
createdMetadata: creationNote,
|
|
335
|
-
createdRound: Number(appCreationTransaction['confirmed-round']),
|
|
336
|
-
...(updateNote ?? creationNote),
|
|
337
|
-
updatedRound: Number(latestAppUpdateTransaction?.['confirmed-round']),
|
|
338
|
-
deleted: createdApp.deleted ?? false,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
catch (e) {
|
|
343
|
-
Config.logger.warn(`Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`, e);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
});
|
|
169
|
+
const lookup = await new AppDeployer(undefined, undefined, indexer).getCreatorAppsByName(getSenderAddress(creatorAccount));
|
|
347
170
|
return {
|
|
348
|
-
creator:
|
|
349
|
-
apps:
|
|
171
|
+
creator: lookup.creator,
|
|
172
|
+
apps: Object.fromEntries(Object.entries(lookup.apps).map(([name, app]) => [
|
|
173
|
+
name,
|
|
174
|
+
{ ...app, appId: Number(app.appId), createdRound: Number(app.createdRound), updatedRound: Number(app.updatedRound) },
|
|
175
|
+
])),
|
|
350
176
|
};
|
|
351
177
|
}
|
|
352
178
|
/**
|
|
179
|
+
* @deprecated Use `{ dAppName: APP_DEPLOY_NOTE_DAPP, data: metadata, format: 'j' }` instead.
|
|
180
|
+
*
|
|
353
181
|
* Return the transaction note for an app deployment.
|
|
354
182
|
* @param metadata The metadata of the deployment
|
|
355
183
|
* @returns The transaction note as a utf-8 string
|
|
@@ -362,6 +190,8 @@ function getAppDeploymentTransactionNote(metadata) {
|
|
|
362
190
|
};
|
|
363
191
|
}
|
|
364
192
|
/**
|
|
193
|
+
* @deprecated Use `AppManager.replaceTealTemplateDeployTimeControlParams` instead
|
|
194
|
+
*
|
|
365
195
|
* Replaces deploy-time deployment control parameters within the given teal code.
|
|
366
196
|
*
|
|
367
197
|
* * `TMPL_UPDATABLE` for updatability / immutability control
|
|
@@ -375,21 +205,11 @@ function getAppDeploymentTransactionNote(metadata) {
|
|
|
375
205
|
* @returns The replaced TEAL code
|
|
376
206
|
*/
|
|
377
207
|
function replaceDeployTimeControlParams(tealCode, params) {
|
|
378
|
-
|
|
379
|
-
if (!tealCode.includes(UPDATABLE_TEMPLATE_NAME)) {
|
|
380
|
-
throw new Error(`Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`);
|
|
381
|
-
}
|
|
382
|
-
tealCode = tealCode.replace(new RegExp(UPDATABLE_TEMPLATE_NAME, 'g'), (params.updatable ? 1 : 0).toString());
|
|
383
|
-
}
|
|
384
|
-
if (params.deletable !== undefined) {
|
|
385
|
-
if (!tealCode.includes(DELETABLE_TEMPLATE_NAME)) {
|
|
386
|
-
throw new Error(`Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`);
|
|
387
|
-
}
|
|
388
|
-
tealCode = tealCode.replace(new RegExp(DELETABLE_TEMPLATE_NAME, 'g'), (params.deletable ? 1 : 0).toString());
|
|
389
|
-
}
|
|
390
|
-
return tealCode;
|
|
208
|
+
return AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, params);
|
|
391
209
|
}
|
|
392
210
|
/**
|
|
211
|
+
* @deprecated Use `AppManager.replaceTealTemplateParams` instead
|
|
212
|
+
*
|
|
393
213
|
* Performs template substitution of a teal file.
|
|
394
214
|
*
|
|
395
215
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
@@ -399,26 +219,11 @@ function replaceDeployTimeControlParams(tealCode, params) {
|
|
|
399
219
|
* @returns The TEAL code with replacements
|
|
400
220
|
*/
|
|
401
221
|
function performTemplateSubstitution(tealCode, templateParams) {
|
|
402
|
-
|
|
403
|
-
for (const key in templateParams) {
|
|
404
|
-
const value = templateParams[key];
|
|
405
|
-
const token = `TMPL_${key.replace(/^TMPL_/, '')}`;
|
|
406
|
-
// If this is a number, first replace any byte representations of the number
|
|
407
|
-
// These may appear in the TEAL in order to circumvent int compression and preserve PC values
|
|
408
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
409
|
-
tealCode = tealCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`);
|
|
410
|
-
// We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both
|
|
411
|
-
}
|
|
412
|
-
tealCode = tealCode.replace(new RegExp(token, 'g'), typeof value === 'string'
|
|
413
|
-
? `0x${Buffer.from(value, 'utf-8').toString('hex')}`
|
|
414
|
-
: ArrayBuffer.isView(value)
|
|
415
|
-
? `0x${Buffer.from(value).toString('hex')}`
|
|
416
|
-
: value.toString());
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return tealCode;
|
|
222
|
+
return AppManager.replaceTealTemplateParams(tealCode, templateParams);
|
|
420
223
|
}
|
|
421
224
|
/**
|
|
225
|
+
* @deprecated Use `algorand.appManager.compileTealTemplate` instead.
|
|
226
|
+
*
|
|
422
227
|
* Performs template substitution of a teal file and compiles it, returning the compiled result.
|
|
423
228
|
*
|
|
424
229
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
@@ -438,6 +243,8 @@ async function performTemplateSubstitutionAndCompile(tealCode, algod, templatePa
|
|
|
438
243
|
return await compileTeal(tealCode, algod);
|
|
439
244
|
}
|
|
440
245
|
/**
|
|
246
|
+
* @deprecated Use `AppManager.stripTealComments` instead.
|
|
247
|
+
*
|
|
441
248
|
* Remove comments from TEAL Code
|
|
442
249
|
*
|
|
443
250
|
* @param tealCode The TEAL logic to compile
|