From 5db6f480806e8700e70ab6068a8d83d36e52b135 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Wed, 23 Nov 2022 14:57:53 +0530 Subject: [PATCH 01/25] Update: Have common method for both RUN and DELOY task --- packages/algob/src/builtin-tasks/deploy.ts | 9 ++--- packages/algob/src/builtin-tasks/run.ts | 38 ++++------------------ 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/packages/algob/src/builtin-tasks/deploy.ts b/packages/algob/src/builtin-tasks/deploy.ts index 29ddd0cbc..d170f67a1 100644 --- a/packages/algob/src/builtin-tasks/deploy.ts +++ b/packages/algob/src/builtin-tasks/deploy.ts @@ -11,7 +11,8 @@ import { toCheckpointFileName, } from "../lib/script-checkpoints"; import { CheckpointRepo, RuntimeEnv } from "../types"; -import { runMultipleScripts } from "./run"; +import { DeployerConfig } from "../internal/deployer_cfg"; +import { runScripts } from "./run"; import { TASK_DEPLOY } from "./task-names"; export interface TaskArgs { @@ -55,8 +56,8 @@ export async function executeDeployTask( const onSuccessFn = (cpData: CheckpointRepo, relativeScriptPath: string): void => { persistCheckpoint(relativeScriptPath, cpData.strippedCP); }; - - return await runMultipleScripts( + const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); + return await runScripts( runtimeEnv, scriptNames, [], @@ -64,7 +65,7 @@ export async function executeDeployTask( force, logDebugTag, true, - algoOp + deployerCfg ); } diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index 9012866b9..f914df541 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -2,7 +2,6 @@ import { BuilderError, ERRORS } from "@algo-builder/web"; import chalk from "chalk"; import debug from "debug"; import fsExtra from "fs-extra"; - import { task } from "../internal/core/config/config-env"; import { DeployerConfig, mkDeployer } from "../internal/deployer_cfg"; import { TxWriterImpl } from "../internal/tx-log-writer"; @@ -54,33 +53,8 @@ function partitionIntoSorted(unsorted: string[]): string[][] { ); } -export async function runMultipleScripts( - runtimeEnv: RuntimeEnv, - scriptNames: string[], - args: string[], - onSuccessFn: (cpData: CheckpointRepo, relativeScriptPath: string) => void, - force: boolean, - logDebugTag: string, - allowWrite: boolean, - algoOp: AlgoOperator -): Promise { - const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); - for (const scripts of partitionIntoSorted(scriptNames)) { - await runSortedScripts( - runtimeEnv, - scripts, - args, - onSuccessFn, - force, - logDebugTag, - allowWrite, - deployerCfg - ); - } -} - // Function only accepts sorted scripts -- only this way it loads the state correctly. -async function runSortedScripts( +export async function runScripts( runtimeEnv: RuntimeEnv, scriptNames: string[], args: string[], @@ -129,15 +103,17 @@ async function executeRunTask( scripts: nonExistent, }); } - await runMultipleScripts( + assertDirChildren(scriptsDirectory, [script]); + const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); + await runScripts( runtimeEnv, - assertDirChildren(scriptsDirectory, [script]), + [script], args, - (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, // eslint-disable-line @typescript-eslint/no-empty-function + (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, true, logDebugTag, false, - algoOp + deployerCfg ); } From 7cbeb577b549de890ac20c74f7b9d5b42db10fdd Mon Sep 17 00:00:00 2001 From: Ravinda Date: Wed, 23 Nov 2022 15:46:36 +0530 Subject: [PATCH 02/25] lint --- packages/algob/src/builtin-tasks/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index f914df541..0e3e4095c 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -109,7 +109,7 @@ async function executeRunTask( runtimeEnv, [script], args, - (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, + (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, // eslint-disable-line @typescript-eslint/no-empty-function true, logDebugTag, false, From 60477d136546b136d8e0e7cdff5ec67c22e17450 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Wed, 23 Nov 2022 16:07:48 +0530 Subject: [PATCH 03/25] fix --- packages/algob/src/builtin-tasks/deploy.ts | 9 ++++---- packages/algob/src/builtin-tasks/run.ts | 27 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/algob/src/builtin-tasks/deploy.ts b/packages/algob/src/builtin-tasks/deploy.ts index d170f67a1..29ddd0cbc 100644 --- a/packages/algob/src/builtin-tasks/deploy.ts +++ b/packages/algob/src/builtin-tasks/deploy.ts @@ -11,8 +11,7 @@ import { toCheckpointFileName, } from "../lib/script-checkpoints"; import { CheckpointRepo, RuntimeEnv } from "../types"; -import { DeployerConfig } from "../internal/deployer_cfg"; -import { runScripts } from "./run"; +import { runMultipleScripts } from "./run"; import { TASK_DEPLOY } from "./task-names"; export interface TaskArgs { @@ -56,8 +55,8 @@ export async function executeDeployTask( const onSuccessFn = (cpData: CheckpointRepo, relativeScriptPath: string): void => { persistCheckpoint(relativeScriptPath, cpData.strippedCP); }; - const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); - return await runScripts( + + return await runMultipleScripts( runtimeEnv, scriptNames, [], @@ -65,7 +64,7 @@ export async function executeDeployTask( force, logDebugTag, true, - deployerCfg + algoOp ); } diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index 0e3e4095c..d9b1bae93 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -53,8 +53,33 @@ function partitionIntoSorted(unsorted: string[]): string[][] { ); } +export async function runMultipleScripts( + runtimeEnv: RuntimeEnv, + scriptNames: string[], + args: string[], + onSuccessFn: (cpData: CheckpointRepo, relativeScriptPath: string) => void, + force: boolean, + logDebugTag: string, + allowWrite: boolean, + algoOp: AlgoOperator +): Promise { + const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); + for (const scripts of partitionIntoSorted(scriptNames)) { + await runSortedScripts( + runtimeEnv, + scripts, + args, + onSuccessFn, + force, + logDebugTag, + allowWrite, + deployerCfg + ); + } +} + // Function only accepts sorted scripts -- only this way it loads the state correctly. -export async function runScripts( +async function runScripts( runtimeEnv: RuntimeEnv, scriptNames: string[], args: string[], From 3d6f536eecdb3785438fc48b142071466b2fe2a6 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Wed, 23 Nov 2022 16:18:36 +0530 Subject: [PATCH 04/25] build fix --- packages/algob/src/builtin-tasks/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index d9b1bae93..9cdd46245 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -65,7 +65,7 @@ export async function runMultipleScripts( ): Promise { const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); for (const scripts of partitionIntoSorted(scriptNames)) { - await runSortedScripts( + await runScripts( runtimeEnv, scripts, args, From 3182b825ec56edddefa5db85d18cce6f51191415 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Fri, 25 Nov 2022 17:36:01 +0530 Subject: [PATCH 05/25] format --- packages/algob/src/builtin-tasks/run.ts | 34 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index 9cdd46245..a49caf7e6 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -21,8 +21,8 @@ import { CheckpointRepo, Deployer, RuntimeEnv } from "../types"; import { TASK_RUN } from "./task-names"; interface Input { - script: string; - args: string[]; + script: string[]; + args: string; } export function filterNonExistent(scripts: string[]): string[] { @@ -122,18 +122,34 @@ async function executeRunTask( algoOp: AlgoOperator ): Promise { const logDebugTag = "algob:tasks:run"; - const nonExistent = filterNonExistent([script]); + let scriptArgs: string[] = []; + let scriptName; + if (script && script.length) { + // get script from script array, first element should be script + scriptName = script[0]; + // reamining elemnts should be the script arguments + scriptArgs.push(...script.slice(1)); + } + // check if args param was defined + if (args) { + // add argument at the starting of arguments array + scriptArgs = [args].concat(scriptArgs); + } + if (!scriptName) { + throw Error("Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3") + } + const nonExistent = filterNonExistent([scriptName]); if (nonExistent.length !== 0) { throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_FILES_NOT_FOUND, { scripts: nonExistent, }); } - assertDirChildren(scriptsDirectory, [script]); + assertDirChildren(scriptsDirectory, [scriptName]); const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); await runScripts( runtimeEnv, - [script], - args, + [scriptName], + scriptArgs, (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, // eslint-disable-line @typescript-eslint/no-empty-function true, logDebugTag, @@ -143,8 +159,8 @@ async function executeRunTask( } export default function (): void { - task(TASK_RUN, "Runs a user-defined script after compiling the project") - .addOptionalParam("script", "A js file to be run within algob's environment.") - .addOptionalVariadicPositionalParam("args", "Argument list to be passed to in the script.") + task(TASK_RUN, "Runs a user-defined script after compiling the project\n\nExample: yarn algob run script.js --args arg1 arg2 arg3") + .addOptionalParam("args", "Argument list to be passed in the script.") + .addVariadicPositionalParam("script", "A js file to be run within algob's environment.") .setAction((input, env) => executeRunTask(input, env, createAlgoOperator(env.network))); } From 6ffb5a7bdbe4f5d67278559748f087da440d0831 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Fri, 25 Nov 2022 17:41:42 +0530 Subject: [PATCH 06/25] ok --- .github/workflows/05-examples.yaml | 54 +++++++++---------- docs/guide/README.md | 2 +- docs/guide/debugging-teal.md | 2 +- docs/guide/deployer.md | 2 +- docs/guide/purestake-api.md | 2 +- docs/guide/user-script-execution.md | 6 +-- docs/tutorials/t-01.md | 4 +- examples/asa/README.md | 6 +-- .../transfer/gold-delegated-lsig.debug.js | 2 +- examples/crowdfunding/README.md | 8 +-- examples/htlc-pyteal-ts/README.md | 2 +- examples/inner-tx-create-assets/README.md | 4 +- examples/multisig/README.md | 4 +- examples/nft/README.md | 2 +- .../permissioned-token-freezing/README.md | 4 +- examples/permissioned-voting/README.md | 4 +- examples/signed-txn/README.md | 2 +- examples/trampoline/README.md | 2 +- packages/algob/sample-project/js/README.md | 4 +- packages/algob/sample-project/ts/README.md | 4 +- packages/algob/src/types.ts | 2 +- packages/web/src/errors/errors-list.ts | 2 +- 22 files changed, 62 insertions(+), 62 deletions(-) diff --git a/.github/workflows/05-examples.yaml b/.github/workflows/05-examples.yaml index 395a6f281..724769c02 100644 --- a/.github/workflows/05-examples.yaml +++ b/.github/workflows/05-examples.yaml @@ -75,29 +75,29 @@ jobs: working-directory: ./examples/asa run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/transfer/gold-contract-sc.js - pipenv run yarn algob run --script scripts/transfer/gold-delegated-lsig.js - pipenv run yarn algob run --script scripts/transfer/gold-to-john.js - pipenv run yarn algob run --script scripts/transfer/master-fund-john.js - pipenv run yarn algob run --script scripts/transfer/tesla-to-john.js + pipenv run yarn algob run scripts/transfer/gold-contract-sc.js + pipenv run yarn algob run scripts/transfer/gold-delegated-lsig.js + pipenv run yarn algob run scripts/transfer/gold-to-john.js + pipenv run yarn algob run scripts/transfer/master-fund-john.js + pipenv run yarn algob run scripts/transfer/tesla-to-john.js - name: Example bond token working-directory: ./examples/bond run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/run/run.js + pipenv run yarn algob run scripts/run/run.js - name: Example crowdfunding working-directory: ./examples/crowdfunding run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/transfer/donate.js + pipenv run yarn algob run scripts/transfer/donate.js - name: Example htlc-pyteal-ts working-directory: ./examples/htlc-pyteal-ts run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/withdraw/htlc-withdraw.ts + pipenv run yarn algob run scripts/withdraw/htlc-withdraw.ts - name: Example multisig run: cd examples/multisig && pipenv run yarn algob deploy @@ -106,20 +106,20 @@ jobs: working-directory: ./examples/nft run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/transfer/create-transfer-nft.js + pipenv run yarn algob run scripts/transfer/create-transfer-nft.js - name: Example permissioned-token working-directory: ./examples/permissioned-token run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/admin/issue.js - pipenv run yarn algob run --script scripts/permissions/whitelist.js - pipenv run yarn algob run --script scripts/user/transfer.js - pipenv run yarn algob run --script scripts/admin/force-transfer.js - pipenv run yarn algob run --script scripts/admin/update-reserve.js - pipenv run yarn algob run --script scripts/permissions/change-perm-manager.js - pipenv run yarn algob run --script scripts/admin/kill.js - pipenv run yarn algob run --script scripts/user/opt-out.js + pipenv run yarn algob run scripts/admin/issue.js + pipenv run yarn algob run scripts/permissions/whitelist.js + pipenv run yarn algob run scripts/user/transfer.js + pipenv run yarn algob run scripts/admin/force-transfer.js + pipenv run yarn algob run scripts/admin/update-reserve.js + pipenv run yarn algob run scripts/permissions/change-perm-manager.js + pipenv run yarn algob run scripts/admin/kill.js + pipenv run yarn algob run scripts/user/opt-out.js run-examples-batch-2: runs-on: ubuntu-20.04 @@ -160,15 +160,15 @@ jobs: working-directory: ./examples/permissioned-token-freezing run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/transfer/set-clear-level.js - pipenv run yarn algob run --script scripts/transfer/transfer-asset.js + pipenv run yarn algob run scripts/transfer/set-clear-level.js + pipenv run yarn algob run scripts/transfer/transfer-asset.js - name: Example permissioned-voting working-directory: ./examples/permissioned-voting run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/vote/vote.js - pipenv run yarn algob run --script scripts/vote/result.js + pipenv run yarn algob run scripts/vote/vote.js + pipenv run yarn algob run scripts/vote/result.js - name: Example ref-templates run: | @@ -179,8 +179,8 @@ jobs: working-directory: ./examples/stateful-counter run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/interaction/call_application.js - pipenv run yarn algob run --script scripts/interaction/delete_application.js + pipenv run yarn algob run scripts/interaction/call_application.js + pipenv run yarn algob run scripts/interaction/delete_application.js run-examples-batch-3: runs-on: ubuntu-20.04 @@ -221,15 +221,15 @@ jobs: working-directory: ./examples/unique-nft-asa run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/run/transfer-nft.js + pipenv run yarn algob run scripts/run/transfer-nft.js - name: Example inner-tx-create-assets working-directory: ./examples/inner-tx-create-assets run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/run/useInnerTxn.js - pipenv run yarn algob run --script scripts/run/useGroupTxn.js + pipenv run yarn algob run scripts/run/useInnerTxn.js + pipenv run yarn algob run scripts/run/useGroupTxn.js - name: Trampoline working-directory: ./examples/trampoline run: | pipenv run yarn algob deploy - pipenv run yarn algob run --script scripts/run/create-fund-app.js + pipenv run yarn algob run scripts/run/create-fund-app.js diff --git a/docs/guide/README.md b/docs/guide/README.md index 626eb0098..15baa124d 100644 --- a/docs/guide/README.md +++ b/docs/guide/README.md @@ -117,7 +117,7 @@ Check the _requirements_ section above first.\_ 1. Add assets and smart-contracts in the `assets` directory. 1. Add deployment scripts in `scripts` directory. 1. Run `yarn run algob deploy` to compile and deploy everything (all scripts nested directly in /scripts). -1. Run `yarn run algob run --script scriptPath/scriptName` to run a script. +1. Run `yarn run algob run scriptPath/scriptName` to run a script. 1. To run `algob` on different network (by default the `default` network is used) use yarn run algob --network diff --git a/docs/guide/debugging-teal.md b/docs/guide/debugging-teal.md index 28dd003b8..b99b6207d 100644 --- a/docs/guide/debugging-teal.md +++ b/docs/guide/debugging-teal.md @@ -26,7 +26,7 @@ If it displays the `tealdbg` help, you're good to go. Creating transaction data (via `goal --dryrun-dump` or SDK) could be a lengthy process, especially when using a transaction group. `Algob` provides an easy way to use debugger: by simply supplying the transactions as an input to the `TealDbg` method (same transaction parameters that we supply to [executeTx](https://algobuilder.dev/api/algob/modules.html#executeTransaction) to execute same transaction on network). -NOTE: You use the `TealDbg` method in an algob script, which can be run using `algob deploy`/`algob run --script` commands. +NOTE: You use the `TealDbg` method in an algob script, which can be run using `algob deploy`/`algob run` commands. ### Using dry run for debugging a TEAL program in an algob script diff --git a/docs/guide/deployer.md b/docs/guide/deployer.md index 51ed43ade..8469ea3d6 100644 --- a/docs/guide/deployer.md +++ b/docs/guide/deployer.md @@ -22,7 +22,7 @@ Deployer class has the following modes: - Run Mode: In run mode user can access/read checkpoints, create logs but cannot write(create) checkpoints. Files placed in nested folders (non-direct children, eg: `scripts/transfer/run-script.js`) of `scripts/` folder are considered to be run in this mode. To run a script in the _run_ mode (the script will receive deployer instance in _run_ mode\_): - yarn run algob run --script scripts/transfer/run-script.js + yarn run algob run scripts/transfer/run-script.js **Note:** In run mode user can `deploy`, `update`, `delete` or perform all these operations in a group transaction using [`executeTx`](https://algobuilder.dev/api/algob/modules.html#executetransaction) function but the `checkpoints will not be created when using run mode.` diff --git a/docs/guide/purestake-api.md b/docs/guide/purestake-api.md index c7b77434f..3b1568255 100644 --- a/docs/guide/purestake-api.md +++ b/docs/guide/purestake-api.md @@ -42,7 +42,7 @@ module.exports = { }; ``` -And while running the script, you can simply pass this cfg with the `--network` flag. (eg. `algob run --script scripts/run.js --network purestake`). +And while running the script, you can simply pass this cfg with the `--network` flag. (eg. `algob run scripts/run.js --network purestake`). ## IndexerV2 diff --git a/docs/guide/user-script-execution.md b/docs/guide/user-script-execution.md index 5c0945fac..a5d1b123e 100644 --- a/docs/guide/user-script-execution.md +++ b/docs/guide/user-script-execution.md @@ -8,7 +8,7 @@ layout: splash In algob, scripts are JS files stored in the `scripts` directory and are meant to interact with the blockchain (deploy ASA, ASC1, run transactions...). -Scripts are run through `algob run --script` and `algob deploy` commands. `algob` is using `algob.config.js` to get information about network and accounts and is executing incremental scripts found in `scripts/`. +Scripts are run through `algob run` and `algob deploy` commands. `algob` is using `algob.config.js` to get information about network and accounts and is executing incremental scripts found in `scripts/`. Please see the [architecture document](https://paper.dropbox.com/published/Algorand-builder-specs--A7njBF~7_VHYy0l3m3RAKgYVBg-c4ycJtlcmEaRIbptAPqNYS6#:h2=Scripts) to see how the scripts are organized and how to use them. @@ -16,7 +16,7 @@ Please see the [architecture document](https://paper.dropbox.com/published/Algor As noted above there are two commands to execute scripts: -- `algob run --script` +- `algob run` - `algob deploy` #### Run @@ -25,7 +25,7 @@ Runs provided scripts and doesn't save script checkpoints. Useful to query the current state of blockchain. Example: - algob run --script scripts/script1.js + algob run scripts/script1.js #### Deploy diff --git a/docs/tutorials/t-01.md b/docs/tutorials/t-01.md index b358beeb9..2912e7b76 100644 --- a/docs/tutorials/t-01.md +++ b/docs/tutorials/t-01.md @@ -356,9 +356,9 @@ async function run(runtimeEnv, deployer) { module.exports = { default: run }; ``` -Similarly to `scripts/0-gold.js`, this file exports one default function. This function, however, will not be run using `algob deploy`. Instead, we will use `algob run --script`: +Similarly to `scripts/0-gold.js`, this file exports one default function. This function, however, will not be run using `algob deploy`. Instead, we will use `algob run`: - algob run --script scripts/transfer/gold-to-john.js + algob run scripts/transfer/gold-to-john.js The main difference between `run` and `deploy` is that: diff --git a/examples/asa/README.md b/examples/asa/README.md index c0e2baba3..d329784bc 100644 --- a/examples/asa/README.md +++ b/examples/asa/README.md @@ -19,10 +19,10 @@ To deploy all assets simply run: It will go through all files in directly placed in the `scripts/` directory (so, it doesn't go recursively into the subdirectories) and run them in the _deploy_ mode. For more information about the deployer read the [deployer guide](https://algobuilder.dev/guide/deployer.html). -Transfers can be executed by executing `algob run --script scripts/transfer/gold-to-john.js` and other scripts in `scripts/transfer/`. +Transfers can be executed by executing `algob run scripts/transfer/gold-to-john.js` and other scripts in `scripts/transfer/`. These scripts contain logic to transfer assets to `john-account` but other accounts can be configured as well. -Balances can be queried by executing `algob run --script scripts/query/john-balances.js`. +Balances can be queried by executing `algob run scripts/query/john-balances.js`. This example also includes smart signatures in (`assets/` directory) that showcase the two different modes of operation (contract & signature delegation): @@ -58,5 +58,5 @@ This example is using PyTEAL, so make sure to follow the Python3 setup described ``` yarn algob deploy -yarn algob run --script scripts/query/john-balances.js +yarn algob run scripts/query/john-balances.js ``` diff --git a/examples/asa/scripts/transfer/gold-delegated-lsig.debug.js b/examples/asa/scripts/transfer/gold-delegated-lsig.debug.js index 1cf3ae321..e25484b86 100644 --- a/examples/asa/scripts/transfer/gold-delegated-lsig.debug.js +++ b/examples/asa/scripts/transfer/gold-delegated-lsig.debug.js @@ -2,7 +2,7 @@ * Description: * This file demonstrates the example to run teal debugger for transfer Algorand * Standard Assets(ASA) & MicroAlgos using delegated lsig (between 2 user accounts). - * You can run it using `algob run --script scripts/transfer/gold-delegated-lsig.debug.js` + * You can run it using `algob run scripts/transfer/gold-delegated-lsig.debug.js` */ const { types } = require("@algo-builder/web"); const { Tealdbg } = require("@algo-builder/algob"); diff --git a/examples/crowdfunding/README.md b/examples/crowdfunding/README.md index 568bf0fd7..43b4a3712 100644 --- a/examples/crowdfunding/README.md +++ b/examples/crowdfunding/README.md @@ -31,19 +31,19 @@ To Create Crowdfunding Stateful Smart Contract Application To Donate: - yarn run algob run --script scripts/transfer/donate.js + yarn run algob run scripts/transfer/donate.js To Claim: - yarn run algob run --script scripts/transfer/claim.js + yarn run algob run scripts/transfer/claim.js To Reclaim: - yarn run algob run --script scripts/transfer/reclaim.js + yarn run algob run scripts/transfer/reclaim.js To Delete application and tranfer remaining funds to crreator: - yarn run algob run --script scripts/transfer/delete.js + yarn run algob run scripts/transfer/delete.js - Some points to be noted: - Creator can only claim funds when total goal is reached. diff --git a/examples/htlc-pyteal-ts/README.md b/examples/htlc-pyteal-ts/README.md index 2be203a63..f6869e229 100644 --- a/examples/htlc-pyteal-ts/README.md +++ b/examples/htlc-pyteal-ts/README.md @@ -26,5 +26,5 @@ This example is using PyTEAL, so make sure to follow the Python3 setup described ``` yarn run algob deploy -yarn run algob run --script scripts/withdraw/htlc-withdraw.ts +yarn run algob run scripts/withdraw/htlc-withdraw.ts ``` diff --git a/examples/inner-tx-create-assets/README.md b/examples/inner-tx-create-assets/README.md index 3080e4171..47145e417 100644 --- a/examples/inner-tx-create-assets/README.md +++ b/examples/inner-tx-create-assets/README.md @@ -13,11 +13,11 @@ yarn run algob deploy ## Deploy new application, asset and log id by group transaction ``` -yarn run algob run --script useGroupTxn.js +yarn run algob run useGroupTxn.js ``` ## Deploy new application, asset and log id by inner transaction ``` -yarn run algob run --script useInnerTxn.js +yarn run algob run useInnerTxn.js ``` diff --git a/examples/multisig/README.md b/examples/multisig/README.md index 70392e283..a2db05c6f 100644 --- a/examples/multisig/README.md +++ b/examples/multisig/README.md @@ -59,8 +59,8 @@ You need to **_save the signed logic signature file in `examples/multisig/assets ### Run ``` -yarn run algob run --script scripts/multisig_goal_sc.js -yarn run algob run --script scripts/multisig_sdk_sc.js +yarn run algob run scripts/multisig_goal_sc.js +yarn run algob run scripts/multisig_sdk_sc.js ``` ### More information diff --git a/examples/nft/README.md b/examples/nft/README.md index 783928d0e..873bfdaf9 100644 --- a/examples/nft/README.md +++ b/examples/nft/README.md @@ -25,5 +25,5 @@ This example is using PyTEAL, so make sure to follow the Python3 setup described ``` yarn run algob deploy -yarn run algob run --script scripts/transfer/create-transfer-nft.js +yarn run algob run scripts/transfer/create-transfer-nft.js ``` diff --git a/examples/permissioned-token-freezing/README.md b/examples/permissioned-token-freezing/README.md index 7a5524946..8adbab5b8 100644 --- a/examples/permissioned-token-freezing/README.md +++ b/examples/permissioned-token-freezing/README.md @@ -38,8 +38,8 @@ yarn run algob deploy ### Run ``` -yarn run algob run --script scripts/transfer/set-clear-level.js // set minimum level(to transfer asset) -yarn run algob run --script scripts/transfer/transfer-asset.js // transfer asset from Alice -> Bob +yarn run algob run scripts/transfer/set-clear-level.js // set minimum level(to transfer asset) +yarn run algob run scripts/transfer/transfer-asset.js // transfer asset from Alice -> Bob ``` ### More information diff --git a/examples/permissioned-voting/README.md b/examples/permissioned-voting/README.md index 0fcc83993..29d6b43af 100644 --- a/examples/permissioned-voting/README.md +++ b/examples/permissioned-voting/README.md @@ -35,8 +35,8 @@ To Create Vote-Token Asset and Permissioned voting application: To Cast a Vote: - yarn run algob run --script scripts/vote/vote.js + yarn run algob run scripts/vote/vote.js To see the results and delete the application: - yarn run algob run --script scripts/vote/result.js + yarn run algob run scripts/vote/result.js diff --git a/examples/signed-txn/README.md b/examples/signed-txn/README.md index 73dea0108..356d94e1f 100644 --- a/examples/signed-txn/README.md +++ b/examples/signed-txn/README.md @@ -30,7 +30,7 @@ The standard transaction file extension is `.txn`, but the code accepts any exte ### Run ``` -yarn run algob run --script scripts/transfer.js +yarn run algob run scripts/transfer.js ``` ### More information diff --git a/examples/trampoline/README.md b/examples/trampoline/README.md index fd9937695..48f112193 100644 --- a/examples/trampoline/README.md +++ b/examples/trampoline/README.md @@ -17,5 +17,5 @@ If you run the file fundApplication.py, it will generate two file TEAL approval. ``` yarn run algob deploy -yarn run algob run --script scripts/run/create-fund-app.js +yarn run algob run scripts/run/create-fund-app.js ``` diff --git a/packages/algob/sample-project/js/README.md b/packages/algob/sample-project/js/README.md index 91bc6f27b..81cce44c4 100644 --- a/packages/algob/sample-project/js/README.md +++ b/packages/algob/sample-project/js/README.md @@ -26,8 +26,8 @@ To run the `sample-project`: - To interact with your deployments you can create a script and run it using: -* `algob run --script scripts/path_to/file1` -* Don’t use algob run --script for deployments. This should be used only for auxiliary scripts, like ad-hock transactions (example: draining an account). +* `algob run scripts/path_to/file1` +* Don’t use algob run for deployments. This should be used only for auxiliary scripts, like ad-hock transactions (example: draining an account). - Run tests: diff --git a/packages/algob/sample-project/ts/README.md b/packages/algob/sample-project/ts/README.md index 9d26dd2a0..14e59f9b5 100644 --- a/packages/algob/sample-project/ts/README.md +++ b/packages/algob/sample-project/ts/README.md @@ -26,8 +26,8 @@ To run the `sample-project`: - To interact with your deployments you can create a script and run it using: -* `algob run --script scripts/path_to/file1` -* Don’t use algob run --script for deployments. This should be used only for auxiliary scripts, like ad-hock transactions (example: draining an account). +* `algob run scripts/path_to/file1` +* Don’t use algob run for deployments. This should be used only for auxiliary scripts, like ad-hock transactions (example: draining an account). - Run tests: diff --git a/packages/algob/src/types.ts b/packages/algob/src/types.ts index fbde401ac..ff11dfcd9 100644 --- a/packages/algob/src/types.ts +++ b/packages/algob/src/types.ts @@ -436,7 +436,7 @@ export interface Deployer { /** * Sets metadata key value for a current network in the chckpoint file based on the - * current deployment script. If run in a non deployment mode (eg `algob run --script script_name.js`) + * current deployment script. If run in a non deployment mode (eg `algob run script_name.js`) * it will throw an exception. */ addCheckpointKV: (key: string, value: string) => void; diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index 9e1ad6f57..5e152803a 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -531,7 +531,7 @@ export const taskErrors = { number: 601, message: "Scripts don't exist: %scripts%.", title: "Scripts don't exist.", - description: `Tried to use \`algob run --script \` to execute a non-existing script(s). + description: `Tried to use \`algob run \` to execute a non-existing script(s). Please double check your script's path`, }, From 89885c32fd405b249ca9bca5ab7da73157191d04 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Fri, 25 Nov 2022 17:50:54 +0530 Subject: [PATCH 07/25] ok --- packages/algob/test/builtin-tasks/deploy.ts | 4 +-- packages/algob/test/builtin-tasks/run.ts | 36 ++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/algob/test/builtin-tasks/deploy.ts b/packages/algob/test/builtin-tasks/deploy.ts index 84c5a2bd0..f79ea5d35 100644 --- a/packages/algob/test/builtin-tasks/deploy.ts +++ b/packages/algob/test/builtin-tasks/deploy.ts @@ -304,7 +304,7 @@ script3: META from third defined: third-ok }); fs.unlinkSync(testFixtureOutputFile); await this.env.run(TASK_RUN, { - script: "scripts/2.js", + script: ["scripts/2.js"], }); const scriptOutputAfter = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal( @@ -321,7 +321,7 @@ script2: META from third defined: undefined\n` }); fs.unlinkSync(testFixtureOutputFile); await this.env.run(TASK_RUN, { - script: "scripts/2.js", + script: ["scripts/2.js"], }); const scriptOutputAfter = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal( diff --git a/packages/algob/test/builtin-tasks/run.ts b/packages/algob/test/builtin-tasks/run.ts index 5b7deaffa..d5d872331 100644 --- a/packages/algob/test/builtin-tasks/run.ts +++ b/packages/algob/test/builtin-tasks/run.ts @@ -22,7 +22,7 @@ describe("Run task", function () { await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "./scripts/does-not-exist", + script: ["./scripts/does-not-exist"], }), ERRORS.BUILTIN_TASKS.RUN_FILES_NOT_FOUND, "./scripts/does-not-exist" @@ -31,27 +31,27 @@ describe("Run task", function () { it("Should run the scripts to completion", async function () { await this.env.run(TASK_RUN, { - script: "./scripts/async-script.js", + script: ["./scripts/async-script.js"], }); }); it("Should run the script without arguments", async function () { await this.env.run(TASK_RUN, { - script: "./scripts/async-script.js", + script: ["./scripts/async-script.js"], }); }); it("Should run the script with empty arguments", async function () { await this.env.run(TASK_RUN, { - script: "./scripts/async-script.js", - args: [] + script: ["./scripts/async-script.js"], + args: "" }); }); it("Should run the script with arguments", async function () { await this.env.run(TASK_RUN, { - script: "./scripts/async-script.js", - args: ["arg1", "arg2"] + script: ["./scripts/async-script.js"], + args: "arg1" }); }); @@ -99,7 +99,7 @@ describe("Run task + clean", function () { it("Should allow to run single script", async function () { await this.env.run(TASK_RUN, { - script: "scripts/1.js", + script: ["scripts/1.js"], }); const scriptOutput = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal( @@ -112,7 +112,7 @@ describe("Run task + clean", function () { await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "scripts/doesnotexist.js", + script: ["scripts/doesnotexist.js"], }), ERRORS.BUILTIN_TASKS.RUN_FILES_NOT_FOUND, "scripts/doesnotexist.js" @@ -123,7 +123,7 @@ describe("Run task + clean", function () { await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "scripts/other-scripts/failing.js" + script: ["scripts/other-scripts/failing.js"] }), ERRORS.BUILTIN_TASKS.SCRIPT_EXECUTION_ERROR, "scripts/other-scripts/failing.js" @@ -132,10 +132,10 @@ describe("Run task + clean", function () { it("Should allow to rerun successful scripts twice", async function () { await this.env.run(TASK_RUN, { - script: "scripts/1.js" + script: ["scripts/1.js"] }); await this.env.run(TASK_RUN, { - script: "scripts/1.js" + script: ["scripts/1.js"] }); const scriptOutput = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal( @@ -151,7 +151,7 @@ scripts directory: script 1 executed fileNames: ["scripts/1.js"], }); await this.env.run(TASK_RUN, { - script: "scripts/1.js", + script: ["scripts/1.js"], }); const scriptOutput = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal( @@ -164,7 +164,7 @@ scripts directory: script 1 executed it("Should not create a snapshot", async function () { await this.env.run(TASK_RUN, { - script: "scripts/2.js", + script: ["scripts/2.js"], }); assert.isFalse(fs.existsSync("artifacts/scripts/2.js")); }); @@ -173,7 +173,7 @@ scripts directory: script 1 executed await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "1.js", + script: ["1.js"], }), ERRORS.BUILTIN_TASKS.SCRIPTS_OUTSIDE_SCRIPTS_DIRECTORY, "1.js" @@ -182,7 +182,7 @@ scripts directory: script 1 executed it("Should not save metadata", async function () { await this.env.run(TASK_RUN, { - script: "scripts/1.js", + script: ["scripts/1.js"], }); const persistedSnapshot = loadCheckpoint("./scripts/1.js"); assert.deepEqual(persistedSnapshot, {}); @@ -213,7 +213,7 @@ scripts directory: script 1 executed await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "scripts/other-scripts/deploy-asa.js", + script: ["scripts/other-scripts/deploy-asa.js"], }), ERRORS.BUILTIN_TASKS.DEPLOYER_EDIT_OUTSIDE_DEPLOY, "deployASA" @@ -228,7 +228,7 @@ scripts directory: script 1 executed await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "scripts/other-scripts/deploy-asc.js", + script: ["scripts/other-scripts/deploy-asc.js"], }), ERRORS.BUILTIN_TASKS.DEPLOYER_EDIT_OUTSIDE_DEPLOY, "fundLsigByFile" From 1e669c9149ff46f4548755d3030560158c1b93a9 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Fri, 25 Nov 2022 17:53:20 +0530 Subject: [PATCH 08/25] ok --- packages/algob/test/builtin-tasks/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algob/test/builtin-tasks/run.ts b/packages/algob/test/builtin-tasks/run.ts index d5d872331..b61dc9eea 100644 --- a/packages/algob/test/builtin-tasks/run.ts +++ b/packages/algob/test/builtin-tasks/run.ts @@ -198,7 +198,7 @@ scripts directory: script 1 executed await expectBuilderErrorAsync( async () => await this.env.run(TASK_RUN, { - script: "scripts/other-scripts/put-metadata.js", + script: ["scripts/other-scripts/put-metadata.js"], }), ERRORS.BUILTIN_TASKS.DEPLOYER_EDIT_OUTSIDE_DEPLOY, "addCheckpointKV" From 881c5c0032fb904a31eb9f1571490f9884507a97 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Fri, 25 Nov 2022 18:43:31 +0530 Subject: [PATCH 09/25] ok --- packages/algob/src/builtin-tasks/run.ts | 41 ++++++++++++------------ packages/algob/test/builtin-tasks/run.ts | 22 +++++++++++++ packages/web/src/errors/errors-list.ts | 6 ++++ 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index a49caf7e6..56484fab9 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -135,27 +135,28 @@ async function executeRunTask( // add argument at the starting of arguments array scriptArgs = [args].concat(scriptArgs); } - if (!scriptName) { - throw Error("Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3") - } - const nonExistent = filterNonExistent([scriptName]); - if (nonExistent.length !== 0) { - throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_FILES_NOT_FOUND, { - scripts: nonExistent, - }); + if (scriptName) { + const nonExistent = filterNonExistent([scriptName]); + if (nonExistent.length !== 0) { + throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_FILES_NOT_FOUND, { + scripts: nonExistent, + }); + } + assertDirChildren(scriptsDirectory, [scriptName]); + const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); + await runScripts( + runtimeEnv, + [scriptName], + scriptArgs, + (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, // eslint-disable-line @typescript-eslint/no-empty-function + true, + logDebugTag, + false, + deployerCfg + ); + } else { + throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_FILE_NOT_FOUND_WITH_SUGGESTION); } - assertDirChildren(scriptsDirectory, [scriptName]); - const deployerCfg = new DeployerConfig(runtimeEnv, algoOp); - await runScripts( - runtimeEnv, - [scriptName], - scriptArgs, - (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, // eslint-disable-line @typescript-eslint/no-empty-function - true, - logDebugTag, - false, - deployerCfg - ); } export default function (): void { diff --git a/packages/algob/test/builtin-tasks/run.ts b/packages/algob/test/builtin-tasks/run.ts index b61dc9eea..b6ddaa174 100644 --- a/packages/algob/test/builtin-tasks/run.ts +++ b/packages/algob/test/builtin-tasks/run.ts @@ -55,6 +55,28 @@ describe("Run task", function () { }); }); + + it("Should fail if a script is not passed as first element of script array", async function () { + await expectBuilderErrorAsync( + async () => + await this.env.run(TASK_RUN, { + script: ["arg1", "./scripts/does-not-exist"], + }), + ERRORS.BUILTIN_TASKS.RUN_FILES_NOT_FOUND, + "arg1" + ); + }); + + it("Should fail if empty script array is passed", async function () { + await expectBuilderErrorAsync( + async () => + await this.env.run(TASK_RUN, { + script: [], + }), + ERRORS.BUILTIN_TASKS.RUN_FILE_NOT_FOUND_WITH_SUGGESTION, + ); + }); + /* TODO:MM compile before running the task it("Should compile before running", async function () { if (await fsExtra.pathExists("cache")) { diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index 5e152803a..a24704f4a 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -667,6 +667,12 @@ Use 'deployer.isDefined(name)' to check if the name is already used. Use 'deployer.isDefined(name)' to check if the name is already used. `, }, + RUN_FILE_NOT_FOUND_WITH_SUGGESTION: { + number: 617, + message: "Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3", + title: "Run file not found.", + description: `Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3`, + } }; export const pluginErrors = { From 3ae6392a73108e9ebac3beee3726100f7095f45b Mon Sep 17 00:00:00 2001 From: Ravinda Date: Mon, 28 Nov 2022 19:15:52 +0530 Subject: [PATCH 10/25] json arg --- packages/algob/src/builtin-tasks/deploy.ts | 2 +- packages/algob/src/builtin-tasks/run.ts | 28 +++++++------------ .../algob/src/internal/util/scripts-runner.ts | 4 +-- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/packages/algob/src/builtin-tasks/deploy.ts b/packages/algob/src/builtin-tasks/deploy.ts index 29ddd0cbc..d09fa7540 100644 --- a/packages/algob/src/builtin-tasks/deploy.ts +++ b/packages/algob/src/builtin-tasks/deploy.ts @@ -59,7 +59,7 @@ export async function executeDeployTask( return await runMultipleScripts( runtimeEnv, scriptNames, - [], + "", // empty argument passed onSuccessFn, force, logDebugTag, diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index 56484fab9..ef4b71d03 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -21,8 +21,8 @@ import { CheckpointRepo, Deployer, RuntimeEnv } from "../types"; import { TASK_RUN } from "./task-names"; interface Input { - script: string[]; - args: string; + script: string; + arg: string; } export function filterNonExistent(scripts: string[]): string[] { @@ -56,7 +56,7 @@ function partitionIntoSorted(unsorted: string[]): string[][] { export async function runMultipleScripts( runtimeEnv: RuntimeEnv, scriptNames: string[], - args: string[], + arg: string, onSuccessFn: (cpData: CheckpointRepo, relativeScriptPath: string) => void, force: boolean, logDebugTag: string, @@ -68,7 +68,7 @@ export async function runMultipleScripts( await runScripts( runtimeEnv, scripts, - args, + arg, onSuccessFn, force, logDebugTag, @@ -82,7 +82,7 @@ export async function runMultipleScripts( async function runScripts( runtimeEnv: RuntimeEnv, scriptNames: string[], - args: string[], + arg: string, onSuccessFn: (cpData: CheckpointRepo, relativeScriptPath: string) => void, force: boolean, logDebugTag: string, @@ -111,29 +111,21 @@ async function runScripts( } deployerCfg.txWriter.setScriptName(relativeScriptPath); log(`Running script ${relativeScriptPath}`); - await runScript(relativeScriptPath, args, runtimeEnv, deployer); + await runScript(relativeScriptPath, arg, runtimeEnv, deployer); onSuccessFn(deployerCfg.cpData, relativeScriptPath); } } async function executeRunTask( - { script, args }: Input, + { script, arg }: Input, runtimeEnv: RuntimeEnv, algoOp: AlgoOperator ): Promise { const logDebugTag = "algob:tasks:run"; - let scriptArgs: string[] = []; let scriptName; if (script && script.length) { // get script from script array, first element should be script scriptName = script[0]; - // reamining elemnts should be the script arguments - scriptArgs.push(...script.slice(1)); - } - // check if args param was defined - if (args) { - // add argument at the starting of arguments array - scriptArgs = [args].concat(scriptArgs); } if (scriptName) { const nonExistent = filterNonExistent([scriptName]); @@ -147,7 +139,7 @@ async function executeRunTask( await runScripts( runtimeEnv, [scriptName], - scriptArgs, + arg, (_cpData: CheckpointRepo, _relativeScriptPath: string) => { }, // eslint-disable-line @typescript-eslint/no-empty-function true, logDebugTag, @@ -161,7 +153,7 @@ async function executeRunTask( export default function (): void { task(TASK_RUN, "Runs a user-defined script after compiling the project\n\nExample: yarn algob run script.js --args arg1 arg2 arg3") - .addOptionalParam("args", "Argument list to be passed in the script.") - .addVariadicPositionalParam("script", "A js file to be run within algob's environment.") + .addVariadicPositionalParam("script", "A script file to be run within algob's environment.") + .addOptionalParam("arg", "Argument to be passed in the script.") .setAction((input, env) => executeRunTask(input, env, createAlgoOperator(env.network))); } diff --git a/packages/algob/src/internal/util/scripts-runner.ts b/packages/algob/src/internal/util/scripts-runner.ts index 0ee0ecb24..7ec111140 100644 --- a/packages/algob/src/internal/util/scripts-runner.ts +++ b/packages/algob/src/internal/util/scripts-runner.ts @@ -62,7 +62,7 @@ function displayErr(error: Error | BuilderError | any, relativeScriptPath: strin export async function runScript( relativeScriptPath: string, - args: string[], + arg: string, runtimeEnv: RuntimeEnv, deployer: Deployer ): Promise { @@ -79,7 +79,7 @@ export async function runScript( }); } try { - await requiredScript.default(runtimeEnv, deployer, args); + await requiredScript.default(runtimeEnv, deployer, arg); } catch (error) { displayErr(error, relativeScriptPath); } From 9dc6f179b49959bf6e4ef00c93841d2e9059c38e Mon Sep 17 00:00:00 2001 From: Ravinda Date: Mon, 28 Nov 2022 19:25:37 +0530 Subject: [PATCH 11/25] build fix --- yarn.lock | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3474c9143..66ffd756b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2207,19 +2207,6 @@ __metadata: languageName: node linkType: hard -"dao@workspace:examples/dao": - version: 0.0.0-use.local - resolution: "dao@workspace:examples/dao" - dependencies: - "@algo-builder/algob": "workspace:*" - "@algo-builder/runtime": "workspace:*" - "@algo-builder/web": "workspace:*" - algosdk: ^1.22.0 - eslint: ^8.26.0 - mocha: ^10.1.0 - languageName: unknown - linkType: soft - "debug@npm:4": version: 4.3.3 resolution: "debug@npm:4.3.3" From 4e4b11f7b63b9499665c4fa70a20875b42c9e3d1 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Mon, 28 Nov 2022 19:32:10 +0530 Subject: [PATCH 12/25] fix --- packages/algob/test/internal/util/scripts-runner.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/algob/test/internal/util/scripts-runner.ts b/packages/algob/test/internal/util/scripts-runner.ts index 621d5355a..a352a1472 100644 --- a/packages/algob/test/internal/util/scripts-runner.ts +++ b/packages/algob/test/internal/util/scripts-runner.ts @@ -25,20 +25,20 @@ describe("Scripts runner", function () { }); it("Should pass params to the script", async function () { - await runScript("./scripts/params-script.js", [], env, new DeployerRunMode(deployerCfg)); + await runScript("./scripts/params-script.js", "", env, new DeployerRunMode(deployerCfg)); const scriptOutput = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal(scriptOutput, "network1"); }); it("Should pass params to the script with arguments", async function () { - await runScript("./scripts/params-script.js", ["arg1", "arg2"], env, new DeployerRunMode(deployerCfg)); + await runScript("./scripts/params-script.js", '"arg1", "arg2"', env, new DeployerRunMode(deployerCfg)); const scriptOutput = fs.readFileSync(testFixtureOutputFile).toString(); assert.equal(scriptOutput, "network1"); }); it("Should run the script to completion", async function () { const before = new Date(); - await runScript("./scripts/async-script.js", [], env, new DeployerRunMode(deployerCfg)); + await runScript("./scripts/async-script.js", "", env, new DeployerRunMode(deployerCfg)); const after = new Date(); assert.isAtLeast(after.getTime() - before.getTime(), 20); }); @@ -46,7 +46,7 @@ describe("Scripts runner", function () { it("Exception shouldn't crash the whole app", async function () { await expectBuilderErrorAsync( async () => - await runScript("./scripts/failing-script.js", [], env, new DeployerRunMode(deployerCfg)), + await runScript("./scripts/failing-script.js", "", env, new DeployerRunMode(deployerCfg)), ERRORS.BUILTIN_TASKS.SCRIPT_EXECUTION_ERROR, "./scripts/failing-script.js" ); @@ -75,7 +75,7 @@ describe("Scripts runner", function () { async () => await runScript( "./scripts/failing-script-load.js", - [], + "", env, new DeployerRunMode(deployerCfg) ), @@ -89,7 +89,7 @@ describe("Scripts runner", function () { it("Should ignore return value", async function () { const out = await runScript( "./scripts/successful-script-return-status.js", - [], + "", env, new DeployerRunMode(deployerCfg) ); From 2d7e029dbb62649b0fd8b56951dd3269c81d3b4c Mon Sep 17 00:00:00 2001 From: Ravinda Date: Mon, 28 Nov 2022 19:40:58 +0530 Subject: [PATCH 13/25] fix --- packages/algob/test/internal/util/scripts-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algob/test/internal/util/scripts-runner.ts b/packages/algob/test/internal/util/scripts-runner.ts index a352a1472..ff1e86940 100644 --- a/packages/algob/test/internal/util/scripts-runner.ts +++ b/packages/algob/test/internal/util/scripts-runner.ts @@ -59,7 +59,7 @@ describe("Scripts runner", function () { async () => await runScript( "./scripts/no-default-method-script.js", - [], + "", env, new DeployerRunMode(deployerCfg) ), From f33df973acd9ba28b95bafa60b53bd2a333a0163 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Mon, 28 Nov 2022 20:05:32 +0530 Subject: [PATCH 14/25] exmaple --- packages/algob/src/builtin-tasks/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index ef4b71d03..b20c22111 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -152,7 +152,7 @@ async function executeRunTask( } export default function (): void { - task(TASK_RUN, "Runs a user-defined script after compiling the project\n\nExample: yarn algob run script.js --args arg1 arg2 arg3") + task(TASK_RUN, `Runs a user-defined script after compiling the project\n\nExample: yarn algob run script.js --arg '{"firstname":"Jesper","surname":"Aaberg"}'`) .addVariadicPositionalParam("script", "A script file to be run within algob's environment.") .addOptionalParam("arg", "Argument to be passed in the script.") .setAction((input, env) => executeRunTask(input, env, createAlgoOperator(env.network))); From 09f543a63e146b7f606090e0a8cba8436bf66cfb Mon Sep 17 00:00:00 2001 From: Ravinda Date: Mon, 28 Nov 2022 20:23:11 +0530 Subject: [PATCH 15/25] fix --- packages/algob/src/builtin-tasks/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index b20c22111..3bb14d4f5 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -154,6 +154,6 @@ async function executeRunTask( export default function (): void { task(TASK_RUN, `Runs a user-defined script after compiling the project\n\nExample: yarn algob run script.js --arg '{"firstname":"Jesper","surname":"Aaberg"}'`) .addVariadicPositionalParam("script", "A script file to be run within algob's environment.") - .addOptionalParam("arg", "Argument to be passed in the script.") + .addOptionalParam("arg", "Argument in JSON string to be passed in the script.") .setAction((input, env) => executeRunTask(input, env, createAlgoOperator(env.network))); } From 88e57f2424e14d51cb2766efd8755fdbee15e9ed Mon Sep 17 00:00:00 2001 From: Ravindra Meena Date: Tue, 29 Nov 2022 13:42:24 +0530 Subject: [PATCH 16/25] Update packages/web/src/errors/errors-list.ts --- packages/web/src/errors/errors-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index a24704f4a..b0f74874a 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -669,7 +669,7 @@ Use 'deployer.isDefined(name)' to check if the name is already used. }, RUN_FILE_NOT_FOUND_WITH_SUGGESTION: { number: 617, - message: "Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3", + message: `Script not found. Please check the format: yarn algob run script.js --arg '' , title: "Run file not found.", description: `Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3`, } From ab73477e1b65b5d1ffd46be533be92379a9b2ce0 Mon Sep 17 00:00:00 2001 From: Ravindra Meena Date: Tue, 29 Nov 2022 13:42:41 +0530 Subject: [PATCH 17/25] Update packages/web/src/errors/errors-list.ts --- packages/web/src/errors/errors-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index b0f74874a..a5a78a594 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -671,7 +671,7 @@ Use 'deployer.isDefined(name)' to check if the name is already used. number: 617, message: `Script not found. Please check the format: yarn algob run script.js --arg '' , title: "Run file not found.", - description: `Script not found. Please check the format: yarn algob run script.js --args arg1 arg2 arg3`, + description: `Script not found. Please check the format: yarn algob run script.js --arg '' , } }; From 7c09a419a7eb80cfdfeb1c50edf59b7a6775d571 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Tue, 29 Nov 2022 13:51:29 +0530 Subject: [PATCH 18/25] fix --- packages/web/src/errors/errors-list.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index a5a78a594..5f67cd13a 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -669,9 +669,9 @@ Use 'deployer.isDefined(name)' to check if the name is already used. }, RUN_FILE_NOT_FOUND_WITH_SUGGESTION: { number: 617, - message: `Script not found. Please check the format: yarn algob run script.js --arg '' , + message: "Script not found. Please check the format: yarn algob run script.js --arg ''", title: "Run file not found.", - description: `Script not found. Please check the format: yarn algob run script.js --arg '' , + description: "Script not found. Please check the format: yarn algob run script.js --arg ''", } }; From 20f5e25f7eb15cc9646ea8c6369b905a679b730e Mon Sep 17 00:00:00 2001 From: Ravinda Date: Tue, 29 Nov 2022 14:23:00 +0530 Subject: [PATCH 19/25] valid json --- packages/algob/src/builtin-tasks/run.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index 3bb14d4f5..2056e80af 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -116,6 +116,15 @@ async function runScripts( } } +const isValidJsonString = (str: string) => { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; +} + async function executeRunTask( { script, arg }: Input, runtimeEnv: RuntimeEnv, @@ -123,6 +132,9 @@ async function executeRunTask( ): Promise { const logDebugTag = "algob:tasks:run"; let scriptName; + if (arg && !isValidJsonString(arg)) { + throw Error("The argument passed is not a valid JSON string."); + } if (script && script.length) { // get script from script array, first element should be script scriptName = script[0]; From f2e94fec6df4f58935f129b26369eb1c93392b9c Mon Sep 17 00:00:00 2001 From: Ravinda Date: Tue, 29 Nov 2022 14:26:37 +0530 Subject: [PATCH 20/25] fix --- packages/algob/test/builtin-tasks/run.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/algob/test/builtin-tasks/run.ts b/packages/algob/test/builtin-tasks/run.ts index b6ddaa174..b176fd92a 100644 --- a/packages/algob/test/builtin-tasks/run.ts +++ b/packages/algob/test/builtin-tasks/run.ts @@ -77,6 +77,13 @@ describe("Run task", function () { ); }); + it("Should throw error when a valid JSON string is not passed as argument in the script", async function () { + assert.throws(async () => await this.env.run(TASK_RUN, { + script: ["./scripts/async-script.js"], + args: "{name: users-name}" + })) + }); + /* TODO:MM compile before running the task it("Should compile before running", async function () { if (await fsExtra.pathExists("cache")) { From 0e8659efc3a27551772dd7f6023f725871e91a83 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Tue, 29 Nov 2022 15:17:36 +0530 Subject: [PATCH 21/25] fix --- packages/algob/src/builtin-tasks/run.ts | 2 +- packages/algob/test/builtin-tasks/run.ts | 16 ++++++++++------ packages/web/src/errors/errors-list.ts | 8 +++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index 2056e80af..d35c66980 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -133,7 +133,7 @@ async function executeRunTask( const logDebugTag = "algob:tasks:run"; let scriptName; if (arg && !isValidJsonString(arg)) { - throw Error("The argument passed is not a valid JSON string."); + throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_ARGUMENT_INVALID); } if (script && script.length) { // get script from script array, first element should be script diff --git a/packages/algob/test/builtin-tasks/run.ts b/packages/algob/test/builtin-tasks/run.ts index b176fd92a..b2e74670e 100644 --- a/packages/algob/test/builtin-tasks/run.ts +++ b/packages/algob/test/builtin-tasks/run.ts @@ -44,14 +44,14 @@ describe("Run task", function () { it("Should run the script with empty arguments", async function () { await this.env.run(TASK_RUN, { script: ["./scripts/async-script.js"], - args: "" + arg: "" }); }); it("Should run the script with arguments", async function () { await this.env.run(TASK_RUN, { script: ["./scripts/async-script.js"], - args: "arg1" + arg: "arg1" }); }); @@ -78,10 +78,14 @@ describe("Run task", function () { }); it("Should throw error when a valid JSON string is not passed as argument in the script", async function () { - assert.throws(async () => await this.env.run(TASK_RUN, { - script: ["./scripts/async-script.js"], - args: "{name: users-name}" - })) + await expectBuilderErrorAsync( + async () => + await this.env.run(TASK_RUN, { + script: ["./scripts/async-script.js"], + arg: "{name: usersname}" + }), + ERRORS.BUILTIN_TASKS.RUN_ARGUMENT_INVALID + ); }); /* TODO:MM compile before running the task diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index 5f67cd13a..64a2cd7d3 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -672,7 +672,13 @@ Use 'deployer.isDefined(name)' to check if the name is already used. message: "Script not found. Please check the format: yarn algob run script.js --arg ''", title: "Run file not found.", description: "Script not found. Please check the format: yarn algob run script.js --arg ''", - } + }, + RUN_ARGUMENT_INVALID: { + number: 618, + message: "The JSON string passed is invalid.", + title: "Run argument is invalid.", + description: "The JSON string passed is invalid.", + }, }; export const pluginErrors = { From 7257dfeb3b248af8cc5698f39ee49f7856057f30 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Tue, 29 Nov 2022 15:27:24 +0530 Subject: [PATCH 22/25] fix --- packages/algob/test/builtin-tasks/run.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/algob/test/builtin-tasks/run.ts b/packages/algob/test/builtin-tasks/run.ts index b2e74670e..07b7c9331 100644 --- a/packages/algob/test/builtin-tasks/run.ts +++ b/packages/algob/test/builtin-tasks/run.ts @@ -51,11 +51,10 @@ describe("Run task", function () { it("Should run the script with arguments", async function () { await this.env.run(TASK_RUN, { script: ["./scripts/async-script.js"], - arg: "arg1" + arg: '{"name":"user"}' }); }); - it("Should fail if a script is not passed as first element of script array", async function () { await expectBuilderErrorAsync( async () => From 16ff230567db0449613f9326d77842b264b7ad8d Mon Sep 17 00:00:00 2001 From: Ravinda Date: Thu, 1 Dec 2022 14:53:21 +0530 Subject: [PATCH 23/25] example --- .github/workflows/05-examples.yaml | 4 +++ examples/script-argument-example/.gitignore | 1 + examples/script-argument-example/README.md | 7 +++++ .../script-argument-example/algob.config.js | 14 ++++++++++ examples/script-argument-example/package.json | 26 +++++++++++++++++++ .../script-argument-example/scripts/script.js | 6 +++++ yarn.lock | 13 ++++++++++ 7 files changed, 71 insertions(+) create mode 100644 examples/script-argument-example/.gitignore create mode 100644 examples/script-argument-example/README.md create mode 100644 examples/script-argument-example/algob.config.js create mode 100644 examples/script-argument-example/package.json create mode 100644 examples/script-argument-example/scripts/script.js diff --git a/.github/workflows/05-examples.yaml b/.github/workflows/05-examples.yaml index 724769c02..700f61ee7 100644 --- a/.github/workflows/05-examples.yaml +++ b/.github/workflows/05-examples.yaml @@ -233,3 +233,7 @@ jobs: run: | pipenv run yarn algob deploy pipenv run yarn algob run scripts/run/create-fund-app.js + - name: Script Argument Example + working-directory: ./examples/script-argument-example + run: | + pipenv run yarn algob run scripts/script.js --arg '{"name":"this was passed as agrument"}' diff --git a/examples/script-argument-example/.gitignore b/examples/script-argument-example/.gitignore new file mode 100644 index 000000000..40b878db5 --- /dev/null +++ b/examples/script-argument-example/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/examples/script-argument-example/README.md b/examples/script-argument-example/README.md new file mode 100644 index 000000000..b74e6823b --- /dev/null +++ b/examples/script-argument-example/README.md @@ -0,0 +1,7 @@ +# Script argument example + +This example demonstrates how you can pass arguments to script. + +The format for passing arguments: + +`yarn algob script.js --arg ''` diff --git a/examples/script-argument-example/algob.config.js b/examples/script-argument-example/algob.config.js new file mode 100644 index 000000000..bf18e5b14 --- /dev/null +++ b/examples/script-argument-example/algob.config.js @@ -0,0 +1,14 @@ +const fs = require("fs"); + +// check if local config in /examples exists if yes then use it, otherwise use a template +// config provided by this repository. + +let config = "../algob.config-local.js"; +try { + fs.accessSync(config, fs.constants.F_OK); +} catch { + config = "../algob.config-template.js"; +} +console.log("config file: ", config); + +module.exports = require(config); diff --git a/examples/script-argument-example/package.json b/examples/script-argument-example/package.json new file mode 100644 index 000000000..d3eba3891 --- /dev/null +++ b/examples/script-argument-example/package.json @@ -0,0 +1,26 @@ +{ + "name": "script-argument-example", + "version": "1.0.0", + "main": "index.js", + "license": "Apache-2.0", + "dependencies": { + "@algo-builder/algob": "workspace:*", + "@algo-builder/runtime": "workspace:*", + "@algo-builder/web": "workspace:*", + "algosdk": "^1.22.0" + }, + "devDependencies": { + "eslint": "^8.26.0", + "mocha": "^10.1.0" + }, + "scripts": { + "algob": "algob", + "lint:check": "eslint --ext .js,.ts scripts", + "lint": "eslint --fix --ext .js,.ts scripts", + "build:docs": "echo ok", + "build": "echo ok" + }, + "mocha": { + "file": "../../test/setup.js" + } +} diff --git a/examples/script-argument-example/scripts/script.js b/examples/script-argument-example/scripts/script.js new file mode 100644 index 000000000..c7c7d587b --- /dev/null +++ b/examples/script-argument-example/scripts/script.js @@ -0,0 +1,6 @@ +async function run(runtimeEnv, deployer, arg) { + // arguments received here + console.log(arg); +} + +module.exports = { default: run }; diff --git a/yarn.lock b/yarn.lock index 66ffd756b..b2c9634bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5888,6 +5888,19 @@ __metadata: languageName: node linkType: hard +"script-argument-example@workspace:examples/script-argument-example": + version: 0.0.0-use.local + resolution: "script-argument-example@workspace:examples/script-argument-example" + dependencies: + "@algo-builder/algob": "workspace:*" + "@algo-builder/runtime": "workspace:*" + "@algo-builder/web": "workspace:*" + algosdk: ^1.22.0 + eslint: ^8.26.0 + mocha: ^10.1.0 + languageName: unknown + linkType: soft + "seek-bzip@npm:^1.0.5": version: 1.0.6 resolution: "seek-bzip@npm:1.0.6" From d4b7b4611b4d9054b938f4b82f27cd2f3a2fe93e Mon Sep 17 00:00:00 2001 From: Ravindra Meena Date: Fri, 2 Dec 2022 12:54:05 +0530 Subject: [PATCH 24/25] Update packages/web/src/errors/errors-list.ts Co-authored-by: thdailong --- packages/web/src/errors/errors-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index 64a2cd7d3..0e2fa1205 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -675,7 +675,7 @@ Use 'deployer.isDefined(name)' to check if the name is already used. }, RUN_ARGUMENT_INVALID: { number: 618, - message: "The JSON string passed is invalid.", + message: "The JSON string passed %jsonString% is invalid.", title: "Run argument is invalid.", description: "The JSON string passed is invalid.", }, From 98ee79a1dd287b10baff163a5369fff2b395eab4 Mon Sep 17 00:00:00 2001 From: Ravinda Date: Fri, 2 Dec 2022 13:00:45 +0530 Subject: [PATCH 25/25] args --- packages/algob/src/builtin-tasks/run.ts | 4 +++- packages/web/src/errors/errors-list.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/algob/src/builtin-tasks/run.ts b/packages/algob/src/builtin-tasks/run.ts index d35c66980..2fc66c0e4 100644 --- a/packages/algob/src/builtin-tasks/run.ts +++ b/packages/algob/src/builtin-tasks/run.ts @@ -133,7 +133,9 @@ async function executeRunTask( const logDebugTag = "algob:tasks:run"; let scriptName; if (arg && !isValidJsonString(arg)) { - throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_ARGUMENT_INVALID); + throw new BuilderError(ERRORS.BUILTIN_TASKS.RUN_ARGUMENT_INVALID, { + jsonString: arg + }); } if (script && script.length) { // get script from script array, first element should be script diff --git a/packages/web/src/errors/errors-list.ts b/packages/web/src/errors/errors-list.ts index 0e2fa1205..ba80a771f 100644 --- a/packages/web/src/errors/errors-list.ts +++ b/packages/web/src/errors/errors-list.ts @@ -675,9 +675,9 @@ Use 'deployer.isDefined(name)' to check if the name is already used. }, RUN_ARGUMENT_INVALID: { number: 618, - message: "The JSON string passed %jsonString% is invalid.", + message: "Invalid JSON string: %jsonString%", title: "Run argument is invalid.", - description: "The JSON string passed is invalid.", + description: "Invalid JSON string: %jsonString%", }, };