Skip to content

Algo Builder v4.0.0

Compare
Choose a tag to compare
@robert-zaremba robert-zaremba released this 24 May 13:14
· 189 commits to master since this release
05ed9d4

Higlights

  • We reworked how the apps are deployed. Specifically, the executeTx and it's parameters. We simplified the type and brought better compatibility with the SDK. You can easily use SDK transactions in all modes (algob, runtime and web)
    This change is targeted to our big goal: use same scripts in algob, runtime and web and make it user friendly. We welcome you freedback in Algob Algorand Discord channel.
  • exeucteTx is now a method of an Executor (base type of Deployer) available in all modes (algob, runtime, web). Previously it was a global function, which made it harder to nicely integrate with the whole framework.
  • TEAL v6 + partial v7 support.

Features

Core:

  • Added support for saving smart contract template params in ASCCache.
  • uselogger from debug package for logging utility in place of all console calls.
  • The compile.ts has been updated and now the tealCode is stored in cache when scTmplParams are used to compile TEAL with hardcoded params.
  • Added following functions in deployer API
    • getDeployedASC: returns cached program (from artifacts/cache) ASCCache object by name. Supports both App and Lsig.
  • You can initialize an new algob project with infrastructure scripts (a copy the /infrastructure directory in repository) by adding the --infrastructure flag. Example:
      algob init --infrastructure
  • Return list of receipts for each txn in group txn. Example:
const receipts = deployer.executeTx([txn0, txn1]);
console.log("txn0 information: ", receipts[0]);
console.log("txn1 information: ", receipts[2]);

