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