├── .editorconfig
├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── pull_request_template.md
└── workflows
│ ├── 01-main.yaml
│ ├── 05-examples.yaml
│ └── reusable-workflow.yaml
├── .gitignore
├── .husky
├── .gitignore
├── pre-commit
└── pre-push
├── .mocharc.json
├── .prettierignore
├── .prettierrc.toml
├── .yarn
├── plugins
│ └── @yarnpkg
│ │ └── plugin-workspace-tools.cjs
└── releases
│ └── yarn-3.3.0.cjs
├── .yarnrc.yml
├── @types
└── .gitkeep
├── CHANGELOG.md
├── LICENSE
├── Pipfile
├── Pipfile.lock
├── README.md
├── algobsetup
├── check_only.sh
├── cleanup.sh
├── docs
├── .gitignore
├── 404.html
├── CNAME
├── Gemfile
├── Gemfile.lock
├── _config.yml
├── _css
│ ├── bootstrap.css
│ └── main.css
├── _data
│ └── navigation.yml
├── _includes
│ ├── donate-modal.html
│ └── head
│ │ └── custom.html
├── _js
│ └── scripts.js
├── _layouts
│ ├── default.html
│ └── landingpage.html
├── _sass
│ ├── minimal-mistakes.scss
│ └── minimal-mistakes
│ │ └── _variables.scss
├── assets
│ ├── audit-diagram.dia
│ ├── audit-diagram.png
│ └── trophy.png
├── auditing.html
├── guide
│ ├── README.md
│ ├── algob-config.md
│ ├── algob-console.md
│ ├── algob-web.md
│ ├── best-practices.md
│ ├── debugging-teal.md
│ ├── deployer.md
│ ├── execute-transaction.md
│ ├── execution-checkpoints.md
│ ├── logs.md
│ ├── purestake-api.md
│ ├── py-teal.md
│ ├── runtime-advanced.md
│ ├── sign-multisig.md
│ ├── signedTransaction.md
│ ├── templates.md
│ ├── testing-teal.md
│ └── user-script-execution.md
├── index.html
├── media
│ ├── .gitignore
│ ├── algob-icon.png
│ ├── algob-icon.xcf
│ ├── logo-icon.png
│ ├── logo-sq-color.png
│ ├── logo-website.png
│ ├── logo.png
│ ├── logo.svg
│ └── oldlogo
│ │ └── logo.svg
└── tutorials
│ ├── t-01.md
│ ├── t-02.md
│ ├── t-03.md
│ ├── t-04.md
│ ├── t-08.md
│ ├── t-08
│ └── assets
│ │ ├── all-wallets.png
│ │ ├── select-wallet.png
│ │ └── wallet-connected.png
│ ├── t-09.md
│ ├── t-09
│ └── assets
│ │ ├── algosigner.png
│ │ ├── myalgo-1.png
│ │ ├── myalgo-2.png
│ │ └── myalgo-3.png
│ ├── t-10.md
│ ├── t-wallet.md
│ ├── t-wallet
│ └── assets
│ │ ├── address_selected.png
│ │ ├── algo_transaction.png
│ │ ├── homescreen.png
│ │ ├── select_network.png
│ │ └── styled_wallet.png
│ ├── tutorial-pipelineui.md
│ └── tutorial-pipelineui
│ └── assets
│ ├── algosigner.png
│ ├── app-deployed.png
│ ├── default-screen-load.png
│ └── increase-counter.png
├── examples
├── .DS_Store
├── .gitignore
├── README.md
├── algob.config-template.js
├── algobpy
│ ├── .gitignore
│ ├── __init__.py
│ └── parse.py
├── asa
│ ├── .DS_Store
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── .DS_Store
│ │ ├── asa.yaml
│ │ ├── pyteal
│ │ │ ├── 4-gold-asa.py
│ │ │ ├── 5-clear.py
│ │ │ ├── 5-contract-asa-stateful.py
│ │ │ └── 5-contract-asa-stateless.py
│ │ └── teal
│ │ │ ├── 2-gold-contract-asc.teal
│ │ │ ├── 3-gold-delegated-asc.teal
│ │ │ └── 4-gold-asa.teal
│ ├── index.js
│ ├── package.json
│ └── scripts
│ │ ├── .DS_Store
│ │ ├── 0-gold-asa.js
│ │ ├── 1-tesla-asa.js
│ │ ├── 2-gold-asc.js
│ │ ├── 3-contract-owned-asa.js
│ │ ├── query
│ │ └── john-balances.js
│ │ └── transfer
│ │ ├── common.js
│ │ ├── contract-owned-asa
│ │ ├── change-contract-owner.js
│ │ ├── contract-to-alice.js
│ │ └── contract-to-bob.js
│ │ ├── gold-contract-sc.js
│ │ ├── gold-delegated-lsig.debug.js
│ │ ├── gold-delegated-lsig.js
│ │ ├── gold-to-john.js
│ │ ├── master-fund-john.js
│ │ └── tesla-to-john.js
├── bond
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── asa.yaml
│ │ ├── bond-dapp-clear.py
│ │ ├── bond-dapp-stateful.py
│ │ ├── buyback-lsig.py
│ │ ├── dex-lsig.py
│ │ └── issuer-lsig.py
│ ├── package.json
│ ├── scripts
│ │ ├── deploy.js
│ │ └── run
│ │ │ ├── common
│ │ │ ├── accounts.js
│ │ │ └── common.js
│ │ │ ├── createBuyback.js
│ │ │ ├── createDex.js
│ │ │ ├── epoch0.js
│ │ │ ├── epoch1.js
│ │ │ ├── exit.js
│ │ │ ├── issue.js
│ │ │ ├── redeem.js
│ │ │ └── run.js
│ └── test
│ │ ├── bond-token-flow.js
│ │ ├── common
│ │ └── common.js
│ │ └── failing-tests.js
├── crowdfunding
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── crowdFundApproval.teal
│ │ ├── crowdFundClear.teal
│ │ ├── crowdFundEscrow.py
│ │ └── wrongEscrow.teal
│ ├── package.json
│ ├── scripts
│ │ ├── common
│ │ │ └── common.js
│ │ ├── createApp.js
│ │ └── transfer
│ │ │ ├── claim.js
│ │ │ ├── delete.js
│ │ │ ├── donate.js
│ │ │ └── reclaim.js
│ └── test
│ │ ├── crowdfundingTest.js
│ │ ├── failing-tests.js
│ │ └── happypaths.js
├── dao
│ └── README.md
├── htlc-pyteal-ts
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ └── htlc.py
│ ├── package.json
│ ├── scripts
│ │ ├── deploy.ts
│ │ └── withdraw
│ │ │ ├── common.ts
│ │ │ └── htlc-withdraw.ts
│ └── tsconfig.json
├── inner-tx-create-assets
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── asa.yaml
│ │ ├── clear.teal
│ │ └── coordinator.py
│ ├── package.json
│ ├── scripts
│ │ ├── common
│ │ │ └── common.js
│ │ ├── deploy.js
│ │ ├── run
│ │ │ ├── useGroupTxn.js
│ │ │ └── useInnerTxn.js
│ │ └── utils
│ │ │ └── index.js
│ └── test
│ │ ├── groupTxn.js
│ │ └── innerTxn.js
├── multisig
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── sample-asc.teal
│ │ ├── sample-raw-asc.blsig
│ │ └── sample-text-asc.lsig
│ ├── package.json
│ └── scripts
│ │ ├── common
│ │ └── common.js
│ │ ├── multisig_goal_sc.js
│ │ └── multisig_sdk_sc.js
├── nft
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── nft_approval.py
│ │ └── nft_clear_state.py
│ ├── package.json
│ └── scripts
│ │ ├── deploy-nft.js
│ │ └── transfer
│ │ ├── common.js
│ │ └── create-transfer-nft.js
├── permissioned-token-freezing
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── asa.yaml
│ │ ├── clawback-escrow.py
│ │ ├── poi-approval.teal
│ │ └── poi-clear.teal
│ ├── package.json
│ ├── scripts
│ │ ├── 0-createAppAsset.js
│ │ ├── 1-assetConfig.js
│ │ ├── common
│ │ │ └── common.js
│ │ └── transfer
│ │ │ ├── set-clear-level.js
│ │ │ ├── transfer-asset.debug.js
│ │ │ └── transfer-asset.js
│ └── test
│ │ └── asset-txfer-test.js
├── permissioned-token
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── asa.yaml
│ │ ├── clawback.py
│ │ ├── clear_state_program.py
│ │ ├── controller.py
│ │ ├── permissions.py
│ │ └── permissions_new.teal
│ ├── package.json
│ ├── scripts
│ │ ├── 0-setup-token.js
│ │ ├── 1-setup-controller.js
│ │ ├── 2-asset-clawback.js
│ │ ├── 3-setup-permissions.js
│ │ ├── 4-setup-new-permissions-app.js
│ │ ├── admin
│ │ │ ├── cease.js
│ │ │ ├── force-transfer.js
│ │ │ ├── issue.js
│ │ │ ├── kill.js
│ │ │ └── update-reserve.js
│ │ ├── common
│ │ │ ├── accounts.js
│ │ │ └── common.js
│ │ ├── permissions
│ │ │ ├── change-perm-manager.js
│ │ │ ├── set-permission-appid.js
│ │ │ └── whitelist.js
│ │ └── user
│ │ │ ├── opt-out.js
│ │ │ └── transfer.js
│ └── test
│ │ ├── common.js
│ │ ├── failing-paths.js
│ │ └── happy-paths.js
├── permissioned-voting
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── asa.yaml
│ │ ├── permissioned-voting-approval.py
│ │ └── permissioned-voting-clear.py
│ ├── package.json
│ └── scripts
│ │ ├── vote
│ │ ├── common.js
│ │ ├── result.js
│ │ └── vote.js
│ │ └── voting.js
├── ref-templates
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── dynamic-fee.py
│ │ └── htlc.py
│ ├── package.json
│ └── scripts
│ │ ├── common
│ │ └── common.js
│ │ ├── dynamic-fee.js
│ │ └── htlc.js
├── script-argument-example
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── package.json
│ └── scripts
│ │ └── script.js
├── signed-txn
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ └── john-to-bob.txn
│ ├── package.json
│ └── scripts
│ │ └── transfer.js
├── stateful-counter
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── approval_program.teal
│ │ └── clear_program.teal
│ ├── index.js
│ ├── package.json
│ └── scripts
│ │ ├── common
│ │ └── common.js
│ │ ├── deploy.js
│ │ └── interaction
│ │ ├── call_application.js
│ │ ├── delete_application.js
│ │ └── update_application.js
├── trampoline
│ ├── .gitignore
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ │ ├── approval.teal
│ │ ├── clear.teal
│ │ └── fundApplication.py
│ ├── package.json
│ └── scripts
│ │ ├── common
│ │ └── common.js
│ │ ├── deployApp.js
│ │ └── run
│ │ └── create-fund-app.js
└── unique-nft-asa
│ ├── README.md
│ ├── algob.config.js
│ ├── assets
│ ├── asa.yaml
│ ├── nft-app-approval.py
│ ├── nft-app-clear.py
│ └── stateless.py
│ ├── package.json
│ ├── scripts
│ ├── 0-deploy-app.js
│ ├── 1-create-nft.js
│ └── run
│ │ ├── common
│ │ └── common.js
│ │ └── transfer-nft.js
│ └── test
│ └── test.js
├── infrastructure
├── .DS_Store
├── .gitignore
├── Makefile
├── README.md
├── private-net-template.json
└── sandbox-docker-compose.yml
├── package.json
├── packages
├── algob
│ ├── .eslintignore
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .mocharc.json
│ ├── LICENSE
│ ├── README.md
│ ├── package.json
│ ├── prepublish.sh
│ ├── project-dev-script.sh
│ ├── sample-project
│ │ ├── common
│ │ │ ├── .gitignore
│ │ │ ├── .yarnrc.yml
│ │ │ ├── algobpy
│ │ │ │ ├── .gitignore
│ │ │ │ ├── __init__.py
│ │ │ │ └── parse.py
│ │ │ └── assets
│ │ │ │ ├── accounts_user.yaml
│ │ │ │ ├── asa.yaml
│ │ │ │ ├── escrow.py
│ │ │ │ └── fee-check.teal
│ │ ├── infrastructure
│ │ │ ├── .gitignore
│ │ │ ├── Makefile
│ │ │ ├── README.md
│ │ │ └── sandbox-docker-compose.yml
│ │ ├── js
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── algob.config.js
│ │ │ ├── package.json
│ │ │ ├── scripts
│ │ │ │ ├── 0-sampleScript.js
│ │ │ │ ├── 1-sampleScript.js
│ │ │ │ └── 2-escrow-account.js
│ │ │ └── test
│ │ │ │ └── sample-test.js
│ │ └── ts
│ │ │ ├── .gitignore
│ │ │ ├── .mocharc.json
│ │ │ ├── README.md
│ │ │ ├── algob.config.ts
│ │ │ ├── package.json
│ │ │ ├── scripts
│ │ │ ├── 0-sampleScript.ts
│ │ │ ├── 1-sampleScript.ts
│ │ │ └── 2-escrow-account.ts
│ │ │ ├── test
│ │ │ ├── sample-test.ts
│ │ │ └── tsconfig.json
│ │ │ └── tsconfig.json
│ ├── src
│ │ ├── builtin-tasks
│ │ │ ├── clean.ts
│ │ │ ├── compile.ts
│ │ │ ├── console.ts
│ │ │ ├── deploy.ts
│ │ │ ├── gen-accounts.ts
│ │ │ ├── help.ts
│ │ │ ├── init.ts
│ │ │ ├── node-info.ts
│ │ │ ├── run.ts
│ │ │ ├── sign-lsig.ts
│ │ │ ├── sign-multisig.ts
│ │ │ ├── task-names.ts
│ │ │ ├── test.ts
│ │ │ └── unbox-template.ts
│ │ ├── config.ts
│ │ ├── index.ts
│ │ ├── internal
│ │ │ ├── cli
│ │ │ │ ├── arguments-parser.ts
│ │ │ │ ├── cli.ts
│ │ │ │ ├── help-printer.ts
│ │ │ │ ├── project-creation.ts
│ │ │ │ └── unbox-template.ts
│ │ │ ├── constants.ts
│ │ │ ├── context.ts
│ │ │ ├── core
│ │ │ │ ├── config
│ │ │ │ │ ├── config-env.ts
│ │ │ │ │ ├── config-errors.ts
│ │ │ │ │ ├── config-loading.ts
│ │ │ │ │ ├── config-resolution.ts
│ │ │ │ │ ├── config-validation.ts
│ │ │ │ │ ├── default-config.ts
│ │ │ │ │ └── extenders.ts
│ │ │ │ ├── errors
│ │ │ │ │ └── errors.ts
│ │ │ │ ├── execution-mode.ts
│ │ │ │ ├── params
│ │ │ │ │ ├── argument-types.ts
│ │ │ │ │ ├── builder-params.ts
│ │ │ │ │ └── env-variables.ts
│ │ │ │ ├── plugins.ts
│ │ │ │ ├── project-structure.ts
│ │ │ │ ├── runtime-environment.ts
│ │ │ │ └── tasks
│ │ │ │ │ ├── builtin-tasks.ts
│ │ │ │ │ ├── dsl.ts
│ │ │ │ │ └── task-definitions.ts
│ │ │ ├── deployer.ts
│ │ │ ├── deployer_cfg.ts
│ │ │ ├── reset.ts
│ │ │ ├── tx-log-writer.ts
│ │ │ └── util
│ │ │ │ ├── caller-package.ts
│ │ │ │ ├── console.ts
│ │ │ │ ├── files.ts
│ │ │ │ ├── lang.ts
│ │ │ │ ├── lazy.ts
│ │ │ │ ├── lists.ts
│ │ │ │ ├── package-info.ts
│ │ │ │ ├── scripts-runner.ts
│ │ │ │ ├── strings.ts
│ │ │ │ ├── unpack.ts
│ │ │ │ └── unsafe.ts
│ │ ├── lib
│ │ │ ├── account.ts
│ │ │ ├── algo-operator.ts
│ │ │ ├── comparators.ts
│ │ │ ├── compile.ts
│ │ │ ├── constants.ts
│ │ │ ├── credentials.ts
│ │ │ ├── driver.ts
│ │ │ ├── dryrun.ts
│ │ │ ├── exceptions.ts
│ │ │ ├── files.ts
│ │ │ ├── lsig.ts
│ │ │ ├── msig.ts
│ │ │ ├── script-checkpoints.ts
│ │ │ ├── status.ts
│ │ │ ├── time.ts
│ │ │ └── tx.ts
│ │ ├── register.ts
│ │ ├── runtime.ts
│ │ └── types.ts
│ ├── test
│ │ ├── .eslintrc.json
│ │ ├── builtin-tasks
│ │ │ ├── .eslintrc.json
│ │ │ ├── clean.ts
│ │ │ ├── compile.ts
│ │ │ ├── deploy.ts
│ │ │ ├── gen-accounts.ts
│ │ │ ├── run.ts
│ │ │ ├── sign-lsig.ts
│ │ │ ├── sign-multisig.ts
│ │ │ └── test.ts
│ │ ├── fixture-projects
│ │ │ ├── .eslintrc.json
│ │ │ ├── abi-contract
│ │ │ │ └── basic-abi.json
│ │ │ ├── algorand-node-data
│ │ │ │ └── Node
│ │ │ │ │ ├── algod.net
│ │ │ │ │ ├── algod.token
│ │ │ │ │ └── kmd
│ │ │ │ │ ├── kmd.net
│ │ │ │ │ └── kmd.token
│ │ │ ├── broken-typescript-config-project
│ │ │ │ ├── algob.config.ts
│ │ │ │ └── tsconfig.json
│ │ │ ├── config-extensions
│ │ │ │ └── algob.config.js
│ │ │ ├── config-project
│ │ │ │ ├── .gitignore
│ │ │ │ ├── algob.config.js
│ │ │ │ └── assets
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── accounts_user.yaml
│ │ │ │ │ ├── asc-fee-check.copy.teal
│ │ │ │ │ ├── asc-fee-check.teal
│ │ │ │ │ ├── gold-asa-py-check.yaml
│ │ │ │ │ ├── gold-asa.py
│ │ │ │ │ ├── gold-asa.teal
│ │ │ │ │ ├── multi-signed-lsig.blsig
│ │ │ │ │ ├── multisig-group.tx
│ │ │ │ │ ├── multisig-signed.txn
│ │ │ │ │ ├── multisig-unsigned.txn
│ │ │ │ │ └── single-signed-lsig.blsig
│ │ │ ├── custom-config-file
│ │ │ │ └── config.js
│ │ │ ├── default-config-project
│ │ │ │ ├── algob.config.js
│ │ │ │ └── contracts
│ │ │ │ │ └── .gitkeep
│ │ │ ├── init-task
│ │ │ │ └── README.md
│ │ │ ├── invalid-config-extension
│ │ │ │ └── algob.config.js
│ │ │ ├── invalid-config
│ │ │ │ └── algob.config.js
│ │ │ ├── nested-node-project
│ │ │ │ ├── node_modules
│ │ │ │ │ ├── clashed
│ │ │ │ │ │ └── package.json
│ │ │ │ │ └── outer
│ │ │ │ │ │ └── package.json
│ │ │ │ ├── package.json
│ │ │ │ ├── project
│ │ │ │ │ ├── nested-caller-package-tester.ts
│ │ │ │ │ └── package.json
│ │ │ │ └── top-caller-package-tester.ts
│ │ │ ├── plugin-loading-project
│ │ │ │ └── node_modules
│ │ │ │ │ ├── pack1
│ │ │ │ │ ├── index.js
│ │ │ │ │ ├── package.json
│ │ │ │ │ ├── plugin-with-function-default-export.js
│ │ │ │ │ ├── plugin-with-function.js
│ │ │ │ │ └── plugin-without-function.js
│ │ │ │ │ ├── prerelease
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── package.json
│ │ │ │ │ ├── requires-missing-pack
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── package.json
│ │ │ │ │ ├── requires-other-version-pack1
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── package.json
│ │ │ │ │ ├── requires-pack1
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── package.json
│ │ │ │ │ └── requires-prerelease
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── package.json
│ │ │ ├── plugin-project
│ │ │ │ ├── buidler-config.ts
│ │ │ │ ├── builder-config.ts
│ │ │ │ └── plugins
│ │ │ │ │ └── example.ts
│ │ │ ├── project-with-scripts
│ │ │ │ ├── .gitignore
│ │ │ │ ├── algob.config.js
│ │ │ │ └── scripts
│ │ │ │ │ ├── async-script.js
│ │ │ │ │ ├── failing-script-load.js
│ │ │ │ │ ├── failing-script.js
│ │ │ │ │ ├── no-default-method-script.js
│ │ │ │ │ ├── params-script.js
│ │ │ │ │ ├── successful-script-return-status.js
│ │ │ │ │ └── successful-script.js
│ │ │ ├── scripts-dir-cp-state
│ │ │ │ ├── .gitignore
│ │ │ │ ├── algob.config.js
│ │ │ │ └── scripts
│ │ │ │ │ ├── 1.js
│ │ │ │ │ ├── 2.js
│ │ │ │ │ └── 3.js
│ │ │ ├── scripts-dir-empty
│ │ │ │ ├── .gitignore
│ │ │ │ ├── algob.config.js
│ │ │ │ └── scripts
│ │ │ │ │ └── .gitkeep
│ │ │ ├── scripts-dir-none
│ │ │ │ ├── .gitignore
│ │ │ │ └── algob.config.js
│ │ │ ├── scripts-dir-recursive-cp
│ │ │ │ ├── .gitignore
│ │ │ │ ├── algob.config.js
│ │ │ │ ├── assets
│ │ │ │ │ └── asa.yaml
│ │ │ │ └── scripts
│ │ │ │ │ ├── 1.js
│ │ │ │ │ ├── 2.js
│ │ │ │ │ ├── nested
│ │ │ │ │ └── nested.js
│ │ │ │ │ └── query.js
│ │ │ ├── scripts-dir
│ │ │ │ ├── .gitignore
│ │ │ │ ├── 1.js
│ │ │ │ ├── algob.config.js
│ │ │ │ └── scripts
│ │ │ │ │ ├── 1.js
│ │ │ │ │ ├── 2.js
│ │ │ │ │ ├── directory
│ │ │ │ │ └── no-run.js
│ │ │ │ │ └── other-scripts
│ │ │ │ │ ├── 1.js
│ │ │ │ │ ├── deploy-asa.js
│ │ │ │ │ ├── deploy-asc.js
│ │ │ │ │ ├── failing.js
│ │ │ │ │ └── put-metadata.js
│ │ │ ├── stateful
│ │ │ │ ├── .gitignore
│ │ │ │ ├── artifacts
│ │ │ │ │ └── .cp.yaml
│ │ │ │ └── assets
│ │ │ │ │ ├── approval.teal
│ │ │ │ │ └── clear.teal
│ │ │ ├── support-external-parameters
│ │ │ │ ├── algob.config.js
│ │ │ │ └── assets
│ │ │ │ │ ├── accounts_user.yaml
│ │ │ │ │ ├── algobpy
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── parse.py
│ │ │ │ │ ├── stateful.py
│ │ │ │ │ └── stateless.py
│ │ │ ├── support-tmpl-parameters
│ │ │ │ ├── assets
│ │ │ │ │ ├── algobpy
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── __pycache__
│ │ │ │ │ │ │ ├── __init__.cpython-38.pyc
│ │ │ │ │ │ │ └── parse.cpython-38.pyc
│ │ │ │ │ │ └── parse.py
│ │ │ │ │ ├── stateful.py
│ │ │ │ │ └── stateless.py
│ │ │ │ ├── expected-stateful.teal
│ │ │ │ └── expected-stateless.teal
│ │ │ ├── top-level-node-project
│ │ │ │ └── node_modules
│ │ │ │ │ └── lib
│ │ │ │ │ └── package.json
│ │ │ └── typescript-project
│ │ │ │ ├── algob.config.ts
│ │ │ │ ├── script.ts
│ │ │ │ ├── test
│ │ │ │ ├── js-test.js
│ │ │ │ └── ts-test.ts
│ │ │ │ └── tsconfig.json
│ │ ├── helpers
│ │ │ ├── assert-methods.ts
│ │ │ ├── environment.test.ts
│ │ │ ├── environment.ts
│ │ │ ├── errors.ts
│ │ │ ├── fs.ts
│ │ │ ├── params.ts
│ │ │ └── project.ts
│ │ ├── internal
│ │ │ ├── cli
│ │ │ │ ├── arguments-parser.ts
│ │ │ │ └── project-creation.ts
│ │ │ ├── context.ts
│ │ │ ├── core
│ │ │ │ ├── config
│ │ │ │ │ ├── config-extensions.ts
│ │ │ │ │ ├── config-loading.ts
│ │ │ │ │ ├── config-resolution.ts
│ │ │ │ │ └── config-validation.ts
│ │ │ │ ├── errors.ts
│ │ │ │ ├── params
│ │ │ │ │ ├── argument-types.ts
│ │ │ │ │ └── env-variables.ts
│ │ │ │ ├── plugins.ts
│ │ │ │ ├── project-structure.ts
│ │ │ │ ├── runtime-environment.ts
│ │ │ │ └── tasks
│ │ │ │ │ ├── dsl.ts
│ │ │ │ │ └── task-definitions.ts
│ │ │ ├── deployer.ts
│ │ │ ├── tx-log-writer.ts
│ │ │ └── util
│ │ │ │ ├── caller-package.ts
│ │ │ │ ├── files.ts
│ │ │ │ ├── lang.ts
│ │ │ │ ├── lazy.ts
│ │ │ │ ├── lists.ts
│ │ │ │ ├── package-info.ts
│ │ │ │ ├── scripts-runner.ts
│ │ │ │ ├── strings.ts
│ │ │ │ └── unsafe.ts
│ │ ├── lib
│ │ │ ├── account.ts
│ │ │ ├── credentials.ts
│ │ │ ├── dryrun.ts
│ │ │ ├── files.ts
│ │ │ ├── script-checkpoints.ts
│ │ │ ├── status.ts
│ │ │ └── tx.ts
│ │ ├── mocks
│ │ │ ├── account.ts
│ │ │ ├── deployer.ts
│ │ │ └── tx.ts
│ │ ├── stubs
│ │ │ └── algo-operator.ts
│ │ └── tsconfig.json
│ └── tsconfig.json
├── runtime
│ ├── .eslintignore
│ ├── .eslintrc.js
│ ├── .mocharc.json
│ ├── LICENSE
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── account.ts
│ │ ├── ctx.ts
│ │ ├── errors
│ │ │ ├── errors-list.ts
│ │ │ ├── runtime-errors.ts
│ │ │ └── validation-errors.ts
│ │ ├── index.ts
│ │ ├── interpreter
│ │ │ ├── interpreter.ts
│ │ │ ├── opcode-list.ts
│ │ │ └── opcode.ts
│ │ ├── lib
│ │ │ ├── asa.ts
│ │ │ ├── compare.ts
│ │ │ ├── constants.ts
│ │ │ ├── files.ts
│ │ │ ├── itxn.ts
│ │ │ ├── load-program.ts
│ │ │ ├── math.ts
│ │ │ ├── parsing.ts
│ │ │ ├── pycompile-op.ts
│ │ │ ├── stack.ts
│ │ │ ├── stateful.ts
│ │ │ └── txn.ts
│ │ ├── logicsig.ts
│ │ ├── mock
│ │ │ └── tx.ts
│ │ ├── parser
│ │ │ └── parser.ts
│ │ ├── runtime.ts
│ │ └── types.ts
│ ├── test
│ │ ├── fixtures
│ │ │ ├── app-update
│ │ │ │ └── assets
│ │ │ │ │ ├── approval_program.py
│ │ │ │ │ ├── approval_program.teal
│ │ │ │ │ └── clear_program.teal
│ │ │ ├── asa-check
│ │ │ │ └── assets
│ │ │ │ │ └── asa.yaml
│ │ │ ├── asa-load-fail
│ │ │ │ └── assets
│ │ │ │ │ └── asa.yaml
│ │ │ ├── atomic-transaction-composer
│ │ │ │ ├── correct-ABI.json
│ │ │ │ ├── network-runtime-undefined.json
│ │ │ │ ├── not-ABI.json
│ │ │ │ └── not-JSON.teal
│ │ │ ├── basic-teal
│ │ │ │ └── assets
│ │ │ │ │ ├── another-basic.teal
│ │ │ │ │ ├── app-mode.teal
│ │ │ │ │ ├── basic.teal
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── incorrect-logic.teal
│ │ │ │ │ ├── label-first-line.teal
│ │ │ │ │ ├── reject.teal
│ │ │ │ │ └── sig-mode.teal
│ │ │ ├── c2c-call
│ │ │ │ └── assets
│ │ │ │ │ ├── c2c-call.py
│ │ │ │ │ ├── c2c-echo.py
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── dummy-approval-v5.teal
│ │ │ │ │ ├── dummy-clear-v5.teal
│ │ │ │ │ ├── inner-tx-deploy.py
│ │ │ │ │ └── seq-call.py
│ │ │ ├── deploy-asa
│ │ │ │ └── assets
│ │ │ │ │ └── asa.yaml
│ │ │ ├── dynamic-op-cost
│ │ │ │ └── assets
│ │ │ │ │ ├── approval-fail.teal
│ │ │ │ │ ├── approval-pass.teal
│ │ │ │ │ ├── clear-fail.teal
│ │ │ │ │ └── clear-pass.teal
│ │ │ ├── escrow-account
│ │ │ │ └── assets
│ │ │ │ │ ├── crowdFundApproval.teal
│ │ │ │ │ ├── crowdFundClear.teal
│ │ │ │ │ ├── crowdFundEscrow.teal
│ │ │ │ │ └── escrow.teal
│ │ │ ├── global-opcodebudget
│ │ │ │ └── assets
│ │ │ │ │ ├── app.teal
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── dummy-app.teal
│ │ │ │ │ └── lsig.teal
│ │ │ ├── group-index
│ │ │ │ └── assets
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── test1.py
│ │ │ │ │ ├── test1.teal
│ │ │ │ │ ├── test2.py
│ │ │ │ │ └── test2.teal
│ │ │ ├── group-inner-transaction
│ │ │ │ └── assets
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── group.py
│ │ │ │ │ └── limit-number-txn.py
│ │ │ ├── inner-transaction
│ │ │ │ └── assets
│ │ │ │ │ ├── approval-asset-tx.py
│ │ │ │ │ ├── approval-payment.py
│ │ │ │ │ ├── approval-rekey.teal
│ │ │ │ │ ├── asa.yaml
│ │ │ │ │ ├── clear-rekey.teal
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ └── rekey-approval-payment.py
│ │ │ ├── knowable-id
│ │ │ │ └── assets
│ │ │ │ │ ├── approval-fail.teal
│ │ │ │ │ ├── approval-pass.teal
│ │ │ │ │ ├── approval.teal
│ │ │ │ │ ├── asa.yaml
│ │ │ │ │ └── clear.teal
│ │ │ ├── loop
│ │ │ │ └── assets
│ │ │ │ │ ├── approval-fail-1.teal
│ │ │ │ │ ├── approval-fail.teal
│ │ │ │ │ ├── approval-pass.teal
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── clearv3.teal
│ │ │ │ │ └── continuous-labels.teal
│ │ │ ├── multi-signature
│ │ │ │ └── assets
│ │ │ │ │ └── sample-asc.teal
│ │ │ ├── shared-space
│ │ │ │ └── assets
│ │ │ │ │ ├── approval-program-1-fail.teal
│ │ │ │ │ ├── approval-program-1.teal
│ │ │ │ │ ├── approval-program-2-fail.teal
│ │ │ │ │ ├── approval-program-2.teal
│ │ │ │ │ └── clear.teal
│ │ │ ├── stateful-update
│ │ │ │ └── assets
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── newapproval.teal
│ │ │ │ │ └── oldapproval.teal
│ │ │ ├── stateful
│ │ │ │ └── assets
│ │ │ │ │ ├── accept-optin.teal
│ │ │ │ │ ├── asa.yaml
│ │ │ │ │ ├── budget-opcode.teal
│ │ │ │ │ ├── clear-pooled-opcode-budget.teal
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ ├── clearv6.teal
│ │ │ │ │ ├── close-clear-ssc.teal
│ │ │ │ │ ├── counter-approval.teal
│ │ │ │ │ ├── crowdfunding.teal
│ │ │ │ │ ├── deleteApp.teal
│ │ │ │ │ ├── empty-app.teal
│ │ │ │ │ ├── pooled-opcode-budget.teal
│ │ │ │ │ ├── reject-optin.teal
│ │ │ │ │ ├── rejectClear.teal
│ │ │ │ │ ├── very-long-approval-2-pages.teal
│ │ │ │ │ └── very-long-approval.teal
│ │ │ ├── sub-routine
│ │ │ │ └── assets
│ │ │ │ │ ├── approval-fail-1.teal
│ │ │ │ │ ├── approval-fail.teal
│ │ │ │ │ ├── approval-pass.teal
│ │ │ │ │ ├── clear.teal
│ │ │ │ │ └── fibonacci.teal
│ │ │ ├── subdir-project
│ │ │ │ └── assets
│ │ │ │ │ ├── file1.teal
│ │ │ │ │ ├── folder-1
│ │ │ │ │ ├── asa.yaml
│ │ │ │ │ └── folder-3
│ │ │ │ │ │ ├── file3.teal
│ │ │ │ │ │ └── folder-4
│ │ │ │ │ │ ├── duplicate-file.teal
│ │ │ │ │ │ └── file4.teal
│ │ │ │ │ └── folder-2
│ │ │ │ │ ├── duplicate-file.teal
│ │ │ │ │ └── file2.teal
│ │ │ └── teal-files
│ │ │ │ └── assets
│ │ │ │ ├── teal-v6.teal
│ │ │ │ ├── teal-v7.teal
│ │ │ │ ├── teal-v8.teal
│ │ │ │ ├── test-addr.teal
│ │ │ │ ├── test-arg.teal
│ │ │ │ ├── test-bitwise.teal
│ │ │ │ ├── test-branch.teal
│ │ │ │ ├── test-byte.teal
│ │ │ │ ├── test-compare.teal
│ │ │ │ ├── test-crypto.teal
│ │ │ │ ├── test-file-1.teal
│ │ │ │ ├── test-file-2.teal
│ │ │ │ ├── test-file-3.teal
│ │ │ │ ├── test-file-4.teal
│ │ │ │ ├── test-file-5.teal
│ │ │ │ ├── test-global.teal
│ │ │ │ ├── test-if-else.teal
│ │ │ │ ├── test-innerTxn-v7.teal
│ │ │ │ ├── test-int-bytec.teal
│ │ │ │ ├── test-interpreter.teal
│ │ │ │ ├── test-label.teal
│ │ │ │ ├── test-len-err.teal
│ │ │ │ ├── test-max-opcost.teal
│ │ │ │ ├── test-mod.teal
│ │ │ │ ├── test-others.teal
│ │ │ │ ├── test-pragma-1.teal
│ │ │ │ ├── test-pragma-2.teal
│ │ │ │ ├── test-pragma-invalid.teal
│ │ │ │ ├── test-pragma-v6.teal
│ │ │ │ ├── test-pragma-v7.teal
│ │ │ │ ├── test-return.teal
│ │ │ │ ├── test-sha256-v1.teal
│ │ │ │ ├── test-sha256-v2.teal
│ │ │ │ ├── test-stateful.teal
│ │ │ │ └── test-store-load.teal
│ │ ├── helpers
│ │ │ ├── data.ts
│ │ │ ├── integration.ts
│ │ │ └── runtime-errors.ts
│ │ ├── integration
│ │ │ ├── app-optin.ts
│ │ │ ├── app-update.ts
│ │ │ ├── asa-load-fail.ts
│ │ │ ├── atomic-transfer.ts
│ │ │ ├── basic-teal.ts
│ │ │ ├── c2c-call
│ │ │ │ └── c2c-call.ts
│ │ │ ├── close-clear-ssc.ts
│ │ │ ├── crowdfunding.ts
│ │ │ ├── deleteApp.ts
│ │ │ ├── deploy-app.ts
│ │ │ ├── deploy-asa.ts
│ │ │ ├── escrow-account.ts
│ │ │ ├── execute-transaction.ts
│ │ │ ├── execution-mode.ts
│ │ │ ├── gas-calculator.ts
│ │ │ ├── global-opcodebudget.ts
│ │ │ ├── group-index.ts
│ │ │ ├── group-inner-transaction.ts
│ │ │ ├── inner-transaction
│ │ │ │ ├── asset-tx.ts
│ │ │ │ └── payment.ts
│ │ │ ├── keyreg.ts
│ │ │ ├── knowable-id.ts
│ │ │ ├── loop.ts
│ │ │ ├── pool-transaction-fee-test.ts
│ │ │ ├── pooled-op-cost.ts
│ │ │ ├── rekey
│ │ │ │ ├── rekey-and-inner-tx.ts
│ │ │ │ └── rekey-transaction.ts
│ │ │ ├── shared-space.ts
│ │ │ ├── stateful-counter.ts
│ │ │ ├── sub-routine.ts
│ │ │ ├── tx-array-len.ts
│ │ │ └── updateApp.ts
│ │ ├── mocks
│ │ │ ├── account.ts
│ │ │ ├── stateful.ts
│ │ │ └── txn.ts
│ │ ├── src
│ │ │ ├── guide-examples.ts
│ │ │ ├── interpreter
│ │ │ │ ├── inner-transaction.ts
│ │ │ │ ├── interpreter.ts
│ │ │ │ ├── opcode-integration.ts
│ │ │ │ ├── opcode-list.ts
│ │ │ │ ├── opcode.ts
│ │ │ │ ├── pooling-inner-transactions-test.ts
│ │ │ │ └── stack.ts
│ │ │ ├── lib
│ │ │ │ ├── asa.ts
│ │ │ │ ├── files.ts
│ │ │ │ ├── math.ts
│ │ │ │ ├── parsing.ts
│ │ │ │ └── txn.ts
│ │ │ ├── logicsig.ts
│ │ │ ├── parser
│ │ │ │ ├── parser.ts
│ │ │ │ └── parsing.ts
│ │ │ └── runtime.ts
│ │ └── tsconfig.json
│ └── tsconfig.json
├── types-download-git-repo
│ ├── .eslintrc.js
│ ├── index.d.ts
│ ├── package.json
│ └── tsconfig.json
└── web
│ ├── .eslintignore
│ ├── .eslintrc.js
│ ├── .mocharc.json
│ ├── LICENSE
│ ├── README.md
│ ├── package.json
│ ├── src
│ ├── algo-signer-types.ts
│ ├── errors
│ │ ├── errors-list.ts
│ │ └── errors.ts
│ ├── index.ts
│ ├── lib
│ │ ├── api.ts
│ │ ├── constants.ts
│ │ ├── logger.ts
│ │ ├── myalgowallet-mode.ts
│ │ ├── parsing.ts
│ │ ├── status.ts
│ │ ├── txn.ts
│ │ ├── utils.ts
│ │ ├── wallectconnect-mode.ts
│ │ └── web-mode.ts
│ ├── types-input.ts
│ └── types.ts
│ ├── test
│ ├── mocks
│ │ ├── algo-signer-mock.ts
│ │ ├── myalgowallet-mock.ts
│ │ ├── sample.teal
│ │ ├── tx.ts
│ │ └── walletconnect-mock.ts
│ ├── src
│ │ ├── lib
│ │ │ ├── myalgowallet-mode.ts
│ │ │ ├── utils.ts
│ │ │ ├── walletconnect-mode.ts
│ │ │ └── web-mode.ts
│ │ └── types.ts
│ └── tsconfig.json
│ └── tsconfig.json
├── test
├── setup.js
└── tsconfig.json
├── tsconfig-project.json
├── tsconfig.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | charset = utf-8
6 | trim_trailing_whitespace = true
7 | insert_final_newline = true
8 | # indent_style = space
9 | # indent_size = 4
10 |
11 | [*.{js,jsx,ts,tsx,json}]
12 | indent_style = tab
13 | indent_size = 2
14 | max_line_length = 110
15 |
16 | [*.go]
17 | max_line_length = 96
18 | indent_style = tab
19 |
20 | [*.sql]
21 | indent_style = tab
22 |
23 | [*.{md,rst}]
24 | trim_trailing_whitespace = false
25 |
26 | [*.{html,mako,less,org}]
27 | indent_style = tab
28 |
29 | [*.py]
30 | indent_style = space
31 | indent_size = 4
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ""
5 | labels: bug
6 | assignees: ""
7 | ---
8 |
9 | ## Describe the bug
10 |
11 | A clear and concise description of what the bug is.
12 |
13 | #### Expected Behavior
14 |
15 | #### Current Behavior
16 |
17 | ## Possible Solution
18 |
19 | ## Steps to Reproduce
20 |
21 | 1.
22 | 2.
23 |
24 | ### Environment
25 |
26 | - OS: [e.g. iOS]
27 | - Node.js version:
28 | - algob version:
29 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ""
5 | labels: ""
6 | assignees: ""
7 | ---
8 |
9 | ## Is your feature request related to a problem? Please describe.
10 |
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | ## Describe the solution you'd like
14 |
15 | A clear and concise description of what you want to happen.
16 |
17 | ## Additional context
18 |
19 | Add any other context or screenshots about the feature request here.
20 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | Closes #x
2 |
3 | ## Proposed Changes
4 |
5 | -
6 | -
7 | -
8 |
9 | ## TODO
10 |
11 | - [ ] update change log
12 |
13 | ## Potential followups
14 |
--------------------------------------------------------------------------------
/.github/workflows/01-main.yaml:
--------------------------------------------------------------------------------
1 | # https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow
2 | # starters: https://github.com/actions/starter-workflows/blob/main/ci/node.js.yml
3 |
4 | name: Run package tests on push
5 |
6 | on:
7 | workflow_dispatch:
8 | push:
9 | branches:
10 | - master
11 | - develop
12 | pull_request:
13 | branches:
14 | - master
15 | - develop
16 |
17 | jobs:
18 | algob-tests:
19 | name: algob
20 | uses: ./.github/workflows/reusable-workflow.yaml
21 | with:
22 | command: cd packages/algob && pipenv run yarn test
23 | secrets: inherit
24 | web-tests:
25 | name: web
26 | uses: ./.github/workflows/reusable-workflow.yaml
27 | with:
28 | command: cd packages/web && pipenv run yarn test
29 | secrets: inherit
30 | runtime-tests:
31 | name: runtime
32 | uses: ./.github/workflows/reusable-workflow.yaml
33 | with:
34 | command: cd packages/runtime && pipenv run yarn test
35 | secrets: inherit
36 |
--------------------------------------------------------------------------------
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 |
5 | yarn run check:only
6 | yarn lint-staged
7 |
--------------------------------------------------------------------------------
/.husky/pre-push:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn build
5 | pipenv run yarn test
6 |
--------------------------------------------------------------------------------
/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "diff": true,
3 | "extension": ["js", "ts"],
4 | "package": "./package.json",
5 | "reporter": "spec",
6 | "slow": 75,
7 | "timeout": 10000,
8 | "ui": "bdd",
9 | "watch-files": ["src/**/*.js", "test/**/*.js", "src/**/*.ts", "test/**/*.ts"],
10 | "require": ["ts-node/register", "source-map-support/register"],
11 | "recursive": true,
12 | "ignore": ["test/fixture-projects/**/*"]
13 | }
14 |
--------------------------------------------------------------------------------
/.prettierrc.toml:
--------------------------------------------------------------------------------
1 | useTabs = true
2 | printWidth = 96
3 |
--------------------------------------------------------------------------------
/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | nodeLinker: node-modules
2 |
3 | plugins:
4 | - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
5 | spec: "@yarnpkg/plugin-workspace-tools"
6 |
7 | pnpMode: loose
8 |
9 | yarnPath: .yarn/releases/yarn-3.3.0.cjs
10 |
--------------------------------------------------------------------------------
/@types/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/@types/.gitkeep
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | url = "https://pypi.python.org/simple"
3 | verify_ssl = true
4 | name = "pypi"
5 |
6 | [packages]
7 | pyteal = "~=0.20.1"
8 | pyyaml = "*"
9 | poetry = "*"
10 | pyteal_utils ={editable = true, ref = "main", git = "https://github.com/algorand/pyteal-utils.git"}
11 | tealer = {editable = true, ref = "dev", git = "https://github.com/crytic/tealer.git"}
12 |
13 | [dev-packages]
14 |
15 | [requires]
16 | python_version = "3.10"
17 |
--------------------------------------------------------------------------------
/check_only.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | COLOR_REST="$(tput sgr0)"
3 | COLOR_MAGENTA="$(tput setaf 5)"
4 | COLOR_RED="$(tput setaf 1)"
5 | COLOR_YELLOW="$(tput setaf 3)"
6 | status=0
7 |
8 | printf "Running check for .only expression in staged files"
9 | for file in $(git diff HEAD --staged --name-only);
10 | do
11 | if [ "${file: -3}" != ".ts" ] && [ "${file: -3}" != ".js" ]; then continue; fi
12 | for line in $(grep -in -E "\.only\(" "$file" | cut -f1 -d:);
13 | do
14 | printf "%40s\n" "${COLOR_RED}ERROR:${COLOR_REST} Disallowed expression${COLOR_YELLOW} .only()${COLOR_REST} in file: $COLOR_MAGENTA${line}:${file}$COLOR_REST"
15 | status=1
16 | done
17 | done
18 | exit $status
19 |
--------------------------------------------------------------------------------
/cleanup.sh:
--------------------------------------------------------------------------------
1 | # removes all yarn artifacts
2 | rm -rf packages/*/node_modules
3 | rm -rf node_modules
4 | rm -rf packages/*/build
5 | rm -rf **/*.log
6 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | .sass-cache
3 | .jekyll-cache
4 | .jekyll-metadata
5 | vendor
6 |
--------------------------------------------------------------------------------
/docs/404.html:
--------------------------------------------------------------------------------
1 | ---
2 | permalink: /404.html
3 | layout: splash
4 | ---
5 |
6 |
19 |
20 |
21 |
404
22 |
23 |
Page not found :(
24 |
The requested page could not be found.
25 |
26 |
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | algobuilder.dev
--------------------------------------------------------------------------------
/docs/_css/main.css:
--------------------------------------------------------------------------------
1 | #header .heading-brand {
2 | float: left;
3 | max-width: 100%;
4 | direction: rtl;
5 | }
6 | #header .logo-img {
7 | max-width: 100%;
8 | }
9 | #header .btn {
10 | margin-top: 20px;
11 | margin-left: 15px;
12 | float: right;
13 | }
14 |
15 | .first-section {
16 | font-size: x-large;
17 | margin-bottom: 50px;
18 | }
19 |
20 | .first-section .doc-links .btn {
21 | margin: 8px;
22 | }
23 |
24 | .first-section a {
25 | text-decoration: underline;
26 | }
27 |
28 | .algo-address {
29 | background: #ffe;
30 | border: 1px solid #664;
31 | border-radius: 16px;
32 | padding: 0.01em 16px;
33 | word-wrap: break-word;
34 | }
35 |
36 | #algo-donate-modal .modal-body {
37 | margin: auto;
38 | }
39 |
40 | .audit-img {
41 | max-width: 100%;
42 | margin: 25px auto;
43 | }
44 |
--------------------------------------------------------------------------------
/docs/_data/navigation.yml:
--------------------------------------------------------------------------------
1 | main:
2 | - title: "Home"
3 | url: /
4 | - title: "Guide"
5 | url: /guide/README
6 | - title: "Algob API"
7 | url: https://algobuilder.dev/api/algob/index.html
8 | - title: "Runtime API"
9 | url: https://algobuilder.dev/api/runtime/index.html
10 | - title: "Web API"
11 | url: https://algobuilder.dev/api/web/index.html
12 |
--------------------------------------------------------------------------------
/docs/_includes/head/custom.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/docs/_js/scripts.js:
--------------------------------------------------------------------------------
1 | $(function () {
2 | // init feather icons
3 | feather.replace();
4 | });
5 |
--------------------------------------------------------------------------------
/docs/assets/audit-diagram.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/assets/audit-diagram.dia
--------------------------------------------------------------------------------
/docs/assets/audit-diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/assets/audit-diagram.png
--------------------------------------------------------------------------------
/docs/assets/trophy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/assets/trophy.png
--------------------------------------------------------------------------------
/docs/guide/logs.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: splash
3 | ---
4 |
5 | # Logs
6 |
7 | Algo Builder project logs the transaction details while deploying ASA and ASC.
8 |
9 | It offers a `log` function for user too. You can use this function to log anything from your deployment script.
10 |
11 | You can also use this in your interaction script.
12 |
13 | # Usage
14 |
15 | `deployer.log(msg: string, obj: any);`
16 |
17 | You can use this line in any of your scripts to log anything.
18 |
19 | Log files are stored in `artifacts/scripts/` folder.
20 |
21 | - Log files are created in given format: `artifacts/scripts/-.log`
22 | - Log file structure:
23 | ```
24 | message content:
25 | object content
26 | ```
27 |
--------------------------------------------------------------------------------
/docs/media/.gitignore:
--------------------------------------------------------------------------------
1 | logo-portal.png
2 | logo.png
3 |
--------------------------------------------------------------------------------
/docs/media/algob-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/media/algob-icon.png
--------------------------------------------------------------------------------
/docs/media/algob-icon.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/media/algob-icon.xcf
--------------------------------------------------------------------------------
/docs/media/logo-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/media/logo-icon.png
--------------------------------------------------------------------------------
/docs/media/logo-sq-color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/media/logo-sq-color.png
--------------------------------------------------------------------------------
/docs/media/logo-website.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/media/logo-website.png
--------------------------------------------------------------------------------
/docs/media/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/media/logo.png
--------------------------------------------------------------------------------
/docs/tutorials/t-08/assets/all-wallets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-08/assets/all-wallets.png
--------------------------------------------------------------------------------
/docs/tutorials/t-08/assets/select-wallet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-08/assets/select-wallet.png
--------------------------------------------------------------------------------
/docs/tutorials/t-08/assets/wallet-connected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-08/assets/wallet-connected.png
--------------------------------------------------------------------------------
/docs/tutorials/t-09/assets/algosigner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-09/assets/algosigner.png
--------------------------------------------------------------------------------
/docs/tutorials/t-09/assets/myalgo-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-09/assets/myalgo-1.png
--------------------------------------------------------------------------------
/docs/tutorials/t-09/assets/myalgo-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-09/assets/myalgo-2.png
--------------------------------------------------------------------------------
/docs/tutorials/t-09/assets/myalgo-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-09/assets/myalgo-3.png
--------------------------------------------------------------------------------
/docs/tutorials/t-wallet/assets/address_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-wallet/assets/address_selected.png
--------------------------------------------------------------------------------
/docs/tutorials/t-wallet/assets/algo_transaction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-wallet/assets/algo_transaction.png
--------------------------------------------------------------------------------
/docs/tutorials/t-wallet/assets/homescreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-wallet/assets/homescreen.png
--------------------------------------------------------------------------------
/docs/tutorials/t-wallet/assets/select_network.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-wallet/assets/select_network.png
--------------------------------------------------------------------------------
/docs/tutorials/t-wallet/assets/styled_wallet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/t-wallet/assets/styled_wallet.png
--------------------------------------------------------------------------------
/docs/tutorials/tutorial-pipelineui/assets/algosigner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/tutorial-pipelineui/assets/algosigner.png
--------------------------------------------------------------------------------
/docs/tutorials/tutorial-pipelineui/assets/app-deployed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/tutorial-pipelineui/assets/app-deployed.png
--------------------------------------------------------------------------------
/docs/tutorials/tutorial-pipelineui/assets/default-screen-load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/tutorial-pipelineui/assets/default-screen-load.png
--------------------------------------------------------------------------------
/docs/tutorials/tutorial-pipelineui/assets/increase-counter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/docs/tutorials/tutorial-pipelineui/assets/increase-counter.png
--------------------------------------------------------------------------------
/examples/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/.DS_Store
--------------------------------------------------------------------------------
/examples/.gitignore:
--------------------------------------------------------------------------------
1 | artifacts/
2 | /algob.config-local.js
3 | node_modules
4 |
--------------------------------------------------------------------------------
/examples/algobpy/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 |
--------------------------------------------------------------------------------
/examples/algobpy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/algobpy/__init__.py
--------------------------------------------------------------------------------
/examples/algobpy/parse.py:
--------------------------------------------------------------------------------
1 | import yaml
2 |
3 |
4 | def parse_params(args, scParam):
5 | '''
6 | Decodes external template parameters and overwrites the default values.
7 | '''
8 | try:
9 | param = yaml.safe_load(args)
10 | for key, value in param.items():
11 | scParam[key] = value
12 | return scParam
13 | except yaml.YAMLError as exc:
14 | print("CAN'T LOAD CUSTOM TEMPLATE PARARMETERS")
15 | raise exc
16 |
--------------------------------------------------------------------------------
/examples/asa/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/asa/.DS_Store
--------------------------------------------------------------------------------
/examples/asa/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/examples/asa/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/asa/assets/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/asa/assets/.DS_Store
--------------------------------------------------------------------------------
/examples/asa/assets/pyteal/5-clear.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def clear_state_program():
4 | return Return(Int(1))
5 |
6 | optimize_options = OptimizeOptions(scratch_slots=True)
7 | if __name__ == "__main__":
8 | print(compileTeal(clear_state_program(), Mode.Application, version = 5, optimize=optimize_options))
--------------------------------------------------------------------------------
/examples/asa/assets/teal/2-gold-contract-asc.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if Transaction type is pay or axfer, algo amount AND asset amount is <= 100
3 | txn TypeEnum
4 | int 1
5 | ==
6 | txn TypeEnum
7 | int 4
8 | ==
9 | ||
10 | txn Amount
11 | int 100
12 | <=
13 | &&
14 | txn AssetAmount
15 | int 100
16 | <=
17 | &&
18 | txn RekeyTo
19 | global ZeroAddress
20 | ==
21 | &&
22 | txn CloseRemainderTo
23 | global ZeroAddress
24 | ==
25 | &&
26 | txn Fee
27 | int 10000
28 | <=
29 | &&
--------------------------------------------------------------------------------
/examples/asa/assets/teal/3-gold-delegated-asc.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if Transaction type is pay, and amount is <= 100
3 | txn TypeEnum
4 | int 1
5 | ==
6 | txn Amount
7 | int 100
8 | <=
9 | &&
10 | txn RekeyTo
11 | global ZeroAddress
12 | ==
13 | &&
14 | txn CloseRemainderTo
15 | global ZeroAddress
16 | ==
17 | &&
18 | txn Fee
19 | int 10000
20 | <=
21 | &&
22 |
--------------------------------------------------------------------------------
/examples/asa/assets/teal/4-gold-asa.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Accepts only if
3 | // + transaction type is OPT-IN OR transaction type is asset transfer,
4 | // + sender is goldOwnerAccount
5 | // + asset transfer amount is less than equal to 1000
6 | global GroupSize
7 | int 1
8 | ==
9 | txn GroupIndex
10 | int 0
11 | ==
12 | &&
13 | txn AssetAmount
14 | int 0
15 | ==
16 | &&
17 | txn TypeEnum
18 | int 4
19 | ==
20 | txn Sender
21 | addr EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY
22 | ==
23 | &&
24 | txn AssetAmount
25 | int 1000
26 | <=
27 | &&
28 | ||
29 | txn TypeEnum
30 | int 4
31 | ==
32 | txn RekeyTo
33 | global ZeroAddress
34 | ==
35 | &&
36 | txn CloseRemainderTo
37 | global ZeroAddress
38 | ==
39 | &&
40 | txn Fee
41 | int 10000
42 | <=
43 | &&
44 | &&
45 |
46 |
--------------------------------------------------------------------------------
/examples/asa/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require("./algob.config");
2 |
--------------------------------------------------------------------------------
/examples/asa/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-asa",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "@algo-builder/algob": "workspace:*",
14 | "eslint": "^8.26.0",
15 | "mocha": "^10.1.0"
16 | },
17 | "scripts": {
18 | "algob": "algob",
19 | "lint:check": "eslint --ext .js,.ts scripts",
20 | "lint": "eslint --fix --ext .js,.ts scripts",
21 | "test": "echo test asa: ok",
22 | "build:docs": "echo ok",
23 | "build": "echo ok"
24 | },
25 | "mocha": {
26 | "file": "../../test/setup.js"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/examples/asa/scripts/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/asa/scripts/.DS_Store
--------------------------------------------------------------------------------
/examples/asa/scripts/query/john-balances.js:
--------------------------------------------------------------------------------
1 | const { printAssets } = require("@algo-builder/algob");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | const john = deployer.accountsByName.get("john");
5 |
6 | // print one by one
7 | // const goldAssetID = deployer.algodClient.asa.get("gold").assetIndex
8 | // await printAssetHolding(deployer.algodClient, john.addr, goldAssetID);
9 | // const teslaAssetID = deployer.algodClient.asa.get("tesla").assetIndex
10 | // await printAssetHolding(deployer.algodClient, john.addr, teslaAssetID);
11 |
12 | // print all at once
13 | await printAssets(deployer, john.addr);
14 | }
15 |
16 | module.exports = { default: run };
17 |
--------------------------------------------------------------------------------
/examples/asa/scripts/transfer/common.js:
--------------------------------------------------------------------------------
1 | const { types } = require("@algo-builder/web");
2 |
3 | exports.tryExecuteTx = async function (deployer, txnParams) {
4 | try {
5 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
6 | return await deployer.executeTx(txnParameters);
7 | } catch (e) {
8 | console.error("Transaction Failed", e.response ? e.response.error : e);
9 | throw e;
10 | }
11 | };
12 |
13 | exports.mkParam = function (senderAccount, receiverAddr, amount, payFlags) {
14 | return {
15 | type: types.TransactionType.TransferAlgo,
16 | sign: types.SignType.SecretKey,
17 | fromAccount: senderAccount,
18 | toAccountAddr: receiverAddr,
19 | amountMicroAlgos: amount,
20 | payFlags: payFlags,
21 | };
22 | };
23 |
--------------------------------------------------------------------------------
/examples/asa/scripts/transfer/master-fund-john.js:
--------------------------------------------------------------------------------
1 | const { mkParam, tryExecuteTx } = require("./common");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | const masterAccount = deployer.accountsByName.get("master-account");
5 | const john = deployer.accountsByName.get("john");
6 |
7 | // fund John account with 1 Algo
8 | await tryExecuteTx(deployer, mkParam(masterAccount, john.addr, 1e6, { note: "ALGO PAID" }));
9 | }
10 |
11 | module.exports = { default: run };
12 |
--------------------------------------------------------------------------------
/examples/asa/scripts/transfer/tesla-to-john.js:
--------------------------------------------------------------------------------
1 | const { balanceOf } = require("@algo-builder/algob");
2 | const { types } = require("@algo-builder/web");
3 | const { tryExecuteTx } = require("./common");
4 |
5 | async function run(runtimeEnv, deployer) {
6 | const teslaAssetID = deployer.asa.get("tesla").assetIndex;
7 |
8 | const john = deployer.accountsByName.get("john");
9 | const elon = deployer.accountsByName.get("elon-musk");
10 |
11 | await tryExecuteTx(deployer, [
12 | {
13 | type: types.TransactionType.TransferAsset,
14 | sign: types.SignType.SecretKey,
15 | fromAccount: elon,
16 | toAccountAddr: john.addr,
17 | amount: 184467440737095516n, // use bigint for large transfer amount
18 | assetID: "tesla", // passing asa name is also supported
19 | payFlags: { totalFee: 1000 },
20 | },
21 | ]);
22 |
23 | console.log("Balance: ", await balanceOf(deployer, john.addr, teslaAssetID));
24 | }
25 |
26 | module.exports = { default: run };
27 |
--------------------------------------------------------------------------------
/examples/bond/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 | let config = "../algob.config-local.js";
6 | try {
7 | fs.accessSync(config, fs.constants.F_OK);
8 | } catch {
9 | config = "../algob.config-template.js";
10 | }
11 | console.log("config file: ", config);
12 |
13 | module.exports = require(config);
14 |
--------------------------------------------------------------------------------
/examples/bond/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | bond-token-0:
2 | total: 1000000
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "BOND"
6 | url: "url"
7 | # User may get "signature validation failed" from node if shorter hash is used.
8 | metadataHash: "12312442142141241244444411111133"
9 | note: "deploying token"
10 | manager: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
11 | reserve: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
12 | freeze: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
13 |
--------------------------------------------------------------------------------
/examples/bond/assets/bond-dapp-clear.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def clear_state_program():
4 | return Return(Int(1))
5 |
6 | optimize_options = OptimizeOptions(scratch_slots=True)
7 | if __name__ == "__main__":
8 | print(compileTeal(clear_state_program(), Mode.Application, version = 5, optimize=optimize_options))
--------------------------------------------------------------------------------
/examples/bond/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "algorand-bond",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing bond; mocha -R progress",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/bond/scripts/run/common/accounts.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This function loads accounts from deployer
3 | * @param deployer deployer object
4 | */
5 | exports.accounts = async function (deployer) {
6 | return {
7 | master: await deployer.accountsByName.get("master-account"),
8 | creator: await deployer.accountsByName.get("john"),
9 | bob: await deployer.accountsByName.get("bob"),
10 | elon: await deployer.accountsByName.get("elon-musk"),
11 | manager: await deployer.accountsByName.get("alice"),
12 | };
13 | };
14 |
--------------------------------------------------------------------------------
/examples/bond/scripts/run/issue.js:
--------------------------------------------------------------------------------
1 | const { issueTx, tryExecuteTx } = require("./common/common");
2 | /**
3 | * In this function tokens are issued to issuer from token creator.
4 | * @param deployer deployer
5 | */
6 | exports.issue = async function (deployer) {
7 | const creatorAccount = deployer.accountsByName.get("john");
8 | const appInfo = deployer.getApp("BondApp");
9 | const issuerLsig = deployer.getLsig("IssuerLsig");
10 | const asaInfo = deployer.getASAInfo("bond-token-0");
11 | const groupTx = issueTx(creatorAccount, issuerLsig, appInfo.appID, asaInfo.assetIndex);
12 |
13 | console.log("Issuing tokens!");
14 | await tryExecuteTx(deployer, groupTx);
15 | console.log("Tokens issued to issuer");
16 | };
17 |
--------------------------------------------------------------------------------
/examples/crowdfunding/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/crowdfunding/assets/crowdFundClear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // approve
3 | int 1
4 | return
--------------------------------------------------------------------------------
/examples/crowdfunding/assets/wrongEscrow.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if Transaction type is pay, Amount is <= 100, Receiver is john AND fee <= 10000
3 | txn TypeEnum
4 | int 1
5 | ==
6 | txn Amount
7 | int 100
8 | <=
9 | &&
10 | txn Receiver
11 | addr 2UBZKFR6RCZL7R24ZG327VKPTPJUPFM6WTG7PJG2ZJLU234F5RGXFLTAKA
12 | ==
13 | &&
14 | txn RekeyTo
15 | global ZeroAddress
16 | ==
17 | &&
18 | txn Fee
19 | int 10000
20 | <=
21 | &&
--------------------------------------------------------------------------------
/examples/crowdfunding/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "crowdfunding-application",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing crowdfunding; mocha -R progress",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/crowdfunding/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | async function tryExecuteTx(deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e);
7 | throw e;
8 | }
9 | }
10 |
11 | module.exports = {
12 | tryExecuteTx,
13 | };
14 |
--------------------------------------------------------------------------------
/examples/dao/README.md:
--------------------------------------------------------------------------------
1 | # Algo Builder DAO
2 |
3 | A decentralized autonomous organization (DAO) is an entity with no central leadership. Decisions get made from the bottom-up, governed by a community organized around a specific set of rules enforced on a blockchain. DAOs are internet-native organizations collectively owned and managed by their members. They have built-in treasuries that are only accessible with the approval of their members. Decisions are made via proposals the group votes on during a specified period.
4 |
5 | The project has been **moved** to it's own repository: [Sigma DAO](https://github.com/scale-it/sigmadao)\*\*.
6 |
7 | It currently contain:
8 |
9 | - full algo-builder project, with scripts and tests
10 | - Vue.js frontend
11 | - Customized Algorand indexer + graphql server.
12 |
--------------------------------------------------------------------------------
/examples/htlc-pyteal-ts/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["../../.eslintrc.js"],
3 | parserOptions: {
4 | project: "./tsconfig.json",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/htlc-pyteal-ts/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | build/
3 |
--------------------------------------------------------------------------------
/examples/htlc-pyteal-ts/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/htlc-pyteal-ts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "htlc-pyteal",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0",
11 | "js-sha256": "^0.9.0"
12 | },
13 | "devDependencies": {
14 | "eslint": "^8.26.0",
15 | "mocha": "^10.1.0"
16 | },
17 | "scripts": {
18 | "algob": "algob",
19 | "lint:check": "eslint --ext .js,.ts scripts",
20 | "lint": "eslint --fix --ext .js,.ts scripts",
21 | "test": "echo ok",
22 | "build:docs": "echo ok",
23 | "build": "tsc --build .",
24 | "build:watch": "tsc -w -p ."
25 | },
26 | "mocha": {
27 | "file": "../../test/setup.js"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/htlc-pyteal-ts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./build/scripts"
5 | },
6 | "include": ["scripts", "../../@types"]
7 | }
8 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
3 |
4 | .env
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/README.md:
--------------------------------------------------------------------------------
1 | # Inner-tx-create-assets
2 |
3 | **Note: This is a demo application, please don't use it in production. Thanks**
4 |
5 | Demo use case for `Txn.created_asset_id()` and `Txn.created_application_id()`.
6 |
7 | ## Deploy smart contract
8 |
9 | ```bash
10 | yarn run algob deploy
11 | ```
12 |
13 | ## Deploy new application, asset and log id by group transaction
14 |
15 | ```
16 | yarn run algob run useGroupTxn.js
17 | ```
18 |
19 | ## Deploy new application, asset and log id by inner transaction
20 |
21 | ```
22 | yarn run algob run useInnerTxn.js
23 | ```
24 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | gold:
2 | total: 5912599999515
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "GLD"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 | silver:
13 | total: 100
14 | decimals: 0
15 | defaultFrozen: false
16 | unitName: "SLV"
17 | url: "url"
18 | # User may get "signature validation failed" from node if shorter hash is used.
19 | metadataHash: "12312442142141241244444411111133"
20 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
21 | reserve: ""
22 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
23 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
24 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 |
3 | int 1
4 | return
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "create-inner-asset",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0",
11 | "dotenv": "^16.0.0"
12 | },
13 | "devDependencies": {
14 | "eslint": "^8.26.0",
15 | "mocha": "^10.1.0"
16 | },
17 | "scripts": {
18 | "algob": "algob",
19 | "lint:check": "eslint --ext .js,.ts scripts",
20 | "lint": "eslint --fix --ext .js,.ts scripts",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | async function tryExecuteTx(deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e);
7 | throw e;
8 | }
9 | }
10 |
11 | module.exports = {
12 | tryExecuteTx,
13 | };
14 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/scripts/run/useInnerTxn.js:
--------------------------------------------------------------------------------
1 | const { types } = require("@algo-builder/web");
2 | const { tryExecuteTx } = require("../common/common");
3 | const { accounts, decodeValue } = require("../utils");
4 |
5 | // Deploy new application
6 | async function run(runtimeEnv, deployer) {
7 | const { creator } = accounts(deployer);
8 |
9 | const proxyAppInfo = deployer.getApp("coordinator");
10 |
11 | // create asset and log new asset id
12 | const masterTxnParam = {
13 | type: types.TransactionType.CallApp,
14 | sign: types.SignType.SecretKey,
15 | fromAccount: creator,
16 | appID: proxyAppInfo.appID,
17 | appArgs: ["str:create_by_inner_txn"],
18 | payFlags: {
19 | totalFee: 3000,
20 | },
21 | };
22 |
23 | const txReceipt = await tryExecuteTx(deployer, [masterTxnParam]);
24 |
25 | // get logs from transaction
26 | const logs = txReceipt[0].logs;
27 | console.log("New asset Id =", decodeValue(logs[0]));
28 | console.log("New application Id =", decodeValue(logs[1]));
29 | }
30 |
31 | module.exports = { default: run };
32 |
--------------------------------------------------------------------------------
/examples/inner-tx-create-assets/scripts/utils/index.js:
--------------------------------------------------------------------------------
1 | const accounts = (deployer) => {
2 | return {
3 | creator: deployer.accountsByName.get("master-account"),
4 | };
5 | };
6 |
7 | const decodeValue = (value) => {
8 | return new TextDecoder().decode(value);
9 | };
10 |
11 | module.exports = {
12 | accounts,
13 | decodeValue,
14 | };
15 |
--------------------------------------------------------------------------------
/examples/multisig/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/examples/multisig/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/multisig/assets/sample-asc.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if Transaction type is pay, Sender is owner of Gold and amount is <= 100
3 | txn TypeEnum
4 | int 1
5 | ==
6 | txn Amount
7 | int 100
8 | <=
9 | &&
10 | txn RekeyTo
11 | global ZeroAddress
12 | ==
13 | &&
14 | txn CloseRemainderTo
15 | global ZeroAddress
16 | ==
17 | &&
18 | txn Fee
19 | int 10000
20 | <=
21 | &&
--------------------------------------------------------------------------------
/examples/multisig/assets/sample-raw-asc.blsig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/multisig/assets/sample-raw-asc.blsig
--------------------------------------------------------------------------------
/examples/multisig/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-multisig",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing multisig: ok",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/multisig/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | exports.tryExecuteTx = async function (deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e);
7 | throw e;
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/examples/nft/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/examples/nft/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/nft/assets/nft_clear_state.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def clear_state_program():
4 | return Return(Int(1))
5 |
6 | optimize_options = OptimizeOptions(scratch_slots=True)
7 | if __name__ == "__main__":
8 | print(compileTeal(clear_state_program(), Mode.Application, version = 5, optimize=optimize_options))
--------------------------------------------------------------------------------
/examples/nft/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nft-pyteal",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing nft: ok",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/permissioned-token-freezing/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/permissioned-token-freezing/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | gold:
2 | total: 1000000
3 | decimals: 0
4 | defaultFrozen: true
5 | unitName: "GLD"
6 | url: "url"
7 | # User may get "signature validation failed" from node if shorter hash is used.
8 | metadataHash: "12312442142141241244444411111133"
9 | note: "note"
10 | # alice-account is the manager and creator of this asset
11 | manager: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
12 | reserve: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
13 | freeze: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
14 | clawback: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
15 |
--------------------------------------------------------------------------------
/examples/permissioned-token-freezing/assets/poi-clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // source: https://github.com/algorand/smart-contracts/blob/master/devrel/poi/poi-clear.teal
3 | int 1
4 | return
--------------------------------------------------------------------------------
/examples/permissioned-token-freezing/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "permissioned-token-freezing",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing permissioned-token-freezing; mocha -R progress",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/permissioned-token-freezing/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | async function tryExecuteTx(deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e);
7 | throw e;
8 | }
9 | }
10 |
11 | module.exports = {
12 | tryExecuteTx,
13 | };
14 |
--------------------------------------------------------------------------------
/examples/permissioned-token/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 | let config = "../algob.config-local.js";
6 | try {
7 | fs.accessSync(config, fs.constants.F_OK);
8 | } catch {
9 | config = "../algob.config-template.js";
10 | }
11 | console.log("config file: ", config);
12 |
13 | module.exports = require(config);
14 |
--------------------------------------------------------------------------------
/examples/permissioned-token/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | tesla:
2 | total: 10000000000 # (10 billions)
3 | decimals: 0 # tokens are not fractional
4 | defaultFrozen: true
5 | unitName: "TESLA"
6 | url: "ipfs.io/ipfs/" # https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu
7 | # User may get "signature validation failed" from node if shorter hash is used.
8 | metadataHash: "12312442142141241244444411111133"
9 | note: "note"
10 | # alice-account is the manager and reserve of this asset
11 | manager: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
12 | reserve: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
13 | freeze: ""
14 | # This address will be changed to the clawback escrow logic sig.
15 | clawback: "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY"
16 |
--------------------------------------------------------------------------------
/examples/permissioned-token/assets/clear_state_program.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def clear_state_program():
4 | return Return(Int(1))
5 |
6 | optimize_options = OptimizeOptions(scratch_slots=True)
7 | if __name__ == "__main__":
8 | print(compileTeal(clear_state_program(), Mode.Application, version = 5, optimize=optimize_options))
--------------------------------------------------------------------------------
/examples/permissioned-token/assets/permissions_new.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // add new permissions contract logic here (eg. KYC)
3 | int 1
4 | return
--------------------------------------------------------------------------------
/examples/permissioned-token/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "permissioned-token",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing permissioned-token; mocha -R progress",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/permissioned-token/scripts/common/accounts.js:
--------------------------------------------------------------------------------
1 | // Accounts below must be defined in the config.
2 |
3 | module.exports = {
4 | owner: "alice",
5 | issuer: "alice",
6 | };
7 |
--------------------------------------------------------------------------------
/examples/permissioned-voting/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/permissioned-voting/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | vote-token:
2 | total: 5912599999515
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "VOTETK"
6 | url: "url"
7 | # User may get "signature validation failed" from node if shorter hash is used.
8 | metadataHash: "12312442142141241244444411111133"
9 | note: "deploying token"
10 | manager: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
11 | reserve: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
12 | freeze: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
13 | optInAccNames: ["alice"]
14 |
--------------------------------------------------------------------------------
/examples/permissioned-voting/assets/permissioned-voting-clear.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def clear_state_program():
4 | return Return(Int(1))
5 |
6 | optimize_options = OptimizeOptions(scratch_slots=True)
7 | if __name__ == "__main__":
8 | print(compileTeal(clear_state_program(), Mode.Application, version = 5, optimize=optimize_options))
--------------------------------------------------------------------------------
/examples/permissioned-voting/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "permissioned-voting-pyteal",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing permissioned voting: ok",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/permissioned-voting/scripts/vote/common.js:
--------------------------------------------------------------------------------
1 | exports.tryExecuteTx = async function (deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e.error);
7 | throw e;
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/examples/ref-templates/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
3 |
4 | .env
--------------------------------------------------------------------------------
/examples/ref-templates/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/ref-templates/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ref-templates",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0",
11 | "dotenv": "^16.0.0"
12 | },
13 | "devDependencies": {
14 | "eslint": "^8.26.0",
15 | "mocha": "^10.1.0"
16 | },
17 | "scripts": {
18 | "algob": "algob",
19 | "lint:check": "eslint --ext .js,.ts scripts",
20 | "lint": "eslint --fix --ext .js,.ts scripts",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/ref-templates/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | const { types } = require("@algo-builder/web");
2 |
3 | async function tryExecuteTx(deployer, txnParams) {
4 | try {
5 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
6 | return await deployer.executeTx(txnParameters);
7 | } catch (e) {
8 | console.error("Transaction Failed", e.response ? e.response.error : e);
9 | throw e;
10 | }
11 | }
12 |
13 | function mkTxnParams(senderAccount, receiverAddr, amount, lsig, payFlags) {
14 | return {
15 | type: types.TransactionType.TransferAlgo,
16 | sign: types.SignType.LogicSignature,
17 | fromAccountAddr: senderAccount.addr,
18 | toAccountAddr: receiverAddr,
19 | amountMicroAlgos: amount,
20 | lsig: lsig,
21 | payFlags: payFlags,
22 | };
23 | }
24 |
25 | module.exports = {
26 | tryExecuteTx,
27 | mkTxnParams,
28 | };
29 |
--------------------------------------------------------------------------------
/examples/script-argument-example/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/examples/script-argument-example/README.md:
--------------------------------------------------------------------------------
1 | # Script argument example
2 |
3 | This example demonstrates how you can pass arguments to script.
4 |
5 | The format for passing arguments:
6 |
7 | `yarn algob script.js --arg ''`
8 |
--------------------------------------------------------------------------------
/examples/script-argument-example/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/script-argument-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "script-argument-example",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "build:docs": "echo ok",
21 | "build": "echo ok"
22 | },
23 | "mocha": {
24 | "file": "../../test/setup.js"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/script-argument-example/scripts/script.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer, arg) {
2 | // arguments received here
3 | console.log(arg);
4 | }
5 |
6 | module.exports = { default: run };
7 |
--------------------------------------------------------------------------------
/examples/signed-txn/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/examples/signed-txn/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/signed-txn/assets/john-to-bob.txn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/examples/signed-txn/assets/john-to-bob.txn
--------------------------------------------------------------------------------
/examples/signed-txn/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "signed-txn-example",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "build:docs": "echo ok",
21 | "build": "echo ok"
22 | },
23 | "mocha": {
24 | "file": "../../test/setup.js"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/signed-txn/scripts/transfer.js:
--------------------------------------------------------------------------------
1 | const { executeSignedTxnFromFile } = require("@algo-builder/algob");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | /* Spec txnParams is encoded in john-to-bob.txn
5 | const john = deployer.accountsByName.get('john');
6 | const bob = deployer.accountsByName.get('bob');
7 | const txnParam = {
8 | type: TransactionType.TransferAlgo,
9 | sign: SignType.SecretKey,
10 | fromAccount: john,
11 | toAccountAddr: bob.addr,
12 | amountMicroAlgos: 20,
13 | payFlags: { totalFee: 1000 }
14 | }; */
15 |
16 | try {
17 | await executeSignedTxnFromFile(deployer, "john-to-bob.txn");
18 | } catch (e) {
19 | console.log(e.response ? e.response.error : e);
20 | throw e;
21 | }
22 | }
23 |
24 | module.exports = { default: run };
25 |
--------------------------------------------------------------------------------
/examples/stateful-counter/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/stateful-counter/assets/approval_program.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int NoOp
4 | txn OnCompletion
5 | ==
6 |
7 | bnz application_call
8 |
9 | int 1
10 | return
11 |
12 | application_call:
13 |
14 | // read global state
15 | byte "counter"
16 | dup
17 | app_global_get
18 |
19 | // increment the value
20 | int 1
21 | +
22 |
23 | // store to scratch space
24 | dup
25 | store 0
26 |
27 | // update global state
28 | app_global_put
29 |
30 | // load return value as approval
31 | load 0
32 | return
--------------------------------------------------------------------------------
/examples/stateful-counter/assets/clear_program.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 1
4 | return
--------------------------------------------------------------------------------
/examples/stateful-counter/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require("./algob.config");
2 |
--------------------------------------------------------------------------------
/examples/stateful-counter/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "stateful-counter",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "build:docs": "echo ok",
21 | "build": "echo ok"
22 | },
23 | "mocha": {
24 | "file": "../../test/setup.js"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/stateful-counter/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | exports.tryExecuteTx = async function (deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e);
7 | throw e;
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/examples/stateful-counter/scripts/interaction/delete_application.js:
--------------------------------------------------------------------------------
1 | const { types } = require("@algo-builder/web");
2 | const { tryExecuteTx } = require("../common/common");
3 |
4 | async function run(runtimeEnv, deployer) {
5 | const creatorAccount = deployer.accountsByName.get("alice");
6 |
7 | // Retreive AppInfo from checkpoints.
8 | const appInfo = deployer.getApp("CounterApp");
9 | const applicationID = appInfo.appID;
10 | console.log("Application Id ", applicationID);
11 |
12 | const tx = {
13 | type: types.TransactionType.DeleteApp,
14 | sign: types.SignType.SecretKey,
15 | fromAccount: creatorAccount,
16 | appID: applicationID,
17 | payFlags: {},
18 | appArgs: [],
19 | };
20 |
21 | await tryExecuteTx(deployer, [tx]);
22 | console.log("Application Deleted!!");
23 | }
24 |
25 | module.exports = { default: run };
26 |
--------------------------------------------------------------------------------
/examples/stateful-counter/scripts/interaction/update_application.js:
--------------------------------------------------------------------------------
1 | const { types } = require("@algo-builder/web");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | const creatorAccount = deployer.accountsByName.get("alice");
5 |
6 | // Retreive AppInfo from checkpoints.
7 | const appInfo = deployer.getApp("CounterApp");
8 | const applicationID = appInfo.appID;
9 | console.log("Application Id ", applicationID);
10 |
11 | const updatedRes = await deployer
12 | .updateApp(
13 | "CounterApp",
14 | creatorAccount,
15 | {}, // pay flags
16 | applicationID,
17 | {
18 | metaType: types.MetaType.FILE,
19 | approvalProgramFilename: "new_approval.teal",
20 | clearProgramFilename: "new_clear.teal",
21 | },
22 | {}
23 | )
24 | .catch((error) => {
25 | throw error;
26 | });
27 | console.log("Application Updated: ", updatedRes);
28 | }
29 |
30 | module.exports = { default: run };
31 |
--------------------------------------------------------------------------------
/examples/trampoline/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/examples/trampoline/README.md:
--------------------------------------------------------------------------------
1 | # Trampoline
2 |
3 | Note: This is a demo application, please don't use it in production. Thanks
4 | Fund app address during create
5 |
6 | Simple example to demonstrate the use of an existing application to dynamically create a transaction to pay an account who's address is unknown at transaction signing time.
7 |
8 | This is especially useful in the case that an application creator wants to create an application and fund it within a single (grouped) transaction.
9 |
10 | ## Setup
11 |
12 | Please follow the [setup](../README.md) instructions to install dependencies and update the config.
13 | This example is using PyTEAL, so make sure to follow the Python3 setup described above.
14 | If you run the file fundApplication.py, it will generate two file TEAL approval.teal and clear.teal
15 |
16 | ## Run
17 |
18 | ```
19 | yarn run algob deploy
20 | yarn run algob run scripts/run/create-fund-app.js
21 | ```
22 |
--------------------------------------------------------------------------------
/examples/trampoline/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 |
6 | let config = "../algob.config-local.js";
7 | try {
8 | fs.accessSync(config, fs.constants.F_OK);
9 | } catch {
10 | config = "../algob.config-template.js";
11 | }
12 | console.log("config file: ", config);
13 |
14 | module.exports = require(config);
15 |
--------------------------------------------------------------------------------
/examples/trampoline/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | return
--------------------------------------------------------------------------------
/examples/trampoline/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "trampoline",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing nft: ok",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/trampoline/scripts/common/common.js:
--------------------------------------------------------------------------------
1 | exports.tryExecuteTx = async function (deployer, txnParams) {
2 | try {
3 | const txnParameters = Array.isArray(txnParams) ? txnParams : [txnParams];
4 | return await deployer.executeTx(txnParameters);
5 | } catch (e) {
6 | console.error("Transaction Failed", e.response ? e.response.error : e);
7 | throw e;
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/examples/unique-nft-asa/algob.config.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | // check if local config in /examples exists if yes then use it, otherwise use a template
4 | // config provided by this repository.
5 | let config = "../algob.config-local.js";
6 | try {
7 | fs.accessSync(config, fs.constants.F_OK);
8 | } catch {
9 | config = "../algob.config-template.js";
10 | }
11 | console.log("config file: ", config);
12 |
13 | module.exports = require(config);
14 |
--------------------------------------------------------------------------------
/examples/unique-nft-asa/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | nft-asa:
2 | # Supply == 1
3 | total: 1
4 | decimals: 0
5 | defaultFrozen: false
6 | unitName: "ACK"
7 | url: "url"
8 | metadataHash: "12312442142141241244444411111133"
9 | note: "note"
10 | manager: ""
11 | reserve: ""
12 | freeze: ""
13 | clawback: ""
14 |
--------------------------------------------------------------------------------
/examples/unique-nft-asa/assets/nft-app-clear.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def clear_state_program():
4 | return Return(Int(1))
5 |
6 | optimize_options = OptimizeOptions(scratch_slots=True)
7 | if __name__ == "__main__":
8 | print(compileTeal(clear_state_program(), Mode.Application, version = 5, optimize=optimize_options))
--------------------------------------------------------------------------------
/examples/unique-nft-asa/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "unique-nft-asa",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "Apache-2.0",
6 | "dependencies": {
7 | "@algo-builder/algob": "workspace:*",
8 | "@algo-builder/runtime": "workspace:*",
9 | "@algo-builder/web": "workspace:*",
10 | "algosdk": "^1.24.0"
11 | },
12 | "devDependencies": {
13 | "eslint": "^8.26.0",
14 | "mocha": "^10.1.0"
15 | },
16 | "scripts": {
17 | "algob": "algob",
18 | "lint:check": "eslint --ext .js,.ts scripts",
19 | "lint": "eslint --fix --ext .js,.ts scripts",
20 | "test": "echo testing unique-nft; mocha -R progress",
21 | "build:docs": "echo ok",
22 | "build": "echo ok"
23 | },
24 | "mocha": {
25 | "file": "../../test/setup.js"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/infrastructure/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/infrastructure/.DS_Store
--------------------------------------------------------------------------------
/infrastructure/.gitignore:
--------------------------------------------------------------------------------
1 | /node_data
2 | .dockerignore
--------------------------------------------------------------------------------
/infrastructure/private-net-template.json:
--------------------------------------------------------------------------------
1 | {
2 | "Genesis": {
3 | "NetworkName": "devnet",
4 | "ConsensusProtocol": "future",
5 | "FirstPartKeyRound": 0,
6 | "LastPartKeyRound": 30000,
7 | "Wallets": [
8 | {
9 | "Name": "Wallet1",
10 | "Stake": 100,
11 | "Online": true
12 | }
13 | ],
14 | "DevMode": true
15 | },
16 | "Nodes": [
17 | {
18 | "Name": "PrimaryNode",
19 | "IsRelay": false,
20 | "Wallets": [
21 | {
22 | "Name": "Wallet1",
23 | "ParticipationOnly": false
24 | }
25 | ]
26 | }
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/packages/algob/.eslintignore:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/algob/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["../../.eslintrc.js"],
3 | parserOptions: {
4 | project: "./test/tsconfig.json",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/packages/algob/.gitignore:
--------------------------------------------------------------------------------
1 | /project-dev
2 | /test/fixture-projects/default-config-project-tmp/
3 |
--------------------------------------------------------------------------------
/packages/algob/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "diff": true,
3 | "extension": ["js", "ts"],
4 | "package": "./package.json",
5 | "reporter": "spec",
6 | "slow": 75,
7 | "timeout": 10000,
8 | "ui": "bdd",
9 | "watch-files": ["src/**/*.js", "test/**/*.js", "src/**/*.ts", "test/**/*.ts"],
10 | "require": ["ts-node/register", "source-map-support/register"],
11 | "recursive": true,
12 | "ignore": ["test/fixture-projects/**/*"],
13 | "file": "../../test/setup.js"
14 | }
15 |
--------------------------------------------------------------------------------
/packages/algob/prepublish.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | for f in Makefile README.md private-net-template.json sandbox-docker-compose.yml
4 | do
5 | cp ../../infrastructure/$f sample-project/infrastructure;
6 | done
7 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/.gitignore:
--------------------------------------------------------------------------------
1 | /node_data
2 | .dockerignore
3 | artifacts/
4 | /algob.config-local.js
5 | node_modules
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | # tsc doesn't support pnp
2 | # workaround: https://next.yarnpkg.com/advanced/pnpify
3 | # or use different node linker, eg: node-modules
4 | nodeLinker: node-modules
5 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/algobpy/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/algobpy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/sample-project/common/algobpy/__init__.py
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/algobpy/parse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import yaml
3 |
4 | '''
5 | Overwrites scParam values if args is defined and has keys common from scParam
6 | '''
7 | def parse_params(args, scParam):
8 |
9 | # decode external parameter and update current values.
10 | # (if an external paramter is passed)
11 | try:
12 | param = yaml.safe_load(args)
13 | for key, value in param.items():
14 | scParam[key] = value
15 | return scParam
16 | except yaml.YAMLError as exc:
17 | print(exc)
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/assets/accounts_user.yaml:
--------------------------------------------------------------------------------
1 | # Example (CHANGE the values below if you want to use it externally):
2 | # - addr: KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY
3 | # mnemonic: call boy rubber fashion arch day capable one sweet skate outside purse
4 | # six early learn tuition eagle love breeze pizza loud today popular able
5 | # divide
6 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | # minimum ASA definition (all optional fields omitted)
2 | minimumASA:
3 | total: 1
4 | decimals: 0
5 | unitName: "unitName"
6 | minimumASA1:
7 | total: 1
8 | decimals: 0
9 | unitName: "unitName"
10 | ## whole ASA definition (contains all fields)
11 | allFieldASA:
12 | total: 1
13 | decimals: 0
14 | defaultFrozen: true
15 | unitName: "unitName"
16 | url: "url"
17 | # User may get "signature validation failed" from node if shorter hash is used.
18 | metadataHash: "12312442142141241244444411111133"
19 | note: "note"
20 | # noteb64: "base64text=="
21 | manager: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
22 | reserve: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
23 | freeze: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
24 | clawback: "WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE"
25 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/common/assets/fee-check.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if the provided fee is at least 10,000 microalgos
3 | txn Fee
4 | int 10000
5 | >=
6 | txn RekeyTo
7 | global ZeroAddress
8 | ==
9 | &&
10 | txn CloseRemainderTo
11 | global ZeroAddress
12 | ==
13 | &&
--------------------------------------------------------------------------------
/packages/algob/sample-project/infrastructure/.gitignore:
--------------------------------------------------------------------------------
1 | /node_data
2 | .dockerignore
--------------------------------------------------------------------------------
/packages/algob/sample-project/js/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .yarn
3 | .DS_Store
4 | .env
5 | artifacts
--------------------------------------------------------------------------------
/packages/algob/sample-project/js/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "sample-project",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "ISC",
6 | "scripts": {
7 | "algob": "./node_modules/.bin/algob"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/js/scripts/0-sampleScript.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | console.log("Sample script has started execution!");
3 | await deployer.deployASA("minimumASA", { creator: deployer.accounts[0] });
4 | // deploy using feePerByte
5 | await deployer.deployASA("minimumASA1", {
6 | creator: deployer.accounts[0],
7 | // totalFee: 10001,
8 | feePerByte: 10,
9 | // firstValid: 2,
10 | validRounds: 1002,
11 | });
12 |
13 | await deployer.deployASA("allFieldASA", {
14 | creator: deployer.accounts[0],
15 | // totalFee: 10001,
16 | feePerByte: 10,
17 | // firstValid: 2,
18 | validRounds: 1002,
19 | });
20 | console.log("Sample script execution has finished!");
21 | }
22 |
23 | module.exports = { default: run };
24 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/js/scripts/1-sampleScript.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | console.log("Sample script for ASC has started execution!");
3 | await deployer.mkContractLsig("feeCheck", "fee-check.teal");
4 | await deployer.fundLsig(
5 | "feeCheck",
6 | { funder: deployer.accounts[0], fundingMicroAlgo: 20e6 },
7 | {}
8 | );
9 |
10 | await deployer.addCheckpointKV("User Checkpoint", "Fund Contract Account");
11 | console.log("Sample script for ASC Funding execution has finished!");
12 | }
13 |
14 | module.exports = { default: run };
15 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .yarn
3 | .DS_Store
4 | .env
5 | artifacts
6 | build
7 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "diff": true,
3 | "extension": ["js", "ts"],
4 | "package": "./package.json",
5 | "reporter": "spec",
6 | "slow": 75,
7 | "timeout": 10000,
8 | "ui": "bdd",
9 | "watch-files": ["src/**/*.js", "test/**/*.js", "src/**/*.ts", "test/**/*.ts"],
10 | "require": ["ts-node/register", "source-map-support/register"],
11 | "recursive": true
12 | }
13 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "sample-project-ts",
3 | "version": "0.0.1",
4 | "main": "index.js",
5 | "license": "ISC",
6 | "scripts": {
7 | "algob": "./node_modules/.bin/algob",
8 | "build": "tsc --build .",
9 | "build:watch": "tsc -w -p ."
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/scripts/0-sampleScript.ts:
--------------------------------------------------------------------------------
1 | import * as algob from "@algo-builder/algob";
2 |
3 | async function run(
4 | runtimeEnv: algob.types.RuntimeEnv,
5 | deployer: algob.types.Deployer
6 | ): Promise {
7 | console.log("Sample script has started execution!");
8 | await deployer.deployASA("minimumASA", { creator: deployer.accounts[0] });
9 | // deploy using feePerByte
10 | await deployer.deployASA("minimumASA1", {
11 | creator: deployer.accounts[0],
12 | // totalFee: 10001,
13 | feePerByte: 10,
14 | // firstValid: 2,
15 | validRounds: 1002,
16 | });
17 |
18 | await deployer.deployASA("allFieldASA", {
19 | creator: deployer.accounts[0],
20 | // totalFee: 10001,
21 | feePerByte: 10,
22 | // firstValid: 2,
23 | validRounds: 1002,
24 | });
25 | console.log("Sample script execution has finished!");
26 | }
27 |
28 | module.exports = { default: run };
29 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/scripts/1-sampleScript.ts:
--------------------------------------------------------------------------------
1 | import * as algob from "@algo-builder/algob";
2 |
3 | async function run(
4 | runtimeEnv: algob.types.RuntimeEnv,
5 | deployer: algob.types.Deployer
6 | ): Promise {
7 | console.log("Sample script for ASC has started execution!");
8 | await deployer.mkContractLsig("feeCheck", "fee-check.teal");
9 | await deployer.fundLsig(
10 | "feeCheck",
11 | { funder: deployer.accounts[0], fundingMicroAlgo: 20e6 },
12 | {}
13 | );
14 |
15 | await deployer.addCheckpointKV("User Checkpoint", "Fund Contract Account");
16 | console.log("Sample script for ASC Funding execution has finished!");
17 | }
18 |
19 | module.exports = { default: run };
20 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "include": ["./"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/sample-project/ts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "lib": ["esnext", "dom"],
5 | "outDir": "./build/scripts",
6 | "typeRoots": ["node_modules/@types"],
7 | "experimentalDecorators": true,
8 | "esModuleInterop": true,
9 | "allowJs": true,
10 | "module": "commonjs",
11 | "resolveJsonModule": true,
12 | "noImplicitReturns": true,
13 | "noImplicitThis": true,
14 | "strict": true,
15 | "forceConsistentCasingInFileNames": true,
16 | "sourceMap": true,
17 | "declaration": true
18 | },
19 | "exclude": ["**/node_modules", "**/webpack"],
20 | "include": ["scripts"]
21 | }
22 |
--------------------------------------------------------------------------------
/packages/algob/src/builtin-tasks/clean.ts:
--------------------------------------------------------------------------------
1 | import fsExtra from "fs-extra";
2 |
3 | import { task } from "../internal/core/config/config-env";
4 | import { RuntimeEnv } from "../types";
5 | import { TASK_CLEAN } from "./task-names";
6 |
7 | export default function (): void {
8 | task(
9 | TASK_CLEAN,
10 | "Clears the cache and deletes all artifacts",
11 | async (_, { config }: RuntimeEnv) => {
12 | if (config.paths == null) {
13 | console.warn("not in a project directory");
14 | return;
15 | }
16 | console.log("cleaning:\n %s \n %s", config.paths.cache, config.paths.artifacts);
17 | await fsExtra.remove(config.paths.cache);
18 | await fsExtra.remove(config.paths.artifacts);
19 | }
20 | );
21 | }
22 |
--------------------------------------------------------------------------------
/packages/algob/src/builtin-tasks/node-info.ts:
--------------------------------------------------------------------------------
1 | import { task } from "../internal/core/config/config-env";
2 | import { createClient } from "../lib/driver";
3 | import { RuntimeEnv, TaskArguments } from "../types";
4 | import { TASK_NODE_INFO } from "./task-names";
5 |
6 | export default function (): void {
7 | task(TASK_NODE_INFO, "Prints node info and status").setAction(nodeInfo);
8 | }
9 |
10 | async function nodeInfo(_taskArgs: TaskArguments, env: RuntimeEnv): Promise {
11 | const n = env.network;
12 | const algocl = createClient(n);
13 | const st = await algocl.status().do();
14 | console.log("NETWORK NAME", n.name);
15 | console.log("NODE ADDRESS", n.config);
16 | console.log("NODE STATUS", st);
17 | }
18 |
--------------------------------------------------------------------------------
/packages/algob/src/builtin-tasks/task-names.ts:
--------------------------------------------------------------------------------
1 | export const TASK_HELP = "help";
2 |
3 | export const TASK_CONSOLE = "console";
4 | export const TASK_CLEAN = "clean";
5 | export const TASK_GEN_ACCOUNTS = "gen-accounts";
6 | export const TASK_INIT = "init";
7 | export const TASK_NODE_INFO = "node-info";
8 | export const TASK_RUN = "run";
9 | export const TASK_DEPLOY = "deploy";
10 | export const TASK_COMPILE = "compile";
11 | export const TASK_UNBOX_TEMPLATE = "unbox-template";
12 | export const TASK_TEST = "test";
13 | export const TASK_SIGN_MULTISIG = "sign-multisig";
14 | export const TASK_SIGN_LSIG = "sign-lsig";
15 |
--------------------------------------------------------------------------------
/packages/algob/src/config.ts:
--------------------------------------------------------------------------------
1 | export * from "./internal/core/config/config-env";
2 | export { Config } from "./types";
3 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/constants.ts:
--------------------------------------------------------------------------------
1 | export const ALGOB_NAME = "algob";
2 | export const ALGOB_CHAIN_NAME = "algobchain";
3 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/core/config/default-config.ts:
--------------------------------------------------------------------------------
1 | import type { ChainCfg, Config } from "../../../types";
2 | import { ALGOB_CHAIN_NAME } from "../../constants";
3 |
4 | const cfg: ChainCfg = {
5 | accounts: [],
6 | paths: { assets: "assets" },
7 | chainName: ALGOB_CHAIN_NAME,
8 | throwOnTransactionFailures: true,
9 | throwOnCallFailures: true,
10 | };
11 |
12 | const defaultConfig: Config = {
13 | networks: {
14 | [ALGOB_CHAIN_NAME]: cfg,
15 | },
16 | // analytics: {
17 | // enabled: true,
18 | // },
19 | mocha: {
20 | timeout: 20000,
21 | },
22 | };
23 |
24 | export default defaultConfig;
25 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/core/config/extenders.ts:
--------------------------------------------------------------------------------
1 | import { EnvironmentExtender } from "../../../types";
2 |
3 | export class ExtenderManager {
4 | private readonly _extenders: EnvironmentExtender[] = [];
5 |
6 | public add(extender: EnvironmentExtender): void {
7 | this._extenders.push(extender);
8 | }
9 |
10 | public getExtenders(): EnvironmentExtender[] {
11 | return this._extenders;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/core/tasks/builtin-tasks.ts:
--------------------------------------------------------------------------------
1 | import * as path from "path";
2 |
3 | import * as tasks from "../../../builtin-tasks/task-names";
4 | import { loadPluginFile } from "../plugins";
5 |
6 | export default function (): void {
7 | const ts = new Map(Object.entries(tasks));
8 | ts.delete("TASK_TEST_EXAMPLE");
9 | ts.delete("TASK_TEST_GET_TEST_FILES");
10 |
11 | const basedir = path.join(__dirname, "..", "..", "..", "builtin-tasks");
12 | for (const t of ts) {
13 | loadPluginFile(path.join(basedir, t[1]));
14 | }
15 | }
16 |
17 | // checks if the task name is not a setup kind of task
18 | export function isSetupTask(taskName: string): boolean {
19 | return (
20 | taskName === tasks.TASK_HELP ||
21 | taskName === tasks.TASK_INIT ||
22 | taskName === tasks.TASK_UNBOX_TEMPLATE
23 | );
24 | }
25 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/util/lang.ts:
--------------------------------------------------------------------------------
1 | export function fromEntries(entries: Array<[string, any]>): T {
2 | // eslint-disable-line @typescript-eslint/no-explicit-any
3 | return Object.assign(
4 | {},
5 | ...entries.map(([name, value]) => ({
6 | [name]: value,
7 | }))
8 | );
9 | }
10 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/util/lists.ts:
--------------------------------------------------------------------------------
1 | function getLast(ts: T[]): T {
2 | return ts[ts.length - 1];
3 | }
4 |
5 | // Takes out the rightest child of a list
6 | // `[[a, b], [c, d]]` would produce `d`
7 | function getLastDeepChild(ts: T[][]): T {
8 | return getLast(getLast(ts));
9 | }
10 |
11 | export function partitionByFn(f: (s: T, s1: T) => boolean, input: T[]): T[][] {
12 | if (input.length === 0) {
13 | return [];
14 | }
15 | const out = [[input[0]]];
16 | for (const current of input.slice(1)) {
17 | const last = getLastDeepChild(out);
18 | if (f(last, current)) {
19 | out.push([current]);
20 | } else {
21 | out[out.length - 1].push(current);
22 | }
23 | }
24 | return out;
25 | }
26 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/util/package-info.ts:
--------------------------------------------------------------------------------
1 | import findupSync from "findup-sync";
2 | import { readJSON } from "fs-extra";
3 | import * as path from "path";
4 |
5 | function getPackageJsonPath(): string | null {
6 | return findClosestPackageJson(__filename);
7 | }
8 |
9 | export function getPackageRoot(): string {
10 | const packageJsonPath = getPackageJsonPath();
11 | if (packageJsonPath === null) {
12 | throw Error("Can't find package root. File `package.json` doesn't exist in the project.");
13 | }
14 |
15 | return path.dirname(packageJsonPath);
16 | }
17 |
18 | export interface PackageJson {
19 | name: string;
20 | version: string;
21 | engines: {
22 | node: string;
23 | };
24 | }
25 |
26 | function findClosestPackageJson(file: string): string | null {
27 | return findupSync("package.json", { cwd: path.dirname(file) }) ?? null;
28 | }
29 |
30 | export async function getPackageJson(): Promise {
31 | const root = getPackageRoot();
32 | return await readJSON(path.join(root, "package.json"));
33 | }
34 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/util/strings.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Returns the plural form of a word.
3 | *
4 | * @param n The number of things to represent. This dictates whether to return
5 | * the singular or plural form of the word.
6 | * @param singular The singular form of the word.
7 | * @param plural An optional plural form of the word. If non is given, the
8 | * plural form is constructed by appending an "s" to the singular form.
9 | */
10 | export function pluralize(n: number, singular: string, plural?: string): string {
11 | if (n === 1) {
12 | return singular;
13 | }
14 |
15 | if (plural !== undefined) {
16 | return plural;
17 | }
18 |
19 | return `${singular}s`;
20 | }
21 |
22 | /**
23 | * Replaces all the instances of [[toReplace]] by [[replacement]] in [[str]].
24 | */
25 | export function replaceAll(str: string, toReplace: string, replacement: string): string {
26 | return str.split(toReplace).join(replacement);
27 | }
28 |
--------------------------------------------------------------------------------
/packages/algob/src/internal/util/unsafe.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This function is a typed version of `Object.keys`. Note that it's type
3 | * unsafe. You have to be sure that `o` has exactly the same keys as `T`.
4 | */
5 | export const unsafeObjectKeys = Object.keys as (o: T) => Array>;
6 |
--------------------------------------------------------------------------------
/packages/algob/src/lib/comparators.ts:
--------------------------------------------------------------------------------
1 | export function cmpStr(a: string, b: string): number {
2 | return a.localeCompare(b);
3 | }
4 |
--------------------------------------------------------------------------------
/packages/algob/src/lib/constants.ts:
--------------------------------------------------------------------------------
1 | import { Algodv2 } from "algosdk";
2 |
3 | export const globalZeroAddress = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ";
4 | export const MIN_UINT64 = 0n;
5 | export const MAX_UINT64 = 0xffffffffffffffffn;
6 | // mock algod credentials
7 | export const mockAlgod = new Algodv2("dummyToken", "https://dummyNetwork", 8080);
8 |
--------------------------------------------------------------------------------
/packages/algob/src/lib/exceptions.ts:
--------------------------------------------------------------------------------
1 | import type { Network } from "../types";
2 |
3 | export function checkAlgorandUnauthorized(e: any, n: Network): boolean {
4 | // eslint-disable-line @typescript-eslint/no-explicit-any
5 | if (
6 | e instanceof Error &&
7 | e.message === "Unauthorized" &&
8 | (e as any).response?.text === '{"message":"Invalid API Token"}\n'
9 | ) {
10 | console.error(
11 | "Wrong credentials to access the Algorand Node. Please verify the access token for the",
12 | '"' + n.name + '"',
13 | "network."
14 | );
15 | // we finish it here, because we know what's wrong and there is not point
16 | // to rethrow the exception
17 | process.exit(1);
18 | }
19 | return false;
20 | }
21 |
--------------------------------------------------------------------------------
/packages/algob/src/lib/time.ts:
--------------------------------------------------------------------------------
1 | // returns current Unix timestamp
2 | export function timestampNow(): number {
3 | return Math.floor(Date.now() / 1000);
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/src/runtime.ts:
--------------------------------------------------------------------------------
1 | import { types as rtypes } from "@algo-builder/runtime";
2 | import { tx as webTx, types } from "@algo-builder/web";
3 |
4 | export { webTx, types, rtypes };
5 |
--------------------------------------------------------------------------------
/packages/algob/test/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "sonarjs/no-duplicate-string": "off"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/algob/test/builtin-tasks/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "sonarjs/no-duplicate-string": "off"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/algob/test/builtin-tasks/test.ts:
--------------------------------------------------------------------------------
1 | import { assert } from "chai";
2 | import path from "path";
3 |
4 | import { TASK_TEST } from "../../build/builtin-tasks/task-names";
5 | import { useCleanFixtureProject } from "../helpers/project";
6 |
7 | describe("Test task", function () {
8 | useCleanFixtureProject("typescript-project");
9 |
10 | it("Should set path to tsconfig in typescript project before running mocha", async function () {
11 | assert.isUndefined(process.env.TS_NODE_PROJECT);
12 |
13 | // should be 'fixture-projects/typescript-project/tsconfig.json'
14 | const expectedTsConfigPath = path.join(process.cwd(), "tsconfig.json");
15 | await this.env.run(TASK_TEST).then(function () {
16 | assert.deepEqual(process.env.TS_NODE_PROJECT, expectedTsConfigPath);
17 | });
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-undef": "off",
4 | "@typescript-eslint/semi": "off"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/abi-contract/basic-abi.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"correct ABI",
3 | "networks":{
4 | "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=":{
5 | "appID": 123456
6 | }
7 | },
8 | "methods":[
9 | {
10 | "name":"add",
11 | "desc":"Add 2 integers",
12 | "args":[ { "type":"uint64" }, { "type":"uint64" } ],
13 | "returns": {"type":"uint64"}
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/algorand-node-data/Node/algod.net:
--------------------------------------------------------------------------------
1 | 127.0.0.1:8081
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/algorand-node-data/Node/algod.token:
--------------------------------------------------------------------------------
1 | algod_token_using_method2
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/algorand-node-data/Node/kmd/kmd.net:
--------------------------------------------------------------------------------
1 | 127.0.0.1:8082
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/algorand-node-data/Node/kmd/kmd.token:
--------------------------------------------------------------------------------
1 | kmd_token_using_method2
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/broken-typescript-config-project/algob.config.ts:
--------------------------------------------------------------------------------
1 | function _implicitAny(a: any) {
2 | return a;
3 | }
4 |
5 | export default {
6 | networks: {
7 | network: {
8 | host: "",
9 | },
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/broken-typescript-config-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2017",
4 | "module": "commonjs",
5 | "declaration": true,
6 | "declarationMap": true,
7 | "sourceMap": true,
8 | "strict": true,
9 | "esModuleInterop": true
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-extensions/algob.config.js:
--------------------------------------------------------------------------------
1 | import { extendConfig } from "../../../src/internal/core/config/config-env";
2 |
3 | extendConfig((config, _userConfig) => {
4 | config.values = [1];
5 | });
6 |
7 | extendConfig((config, _userConfig) => {
8 | config.values.push(2);
9 | });
10 |
11 | module.exports = {};
12 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/.gitignore:
--------------------------------------------------------------------------------
1 | /artifacts
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/README.md:
--------------------------------------------------------------------------------
1 | This is a sample README file.
2 | For tests we just want some no asset and no .teal file in this directory.
3 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/accounts_user.yaml:
--------------------------------------------------------------------------------
1 | - addr: KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY
2 | mnemonic: call boy rubber fashion arch day capable one sweet skate outside purse
3 | six early learn tuition eagle love breeze pizza loud today popular able
4 | divide
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/asc-fee-check.copy.teal:
--------------------------------------------------------------------------------
1 | // Check if the provided fee is at least 10,000 microalgos
2 | txn Fee
3 | int 10000
4 | <=
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/asc-fee-check.teal:
--------------------------------------------------------------------------------
1 | // Check if the provided fee is at least 10,000 microalgos
2 | txn Fee
3 | int 10000
4 | <=
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/gold-asa-py-check.yaml:
--------------------------------------------------------------------------------
1 | filename: gold-asa.py
2 | timestamp: 10
3 | compiled: compiled
4 | compiledHash: compiledHash
5 | srcHash: 2014712600
6 | tealCode: |
7 | #pragma version 2
8 | global GroupSize
9 | int 1
10 | ==
11 | txn GroupIndex
12 | int 0
13 | ==
14 | &&
15 | txn TypeEnum
16 | int 4
17 | ==
18 | &&
19 | txn AssetAmount
20 | int 0
21 | ==
22 | &&
23 | txn TypeEnum
24 | int 4
25 | ==
26 | txn Sender
27 | addr M7VR2MGHI35EG2NMYOF3X337636PIOFVSP2HNIFUKAG7WW6BDWDCA3E2DA
28 | ==
29 | &&
30 | txn AssetAmount
31 | int 1000
32 | <=
33 | &&
34 | ||
35 | return
36 | base64ToBytes:
37 | - 0
38 | scParams:
39 | bob: 2ILRL5YU3FZ4JDQZQVXEZUYKEWF7IEIGRRCPCMI36VKSGDMAS6FHSBXZDQ
40 | alice: EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY
41 | hash_image: QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc=
42 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/gold-asa.py:
--------------------------------------------------------------------------------
1 |
2 | from pyteal import *
3 |
4 | """GOLD Transfer"""
5 | ''' Accepts only if (transaction type is OPT-IN OR (transaction type is asset transfer,
6 | sender is goldOwnerAccount and asset transfer amount is less than equal to 1000 ))'''
7 |
8 | asset_amt = Int(1000)
9 | arg_sender = Addr("M7VR2MGHI35EG2NMYOF3X337636PIOFVSP2HNIFUKAG7WW6BDWDCA3E2DA")
10 |
11 | def gold_asc(asset_amt=asset_amt, arg_sender=arg_sender):
12 |
13 | asa_opt_in = And(
14 | Global.group_size() == Int(1),
15 | Txn.group_index() == Int(0),
16 | Txn.type_enum() == Int(4),
17 | Txn.asset_amount() == Int(0)
18 | )
19 |
20 | pay_gold = And(
21 | Txn.type_enum() == Int(4),
22 | Txn.sender() == arg_sender,
23 | Txn.asset_amount() <= asset_amt
24 | )
25 |
26 | combine = Or(asa_opt_in, pay_gold)
27 |
28 | return combine
29 |
30 | optimize_options = OptimizeOptions(scratch_slots=True)
31 | if __name__ == "__main__":
32 | print(compileTeal(gold_asc(), Mode.Signature, optimize=optimize_options))
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/gold-asa.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | global GroupSize
3 | int 1
4 | ==
5 | txn GroupIndex
6 | int 0
7 | ==
8 | &&
9 | txn TypeEnum
10 | int 4
11 | ==
12 | &&
13 | txn AssetAmount
14 | int 0
15 | ==
16 | &&
17 | txn TypeEnum
18 | int 4
19 | ==
20 | txn Sender
21 | addr M7VR2MGHI35EG2NMYOF3X337636PIOFVSP2HNIFUKAG7WW6BDWDCA3E2DA
22 | ==
23 | &&
24 | txn AssetAmount
25 | int 1000
26 | <=
27 | &&
28 | ||
29 | return
30 |
31 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/multi-signed-lsig.blsig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/config-project/assets/multi-signed-lsig.blsig
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/multisig-group.tx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/config-project/assets/multisig-group.tx
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/multisig-signed.txn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/config-project/assets/multisig-signed.txn
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/multisig-unsigned.txn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/config-project/assets/multisig-unsigned.txn
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/config-project/assets/single-signed-lsig.blsig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/config-project/assets/single-signed-lsig.blsig
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/custom-config-file/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/default-config-project/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/default-config-project/contracts/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/default-config-project/contracts/.gitkeep
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/init-task/README.md:
--------------------------------------------------------------------------------
1 | # Init Task
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/invalid-config-extension/algob.config.js:
--------------------------------------------------------------------------------
1 | extendConfig((config, userConfig) => {
2 | userConfig.networks.asd = 123;
3 | });
4 |
5 | module.exports = { networks: {} };
6 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/invalid-config/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: false,
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/nested-node-project/node_modules/clashed/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clashed",
3 | "version": "1.0.0"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/nested-node-project/node_modules/outer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "outer",
3 | "version": "0.0.1"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/nested-node-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "top-level-node-project"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/nested-node-project/project/nested-caller-package-tester.ts:
--------------------------------------------------------------------------------
1 | import { getClosestCallerPackage } from "../../../../src/internal/util/caller-package";
2 | import {
3 | call as callFromTop,
4 | callFromNestedModule as topCallFromNestedModule,
5 | } from "../top-caller-package-tester";
6 |
7 | export function call(): string | undefined {
8 | return getClosestCallerPackage();
9 | }
10 |
11 | export function callFromNestedModule(): string | undefined {
12 | return call();
13 | }
14 |
15 | export function callFromTopModule(): string | undefined {
16 | return callFromTop();
17 | }
18 |
19 | export function indirectlyCallFromNestedpModule(): string | undefined {
20 | return topCallFromNestedModule();
21 | }
22 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/nested-node-project/project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nested-node-project"
3 | }
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/nested-node-project/top-caller-package-tester.ts:
--------------------------------------------------------------------------------
1 | import { getClosestCallerPackage } from "../../../src/internal/util/caller-package";
2 | import {
3 | call as callFromNested,
4 | callFromTopModule as nestedCallFromTopModule,
5 | } from "./project/nested-caller-package-tester";
6 |
7 | export function call(): string | undefined {
8 | return getClosestCallerPackage();
9 | }
10 |
11 | export function callFromNestedModule(): string | undefined {
12 | return callFromNested();
13 | }
14 |
15 | export function callFromTopModule(): string | undefined {
16 | return call();
17 | }
18 |
19 | export function indirectlyCallFromTopModule(): string | undefined {
20 | return nestedCallFromTopModule();
21 | }
22 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/pack1/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 | global.loaded = true;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/pack1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pack1",
3 | "version": "2.1.0"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/pack1/plugin-with-function-default-export.js:
--------------------------------------------------------------------------------
1 | module.exports.default = function () {
2 | global.loaded = true;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/pack1/plugin-with-function.js:
--------------------------------------------------------------------------------
1 | module.exports = function () {
2 | global.loaded = true;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/pack1/plugin-without-function.js:
--------------------------------------------------------------------------------
1 | global.loaded = true;
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/prerelease/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 | global.loaded = true;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/prerelease/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "prerelease",
3 | "version": "2.1.0-rc.0"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-missing-pack/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 | global.loaded = true;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-missing-pack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "requires-missing-pack",
3 | "version": "1.0.0",
4 | "peerDependencies": {
5 | "non-existent": "^0.0.1"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-other-version-pack1/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 | global.loaded = true;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-other-version-pack1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "requires-other-version-pack1",
3 | "version": "1.0.0",
4 | "peerDependencies": {
5 | "pack1": "^0.0.1"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-pack1/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 | global.loaded = true;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-pack1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "requires-pack1",
3 | "version": "1.2.3",
4 | "peerDependencies": {
5 | "pack1": "^2.0.1"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-prerelease/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 | global.loaded = true;
3 | };
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-loading-project/node_modules/requires-prerelease/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "requires-pack1",
3 | "version": "1.2.3",
4 | "peerDependencies": {
5 | "prerelease": "^2.0.0"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-project/buidler-config.ts:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-project/builder-config.ts:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/plugin-project/plugins/example.ts:
--------------------------------------------------------------------------------
1 | import { extendEnvironment } from "../../../../src/internal/core/config/config-env";
2 |
3 | extendEnvironment((env: any) => {
4 | env.__test_key = "a value";
5 | env.__test_bleep = (x: number) => x * 2;
6 | });
7 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /artifacts
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | custom: {
4 | host: "example.com",
5 | token: "somefaketoken",
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/async-script.js:
--------------------------------------------------------------------------------
1 | function run(runtimeEnv, deployer) {
2 | return new Promise((resolve) => setTimeout(resolve, 100));
3 | }
4 |
5 | module.exports = { default: run };
6 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/failing-script-load.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | fs.appendFileSync("output.txt", "failing load script executed\n");
3 |
4 | throw new Error("This error is intended");
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/failing-script.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", "failing script: before exception");
5 | throw new Error("Error originating from script");
6 | }
7 |
8 | module.exports = { default: run };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/no-default-method-script.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | fs.appendFileSync("output.txt", "script with no default method has been loaded");
3 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/params-script.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", runtimeEnv.network.name);
5 | }
6 |
7 | module.exports = { default: run };
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/successful-script-return-status.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | return 1.5;
3 | }
4 |
5 | module.exports = { default: run };
6 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/project-with-scripts/scripts/successful-script.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | if (runtimeEnv.config === undefined || runtimeEnv.network === undefined) {
5 | throw new Error("Config was not provided");
6 | }
7 | fs.appendFileSync("output.txt", runtimeEnv.network.name);
8 | }
9 |
10 | module.exports = { default: run };
11 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-cp-state/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /artifacts
3 | output.txt
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-cp-state/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | custom: {
4 | host: "example.com",
5 | token: "somefaketoken",
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-cp-state/scripts/1.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | if (deployer.isDeployMode) {
5 | deployer.addCheckpointKV("META from first", "first-ok");
6 | }
7 | fs.appendFileSync(
8 | "output.txt",
9 | "script1: META from first defined: " + deployer.getCheckpointKV("META from first") + "\n"
10 | );
11 | fs.appendFileSync(
12 | "output.txt",
13 | "script1: META from second defined: " + deployer.getCheckpointKV("META from second") + "\n"
14 | );
15 | fs.appendFileSync(
16 | "output.txt",
17 | "script1: META from third defined: " + deployer.getCheckpointKV("META from third") + "\n"
18 | );
19 | }
20 |
21 | module.exports = { default: run };
22 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-cp-state/scripts/2.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | if (deployer.isDeployMode) {
5 | deployer.addCheckpointKV("META from second", "second-ok");
6 | }
7 | fs.appendFileSync(
8 | "output.txt",
9 | "script2: META from first defined: " + deployer.getCheckpointKV("META from first") + "\n"
10 | );
11 | fs.appendFileSync(
12 | "output.txt",
13 | "script2: META from second defined: " + deployer.getCheckpointKV("META from second") + "\n"
14 | );
15 | fs.appendFileSync(
16 | "output.txt",
17 | "script2: META from third defined: " + deployer.getCheckpointKV("META from third") + "\n"
18 | );
19 | }
20 |
21 | module.exports = { default: run };
22 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-cp-state/scripts/3.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | if (deployer.isDeployMode) {
5 | deployer.addCheckpointKV("META from third", "third-ok");
6 | }
7 | fs.appendFileSync(
8 | "output.txt",
9 | "script3: META from first defined: " + deployer.getCheckpointKV("META from first") + "\n"
10 | );
11 | fs.appendFileSync(
12 | "output.txt",
13 | "script3: META from second defined: " + deployer.getCheckpointKV("META from second") + "\n"
14 | );
15 | fs.appendFileSync(
16 | "output.txt",
17 | "script3: META from third defined: " + deployer.getCheckpointKV("META from third") + "\n"
18 | );
19 | }
20 |
21 | module.exports = { default: run };
22 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-empty/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /artifacts
3 | output.txt
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-empty/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | custom: {
4 | host: "example.com",
5 | token: "somefaketoken",
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-empty/scripts/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/scripts-dir-empty/scripts/.gitkeep
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-none/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /artifacts
3 | output.txt
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-none/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | custom: {
4 | host: "example.com",
5 | token: "somefaketoken",
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /artifacts
3 | output.txt
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | custom: {
4 | host: "example.com",
5 | token: "somefaketoken",
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | ASA from first:
2 | total: 1
3 | decimals: 0
4 | unitName: "ASA"
5 | defaultFrozen: false
6 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/scripts/1.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | if (deployer.isDeployMode) {
3 | await deployer.deployASA("ASA from first", {
4 | creator: deployer.accountsByName.get("acc-name-1"),
5 | });
6 | }
7 | }
8 |
9 | module.exports = { default: run };
10 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/scripts/2.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | if (deployer.isDeployMode) {
3 | await deployer.fundLsigByFile(
4 | "fee-check.teal",
5 | { funder: deployer.accounts[0], fundingMicroAlgo: 100000000 },
6 | {}
7 | );
8 | }
9 | }
10 |
11 | module.exports = { default: run };
12 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/scripts/nested/nested.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | if (deployer.isDeployMode) {
3 | await deployer.deployASA("ASA from nested", {}, deployer.accountsByName.get("acc-name-1"));
4 | }
5 | }
6 |
7 | module.exports = { default: run };
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir-recursive-cp/scripts/query.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync(
5 | "output.txt",
6 | "ASA from first defined: " + deployer.isDefined("ASA from first") + "\n"
7 | );
8 | fs.appendFileSync(
9 | "output.txt",
10 | "Lsig from second defined: " + deployer.isDefined("fee-check.teal")
11 | );
12 | }
13 |
14 | module.exports = { default: run };
15 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /artifacts
3 | output.txt
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/1.js:
--------------------------------------------------------------------------------
1 | throw new Error("script in root directory: This script shouldn't run");
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/algob.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | custom: {
4 | host: "example.com",
5 | token: "somefaketoken",
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/1.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", "scripts directory: script 1 executed\n");
5 | if (deployer.isDeployMode) {
6 | deployer.addCheckpointKV("script 1 key", "script 1 value");
7 | }
8 | }
9 |
10 | module.exports = { default: run };
11 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/2.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | await new Promise((resolve) => setTimeout(resolve, 100));
5 | fs.appendFileSync("output.txt", "scripts directory: script 2 executed\n");
6 | if (deployer.isDeployMode) {
7 | deployer.addCheckpointKV("script 2 key", "script 2 value");
8 | }
9 | }
10 |
11 | module.exports = { default: run };
12 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/directory/no-run.js:
--------------------------------------------------------------------------------
1 | throw new Error("scripts/directory/no-run.js: This script shouldn't be executed");
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/other-scripts/1.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", "other scripts directory: script 1 executed\n");
5 | }
6 |
7 | module.exports = { default: run };
8 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/other-scripts/deploy-asa.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", "deployASA script\n");
5 | await deployer.deployASA("metadata key", {
6 | creator: deployer.accountsByName.get("acc-name-1"),
7 | });
8 | fs.appendFileSync("output.txt", "deployASA script after\n");
9 | }
10 |
11 | module.exports = { default: run };
12 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/other-scripts/deploy-asc.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", "fundLsigByFile script\n");
5 | await deployer.fundLsigByFile("metadata key", {}, "metadata value");
6 | fs.appendFileSync("output.txt", "fundLsigByFile script after\n");
7 | }
8 |
9 | module.exports = { default: run };
10 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/other-scripts/failing.js:
--------------------------------------------------------------------------------
1 | async function run(runtimeEnv, deployer) {
2 | throw new Error("failing script");
3 | }
4 |
5 | module.exports = { default: run };
6 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/scripts-dir/scripts/other-scripts/put-metadata.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 |
3 | async function run(runtimeEnv, deployer) {
4 | fs.appendFileSync("output.txt", "put metadata script\n");
5 | deployer.addCheckpointKV("metadata key", "metadata value");
6 | fs.appendFileSync("output.txt", "put metadata script after");
7 | }
8 |
9 | module.exports = { default: run };
10 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/stateful/.gitignore:
--------------------------------------------------------------------------------
1 | /artifacts
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/stateful/artifacts/.cp.yaml:
--------------------------------------------------------------------------------
1 | network1:
2 | timestamp: 1623663397441
3 | metadata: {}
4 | asa:
5 | silver:
6 | creator: addr-1-get-address-dry-run
7 | txId: tx-id-dry-run
8 | assetIndex: 1
9 | confirmedRound: -1
10 | assetDef:
11 | total: 1
12 | decimals: 1
13 | unitName: ASA
14 | defaultFrozen: false
15 | deleted: true
16 | ssc:
17 | approval.teal-clear.teal:
18 | 1:
19 | creator: 2ILRL5YU3FZ4JDQZQVXEZUYKEWF7IEIGRRCPCMI36VKSGDMAS6FHSBXZDQ-get-address-dry-run
20 | txId: tx-id-dry-run
21 | confirmedRound: -1
22 | appID: 33
23 | timestamp: 1
24 | deleted: false
25 | dLsig: {}
26 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/stateful/assets/approval.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | // read global state
14 | byte "counter"
15 | dup
16 | app_global_get
17 |
18 | // increment the value
19 | int 1
20 | +
21 |
22 | // store to scratch space
23 | dup
24 | store 0
25 |
26 | // update global state
27 | app_global_put
28 |
29 | // read local state for sender
30 | int 0
31 | byte "counter"
32 | app_local_get
33 |
34 | // increment the value
35 | int 1
36 | +
37 | store 1
38 |
39 | // update local state for sender
40 | int 0
41 | byte "counter"
42 | load 1
43 | app_local_put
44 |
45 | // load return value as approval
46 | load 0
47 | return
48 |
49 | on_creation:
50 | int 1
51 | return
52 |
53 | on_optin:
54 | int 0
55 | byte "counter"
56 | int 0
57 | app_local_put
58 | int 1
59 | return
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/stateful/assets/clear.teal:
--------------------------------------------------------------------------------
1 | int 1
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-external-parameters/algob.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable max-len */
2 |
3 | const accounts = [
4 | {
5 | name: "a_cfg",
6 | addr: "KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY",
7 | sk: new Uint8Array([
8 | 3, 169, 134, 121, 53, 133, 5, 224, 60, 164, 154, 221, 134, 50, 59, 233, 234, 228, 20, 217,
9 | 47, 234, 40, 26, 33, 55, 90, 26, 66, 141, 7, 85, 81, 88, 241, 118, 22, 102, 228, 46, 242,
10 | 255, 165, 169, 111, 58, 67, 114, 39, 179, 239, 0, 237, 28, 42, 0, 154, 0, 73, 27, 226, 74,
11 | 204, 187,
12 | ]),
13 | },
14 | ];
15 |
16 | task("example2", "example task", async (_ret) => 28);
17 | task("example", "example task", async (__, { run }) => run("example2"));
18 |
19 | module.exports = {
20 | networks: {
21 | localhost: {
22 | host: "http://127.0.0.1",
23 | port: 8080,
24 | token: "somefaketoken",
25 | accounts: accounts,
26 | },
27 | },
28 | };
29 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-external-parameters/assets/accounts_user.yaml:
--------------------------------------------------------------------------------
1 | - addr: KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY
2 | mnemonic: call boy rubber fashion arch day capable one sweet skate outside purse
3 | six early learn tuition eagle love breeze pizza loud today popular able
4 | divide
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-external-parameters/assets/algobpy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/support-external-parameters/assets/algobpy/__init__.py
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-external-parameters/assets/algobpy/parse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import yaml
3 |
4 | '''
5 | Overwrites scParam values if args is defined and has keys common from scParam
6 | '''
7 | def parse_params(args, scParam):
8 |
9 | # decode external parameter and update current values.
10 | # (if an external paramter is passed)
11 | try:
12 | param = yaml.safe_load(args)
13 | for key, value in param.items():
14 | scParam[key] = value
15 | return scParam
16 | except yaml.YAMLError as exc:
17 | print(exc)
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/__init__.py
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/__pycache__/parse.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/__pycache__/parse.cpython-38.pyc
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/algobpy/parse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import yaml
3 |
4 | '''
5 | Overwrites scParam values if args is defined and has keys common from scParam
6 | '''
7 | def parse_params(args, scParam):
8 |
9 | # decode external parameter and update current values.
10 | # (if an external paramter is passed)
11 | try:
12 | param = yaml.safe_load(args)
13 | for key, value in param.items():
14 | scParam[key] = value
15 | return scParam
16 | except yaml.YAMLError as exc:
17 | print(exc)
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/assets/stateless.py:
--------------------------------------------------------------------------------
1 | # This example is provided for informational purposes only
2 | import sys
3 | from algobpy.parse import parse_params
4 |
5 | from pyteal import *
6 |
7 | """GOLD Transfer"""
8 | ''' Accepts only if (transaction type is OPT-IN OR (transaction type is asset transfer,
9 | sender is goldOwnerAccount and asset transfer amount is less than equal to 1000 ))'''
10 |
11 | def gold_asc():
12 |
13 | asa_opt_in = And(
14 | Global.group_size() == Int(1),
15 | Txn.group_index() == Int(0),
16 | Txn.type_enum() == Int(4),
17 | Txn.asset_amount() == Int(0)
18 | )
19 |
20 | pay_gold = And(
21 | Txn.type_enum() == Int(4),
22 | Txn.sender() == Tmpl.Addr("TMPL_SENDER"),
23 | Txn.asset_amount() <= Tmpl.Int("TMPL_AMOUNT")
24 | )
25 |
26 | combine = Or(asa_opt_in, pay_gold)
27 |
28 | return combine
29 |
30 | optimize_options = OptimizeOptions(scratch_slots=True)
31 | if __name__ == "__main__":
32 | print(compileTeal(gold_asc(), Mode.Signature, optimize=optimize_options))
33 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/expected-stateful.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | txn ApplicationID
3 | int 0
4 | ==
5 | bnz main_l4
6 | txn OnCompletion
7 | int OptIn
8 | ==
9 | bnz main_l3
10 | err
11 | main_l3:
12 | int 0
13 | byte "balance"
14 | int 0
15 | app_local_put
16 | int 1
17 | return
18 | main_l4:
19 | txn AssetAmount
20 | int 100
21 | <=
22 | bnz main_l6
23 | err
24 | main_l6:
25 | txn Sender
26 | addr KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY
27 | ==
28 | bnz main_l8
29 | err
30 | main_l8:
31 | int 0
32 | byte "admin"
33 | int 1
34 | app_local_put
35 | int 0
36 | byte "balance"
37 | int 0
38 | app_local_put
39 | int 1
40 | return
41 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/support-tmpl-parameters/expected-stateless.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | global GroupSize
3 | int 1
4 | ==
5 | txn GroupIndex
6 | int 0
7 | ==
8 | &&
9 | txn TypeEnum
10 | int 4
11 | ==
12 | &&
13 | txn AssetAmount
14 | int 0
15 | ==
16 | &&
17 | txn TypeEnum
18 | int 4
19 | ==
20 | txn Sender
21 | addr KFMPC5QWM3SC54X7UWUW6OSDOIT3H3YA5UOCUAE2ABERXYSKZS5Q3X5IZY
22 | ==
23 | &&
24 | txn AssetAmount
25 | int 1000
26 | <=
27 | &&
28 | ||
29 | return
30 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/top-level-node-project/node_modules/lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "lib",
3 | "version": "1.2.3"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/typescript-project/algob.config.ts:
--------------------------------------------------------------------------------
1 | export default {};
2 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/typescript-project/script.ts:
--------------------------------------------------------------------------------
1 | import process from "process";
2 |
3 | process.exit(123);
4 |
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/typescript-project/test/js-test.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/typescript-project/test/js-test.js
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/typescript-project/test/ts-test.ts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/algob/test/fixture-projects/typescript-project/test/ts-test.ts
--------------------------------------------------------------------------------
/packages/algob/test/fixture-projects/typescript-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/algob/test/helpers/assert-methods.ts:
--------------------------------------------------------------------------------
1 | import type { Account } from "algosdk";
2 | import { assert } from "chai";
3 |
4 | export function assertAccountsEqual(ls1: Account[], ls2: Account[]): void {
5 | assert.equal(ls1.length, ls2.length, "account lists must have same length");
6 | for (let i = 0; i < ls1.length; ++i) {
7 | const a1 = ls1[i];
8 | const a2 = ls2[i];
9 | assert.equal(a1.addr, a2.addr, "addresses must equal");
10 | // for some reason a1.sk is a proxy object and we can't easily compare it.
11 | for (let j = 0; j < 64; ++j) {
12 | assert.equal(a1.sk[j], a2.sk[j], "secret key must equal");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/algob/test/helpers/fs.ts:
--------------------------------------------------------------------------------
1 | import fsExtra from "fs-extra";
2 | import * as os from "os";
3 | import path from "path";
4 |
5 | declare module "mocha" {
6 | interface Context {
7 | tmpDir: string;
8 | }
9 | }
10 |
11 | async function getEmptyTmpDir(nameHint: string): Promise {
12 | const tmpDirContainer = os.tmpdir();
13 | const tmpDir = path.join(tmpDirContainer, `algob-tests-${nameHint}`);
14 | await fsExtra.ensureDir(tmpDir);
15 | await fsExtra.emptyDir(tmpDir);
16 |
17 | return tmpDir;
18 | }
19 |
20 | export function useTmpDir(nameHint: string): void {
21 | nameHint = nameHint.replace(/\s+/, "-");
22 |
23 | beforeEach("Creating tmp dir", async function () {
24 | this.tmpDir = await getEmptyTmpDir(nameHint);
25 | });
26 | }
27 |
--------------------------------------------------------------------------------
/packages/algob/test/helpers/params.ts:
--------------------------------------------------------------------------------
1 | import { types as rtypes } from "@algo-builder/runtime";
2 |
3 | import { PromiseAny, RuntimeEnv } from "../../src/types";
4 |
5 | function mkAcc(name: string): rtypes.Account {
6 | return {
7 | name: "acc-name-" + name,
8 | addr: "addr-" + name,
9 | sk: new Uint8Array(Buffer.from("sk-" + name, "utf16le")),
10 | };
11 | }
12 |
13 | export function mkEnv(networkName?: string): RuntimeEnv {
14 | return {
15 | config: {
16 | networks: {},
17 | },
18 | runtimeArgs: {
19 | network: "network string",
20 | showStackTraces: false,
21 | version: false,
22 | help: false,
23 | verbose: false,
24 | },
25 | tasks: {},
26 | run: async (_name, _args): PromiseAny => "nothing",
27 | network: {
28 | name: networkName === undefined ? "network1" : networkName,
29 | config: {
30 | accounts: [mkAcc("1"), mkAcc("2"), mkAcc("3")],
31 | host: "network host",
32 | port: 1,
33 | token: "network token",
34 | },
35 | },
36 | };
37 | }
38 |
--------------------------------------------------------------------------------
/packages/algob/test/internal/tx-log-writer.ts:
--------------------------------------------------------------------------------
1 | import { assert } from "chai";
2 |
3 | import { TxWriterImpl } from "../../src/internal/tx-log-writer";
4 |
5 | class TxWriterMock extends TxWriterImpl {
6 | writtenContent = [] as any;
7 |
8 | push(filename: any, content: any): void {
9 | this.writtenContent.push({ filename, content });
10 | }
11 | }
12 |
13 | describe("Log Writer", function () {
14 | const writer = new TxWriterMock("");
15 |
16 | it("change script name", function () {
17 | writer.setScriptName("sc-1.js");
18 | assert.equal("sc-1.js", writer.scriptName);
19 | });
20 |
21 | it("Write files", function () {
22 | writer.writtenContent.pop();
23 | writer.push("WriteFile", { file: "file1" });
24 | assert.deepEqual(writer.writtenContent, [
25 | {
26 | filename: "WriteFile",
27 | content: { file: "file1" },
28 | },
29 | ]);
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/packages/algob/test/internal/util/files.ts:
--------------------------------------------------------------------------------
1 | import { ERRORS } from "@algo-builder/web";
2 | import { assert } from "chai";
3 |
4 | import { TASK_TEST } from "../../../src/builtin-tasks/task-names";
5 | import { loadFilenames } from "../../../src/internal/util/files";
6 | import { expectBuilderError } from "../../helpers/errors";
7 | import { useCleanFixtureProject } from "../../helpers/project";
8 |
9 | describe("loadFilenames", function () {
10 | useCleanFixtureProject("typescript-project");
11 | it("Should load ts and js files from test folder", function () {
12 | const ls = loadFilenames("test");
13 | const expected = ["test/js-test.js", "test/ts-test.ts"];
14 | assert.deepEqual(ls, expected);
15 | });
16 |
17 | it('Should throw error if dir name is not "test"', function () {
18 | expectBuilderError(
19 | () => loadFilenames("tests", TASK_TEST), // as dir should be "test"
20 | ERRORS.BUILTIN_TASKS.TESTS_DIRECTORY_NOT_FOUND
21 | );
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/packages/algob/test/internal/util/lang.ts:
--------------------------------------------------------------------------------
1 | import { assert } from "chai";
2 |
3 | import { fromEntries } from "../../../src/internal/util/lang";
4 |
5 | describe("From entries", function () {
6 | it("Should return an empty object if entries is an empty array", function () {
7 | assert.deepEqual(fromEntries([]), {});
8 | });
9 |
10 | it("Should construct an object", function () {
11 | const o = {};
12 | assert.deepEqual(
13 | fromEntries([
14 | ["a", 1],
15 | ["b", true],
16 | ["c", o],
17 | ]),
18 | {
19 | a: 1,
20 | b: true,
21 | c: o,
22 | }
23 | );
24 | });
25 |
26 | it("Should keep the last entry if there are multiple ones with the same key", function () {
27 | assert.deepEqual(
28 | fromEntries([
29 | ["a", 1],
30 | ["b", 2],
31 | ["a", 3],
32 | ]),
33 | {
34 | a: 3,
35 | b: 2,
36 | }
37 | );
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/packages/algob/test/internal/util/package-info.ts:
--------------------------------------------------------------------------------
1 | import { assert } from "chai";
2 | import fsExtra from "fs-extra";
3 | import path from "path";
4 |
5 | import { getPackageJson, getPackageRoot } from "../../../src/internal/util/package-info";
6 |
7 | describe("package-info", function () {
8 | it("Should give the right package.json", async function () {
9 | const packageJson = await getPackageJson();
10 | assert.equal(packageJson.name, "@algo-builder/algob");
11 | // We don't test the version number because that would be hard to maintain
12 | assert.isString(packageJson.version);
13 | });
14 |
15 | it("should give the right package root", async function () {
16 | const root = await fsExtra.realpath(path.join(__dirname, "..", "..", ".."));
17 | assert.equal(await getPackageRoot(), root);
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/packages/algob/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "include": ["../src", "../../../@types", "./"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/algob/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./build"
5 | },
6 | "include": ["src", "../../@types"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/runtime/.eslintignore:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/runtime/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["../../.eslintrc.js"],
3 | parserOptions: {
4 | project: "./test/tsconfig.json",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/packages/runtime/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "diff": true,
3 | "extension": ["js", "ts"],
4 | "package": "./package.json",
5 | "reporter": "spec",
6 | "slow": 75,
7 | "timeout": 10000,
8 | "ui": "bdd",
9 | "watch-files": ["src/**/*.js", "test/**/*.js", "src/**/*.ts", "test/**/*.ts"],
10 | "require": ["ts-node/register", "source-map-support/register"],
11 | "recursive": true,
12 | "ignore": ["test/fixture-projects/**/*"],
13 | "file": "../../test/setup.js"
14 | }
15 |
--------------------------------------------------------------------------------
/packages/runtime/src/errors/validation-errors.ts:
--------------------------------------------------------------------------------
1 | import { z } from "zod";
2 |
3 | function parseZodSubError(e: z.ZodIssueOptionalMessage, indent: number): string {
4 | if (e.code === z.ZodIssueCode.invalid_union) {
5 | return e.unionErrors.map((ue) => parseZodErrorInternal(ue, indent + 2)).join("");
6 | }
7 | return "";
8 | }
9 |
10 | function parseZodErrorInternal(ze: z.ZodError, indent: number): string {
11 | return ze.errors
12 | .map((e) => {
13 | return (
14 | " ".repeat(indent) +
15 | "[" +
16 | e.path.join(", ") +
17 | "]" +
18 | ": " +
19 | e.message +
20 | "\n" +
21 | parseZodSubError(e, indent)
22 | );
23 | })
24 | .join("\n");
25 | }
26 |
27 | export function parseZodError(ze: z.ZodError): string {
28 | return parseZodErrorInternal(ze, 10);
29 | }
30 |
--------------------------------------------------------------------------------
/packages/runtime/src/lib/math.ts:
--------------------------------------------------------------------------------
1 | // compute square root of bigint
2 | // ref https://stackoverflow.com/questions/53683995/javascript-big-integer-square-root
3 | export const bigintSqrt = (value: bigint): bigint => {
4 | if (value < 2n) {
5 | return value;
6 | }
7 |
8 | if (value < 16n) {
9 | return BigInt(Math.floor(Math.sqrt(Number(value))));
10 | }
11 |
12 | let x1;
13 | if (value < 1n << 52n) {
14 | x1 = BigInt(Math.floor(Math.sqrt(Number(value)))) - 3n;
15 | } else {
16 | x1 = (1n << 52n) - 2n;
17 | }
18 |
19 | let x0 = -1n;
20 | while (x0 !== x1 && x0 !== x1 - 1n) {
21 | x0 = x1;
22 | x1 = (value / x0 + x0) >> 1n;
23 | }
24 | return x0;
25 | };
26 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/app-update/assets/clear_program.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | // approve
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/asa-check/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | gold:
2 | total: 5912599999515
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "GLD"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 | silver:
13 | total: 100
14 | decimals: 0
15 | defaultFrozen: false
16 | unitName: "SLV"
17 | url: "url"
18 | # User may get "signature validation failed" from node if shorter hash is used.
19 | metadataHash: "12312442142141241244444411111133"
20 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
21 | reserve: ""
22 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
23 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
24 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/asa-load-fail/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | asa:
2 | total: 10000
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "ASA"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 | optInAccNames: ["alice", "elon"]
13 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/atomic-transaction-composer/correct-ABI.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"correct ABI",
3 | "networks":{
4 | "runtime":{
5 | "appID": 123456
6 | }
7 | },
8 | "methods":[
9 | {
10 | "name":"add",
11 | "desc":"Add 2 integers",
12 | "args":[ { "type":"uint64" }, { "type":"uint64" } ],
13 | "returns": {"type":"uint64"}
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/atomic-transaction-composer/network-runtime-undefined.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"network-runtime-undefined",
3 | "networks":{
4 | "MainNet":{
5 | "appID": 123456
6 | }
7 | },
8 | "methods":[
9 | {
10 | "name":"add",
11 | "desc":"Add 2 integers",
12 | "args":[ { "type":"uint64" }, { "type":"uint64" } ],
13 | "returns": {"type":"uint64"}
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/atomic-transaction-composer/not-ABI.json:
--------------------------------------------------------------------------------
1 | {"name":"John", "age":30, "car":null}
2 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/atomic-transaction-composer/not-JSON.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | return
4 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/another-basic.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 1
4 | int 2
5 | +
6 | int 3
7 | ==
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/app-mode.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | // fails if: signature mode opcode{args} is used in application mode
3 | int 0
4 | args
5 | int 1
6 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/basic.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | int 2
4 | +
5 | pop
6 | int 15
7 | int 3
8 | /
9 | int 5
10 | ==
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | // default clear program
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/incorrect-logic.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 6
3 | int 3
4 | -
5 | int 2
6 | ==
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/label-first-line.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 |
3 | txn ApplicationID
4 | bz creation
5 |
6 | loop:
7 | load 0
8 | int 10
9 | <
10 | bz break
11 |
12 | load 0
13 | int 1
14 | +
15 | store 0
16 |
17 | b loop
18 |
19 | break:
20 |
21 | int 1
22 | return
23 |
24 | creation:
25 | int 1
26 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/reject.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 0
3 | return
4 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/basic-teal/assets/sig-mode.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | // fails if: application mode opcode{log} is used in signature mode (logicsig)
3 | int 1
4 | int 2
5 | +
6 | pop
7 | byte "logging..."
8 | log
9 | int 1
10 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/c2c-call/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/c2c-call/assets/dummy-approval-v5.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/c2c-call/assets/dummy-clear-v5.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/deploy-asa/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | asa:
2 | total: 10000
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "ASA"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 | optInAccNames: ["bob", "alice"]
13 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/dynamic-op-cost/assets/approval-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 3
2 | // this file is same as `approval-pass.teal`, only difference is the teal version.
3 | // so for this contract cost is calculated before execution
4 |
5 | int 0
6 | txn ApplicationID
7 | ==
8 | bnz on_creation
9 |
10 | keccak256
11 | keccak256
12 | keccak256
13 | keccak256
14 | keccak256
15 | keccak256
16 |
17 | on_creation:
18 | int 1
19 | return
20 |
21 | int 1
22 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/dynamic-op-cost/assets/approval-pass.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // this file is same as `approval-fail.teal`, only difference is the teal version.
3 | // so for this contract cost is calculated during execution (dynamically)
4 | // this contract will pass if we deploy a new app
5 |
6 | int 0
7 | txn ApplicationID
8 | ==
9 | bnz on_creation
10 |
11 | // if not_creation, then cost will exceed threshold
12 | keccak256
13 | keccak256
14 | keccak256
15 | keccak256
16 | keccak256
17 | keccak256
18 |
19 | on_creation:
20 | int 1
21 | return
22 |
23 | int 1
24 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/dynamic-op-cost/assets/clear-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 3
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/dynamic-op-cost/assets/clear-pass.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/escrow-account/assets/crowdFundClear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // approve
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/escrow-account/assets/crowdFundEscrow.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | global GroupSize
3 | int 2
4 | ==
5 | gtxn 0 TypeEnum
6 | int appl
7 | ==
8 | &&
9 | gtxn 0 ApplicationID
10 | int 1
11 | ==
12 | &&
13 | gtxn 0 OnCompletion
14 | int NoOp
15 | ==
16 | gtxn 0 OnCompletion
17 | int DeleteApplication
18 | ==
19 | ||
20 | &&
21 | gtxn 0 RekeyTo
22 | global ZeroAddress
23 | ==
24 | gtxn 1 RekeyTo
25 | global ZeroAddress
26 | ==
27 | &&
28 | &&
29 | return
30 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/escrow-account/assets/escrow.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if Transaction type is pay, Amount is <= 100, Receiver is john AND fee <= 10000
3 | txn TypeEnum
4 | int 1
5 | ==
6 | txn Amount
7 | int 100
8 | <=
9 | &&
10 | txn Receiver
11 | addr 2UBZKFR6RCZL7R24ZG327VKPTPJUPFM6WTG7PJG2ZJLU234F5RGXFLTAKA
12 | ==
13 | &&
14 | txn RekeyTo
15 | global ZeroAddress
16 | ==
17 | &&
18 | txn Fee
19 | int 10000
20 | <=
21 | &&
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/global-opcodebudget/assets/app.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 |
3 | txn ApplicationID
4 | bz on_creation
5 |
6 | txna ApplicationArgs 0
7 | byte "normal_tx"
8 | ==
9 | bnz normal_tx
10 |
11 | txna ApplicationArgs 0
12 | byte "inner_tx"
13 | ==
14 | bnz inner_tx
15 |
16 | normal_tx:
17 | global OpcodeBudget
18 | itob
19 | log
20 | int 1
21 | return
22 |
23 | inner_tx:
24 | // call to dummy app
25 | itxn_begin
26 | int appl
27 | itxn_field TypeEnum
28 | txna ApplicationArgs 1
29 | btoi
30 | txnas Applications
31 | itxn_field ApplicationID
32 | int 0
33 | itxn_field Fee
34 | itxn_submit
35 |
36 | global OpcodeBudget
37 | itob
38 | log
39 |
40 | int 1
41 | return
42 |
43 | on_creation:
44 | int 1
45 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/global-opcodebudget/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/global-opcodebudget/assets/dummy-app.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/global-opcodebudget/assets/lsig.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | int 2
4 | +
5 | global OpcodeBudget
6 | int 19996
7 | ==
8 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/group-index/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | // approve
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/group-index/assets/test1.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def contract():
4 | program = Cond(
5 | [Txn.application_id() == Int(0), Int(1)], # on creation
6 | [Txn.on_completion() == OnComplete.DeleteApplication, Int(0)],
7 | [Txn.on_completion() == OnComplete.UpdateApplication, Int(0)],
8 | [Txn.on_completion() == OnComplete.CloseOut, Int(0)],
9 | [Txn.on_completion() == OnComplete.OptIn, Int(0)],
10 | [Txn.on_completion() == OnComplete.NoOp, Txn.group_index() == Int(0)]
11 | )
12 | return program
13 |
14 | optimize_options = OptimizeOptions(scratch_slots=True)
15 | if __name__ == "__main__":
16 | print(compileTeal(contract(), Mode.Application, version = 4, optimize=optimize_options))
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/group-index/assets/test1.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | txn ApplicationID
3 | int 0
4 | ==
5 | bnz l12
6 | txn OnCompletion
7 | int DeleteApplication
8 | ==
9 | bnz l11
10 | txn OnCompletion
11 | int UpdateApplication
12 | ==
13 | bnz l10
14 | txn OnCompletion
15 | int CloseOut
16 | ==
17 | bnz l9
18 | txn OnCompletion
19 | int OptIn
20 | ==
21 | bnz l8
22 | txn OnCompletion
23 | int NoOp
24 | ==
25 | bnz l7
26 | err
27 | l7:
28 | txn GroupIndex
29 | int 0
30 | ==
31 | b l13
32 | l8:
33 | int 0
34 | b l13
35 | l9:
36 | int 0
37 | b l13
38 | l10:
39 | int 0
40 | b l13
41 | l11:
42 | int 0
43 | b l13
44 | l12:
45 | int 1
46 | l13:
47 |
48 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/group-index/assets/test2.py:
--------------------------------------------------------------------------------
1 | from pyteal import *
2 |
3 | def contract():
4 | program = Cond(
5 | [Txn.application_id() == Int(0), Int(1)], # on creation
6 | [Txn.on_completion() == OnComplete.DeleteApplication, Int(0)],
7 | [Txn.on_completion() == OnComplete.UpdateApplication, Int(0)],
8 | [Txn.on_completion() == OnComplete.CloseOut, Int(0)],
9 | [Txn.on_completion() == OnComplete.OptIn, Int(0)],
10 | [Txn.on_completion() == OnComplete.NoOp, Txn.group_index() == Int(1)]
11 | )
12 | return program
13 |
14 | optimize_options = OptimizeOptions(scratch_slots=True)
15 | if __name__ == "__main__":
16 | print(compileTeal(contract(), Mode.Application, version = 4, optimize=optimize_options))
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/group-index/assets/test2.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | txn ApplicationID
3 | int 0
4 | ==
5 | bnz l12
6 | txn OnCompletion
7 | int DeleteApplication
8 | ==
9 | bnz l11
10 | txn OnCompletion
11 | int UpdateApplication
12 | ==
13 | bnz l10
14 | txn OnCompletion
15 | int CloseOut
16 | ==
17 | bnz l9
18 | txn OnCompletion
19 | int OptIn
20 | ==
21 | bnz l8
22 | txn OnCompletion
23 | int NoOp
24 | ==
25 | bnz l7
26 | err
27 | l7:
28 | txn GroupIndex
29 | int 1
30 | ==
31 | b l13
32 | l8:
33 | int 0
34 | b l13
35 | l9:
36 | int 0
37 | b l13
38 | l10:
39 | int 0
40 | b l13
41 | l11:
42 | int 0
43 | b l13
44 | l12:
45 | int 1
46 | l13:
47 |
48 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/group-inner-transaction/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 |
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/inner-transaction/assets/approval-rekey.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | txn ApplicationID
3 | int 0
4 | ==
5 | bnz on_creation
6 |
7 | itxn_begin
8 | int pay
9 | itxn_field TypeEnum
10 | txna Accounts 0
11 | itxn_field Receiver
12 | int 0
13 | itxn_field Amount
14 | txna Accounts 1
15 | itxn_field RekeyTo
16 | int 1000
17 | itxn_field Fee
18 | itxn_submit
19 | int 1
20 | return
21 |
22 | on_creation:
23 | int 1
24 | return
25 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/inner-transaction/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | gold:
2 | total: 5912599999515
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "GLD"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/inner-transaction/assets/clear-rekey.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/inner-transaction/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/knowable-id/assets/approval-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | // Get the created id of the asset created in the first tx
4 | gaid 2
5 | store 1
6 | byte "first"
7 | load 1
8 | app_global_put
9 |
10 | int 1
11 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/knowable-id/assets/approval-pass.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | // Get the created id of the asset created in the first tx
4 | gaid 0
5 | store 1
6 | byte "first"
7 | load 1
8 | app_global_put
9 |
10 | // Get the created id of the asset created in the second tx
11 | int 1
12 | gaids
13 | store 1
14 | byte "second"
15 | load 1
16 | app_global_put
17 |
18 | int 1
19 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/knowable-id/assets/approval.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | // Get the created id of the asset created in the first tx
4 | gaid 0
5 | store 1
6 | byte "first"
7 | load 1
8 | app_global_put
9 |
10 | int 1
11 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/knowable-id/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | gold:
2 | total: 5912599999515
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "GLD"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/knowable-id/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // approve
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/loop/assets/approval-fail-1.teal:
--------------------------------------------------------------------------------
1 | #pragma version 3
2 | // loop 1 - 10
3 | // init loop var
4 | int 0
5 | loop:
6 | int 1
7 | +
8 | // loop code
9 | // check upper bound
10 | dup
11 | int 10
12 | <=
13 | bnz loop
14 | // check whether loop was executed
15 | int 11
16 | ==
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/loop/assets/approval-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // loop 1 - 10
3 | // init loop var
4 | int 0
5 | loop:
6 | int 1
7 | +
8 | // loop code
9 | // check upper bound
10 | dup
11 | int 10
12 | <=
13 | bnz loop
14 | // check whether loop was executed
15 | int 10
16 | ==
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/loop/assets/approval-pass.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // loop 1 - 10
3 | // init loop var
4 | int 0
5 | loop:
6 | int 1
7 | +
8 | // loop code
9 | // check upper bound
10 | dup
11 | int 10
12 | <=
13 | bnz loop
14 | // check whether loop was executed
15 | int 11
16 | ==
17 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/loop/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/loop/assets/clearv3.teal:
--------------------------------------------------------------------------------
1 | #pragma version 3
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/loop/assets/continuous-labels.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // loop 1 - 10
3 | // init loop var
4 | int 0
5 | loop:
6 | b1:
7 | b2:
8 | int 1
9 | +
10 | // loop code
11 | // check upper bound
12 | dup
13 | int 10
14 | <=
15 | bnz loop
16 | // check whether loop was executed
17 | int 11
18 | ==
19 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/multi-signature/assets/sample-asc.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // Check if Transaction type is pay, Sender is owner of Gold and amount is <= 100
3 | txn TypeEnum
4 | int 1
5 | ==
6 | txn Amount
7 | int 100
8 | <=
9 | &&
10 | txn RekeyTo
11 | global ZeroAddress
12 | ==
13 | &&
14 | txn CloseRemainderTo
15 | global ZeroAddress
16 | ==
17 | &&
18 | txn Fee
19 | int 10000
20 | <=
21 | &&
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/shared-space/assets/approval-program-1-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | on_creation:
14 | int 1
15 | return
16 |
17 | on_optin:
18 | int 1
19 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/shared-space/assets/approval-program-1.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | on_creation:
14 | int 5
15 | store 1
16 | int 6
17 | store 2
18 | int 1
19 | return
20 |
21 | on_optin:
22 | int 1
23 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/shared-space/assets/approval-program-2-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | on_creation:
14 | // push 1st value from scratch space of 0th transaction
15 | gload 0 1
16 | // verify if value is correct
17 | // wrong value is passed here so it will fail
18 | int 1
19 | ==
20 | int 0
21 | // push 2nd value from scratch space of 0th transaction
22 | gloads 2
23 | // verify if value is correct
24 | int 6
25 | ==
26 | &&
27 | return
28 |
29 | on_optin:
30 | int 1
31 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/shared-space/assets/approval-program-2.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | on_creation:
14 | // push 1st value from scratch space of 0th transaction
15 | gload 0 1
16 | // verify if value is correct
17 | int 5
18 | ==
19 | int 0
20 | // push 2nd value from scratch space of 0th transaction
21 | gloads 2
22 | // verify if value is correct
23 | int 6
24 | ==
25 | &&
26 | return
27 |
28 | on_optin:
29 | int 1
30 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/shared-space/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // approve
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful-update/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful-update/assets/newapproval.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | txn OnCompletion
4 | int NoOp
5 | ==
6 | bnz handle_noop
7 |
8 | int 0
9 | return
10 |
11 | handle_noop:
12 | // verify state from previous approval program
13 | byte "global-key"
14 | app_global_get
15 | byte "global-val"
16 | ==
17 | int 0
18 | byte "local-key"
19 | app_local_get
20 | byte "local-val"
21 | ==
22 | &&
23 | bz failed
24 |
25 | // after verifying, set new state
26 | byte "new-global-key"
27 | byte "new-global-val"
28 | app_global_put
29 |
30 | int 0
31 | byte "new-local-key"
32 | byte "new-local-val"
33 | app_local_put
34 |
35 | // return success
36 | int 1
37 | return
38 |
39 | failed:
40 | int 0
41 | return
42 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful-update/assets/oldapproval.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | // check if the app is being created
4 | // if so save creator
5 | int 0
6 | txn ApplicationID
7 | ==
8 |
9 | // if not creation skip this section
10 | bz not_creation
11 |
12 | // save the creator address to the global state
13 | byte "Creator"
14 | txn Sender
15 | app_global_put
16 |
17 |
18 | // return a success
19 | int 1
20 | return
21 |
22 | not_creation:
23 | int UpdateApplication
24 | txn OnCompletion
25 | ==
26 |
27 | bz finished
28 |
29 | // only creator can update the app
30 | byte "Creator"
31 | app_global_get
32 | txn Sender
33 | ==
34 | bz failed
35 |
36 | // update global state before updating application
37 | byte "global-key"
38 | byte "global-val"
39 | app_global_put
40 |
41 | // update local state before updating application
42 | int 0
43 | byte "local-key"
44 | byte "local-val"
45 | app_local_put
46 |
47 | finished:
48 | int 1
49 | return
50 |
51 | failed:
52 | int 0
53 | return
54 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/accept-optin.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | on_creation:
14 | int 1
15 | return
16 |
17 | on_optin:
18 | int 0
19 | byte "counter"
20 | int 0
21 | app_local_put
22 | int 1
23 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/asa.yaml:
--------------------------------------------------------------------------------
1 | gold:
2 | total: 5912599999515
3 | decimals: 0
4 | defaultFrozen: false
5 | unitName: "GLD"
6 | url: "url"
7 | metadataHash: "12312442142141241244444411111133"
8 | manager: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
9 | reserve: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
10 | freeze: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
11 | clawback: "WHVQXVVCQAD7WX3HHFKNVUL3MOANX3BYXXMEEJEJWOZNRXJNTN7LTNPSTY"
12 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/budget-opcode.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 |
3 | txn ApplicationID
4 | bz on_creation
5 |
6 | txna ApplicationArgs 0
7 | byte "budget"
8 | ==
9 | bnz budget
10 |
11 | int 0
12 | store 0
13 |
14 | loop:
15 |
16 | load 0
17 | int 1
18 | +
19 | dup
20 | store 0
21 |
22 | int 100
23 | <
24 | bnz loop
25 |
26 | int 1
27 | return
28 |
29 | budget:
30 | int 1
31 | return
32 |
33 | on_creation:
34 | int 1
35 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/clear-pooled-opcode-budget.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/clearv6.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 |
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/close-clear-ssc.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // check if application is being created
3 | // This ssc only allows creator to close out
4 | int 0
5 | txn ApplicationID
6 | ==
7 |
8 | bz not_creation
9 |
10 | // save the creator address to the global state
11 | byte "Creator"
12 | txn Sender
13 | app_global_put
14 | int 1
15 | return
16 |
17 | not_creation:
18 | int CloseOut
19 | txn OnCompletion
20 | ==
21 | int ClearState
22 | txn OnCompletion
23 | ==
24 | ||
25 |
26 | // finish if not closeOut/Clear call
27 | bz finished
28 |
29 | // check if creator is closing out
30 | byte "Creator"
31 | app_global_get
32 | txn Sender
33 | ==
34 | bz failed
35 |
36 | // update global state before closing out
37 | byte "global-key"
38 | byte "global-val"
39 | app_global_put
40 |
41 | finished:
42 | int 1
43 | return
44 |
45 | failed:
46 | int 0
47 | return
48 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/counter-approval.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | // read global state
14 | byte "counter"
15 | dup
16 | app_global_get
17 |
18 | // increment the value
19 | int 1
20 | +
21 |
22 | // store to scratch space
23 | dup
24 | store 0
25 |
26 | // update global state
27 | app_global_put
28 |
29 | // read local state for sender
30 | int 0
31 | byte "counter"
32 | app_local_get
33 |
34 | // increment the value
35 | int 1
36 | +
37 | store 1
38 |
39 | // update local state for sender
40 | int 0
41 | byte "counter"
42 | load 1
43 | app_local_put
44 |
45 | // load return value as approval
46 | load 0
47 | return
48 |
49 | on_creation:
50 | int 1
51 | return
52 |
53 | on_optin:
54 | int 0
55 | byte "counter"
56 | int 0
57 | app_local_put
58 | int 1
59 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/deleteApp.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | // check if application is being created
4 | int 0
5 | txn ApplicationID
6 | ==
7 |
8 | bz not_creation
9 |
10 | // save the creator address to the global state
11 | byte "Creator"
12 | txn Sender
13 | app_global_put
14 | int 1
15 | return
16 |
17 | not_creation:
18 | int DeleteApplication
19 | txn OnCompletion
20 | ==
21 |
22 | bz finished
23 |
24 | // check if creator is deleting
25 | byte "Creator"
26 | app_global_get
27 | txn Sender
28 | ==
29 | bz failed
30 |
31 | finished:
32 | int 1
33 | return
34 |
35 | failed:
36 | int 0
37 | return
38 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/empty-app.teal:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/runtime/test/fixtures/stateful/assets/empty-app.teal
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/reject-optin.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 |
3 | int 0
4 | txn ApplicationID
5 | ==
6 | bnz on_creation
7 |
8 | int OptIn
9 | txn OnCompletion
10 | ==
11 | bnz on_optin
12 |
13 | on_creation:
14 | int 1
15 | return
16 |
17 | on_optin:
18 | int 0
19 | byte "counter"
20 | int 0
21 | app_local_put
22 | int 0
23 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/stateful/assets/rejectClear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 0
3 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/sub-routine/assets/approval-fail-1.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | retsub
3 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/sub-routine/assets/approval-fail.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // This file shows is used to test whether subroutine
3 | // is working, from tealv4, program can jump to any label
4 | // instead of only forward.
5 | // jump to main loop
6 | b main
7 |
8 | // subroutine
9 | my_subroutine:
10 | // implement subroutine code
11 | // with the two args
12 | +
13 | retsub
14 |
15 | main:
16 | int 1
17 | int 5
18 | callsub my_subroutine
19 | int 5
20 | ==
21 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/sub-routine/assets/approval-pass.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // This file shows is used to test whether subroutine
3 | // is working, from tealv4, program can jump to any label
4 | // instead of only forward.
5 | // jump to main loop
6 | b main
7 |
8 | // subroutine
9 | my_subroutine:
10 | // implement subroutine code
11 | // with the two args
12 | +
13 | retsub
14 |
15 | main:
16 | int 1
17 | int 5
18 | callsub my_subroutine
19 | int 6
20 | ==
21 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/sub-routine/assets/clear.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/sub-routine/assets/fibonacci.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // This program calculates fibonacci number recursively
3 |
4 | b main
5 |
6 | fibo:
7 | // check if nth number is [0,1]
8 | dup
9 | int 1
10 | <=
11 | bnz finish
12 |
13 | // push (n - 1) into stack and call subroutine
14 | dup
15 | int 1
16 | -
17 | callsub fibo
18 |
19 | // push (n - 2) into stack and call subroutine
20 | int 2
21 | -
22 | callsub fibo
23 | retsub
24 |
25 | // base condition
26 | finish:
27 | load 0
28 | int 1
29 | +
30 | store 0
31 | pop
32 | retsub
33 |
34 | main:
35 | // load nth value in stack
36 | txn ApplicationArgs 0
37 | btoi
38 |
39 | int 1
40 | -
41 |
42 | callsub fibo
43 | // store Fibonacci number
44 | byte "result"
45 | load 0
46 | app_global_put
47 | int 1
48 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/file1.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/folder-1/asa.yaml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scale-it/algo-builder/c07b978651def4891768c618f0bc9cd7fab69bca/packages/runtime/test/fixtures/subdir-project/assets/folder-1/asa.yaml
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/folder-1/folder-3/file3.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/folder-1/folder-3/folder-4/duplicate-file.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/folder-1/folder-3/folder-4/file4.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/folder-2/duplicate-file.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/subdir-project/assets/folder-2/file2.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/teal-v6.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | bsqrt
3 | divw
4 | gloadss
5 | acct_params_get AcctBalance
6 | itxn_next
7 | gitxn 0 Fee
8 | gitxna 1 Accounts 1
9 | gitxnas 0 Accounts
10 | itxnas Accounts
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/teal-v7.teal:
--------------------------------------------------------------------------------
1 | #pragma version 7
2 | base64_decode URLEncoding
3 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/teal-v8.teal:
--------------------------------------------------------------------------------
1 | #pragma version 8
2 | switch zero one
3 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-addr.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | addr WWYNX3TKQYVEREVSW6QQP3SXSFOCE3SKUSEIVJ7YAGUPEACNI5UGI4DZCE // comment here
3 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-arg.teal:
--------------------------------------------------------------------------------
1 | arg_0
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-bitwise.teal:
--------------------------------------------------------------------------------
1 | // comment
2 | |
3 |
4 | &
5 |
6 | ^
7 | ~
8 | // comments
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-branch.teal:
--------------------------------------------------------------------------------
1 | // comment here
2 | b label1
3 | bz label2
4 | bnz label3
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-byte.teal:
--------------------------------------------------------------------------------
1 | byte base64 QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc=
2 | byte b64 QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc=
3 | byte base64(QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc=)
4 | byte b64(QzYhq9JlYbn2QdOMrhyxVlNtNjeyvyJc/I8d8VAGfGc=)
5 | byte base32 MFRGGZDFMY======
6 | byte b32 MFRGGZDFMY======
7 | byte base32(MFRGGZDFMY======)
8 | byte b32(MFRGGZDFMY======)
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-compare.teal:
--------------------------------------------------------------------------------
1 | <
2 | >
3 | <=
4 | >=
5 | &&
6 | ||
7 | ==
8 | !=
9 | !
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-crypto.teal:
--------------------------------------------------------------------------------
1 | sha256
2 | keccak256
3 | sha512_256
4 | ed25519verify
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-file-1.teal:
--------------------------------------------------------------------------------
1 | int 1
2 | int 3
3 | +
4 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-file-2.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 1
3 | int 3
4 | +//comment here
5 |
6 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-file-3.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 5
3 | int 3//comment here
4 | -//comment here
5 |
6 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-file-4.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 6 // comment here
3 | int 3
4 |
5 |
6 | / //comment here
7 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-file-5.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | // comment here
3 |
4 | int 5
5 |
6 | int 3
7 |
8 |
9 | //commet here
10 | * //comment here
11 |
12 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-global.teal:
--------------------------------------------------------------------------------
1 | // comment
2 | // comment here
3 | global MinTxnFee
4 | global MinBalance
5 | global MaxTxnLife
6 | global ZeroAddress
7 | global GroupSize
8 | global LogicSigVersion
9 | global Round
10 | global LatestTimestamp
11 | global CurrentApplicationID
12 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-if-else.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 5
3 | int 3
4 | +
5 | int 8
6 | ==
7 | bnz success
8 | int 1 //not calculate into cost
9 | int 4 //not calculate into cost
10 | success:
11 | int 1
12 | return
13 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-innerTxn-v7.teal:
--------------------------------------------------------------------------------
1 | #pragma version 7
2 | itxn_begin
3 | int pay
4 | itxn_field TypeEnum
5 | txn Sender
6 | itxn_field Receiver
7 | int 1000
8 | itxn_field Amount
9 | itxn_next
10 | int pay
11 | itxn_field TypeEnum
12 | txn Sender
13 | itxn_field Receiver
14 | int 1000
15 | itxn_field Amount
16 | int 2000
17 | itxn_field Fee
18 | int 1
19 | byte "Log"
20 | log
21 | return
22 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-int-bytec.teal:
--------------------------------------------------------------------------------
1 | intc_0
2 | bytec_0
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-interpreter.teal:
--------------------------------------------------------------------------------
1 | #pragma version 4
2 | int 5
3 | int 3
4 | +
5 | int 8
6 | ==
7 |
8 |
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-label.teal:
--------------------------------------------------------------------------------
1 | // comment here
2 | label:
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-len-err.teal:
--------------------------------------------------------------------------------
1 | len // here
2 | err//comment
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-max-opcost.teal:
--------------------------------------------------------------------------------
1 | ed25519verify
2 | ed25519verify
3 | ed25519verify
4 | ed25519verify
5 | ed25519verify
6 | ed25519verify
7 | ed25519verify
8 | ed25519verify
9 | ed25519verify
10 | ed25519verify
11 | ed25519verify
12 | ed25519verify
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-mod.teal:
--------------------------------------------------------------------------------
1 | int 6
2 | int 3
3 | %
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-others.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | itob
3 | btoi
4 | mulw
5 | addw /// comment
6 | pop
7 | dup
8 | dup2
9 | concat
10 | substring 0 4
11 | substring3
12 | divw
13 | // comments
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-pragma-1.teal:
--------------------------------------------------------------------------------
1 | // comment here
2 | #pragma version 4
3 | int 1
4 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-pragma-2.teal:
--------------------------------------------------------------------------------
1 |
2 |
3 | #pragma version 4
4 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-pragma-invalid.teal:
--------------------------------------------------------------------------------
1 | #pragma version 9
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-pragma-v6.teal:
--------------------------------------------------------------------------------
1 | #pragma version 6
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-pragma-v7.teal:
--------------------------------------------------------------------------------
1 | #pragma version 7
2 | int 1
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-return.teal:
--------------------------------------------------------------------------------
1 | // comment here
2 | return
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-sha256-v1.teal:
--------------------------------------------------------------------------------
1 | #pragma version 1
2 | int 1
3 | itob
4 | sha256
5 | int 1
6 | itob
7 | ==
8 | int 0
9 | ==
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-sha256-v2.teal:
--------------------------------------------------------------------------------
1 | #pragma version 2
2 | int 1
3 | itob
4 | sha256
5 | int 1
6 | itob
7 | ==
8 | int 0
9 | ==
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-stateful.teal:
--------------------------------------------------------------------------------
1 | #pragma version 5
2 | // comments
3 | // Balance and Assets opcodes
4 | balance
5 | asset_holding_get AssetBalance
6 | asset_params_get AssetTotal
7 | // Stateful opcodes
8 | app_opted_in
9 | app_local_get // here balance
10 | app_local_get_ex
11 | app_global_get
12 | app_global_get_ex
13 | app_local_put
14 | app_global_put
15 | app_local_del
16 | app_global_del
17 | int 10
18 | app_params_get AppCreator
--------------------------------------------------------------------------------
/packages/runtime/test/fixtures/teal-files/assets/test-store-load.teal:
--------------------------------------------------------------------------------
1 | store 0
2 | load 0
--------------------------------------------------------------------------------
/packages/runtime/test/helpers/data.ts:
--------------------------------------------------------------------------------
1 | // random 32 bytes
2 | export const key1 = new Uint8Array([
3 | 0x58, 0xad, 0xbb, 0xed, 0x87, 0xb8, 0xc7, 0x1e, 0x87, 0xbb, 0x61, 0x7c, 0x91, 0xfd, 0x46,
4 | 0xfc, 0x8a, 0x86, 0x87, 0xc2, 0xeb, 0x33, 0xf8, 0x73, 0xf8, 0x6f, 0x08, 0x5b, 0x2e, 0xe3,
5 | 0xc7, 0x26,
6 | ]);
7 | export const key2 = new Uint8Array([
8 | 0x58, 0xad, 0xbb, 0xed, 0x87, 0xb8, 0xc7, 0x1e, 0x87, 0xbb, 0x61, 0x7c, 0x91, 0xfd, 0x46,
9 | 0xfc, 0x8a, 0x86, 0x87, 0xc2, 0xeb, 0x33, 0xf8, 0x73, 0xf8, 0x6f, 0x08, 0x5b, 0x2e, 0xe3,
10 | 0xc7, 0x27,
11 | ]);
12 |
--------------------------------------------------------------------------------
/packages/runtime/test/helpers/integration.ts:
--------------------------------------------------------------------------------
1 | import * as fs from "fs";
2 | import path from "path";
3 |
4 | /**
5 | * This helper adds mocha hooks to run the tests inside one of the projects in test/fixtures.
6 | * @param fixtureName: The base name of the folder in test/fixtures
7 | */
8 | export function useFixture(fixtureName: string): void {
9 | let dirPath: string;
10 | let prevWorkingDir: string;
11 |
12 | before(() => {
13 | dirPath = getFixtureWorkingDir(fixtureName);
14 | prevWorkingDir = process.cwd();
15 | process.chdir(dirPath);
16 | });
17 |
18 | after(() => {
19 | process.chdir(prevWorkingDir);
20 | });
21 | }
22 |
23 | export function getFixtureWorkingDir(fixtureName: string): string {
24 | const filePath = path.join(__dirname, "..", "fixtures", fixtureName);
25 | if (!fs.existsSync(filePath)) {
26 | throw new Error(`Fixture files ${fixtureName} doesn't exist`);
27 | }
28 |
29 | return fs.realpathSync(filePath);
30 | }
31 |
--------------------------------------------------------------------------------
/packages/runtime/test/src/lib/math.ts:
--------------------------------------------------------------------------------
1 | import { assert } from "chai";
2 |
3 | import { bigintSqrt } from "../../../src/lib/math";
4 |
5 | describe("Math package", function () {
6 | it("sqrt function", function () {
7 | const inputs = [4n, 10n, 25n, BigInt(1e8), 1n << 64n, (1n << 64n) - 1n];
8 | const outputs = [2n, 3n, 5n, BigInt(1e4), 1n << 32n, (1n << 32n) - 1n];
9 | inputs.forEach((value, index) => {
10 | assert.equal(bigintSqrt(value), outputs[index]);
11 | });
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/packages/runtime/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "include": ["../src", "../../../@types", "./"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/runtime/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./build"
5 | },
6 | "include": ["src", "../../@types"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/types-download-git-repo/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["../../.eslintrc.js"],
3 | parserOptions: {
4 | project: "./tsconfig.json",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/packages/types-download-git-repo/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module "download-git-repo" {
2 | export default function download(
3 | url: string,
4 | dir: string,
5 | callback: (error: Error | undefined) => void
6 | ): Promise;
7 | }
8 |
--------------------------------------------------------------------------------
/packages/types-download-git-repo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@types/download-git-repo",
3 | "version": "0.1.0",
4 | "description": "TypeScript Declaration File",
5 | "main": "",
6 | "typings": "index.d.ts",
7 | "license": "MIT",
8 | "scripts": {
9 | "lint:check": "eslint ./index.d.ts",
10 | "lint": "eslint --fix ./index.d.ts",
11 | "build": "tsc",
12 | "build:docs": "echo ok",
13 | "test": "echo ok"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/types-download-git-repo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "noEmit": true
5 | },
6 | "files": ["index.d.ts"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/web/.eslintignore:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/web/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["../../.eslintrc.js"],
3 | parserOptions: {
4 | project: "./test/tsconfig.json",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/packages/web/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "diff": true,
3 | "extension": ["js", "ts"],
4 | "package": "./package.json",
5 | "reporter": "spec",
6 | "slow": 75,
7 | "timeout": 10000,
8 | "ui": "bdd",
9 | "watch-files": ["src/**/*.js", "test/**/*.js", "src/**/*.ts", "test/**/*.ts"],
10 | "require": ["ts-node/register", "source-map-support/register"],
11 | "recursive": true,
12 | "ignore": ["test/fixture-projects/**/*"],
13 | "file": "../../test/setup.js"
14 | }
15 |
--------------------------------------------------------------------------------
/packages/web/src/index.ts:
--------------------------------------------------------------------------------
1 | export * as parsing from "./lib/parsing";
2 | export * as status from "./lib/status";
3 | export * as tx from "./lib/txn";
4 | export * as types from "./types";
5 | export * as utils from "./lib/utils";
6 |
7 | export { ASADefSchema, ASADefsSchema } from "./types-input";
8 | export { BuilderError, applyErrorMessageTemplate, parseAlgorandError } from "./errors/errors";
9 | export { ERRORS, ErrorDescriptor, ERROR_RANGES } from "./errors/errors-list";
10 | export { WebMode } from "./lib/web-mode";
11 | export { WallectConnectSession } from "./lib/wallectconnect-mode";
12 | export { MyAlgoWalletSession } from "./lib/myalgowallet-mode";
13 | export { getSuggestedParams, mkTxParams } from "./lib/api";
14 | export {
15 | mainnetURL,
16 | testnetURL,
17 | betanetURL,
18 | mainnetGenesisHash,
19 | testnetGenesisHash,
20 | betanetGenesisHash,
21 | runtimeGenesisHash,
22 | } from "./lib/constants";
23 |
--------------------------------------------------------------------------------
/packages/web/src/lib/constants.ts:
--------------------------------------------------------------------------------
1 | export const MIN_UINT64 = 0n;
2 | export const MAX_UINT64 = 0xffffffffffffffffn;
3 | export const reDigit = /^\d+$/;
4 | export const WAIT_ROUNDS = 10; // for transaction confirmation
5 | // wallect connect
6 | export const ALGORAND_SIGN_TRANSACTION_REQUEST = "algo_signTxn";
7 | export const mainnetURL = "https://node.algoexplorerapi.io";
8 | export const testnetURL = "https://node.testnet.algoexplorerapi.io";
9 | export const betanetURL = "https://node.betanet.algoexplorerapi.io";
10 |
11 | //official networks https://developer.algorand.org/docs/get-details/algorand-networks/
12 | export const mainnetGenesisHash = "wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=";
13 | export const testnetGenesisHash = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=";
14 | export const betanetGenesisHash = "mFgazF+2uRS1tMiL9dsj01hJGySEmPN28B/TjjvpVW0=";
15 |
16 | //runtime network
17 | export const runtimeGenesisHash = "runtime";
18 |
--------------------------------------------------------------------------------
/packages/web/src/lib/logger.ts:
--------------------------------------------------------------------------------
1 | import debug from "debug";
2 |
3 | const log = debug("algob/web:log");
4 |
5 | const error = debug("algob/web:error");
6 | error.log = console.error.bind(console);
7 |
8 | const warn = debug("algob/web:warn");
9 | warn.log = console.warn.bind(console);
10 |
11 | debug.enable("algob/web:*");
12 |
13 | export { log, error, warn, debug };
14 |
--------------------------------------------------------------------------------
/packages/web/src/lib/status.ts:
--------------------------------------------------------------------------------
1 | import type { Algodv2, modelsv2 } from "algosdk";
2 |
3 | /**
4 | * Returns `account` balance of `assetID`. Returns 0 if the account is not
5 | * opted-in to the given asset id.
6 | * @param algodClient Algodv2 instance
7 | * @param accountAddress account to return assetholding info
8 | * @param assetID asset index
9 | */
10 | export async function getAssetHolding(
11 | algodClient: Algodv2,
12 | accountAddress: string,
13 | assetID: number
14 | ): Promise {
15 | const accountInfo = await algodClient.accountInformation(accountAddress).do();
16 | for (const asset of accountInfo.assets) {
17 | if (asset["asset-id"] === assetID) {
18 | return asset;
19 | }
20 | }
21 | return undefined;
22 | }
23 |
--------------------------------------------------------------------------------
/packages/web/src/lib/utils.ts:
--------------------------------------------------------------------------------
1 | import {
2 | betanetGenesisHash,
3 | mainnetGenesisHash,
4 | runtimeGenesisHash,
5 | testnetGenesisHash,
6 | } from "./constants";
7 |
8 | /**
9 | * Queris the genesish hash based on the network name
10 | * @param networkName string name of the network
11 | * @returns if the network is known the genesisHash otherwise returns undefined
12 | */
13 | export function getGenesisHashFromName(networkName: string): string | undefined {
14 | switch (networkName.toLowerCase()) {
15 | case "mainnet":
16 | return mainnetGenesisHash;
17 | case "testnet":
18 | return testnetGenesisHash;
19 | case "betanet":
20 | return betanetGenesisHash;
21 | case "runtime":
22 | return runtimeGenesisHash;
23 | default:
24 | return undefined;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/packages/web/test/mocks/sample.teal:
--------------------------------------------------------------------------------
1 | int 1
--------------------------------------------------------------------------------
/packages/web/test/src/lib/utils.ts:
--------------------------------------------------------------------------------
1 | import {
2 | betanetGenesisHash,
3 | mainnetGenesisHash,
4 | runtimeGenesisHash,
5 | testnetGenesisHash,
6 | utils,
7 | } from "@algo-builder/web";
8 | import { expect } from "chai";
9 |
10 | describe("Utility functions from algob/web", function () {
11 | describe("getGenesisHashFromName()", function () {
12 | const testGenesisHash = [
13 | { name: "mainnet", expected: mainnetGenesisHash },
14 | { name: "testnet", expected: testnetGenesisHash },
15 | { name: "betanet", expected: betanetGenesisHash },
16 | { name: "runtime", expected: runtimeGenesisHash },
17 | ];
18 |
19 | testGenesisHash.forEach(({ name, expected }) => {
20 | it(`Should return ${expected} for ${name}`, function () {
21 | expect(utils.getGenesisHashFromName(name)).to.equal(expected);
22 | });
23 | });
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/packages/web/test/src/types.ts:
--------------------------------------------------------------------------------
1 | import { assert } from "chai";
2 |
3 | import { isSDKTransactionAndSign, SignType } from "../../src/types";
4 | import { txObject } from "../mocks/tx";
5 |
6 | describe("Transaction And Sign interface", function () {
7 | it("should return false if transaction object is not SDK transaction", function () {
8 | const param: unknown = {
9 | transaction: { name: "AA" },
10 | sign: { sign: "sd" },
11 | };
12 |
13 | assert.isFalse(isSDKTransactionAndSign(param));
14 | });
15 |
16 | it("should return false if sign is not in transaction", function () {
17 | const param: unknown = {
18 | transaction: txObject,
19 | };
20 |
21 | assert.isFalse(isSDKTransactionAndSign(param));
22 | });
23 |
24 | it("should return true if sign and transaction is present", function () {
25 | const param: unknown = {
26 | transaction: txObject,
27 | sign: { sign: SignType.SecretKey, fromAccount: [] },
28 | };
29 |
30 | assert.isTrue(isSDKTransactionAndSign(param));
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/packages/web/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "include": ["../src", "../../../@types", "./"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/web/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./build"
5 | },
6 | "include": ["src", "../../@types"]
7 | }
8 |
--------------------------------------------------------------------------------
/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["../packages", "../@types"]
3 | }
4 |
--------------------------------------------------------------------------------
/tsconfig-project.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./build"
5 | },
6 | "include": ["src", "../../@types"]
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "lib": ["esnext", "dom"],
5 | "typeRoots": ["node_modules/@types"],
6 | "experimentalDecorators": true,
7 | "esModuleInterop": true,
8 | "allowJs": true,
9 | "module": "commonjs",
10 | "resolveJsonModule": true,
11 | "noImplicitReturns": true,
12 | "noImplicitThis": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "sourceMap": true,
16 | "declaration": true
17 | },
18 | "exclude": ["**/node_modules", "**/webpack"]
19 | }
20 |
--------------------------------------------------------------------------------