JS Runtime and testing features:

  • runtime.defaultAccounts - a list of pre-generated 16 accounts with pre-defined addresses and keys, each with 1e8 microAlgos (100 Algos)

  • runtime.resetDefaultAccounts() - will recreate the default accounts (reset their state).

  • unit tests that cover new scenarios when runtime.defaultAccounts and runtime.resetDefaultAccounts() are used.

    • bond-token-flow test to also use runtime.defaultAccounts. (see example)
  • Support execution of algo-sdk-js transactionAndSign in Runtime #601.

  • Added support for checking against opcode their execution mode in runtime. For eg. arg can only be run in signature mode, and parser will reject the execution if run in application mode.

  • Support RekeyTo field in the inner transaction for TEAL v6.

  • Support keyreg transaction in inner transaction in JS runtime.

  • Enable transfer ALGO to a not regeistred account.

  • Every opcode class has been updated and now their execute method returns its cost.

  • Teal V6 support:

    • Add new opcode bsqrt and divw(##605).
    • Add new opcode gloadss(#606).
    • Add new opcode acct_params_get(#618).
    • Add new opcode itxn_next(#626).
    • Add new opcode gitxn, gitxna and gitxnas.(#628).
    • Contract to contract calls. However we limit c2c call with only AppCall(NoOpt) transactions.(#611)
    • Full support for inner transactions: itxn, itxna and itxnas
  • Teal v7 support:

    • opcode base64decode (##653)
  • algob test now runs tests recursively in test directory and subdirectories. Before only the files inside the test directory where run.

Dependencies:

  • Upgraded PyTEAL version 0.13.0 in Pipfile.
  • Upgraded JS SDK to v1.16.0

Template improvements

  • We updated the examples/DAO design. We removed treasury Smart Signature to simplify deposit management. Now a DAO app is managing voting, deposits and treasury.
  • Enabled PyTEAL Optimizer option in all our examples.

API breaking

  • Improved the smart contract deployment process. We changed the DeployASAParam and DeployASCParam to make it more explicit. The deployer.deploy* also got improvemetns with a cost of API breaking. We created the following types to describe the smart-contract to be deplyed:
// from file
type SourceFile = {
	metaType: MetaType.FILE;
	approvalProgramFilename: string;
	clearProgramFilename: string;
};

// from teal source code (string).
type SourceCode = {
	metaType: MetaType.SOURCE_CODE;
	approvalProgramCode: string;
	clearProgramCode: string;
};

// from compiled source code.
type SourceCompiled = {
	metaType: MetaType.BYTES;
	approvalProgramBytes: Uint8Array;
	clearProgramBytes: Uint8Array;
};

And the following types are added for the Smart Contract definition

export type AppDefinitionFromFile = StorageConfig & AppOptionalFlags & SourceFile;

export type AppDefinitionFromSource = StorageConfig & AppOptionalFlags & SourceCode;

export type AppDefinitionFromSourceCompiled = StorageConfig & AppOptionalFlags & SourceCompiled;

export type AppDefinition =
	| AppDefinitionFromFile
	| AppDefinitionFromSource
	| AppDefinitionFromSourceCompiled;

export type DeployAppParam = BasicParams & {
	type: TransactionType.DeployApp;
	appDefinition: AppDefinition;
};

See packages/web/src/types.ts for more details.

  • We have updated parameters of deployApp method:
/// old
  /**
	 * deploy a new application and returns application id
	 * @param approvalProgram application approval program (TEAL code or program filename)
	 * @param clearProgram application clear program (TEAL code or program filename)
	 * @param flags SSCDeployment flags
	 * @param payFlags Transaction parameters
	 * @param scTmplParams Smart Contract template parameters
	 * @param debugStack: if passed then TEAL Stack is logged to console after
	 * each opcode execution (upto depth = debugStack)
	 */
	deployApp(
		approvalProgram: string,
		clearProgram: string,
		flags: AppDeploymentFlags,
		payFlags: types.TxParams,
		scTmplParams?: SCParams,
		debugStack?: number
	): {...}

/// new
	/**
	 * deploy a new application and returns application id
	 * @param payFlags Transaction parameters
	 * @param appDefinition app definition
	 * @param scTmplParams Smart Contract template parameters
	 * @param debugStack: if passed then TEAL Stack is logged to console after
	 * each opcode execution (upto depth = debugStack)
	 */
	deployApp(
		sender: AccountSDK,
		appDefinition: types.AppDefinition,
		payFlags: types.TxParams,
		scTmplParams?: SCParams,
		debugStack?: number
	):
  • We have changed the parameters of updateApp method. Details:
  // old
	/**
	 * Update application
	 * @param senderAddr sender address
	 * @param appID application Id
	 * @param approvalProgram new approval program (TEAL code or program filename)
	 * @param clearProgram new clear program (TEAL code or program filename)
	 * @param payFlags Transaction parameters
	 * @param flags Stateful smart contract transaction optional parameters (accounts, args..)
	 * @param debugStack: if passed then TEAL Stack is logged to console after
	 * each opcode execution (upto depth = debugStack)
	 */
	updateApp(
		senderAddr: string,
		appID: number,
		approvalProgram: string,
		clearProgram: string,
		payFlags: types.TxParams,
		flags: AppOptionalFlags,
		scTmplParams?: SCParams,
		debugStack?: number
	)

  // new
  /**
	 * Update application
	 * @param appName application Name. Note in runtime application name just placeholder params
	 * @param senderAddr sender address
	 * @param appID application Id
	 * @param newAppCode new application source code
	 * @param payFlags Transaction parameters
	 * @param flags Stateful smart contract transaction optional parameters (accounts, args..)
	 * @param debugStack: if passed then TEAL Stack is logged to console after
	 * each opcode execution (upto depth = debugStack)
	 */
	updateApp(
		appName: string,
		senderAddr: string,
		appID: number,
		newAppCode: types.SmartContract,
		payFlags: types.TxParams,
		flags: AppOptionalFlags,
		scTmplParams?: SCParams,
		debugStack?: number
	)
  • The appName field is required now. We can use deployer.getApp(appName) to get checkpoint data of application. In web-mode, you can set it empty.

  • We removed runtime.addApp, deployer.getAppByFile methods.

  • We have changed the naming convention for the clearing proposal part of the DAO:

    • Renamed clearProposal to closeProposal,
    • Renamed clear_proposal to close_proposal,
    • Renamed mkClearProposalTx to mkCloseProposalTx.
  • We have updated the default behavior of algob deployer for loading data from checkpoint to be queried by "app/lsig" name (note: passing name is required). The existing functionality has been moved to <func>ByFile functions (legacy functions based on file querying):

    • Application:

      • Previous getApp(approval.py, clear.py) has been changed to getAppByFile(approval.py, clear.py).
      • New getApp(appName) function queries app info using the app name.
    • Smart signatures:

      • Existing getDelegatedLsig(lsig.py), getContractLsig(lsig.py) have been removed. Use getLsig function to query logic signature from name or filename in a checkpoint.
      • New getApp(appName) function queries app info using the app name.
      • Existing fundLsig(lsig.py, ..) function has been changed to fundLsigByFile(lsig.py, ..). Now fundLsig(lsigName, ..) will take lsig name.
      • Existing mkDelegatedLsig(fileName, signer, ..), mkContractLsig(fileName, ..) have been updated to take the lsigName as a required parameter (first parameter passed to function):
        • mkDelegatedLsig(lsigName, fileName, signer)
        • mkContractLsig(lsigName, fileName).
          Here fileName represent the name of smart contract file (eg. treasury-lsig.teal), and lsigName represents the "name" you want to assign to this lsig (eg. treasuryLsig).

    For reference you can check out examples/asa.

  • Updated getLsig, getDelegatedLsigByFile, getContractLsigByFile, getApp to throw an error if information against checkpoint (by name or file) is not found.

  • Updated TxReceipts for runtimes' deployApp, deployASA to use same types as algob (AppInfo, ASAInfo).

  • Updated txId key in returned App/ASA info to txID.

  • printLocalStateSCC renamed to printLocalStateApp.

  • printGlobalStateSCC renamed to printGlobalStateApp.

  • The PyASCCache has been merged to ASCCache and is not used anymore.

  • Only use list transaction in executeTx.

  • Rename the executeTransaction to executeTx

  • The Deployer interface now contains a new method executeTx while the old function is still supporoted it is
    recommended to use the method from Deployer rather than the function dirrectly.

  • executeTx method from WebMode class now returns Promise<algosdk.modelsv2.PendingTransactionResponse> .

Bug fixes

  • Return error when closeRemainderTo and fromAccountAddr is the same.
  • When close account should remove auth/spend address. Fixed in #575.
  • Approval program and clear propram should throw error if they are mismatch version. Fixed in #620
  • Allow token to be empty.
  • Throw error when issue inner transactions in clear program. Fixed in #667.
  • Parameters in extract* opcodes can greater than uint8. Fixed in #666.
  • Wallet contructor come from a parameter walletURL(token, server, port)
  • Restirct duplicate transaction in group transaction.

Infrastructure

  • Updated setup-master-account and sandbox-setup-master-account commands to run multiple times.

Notes

We continue to use yarn v3. Please share your feedback about it. Hope this improved your workflow.

Full Changelog: v3.3.0...v4.0.0