@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.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import algosdk from 'algosdk';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import algosdk, { Address } from 'algosdk';
|
|
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 { TransactionComposer } 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,135 @@ 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,
|
|
30
|
+
const appManager = new AppManager(algod);
|
|
31
|
+
const newGroup = () => new TransactionComposer({
|
|
32
|
+
algod,
|
|
33
|
+
getSigner: () => getSenderTransactionSigner(deployment.from),
|
|
34
|
+
getSuggestedParams: async () => deployment.transactionParams ? { ...deployment.transactionParams } : await algod.getTransactionParams().do(),
|
|
35
|
+
appManager,
|
|
91
36
|
});
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
callType: 'delete_application',
|
|
111
|
-
from: appParams.from,
|
|
112
|
-
args: deleteArgs,
|
|
113
|
-
transactionParams: appParams.transactionParams,
|
|
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: Address.fromString(deployment.existingDeployments.creator),
|
|
131
|
+
apps: Object.fromEntries(Object.entries(deployment.existingDeployments.apps).map(([name, app]) => [
|
|
132
|
+
name,
|
|
133
|
+
{
|
|
134
|
+
...app,
|
|
135
|
+
appAddress: Address.fromString(app.appAddress),
|
|
136
|
+
appId: BigInt(app.appId),
|
|
137
|
+
createdRound: BigInt(app.createdRound),
|
|
138
|
+
updatedRound: BigInt(app.updatedRound),
|
|
139
|
+
},
|
|
140
|
+
])),
|
|
244
141
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
142
|
+
: undefined,
|
|
143
|
+
maxRoundsToWaitForConfirmation: deployment.maxRoundsToWaitForConfirmation,
|
|
144
|
+
populateAppCallResources: deployment.populateAppCallResources,
|
|
145
|
+
suppressLog: deployment.suppressLog,
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
...result,
|
|
149
|
+
appAddress: result.appAddress.toString(),
|
|
150
|
+
appId: Number(result.appId),
|
|
151
|
+
createdRound: Number(result.createdRound),
|
|
152
|
+
updatedRound: Number(result.updatedRound),
|
|
153
|
+
};
|
|
250
154
|
}
|
|
251
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use `before.numByteSlice < after.numByteSlice || before.numUint < after.numUint` instead.
|
|
157
|
+
*
|
|
158
|
+
* Returns true is there is a breaking change in the application state schema from before to after.
|
|
252
159
|
* i.e. if the schema becomes larger, since applications can't ask for more schema after creation.
|
|
253
160
|
* Otherwise, there is no error, the app just doesn't store data in the extra schema :(
|
|
254
161
|
*
|
|
@@ -260,6 +167,8 @@ function isSchemaIsBroken(before, after) {
|
|
|
260
167
|
return before.numByteSlice < after.numByteSlice || before.numUint < after.numUint;
|
|
261
168
|
}
|
|
262
169
|
/**
|
|
170
|
+
* @deprecated Use `algorand.appDeployer.getCreatorAppsByName` instead.
|
|
171
|
+
*
|
|
263
172
|
* 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
173
|
*
|
|
265
174
|
* **Note:** It's recommended this is only called once and then stored since it's a somewhat expensive operation (multiple indexer calls).
|
|
@@ -269,87 +178,24 @@ function isSchemaIsBroken(before, after) {
|
|
|
269
178
|
* @returns A name-based lookup of the app information (id, address)
|
|
270
179
|
*/
|
|
271
180
|
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
|
-
});
|
|
181
|
+
const lookup = await new AppDeployer(undefined, undefined, indexer).getCreatorAppsByName(getSenderAddress(creatorAccount));
|
|
347
182
|
return {
|
|
348
|
-
creator:
|
|
349
|
-
apps:
|
|
183
|
+
creator: lookup.creator.toString(),
|
|
184
|
+
apps: Object.fromEntries(Object.entries(lookup.apps).map(([name, app]) => [
|
|
185
|
+
name,
|
|
186
|
+
{
|
|
187
|
+
...app,
|
|
188
|
+
appAddress: app.appAddress.toString(),
|
|
189
|
+
appId: Number(app.appId),
|
|
190
|
+
createdRound: Number(app.createdRound),
|
|
191
|
+
updatedRound: Number(app.updatedRound),
|
|
192
|
+
},
|
|
193
|
+
])),
|
|
350
194
|
};
|
|
351
195
|
}
|
|
352
196
|
/**
|
|
197
|
+
* @deprecated Use `{ dAppName: APP_DEPLOY_NOTE_DAPP, data: metadata, format: 'j' }` instead.
|
|
198
|
+
*
|
|
353
199
|
* Return the transaction note for an app deployment.
|
|
354
200
|
* @param metadata The metadata of the deployment
|
|
355
201
|
* @returns The transaction note as a utf-8 string
|
|
@@ -362,6 +208,8 @@ function getAppDeploymentTransactionNote(metadata) {
|
|
|
362
208
|
};
|
|
363
209
|
}
|
|
364
210
|
/**
|
|
211
|
+
* @deprecated Use `AppManager.replaceTealTemplateDeployTimeControlParams` instead
|
|
212
|
+
*
|
|
365
213
|
* Replaces deploy-time deployment control parameters within the given teal code.
|
|
366
214
|
*
|
|
367
215
|
* * `TMPL_UPDATABLE` for updatability / immutability control
|
|
@@ -375,21 +223,11 @@ function getAppDeploymentTransactionNote(metadata) {
|
|
|
375
223
|
* @returns The replaced TEAL code
|
|
376
224
|
*/
|
|
377
225
|
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;
|
|
226
|
+
return AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, params);
|
|
391
227
|
}
|
|
392
228
|
/**
|
|
229
|
+
* @deprecated Use `AppManager.replaceTealTemplateParams` instead
|
|
230
|
+
*
|
|
393
231
|
* Performs template substitution of a teal file.
|
|
394
232
|
*
|
|
395
233
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
@@ -399,26 +237,11 @@ function replaceDeployTimeControlParams(tealCode, params) {
|
|
|
399
237
|
* @returns The TEAL code with replacements
|
|
400
238
|
*/
|
|
401
239
|
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;
|
|
240
|
+
return AppManager.replaceTealTemplateParams(tealCode, templateParams);
|
|
420
241
|
}
|
|
421
242
|
/**
|
|
243
|
+
* @deprecated Use `algorand.appManager.compileTealTemplate` instead.
|
|
244
|
+
*
|
|
422
245
|
* Performs template substitution of a teal file and compiles it, returning the compiled result.
|
|
423
246
|
*
|
|
424
247
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
@@ -438,21 +261,15 @@ async function performTemplateSubstitutionAndCompile(tealCode, algod, templatePa
|
|
|
438
261
|
return await compileTeal(tealCode, algod);
|
|
439
262
|
}
|
|
440
263
|
/**
|
|
264
|
+
* @deprecated Use `AppManager.stripTealComments` instead.
|
|
265
|
+
*
|
|
441
266
|
* Remove comments from TEAL Code
|
|
442
267
|
*
|
|
443
268
|
* @param tealCode The TEAL logic to compile
|
|
444
269
|
* @returns The TEAL without comments
|
|
445
270
|
*/
|
|
446
271
|
function stripTealComments(tealCode) {
|
|
447
|
-
|
|
448
|
-
const regex = /\/\/(?=([^"\\]*(\\.|"([^"\\]*\\.)*[^"\\]*"))*[^"]*$)/;
|
|
449
|
-
tealCode = tealCode
|
|
450
|
-
.split('\n')
|
|
451
|
-
.map((tealCodeLine) => {
|
|
452
|
-
return tealCodeLine.split(regex)[0].trim();
|
|
453
|
-
})
|
|
454
|
-
.join('\n');
|
|
455
|
-
return tealCode;
|
|
272
|
+
return AppManager.stripTealComments(tealCode);
|
|
456
273
|
}
|
|
457
274
|
|
|
458
275
|
export { deployApp, getAppDeploymentTransactionNote, getCreatorAppsByName, isSchemaIsBroken, performTemplateSubstitution, performTemplateSubstitutionAndCompile, replaceDeployTimeControlParams, stripTealComments };
|