@algorandfoundation/algokit-utils 6.3.0-beta.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +22 -26
- package/account/account.d.ts +12 -10
- package/account/account.js +17 -14
- package/account/account.js.map +1 -1
- package/account/account.mjs +18 -15
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +0 -1
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +2 -3
- package/account/get-account.js +1 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +2 -3
- package/account/get-dispenser-account.js +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/index.d.ts +0 -1
- package/account/mnemonic-account.d.ts +1 -2
- package/account/mnemonic-account.js +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +15 -5
- package/amount.js +9 -2
- package/amount.js.map +1 -1
- package/amount.mjs +9 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +19 -5
- package/app-client.js +19 -4
- package/app-client.js.map +1 -1
- package/app-client.mjs +19 -4
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +18 -2
- package/app-deploy.js +159 -342
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +163 -346
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +39 -3
- package/app.js +121 -371
- package/app.js.map +1 -1
- package/app.mjs +122 -372
- package/app.mjs.map +1 -1
- package/asset.d.ts +5 -6
- package/asset.js +5 -8
- package/asset.js.map +1 -1
- package/asset.mjs +5 -8
- package/asset.mjs.map +1 -1
- package/config.d.ts +0 -1
- package/config.js.map +1 -1
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +3 -5
- package/debugging/debugging.js +4 -128
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +4 -109
- package/debugging/debugging.mjs.map +1 -1
- package/debugging/index.d.ts +0 -2
- package/dispenser-client.d.ts +0 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +5 -4
- package/index.js +36 -26
- package/index.js.map +1 -1
- package/index.mjs +6 -5
- package/index.mjs.map +1 -1
- package/indexer-lookup.d.ts +10 -9
- package/indexer-lookup.js +14 -10
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +14 -10
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-kmd-wallet-account.js +1 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +1 -2
- package/localnet/get-localnet-dispenser-account.js +1 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-or-create-kmd-wallet-account.js +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/index.d.ts +0 -1
- package/localnet/is-localnet.d.ts +1 -2
- package/localnet/is-localnet.js +1 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +3 -10
- package/network-client.js +4 -11
- package/network-client.js.map +1 -1
- package/network-client.mjs +4 -11
- package/network-client.mjs.map +1 -1
- package/package.json +3 -4
- package/testing/_asset.d.ts +2 -2
- package/testing/account.d.ts +4 -4
- package/testing/account.js +8 -2
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +9 -3
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +0 -1
- package/testing/fixtures/algorand-fixture.js +13 -14
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +13 -14
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/fixtures/index.d.ts +0 -1
- package/testing/index.d.ts +0 -1
- package/testing/indexer.d.ts +0 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +0 -1
- package/testing/test-logger.js +7 -3
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +7 -3
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +0 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/index.d.ts +0 -1
- package/transaction/legacy-bridge.d.ts +31 -6
- package/transaction/legacy-bridge.js +101 -7
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +101 -10
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -2
- package/transaction/perform-atomic-transaction-composer-simulate.js +14 -9
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -10
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +38 -19
- package/transaction/transaction.js +217 -137
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +218 -138
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/index.d.ts +0 -1
- package/transfer/transfer-algos.d.ts +1 -2
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -2
- package/transfer/transfer.js +6 -4
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +6 -4
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +33 -25
- package/types/account-manager.js +54 -31
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +56 -33
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +17 -9
- package/types/account.js +2 -2
- package/types/account.js.map +1 -1
- package/types/account.mjs +3 -3
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +1 -3
- package/types/algo-http-client-with-retry.js +33 -3
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +32 -2
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +28 -0
- package/types/algorand-client-interface.js +3 -0
- package/types/algorand-client-interface.js.map +1 -0
- package/types/algorand-client-interface.mjs +2 -0
- package/types/algorand-client-interface.mjs.map +1 -0
- package/types/algorand-client-transaction-creator.d.ts +452 -23
- package/types/algorand-client-transaction-creator.js +407 -23
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +407 -23
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +772 -47
- package/types/algorand-client-transaction-sender.js +445 -15
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +445 -15
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +24 -17
- package/types/algorand-client.js +26 -16
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +28 -15
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +10 -11
- package/types/amount.js +7 -7
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +7 -7
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +359 -0
- package/types/app-arc56.js +184 -0
- package/types/app-arc56.js.map +1 -0
- package/types/app-arc56.mjs +175 -0
- package/types/app-arc56.mjs.map +1 -0
- package/types/app-client.d.ts +1508 -12
- package/types/app-client.js +1018 -29
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1020 -32
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +126 -0
- package/types/app-deployer.js +353 -0
- package/types/app-deployer.js.map +1 -0
- package/types/app-deployer.mjs +351 -0
- package/types/app-deployer.mjs.map +1 -0
- package/types/app-factory.d.ts +846 -0
- package/types/app-factory.js +410 -0
- package/types/app-factory.js.map +1 -0
- package/types/app-factory.mjs +408 -0
- package/types/app-factory.mjs.map +1 -0
- package/types/app-manager.d.ts +244 -0
- package/types/app-manager.js +423 -0
- package/types/app-manager.js.map +1 -0
- package/types/app-manager.mjs +421 -0
- package/types/app-manager.mjs.map +1 -0
- package/types/app-spec.d.ts +2 -1
- package/types/app-spec.js +127 -0
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +126 -0
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +57 -18
- package/types/app.js +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +10 -10
- package/types/asset-manager.js +13 -17
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +13 -17
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +0 -1
- package/types/async-event-emitter.d.ts +14 -0
- package/types/async-event-emitter.js +50 -0
- package/types/async-event-emitter.js.map +1 -0
- package/types/async-event-emitter.mjs +48 -0
- package/types/async-event-emitter.mjs.map +1 -0
- package/types/client-manager.d.ts +135 -60
- package/types/client-manager.js +158 -44
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +159 -45
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +271 -87
- package/types/composer.js +405 -125
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +407 -125
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +3 -6
- package/types/config.js +5 -44
- package/types/config.js.map +1 -1
- package/types/config.mjs +5 -27
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +29 -101
- package/types/debugging.js +16 -109
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -107
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +2 -2
- package/types/dispenser-client.js +10 -5
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +10 -5
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +7 -0
- package/types/expand.js +3 -0
- package/types/expand.js.map +1 -0
- package/types/expand.mjs +2 -0
- package/types/expand.mjs.map +1 -0
- package/types/indexer.d.ts +74 -756
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +2 -3
- package/types/kmd-account-manager.js +3 -3
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +4 -4
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.d.ts +0 -1
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -4
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +14 -2
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +8 -10
- package/types/transaction.d.ts +17 -4
- package/types/transfer.d.ts +0 -1
- package/util.d.ts +2 -2
- package/util.js +11 -10
- package/util.js.map +1 -1
- package/util.mjs +11 -10
- package/util.mjs.map +1 -1
- package/account/account.d.ts.map +0 -1
- package/account/get-account-config-from-environment.d.ts.map +0 -1
- package/account/get-account.d.ts.map +0 -1
- package/account/get-dispenser-account.d.ts.map +0 -1
- package/account/index.d.ts.map +0 -1
- package/account/mnemonic-account.d.ts.map +0 -1
- package/amount.d.ts.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app.d.ts.map +0 -1
- package/asset.d.ts.map +0 -1
- package/config.d.ts.map +0 -1
- package/debugging/debugging.d.ts.map +0 -1
- package/debugging/index.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.d.ts +0 -20
- package/debugging/simulate-and-persist-response.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.js +0 -108
- package/debugging/simulate-and-persist-response.js.map +0 -1
- package/debugging/simulate-and-persist-response.mjs +0 -89
- package/debugging/simulate-and-persist-response.mjs.map +0 -1
- package/dispenser-client.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/index.d.ts.map +0 -1
- package/localnet/is-localnet.d.ts.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/testing/_asset.d.ts.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/transaction/index.d.ts.map +0 -1
- package/transaction/legacy-bridge.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
- package/transaction/transaction.d.ts.map +0 -1
- package/transfer/index.d.ts.map +0 -1
- package/transfer/transfer-algos.d.ts.map +0 -1
- package/transfer/transfer.d.ts.map +0 -1
- package/types/account-manager.d.ts.map +0 -1
- package/types/account.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algorand-client-transaction-creator.d.ts.map +0 -1
- package/types/algorand-client-transaction-sender.d.ts.map +0 -1
- package/types/algorand-client.d.ts.map +0 -1
- package/types/amount.d.ts.map +0 -1
- package/types/app-client.d.ts.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.d.ts.map +0 -1
- package/types/asset-manager.d.ts.map +0 -1
- package/types/asset.d.ts.map +0 -1
- package/types/client-manager.d.ts.map +0 -1
- package/types/composer.d.ts.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/debugging.d.ts.map +0 -1
- package/types/dispenser-client.d.ts.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/kmd-account-manager.d.ts.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/network-client.d.ts.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/transaction.d.ts.map +0 -1
- package/types/transfer.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -41
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.js +0 -153
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/types/urlTokenBaseHTTPClient.mjs +0 -151
- package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
- package/util.d.ts.map +0 -1
package/app-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,135 @@ 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,
|
|
32
|
+
const appManager = new types_appManager.AppManager(algod);
|
|
33
|
+
const newGroup = () => new types_composer.TransactionComposer({
|
|
34
|
+
algod,
|
|
35
|
+
getSigner: () => transaction.getSenderTransactionSigner(deployment.from),
|
|
36
|
+
getSuggestedParams: async () => deployment.transactionParams ? { ...deployment.transactionParams } : await algod.getTransactionParams().do(),
|
|
37
|
+
appManager,
|
|
93
38
|
});
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
callType: 'delete_application',
|
|
113
|
-
from: appParams.from,
|
|
114
|
-
args: deleteArgs,
|
|
115
|
-
transactionParams: appParams.transactionParams,
|
|
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: algosdk.Address.fromString(deployment.existingDeployments.creator),
|
|
133
|
+
apps: Object.fromEntries(Object.entries(deployment.existingDeployments.apps).map(([name, app]) => [
|
|
134
|
+
name,
|
|
135
|
+
{
|
|
136
|
+
...app,
|
|
137
|
+
appAddress: algosdk.Address.fromString(app.appAddress),
|
|
138
|
+
appId: BigInt(app.appId),
|
|
139
|
+
createdRound: BigInt(app.createdRound),
|
|
140
|
+
updatedRound: BigInt(app.updatedRound),
|
|
141
|
+
},
|
|
142
|
+
])),
|
|
246
143
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
144
|
+
: undefined,
|
|
145
|
+
maxRoundsToWaitForConfirmation: deployment.maxRoundsToWaitForConfirmation,
|
|
146
|
+
populateAppCallResources: deployment.populateAppCallResources,
|
|
147
|
+
suppressLog: deployment.suppressLog,
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
...result,
|
|
151
|
+
appAddress: result.appAddress.toString(),
|
|
152
|
+
appId: Number(result.appId),
|
|
153
|
+
createdRound: Number(result.createdRound),
|
|
154
|
+
updatedRound: Number(result.updatedRound),
|
|
155
|
+
};
|
|
252
156
|
}
|
|
253
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated Use `before.numByteSlice < after.numByteSlice || before.numUint < after.numUint` instead.
|
|
159
|
+
*
|
|
160
|
+
* Returns true is there is a breaking change in the application state schema from before to after.
|
|
254
161
|
* i.e. if the schema becomes larger, since applications can't ask for more schema after creation.
|
|
255
162
|
* Otherwise, there is no error, the app just doesn't store data in the extra schema :(
|
|
256
163
|
*
|
|
@@ -262,6 +169,8 @@ function isSchemaIsBroken(before, after) {
|
|
|
262
169
|
return before.numByteSlice < after.numByteSlice || before.numUint < after.numUint;
|
|
263
170
|
}
|
|
264
171
|
/**
|
|
172
|
+
* @deprecated Use `algorand.appDeployer.getCreatorAppsByName` instead.
|
|
173
|
+
*
|
|
265
174
|
* 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
175
|
*
|
|
267
176
|
* **Note:** It's recommended this is only called once and then stored since it's a somewhat expensive operation (multiple indexer calls).
|
|
@@ -271,87 +180,24 @@ function isSchemaIsBroken(before, after) {
|
|
|
271
180
|
* @returns A name-based lookup of the app information (id, address)
|
|
272
181
|
*/
|
|
273
182
|
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
|
-
});
|
|
183
|
+
const lookup = await new types_appDeployer.AppDeployer(undefined, undefined, indexer).getCreatorAppsByName(transaction.getSenderAddress(creatorAccount));
|
|
349
184
|
return {
|
|
350
|
-
creator:
|
|
351
|
-
apps:
|
|
185
|
+
creator: lookup.creator.toString(),
|
|
186
|
+
apps: Object.fromEntries(Object.entries(lookup.apps).map(([name, app]) => [
|
|
187
|
+
name,
|
|
188
|
+
{
|
|
189
|
+
...app,
|
|
190
|
+
appAddress: app.appAddress.toString(),
|
|
191
|
+
appId: Number(app.appId),
|
|
192
|
+
createdRound: Number(app.createdRound),
|
|
193
|
+
updatedRound: Number(app.updatedRound),
|
|
194
|
+
},
|
|
195
|
+
])),
|
|
352
196
|
};
|
|
353
197
|
}
|
|
354
198
|
/**
|
|
199
|
+
* @deprecated Use `{ dAppName: APP_DEPLOY_NOTE_DAPP, data: metadata, format: 'j' }` instead.
|
|
200
|
+
*
|
|
355
201
|
* Return the transaction note for an app deployment.
|
|
356
202
|
* @param metadata The metadata of the deployment
|
|
357
203
|
* @returns The transaction note as a utf-8 string
|
|
@@ -364,6 +210,8 @@ function getAppDeploymentTransactionNote(metadata) {
|
|
|
364
210
|
};
|
|
365
211
|
}
|
|
366
212
|
/**
|
|
213
|
+
* @deprecated Use `AppManager.replaceTealTemplateDeployTimeControlParams` instead
|
|
214
|
+
*
|
|
367
215
|
* Replaces deploy-time deployment control parameters within the given teal code.
|
|
368
216
|
*
|
|
369
217
|
* * `TMPL_UPDATABLE` for updatability / immutability control
|
|
@@ -377,21 +225,11 @@ function getAppDeploymentTransactionNote(metadata) {
|
|
|
377
225
|
* @returns The replaced TEAL code
|
|
378
226
|
*/
|
|
379
227
|
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;
|
|
228
|
+
return types_appManager.AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, params);
|
|
393
229
|
}
|
|
394
230
|
/**
|
|
231
|
+
* @deprecated Use `AppManager.replaceTealTemplateParams` instead
|
|
232
|
+
*
|
|
395
233
|
* Performs template substitution of a teal file.
|
|
396
234
|
*
|
|
397
235
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
@@ -401,26 +239,11 @@ function replaceDeployTimeControlParams(tealCode, params) {
|
|
|
401
239
|
* @returns The TEAL code with replacements
|
|
402
240
|
*/
|
|
403
241
|
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;
|
|
242
|
+
return types_appManager.AppManager.replaceTealTemplateParams(tealCode, templateParams);
|
|
422
243
|
}
|
|
423
244
|
/**
|
|
245
|
+
* @deprecated Use `algorand.appManager.compileTealTemplate` instead.
|
|
246
|
+
*
|
|
424
247
|
* Performs template substitution of a teal file and compiles it, returning the compiled result.
|
|
425
248
|
*
|
|
426
249
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
@@ -440,21 +263,15 @@ async function performTemplateSubstitutionAndCompile(tealCode, algod, templatePa
|
|
|
440
263
|
return await app.compileTeal(tealCode, algod);
|
|
441
264
|
}
|
|
442
265
|
/**
|
|
266
|
+
* @deprecated Use `AppManager.stripTealComments` instead.
|
|
267
|
+
*
|
|
443
268
|
* Remove comments from TEAL Code
|
|
444
269
|
*
|
|
445
270
|
* @param tealCode The TEAL logic to compile
|
|
446
271
|
* @returns The TEAL without comments
|
|
447
272
|
*/
|
|
448
273
|
function stripTealComments(tealCode) {
|
|
449
|
-
|
|
450
|
-
const regex = /\/\/(?=([^"\\]*(\\.|"([^"\\]*\\.)*[^"\\]*"))*[^"]*$)/;
|
|
451
|
-
tealCode = tealCode
|
|
452
|
-
.split('\n')
|
|
453
|
-
.map((tealCodeLine) => {
|
|
454
|
-
return tealCodeLine.split(regex)[0].trim();
|
|
455
|
-
})
|
|
456
|
-
.join('\n');
|
|
457
|
-
return tealCode;
|
|
274
|
+
return types_appManager.AppManager.stripTealComments(tealCode);
|
|
458
275
|
}
|
|
459
276
|
|
|
460
277
|
exports.deployApp = deployApp;
|