Options
All
  • Public
  • Public/Protected
  • All
Menu

@algo-builder/runtime

Index

Variables

ERRORS: { [ _category in keyof typeof RUNTIME_ERROR_RANGES]: {} } = ...

Functions

  • checkIfAssetDeletionTx(txn: Transaction): boolean
  • getPathFromDirRecursive(dir: string, fileName: string, warnMsg?: string): string | undefined
  • Searches recursively and returns path of file in a given directory. Throws error if multiple files with same name are found (in directory or sub-directory)

    Parameters

    • dir: string

      directory name

    • fileName: string

      name of file to search in directory

    • Optional warnMsg: string

      if file does not exist & warning message is passed, then console log warning, and return. throws error otherwise

    Returns string | undefined

  • getProgram(fileName: string, scInitParam?: SCParams, logs?: boolean): string
  • returns program TEAL code.

    Parameters

    • fileName: string

      filename in /assets. Must end with .teal OR .py

    • Optional scInitParam: SCParams

      smart contract template parameters, used to set hardcoded values in .py smart contract. (used only when compiling PyTEAL to TEAL)

    • logs: boolean = true

      only show logs on console when set as true. By default this value is true

    Returns string

  • Loads, validates and returns asset definitions from the assets/asa.yaml file

    Parameters

    • accounts: AccountMap | RuntimeAccountMap

      map of string => account. AccountMap is the SDK account type, used in builder. RuntimeAccountMap is for AccountStore used in runtime (where we use maps instead of arrays in sdk structures).

    Returns types.ASADefs

  • loadFromYamlFileSilent(filePath: string, options?: Options): any
  • loadFromYamlFileSilentWithMessage(filePath: string, messageIfNotPresent: string, options?: Options): any
  • lsTreeWalk(directoryName: string): string[]
  • overrideASADef(accounts: AccountMap, origDef: { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }, newDef?: Partial<{ clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }>): types.ASADef
  • Override & validate ASA definition in asa.yaml using custom params passed via deployASA

    Parameters

    • accounts: AccountMap

      accounts by name

    • origDef: { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }

      source asset definition (in asa.yaml)

      • Optional clawback?: string
      • decimals: number | bigint
      • Optional defaultFrozen?: boolean
      • Optional freeze?: string
      • Optional manager?: string
      • Optional metadataHash?: string | Uint8Array | Buffer
      • Optional name?: string
      • Optional note?: string
      • Optional noteb64?: string
      • Optional optInAccNames?: string[]
      • Optional reserve?: string
      • total: string | number | bigint
      • Optional unitName?: string
      • Optional url?: string
    • Optional newDef: Partial<{ clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }>

      custom asset def params (passed during ASA deployment)

    Returns types.ASADef

    overriden asset definition. If custom params are empty, return source asa def

  • parseASADef(asaDef: { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }, source?: string): types.ASADef
  • Validate and parse each field of asset definition. metadataHash, if provided as a Buffer will be transformed into Uint8Array.

    Parameters

    • asaDef: { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }

      asset definition

      • Optional clawback?: string
      • decimals: number | bigint
      • Optional defaultFrozen?: boolean
      • Optional freeze?: string
      • Optional manager?: string
      • Optional metadataHash?: string | Uint8Array | Buffer
      • Optional name?: string
      • Optional note?: string
      • Optional noteb64?: string
      • Optional optInAccNames?: string[]
      • Optional reserve?: string
      • total: string | number | bigint
      • Optional unitName?: string
      • Optional url?: string
    • Optional source: string

      source of assetDef: asa.yaml file OR function deployASA

    Returns types.ASADef

    parsed asa definition

  • parseZodError(ze: ZodError<any>): string
  • validateASADefs(asaDefs: Record<string, { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }>, accounts: AccountMap | RuntimeAccountMap, filename: string): types.ASADefs
  • Parses, overrides and validates asset defs map. Filaname parameter is used to indicate an ASA definition source when reporting errors.

    Parameters

    • asaDefs: Record<string, { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }>

      asset definitions to validate

    • accounts: AccountMap | RuntimeAccountMap

      map of string => account. AccountMap is the SDK account type, used in builder. RuntimeAccountMap is for AccountStore used in runtime (where we use maps instead of arrays in sdk structures).

    • filename: string

      asa filename

    Returns types.ASADefs

  • validateOptInAccNames(accounts: AccountMap | RuntimeAccountMap, asaDef: { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }, source?: string): void
  • Validates asset definitions and checks if opt-in acc names are present in network

    Parameters

    • accounts: AccountMap | RuntimeAccountMap

      AccountMap is the SDK account type, used in builder. RuntimeAccountMap is for AccountStore used in runtime (where we use maps instead of arrays in sdk structures).

    • asaDef: { clawback?: string; decimals: number | bigint; defaultFrozen?: boolean; freeze?: string; manager?: string; metadataHash?: string | Uint8Array | Buffer; name?: string; note?: string; noteb64?: string; optInAccNames?: string[]; reserve?: string; total: string | number | bigint; unitName?: string; url?: string }

      asset definition

      • Optional clawback?: string
      • decimals: number | bigint
      • Optional defaultFrozen?: boolean
      • Optional freeze?: string
      • Optional manager?: string
      • Optional metadataHash?: string | Uint8Array | Buffer
      • Optional name?: string
      • Optional note?: string
      • Optional noteb64?: string
      • Optional optInAccNames?: string[]
      • Optional reserve?: string
      • total: string | number | bigint
      • Optional unitName?: string
      • Optional url?: string
    • Optional source: string

    Returns void

Generated using TypeDoc