code
stringlengths
0
390k
repo_name
stringclasses
1 value
path
stringlengths
12
69
language
stringclasses
1 value
license
stringclasses
1 value
size
int64
0
390k
# ruff: noqa # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc....
algorandfoundation/puya
docs/conf.py
Python
NOASSERTION
2,216
algorandfoundation/puya
examples/__init__.py
Python
NOASSERTION
0
# WARNING: This code is provided for example only. Do NOT deploy to mainnet. from algopy import ( Account, ARC4Contract, Asset, Global, Txn, UInt64, arc4, gtxn, itxn, op, subroutine, ) # Total supply of the pool tokens TOTAL_SUPPLY = 10_000_000_000 # scale helps with precis...
algorandfoundation/puya
examples/amm/contract.py
Python
NOASSERTION
12,955
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class ConstantProductAMM(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod def set_governor( self, new_governor: algopy.Account, ) -> None: """ sets the govern...
algorandfoundation/puya
examples/amm/out/client_ConstantProductAMM.py
Python
NOASSERTION
2,067
import typing from algopy import ARC4Contract, arc4 class Swapped(arc4.Struct): a: arc4.UInt64 b: arc4.UInt64 class EventEmitter(ARC4Contract): @arc4.abimethod def emit_swapped(self, a: arc4.UInt64, b: arc4.UInt64) -> None: arc4.emit(Swapped(b, a)) arc4.emit("Swapped(uint64,uint64)"...
algorandfoundation/puya
examples/arc_28/contract.py
Python
NOASSERTION
633
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class EventEmitter(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod def emit_swapped( self, a: algopy.arc4.UIntN[typing.Literal[64]], b: algopy.arc4.UIntN[typing.Literal[...
algorandfoundation/puya
examples/arc_28/out/client_EventEmitter.py
Python
NOASSERTION
578
from algopy import ( Account, ARC4Contract, Asset, Global, LocalState, Txn, UInt64, arc4, gtxn, itxn, subroutine, ) class Auction(ARC4Contract): def __init__(self) -> None: self.auction_end = UInt64(0) self.previous_bid = UInt64(0) self.asa_amoun...
algorandfoundation/puya
examples/auction/contract.py
Python
NOASSERTION
3,611
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class Auction(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod def opt_into_asset( self, asset: algopy.Asset, ) -> None: ... @algopy.arc4.abimethod def start_auction...
algorandfoundation/puya
examples/auction/out/client_Auction.py
Python
NOASSERTION
914
import typing from algopy import Box, BoxMap, BoxRef, Bytes, Global, String, Txn, UInt64, arc4, subroutine StaticInts: typing.TypeAlias = arc4.StaticArray[arc4.UInt8, typing.Literal[4]] class BoxContract(arc4.ARC4Contract): def __init__(self) -> None: self.box_a = Box(UInt64) self.box_b = Box[ar...
algorandfoundation/puya
examples/box_storage/contract.py
Python
NOASSERTION
6,493
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class BoxContract(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod def set_boxes( self, a: algopy.arc4.UIntN[typing.Literal[64]], b: algopy.arc4.DynamicBytes, c: ...
algorandfoundation/puya
examples/box_storage/out/client_BoxContract.py
Python
NOASSERTION
1,776
from algopy import Bytes, Contract, Txn, UInt64, log, op, subroutine ADD = 1 SUB = 2 MUL = 3 DIV = 4 @subroutine def itoa(i: UInt64) -> Bytes: digits = Bytes(b"0123456789") radix = digits.length if i < radix: return digits[i] return itoa(i // radix) + digits[i % radix] class MyContract(Cont...
algorandfoundation/puya
examples/calculator/contract.py
Python
NOASSERTION
2,278
from algopy import ( Account, Application, Asset, Bytes, Contract, GlobalState, String, UInt64, subroutine, ) class AppStateContract(Contract): def __init__(self) -> None: self.global_int_full = GlobalState(UInt64(55)) self.global_int_simplified = UInt64(33) ...
algorandfoundation/puya
examples/global_state/contract.py
Python
NOASSERTION
2,937
from algopy import Contract, Txn, log class HelloWorldContract(Contract): def approval_program(self) -> bool: name = Txn.application_args(0) log(b"Hello, " + name) return True def clear_state_program(self) -> bool: return True
algorandfoundation/puya
examples/hello_world/contract.py
Python
NOASSERTION
270
from algopy import ARC4Contract, String, arc4 # Note: this contract is also used in the Puya AlgoKit template. So any breaking changes # that require fixing this contract should also be made there # https://github.com/algorandfoundation/algokit-puya-template/blob/main/template_content/pyproject.toml.jinja # https://gi...
algorandfoundation/puya
examples/hello_world_arc4/contract.py
Python
NOASSERTION
680
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class HelloWorldContract(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod def hello( self, name: algopy.arc4.String, ) -> algopy.arc4.String: ...
algorandfoundation/puya
examples/hello_world_arc4/out/client_HelloWorldContract.py
Python
NOASSERTION
292
from algopy import ( Account, Bytes, Contract, LocalState, OnCompleteAction, String, Txn, UInt64, log, subroutine, ) class LocalStateContract(Contract): def __init__(self) -> None: self.local = LocalState(Bytes) self.local_bool = LocalState(bool) def ap...
algorandfoundation/puya
examples/local_state/local_state_contract.py
Python
NOASSERTION
3,010
from algopy import ( Bytes, Contract, LocalState, OnCompleteAction, Txn, UInt64, log, op, subroutine, ) class LocalStateContract(Contract, name="LocalStateWithOffsets"): def __init__(self) -> None: self.local = LocalState(Bytes) def approval_program(self) -> bool: ...
algorandfoundation/puya
examples/local_state/local_state_with_offsets.py
Python
NOASSERTION
2,220
import typing from algopy import BigUInt, Bytes, arc4, op, subroutine, urange Bytes32: typing.TypeAlias = arc4.StaticArray[arc4.Byte, typing.Literal[32]] Proof: typing.TypeAlias = arc4.DynamicArray[Bytes32] class MerkleTree(arc4.ARC4Contract): @arc4.abimethod(create="require") def create(self, root: Bytes32...
algorandfoundation/puya
examples/merkle/contract.py
Python
NOASSERTION
860
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class MerkleTree(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod(create='require') def create( self, root: algopy.arc4.StaticArray[algopy.arc4.Byte, typing.Literal[32]], ) -...
algorandfoundation/puya
examples/merkle/out/client_MerkleTree.py
Python
NOASSERTION
602
from algopy import ARC4Contract, Asset, arc4, op, subroutine class UserStruct(arc4.Struct): name: arc4.String id: arc4.UInt64 asset: arc4.UInt64 class ExampleContract(ARC4Contract): @subroutine def read_from_box(self, user_id: arc4.UInt64) -> UserStruct: box_data, exists = op.Box.get(use...
algorandfoundation/puya
examples/struct_in_box/contract.py
Python
NOASSERTION
1,365
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class UserStruct(algopy.arc4.Struct): name: algopy.arc4.String id: algopy.arc4.UIntN[typing.Literal[64]] asset: algopy.arc4.UIntN[typing.Literal[64]] class ExampleContract(algopy.arc4.ARC4Client, typing.Pro...
algorandfoundation/puya
examples/struct_in_box/out/client_ExampleContract.py
Python
NOASSERTION
749
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class TicTacToeContract(algopy.arc4.ARC4Client, typing.Protocol): @algopy.arc4.abimethod(create='allow') def new_game( self, move: algopy.arc4.Tuple[algopy.arc4.UIntN[typing.Literal[64]], algopy...
algorandfoundation/puya
examples/tictactoe/out/client_TicTacToeContract.py
Python
NOASSERTION
863
# ruff: noqa: PT018 import typing from algopy import Account, GlobalState, Txn, UInt64, arc4, op, subroutine Row: typing.TypeAlias = arc4.StaticArray[arc4.UInt8, typing.Literal[3]] Game: typing.TypeAlias = arc4.StaticArray[Row, typing.Literal[3]] Move: typing.TypeAlias = tuple[UInt64, UInt64] EMPTY = 0 HOST = 1 CHALL...
algorandfoundation/puya
examples/tictactoe/tictactoe.py
Python
NOASSERTION
3,051
# This file is auto-generated, do not modify # flake8: noqa # fmt: off import typing import algopy class VotingPreconditions(algopy.arc4.Struct): is_voting_open: algopy.arc4.UIntN[typing.Literal[64]] is_allowed_to_vote: algopy.arc4.UIntN[typing.Literal[64]] has_already_voted: algopy.arc4.UIntN[typing.Lite...
algorandfoundation/puya
examples/voting/out/client_VotingRoundApp.py
Python
NOASSERTION
1,622
# Converted from https://github.com/algorandfoundation/nft_voting_tool/blob/c0f8be47ab80c8694d2cf40ca0df54cec07ff14a/src/algorand/smart_contracts/voting.py import typing from algopy import ( Account, ARC4Contract, BoxMap, BoxRef, Bytes, Global, GlobalState, OpUpFeeSource, String, ...
algorandfoundation/puya
examples/voting/voting.py
Python
NOASSERTION
8,705
algorandfoundation/puya
scripts/__init__.py
Python
NOASSERTION
0
import csv import subprocess from pathlib import Path from scripts.compile_all_examples import ProgramSizes _SCRIPTS_DIR = Path(__file__).parent _ROOT_DIR = _SCRIPTS_DIR.parent def main() -> None: sizes_path = _ROOT_DIR / "examples" / "sizes.txt" curr_text = sizes_path.read_text("utf8") prev_text = subp...
algorandfoundation/puya
scripts/analyse_sizes_diff.py
Python
NOASSERTION
1,735
import typing from collections import Counter from collections.abc import Iterator from pathlib import Path VCS_ROOT = Path(__file__).parent.parent OUTPUT_BASE_DIRS = ["examples", "test_cases"] CODE_INDENT = " " INTERESTING_OPS = frozenset( [ # pure stack manipulation "intc", *[f"intc...
algorandfoundation/puya
scripts/analyse_teal_op_frequencies.py
Python
NOASSERTION
3,342
import argparse import base64 from pathlib import Path from algosdk.v2client.algod import AlgodClient def main(path: list[Path]) -> None: algod_client = AlgodClient(algod_token="a" * 64, algod_address="http://localhost:4001") for p in path: response = algod_client.compile(p.read_text("utf8")) ...
algorandfoundation/puya
scripts/assemble.py
Python
NOASSERTION
677
#!/usr/bin/env python3 import argparse import json import operator import os import re import shutil import subprocess import sys from collections import defaultdict from collections.abc import Iterable from concurrent.futures import ProcessPoolExecutor from pathlib import Path import algokit_utils.deploy import attrs...
algorandfoundation/puya
scripts/compile_all_examples.py
Python
NOASSERTION
12,912
import argparse import contextlib import json import typing from collections.abc import Iterator from dataclasses import dataclass from functools import cached_property from pathlib import Path from algosdk.atomic_transaction_composer import ( AccountTransactionSigner, AtomicTransactionComposer, Transactio...
algorandfoundation/puya
scripts/dry_run_create.py
Python
NOASSERTION
3,852
#!/usr/bin/env python3 import json import subprocess from pathlib import Path from puya import log from puya.ussemble.op_spec_models import ImmediateEnum, ImmediateKind, OpSpec from scripts.transform_lang_spec import ( LanguageSpec, ) logger = log.get_logger(__name__) VCS_ROOT = Path(__file__).parent.parent def...
algorandfoundation/puya
scripts/generate_assemble_op_spec.py
Python
NOASSERTION
1,735
import builtins import json import keyword import subprocess import textwrap from collections.abc import Iterable, Iterator from pathlib import Path from puya import log from puya.ir.avm_ops_models import ( AVMOpData, DynamicVariants, ImmediateKind, OpSignature, RunMode, StackType, Variant,...
algorandfoundation/puya
scripts/generate_avm_ops.py
Python
NOASSERTION
8,430
#!/usr/bin/env python3 import subprocess import sys import typing from collections.abc import Callable from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent / "src" / "puyapy" / "_vendor")) import attrs import mypy.build import mypy.nodes from mypy.visitor import NodeVisitor from puyapy.compi...
algorandfoundation/puya
scripts/generate_docs.py
Python
NOASSERTION
14,331
#!/usr/bin/env python3 import subprocess from pathlib import Path SCRIPTS_DIR = Path(__file__).parent VCS_ROOT = SCRIPTS_DIR.parent LIB_NAME = "_puya_lib" def main() -> None: # compile puya lib # normalize source_location.path # save subprocess.run(["puyapy", "--output-awst-json", f"src/{LIB_NAME}"]...
algorandfoundation/puya
scripts/generate_puya_lib.py
Python
NOASSERTION
935
#!/usr/bin/env python3 import builtins import copy import json import keyword import subprocess import textwrap import typing from collections.abc import Iterable, Iterator, Sequence from pathlib import Path import attrs from puya import log from puya.algo_constants import SUPPORTED_AVM_VERSIONS from puyapy.awst_buil...
algorandfoundation/puya
scripts/generate_stubs.py
Python
NOASSERTION
33,877
#!/usr/bin/env python3 import contextlib import enum import json import logging import typing from pathlib import Path import attrs import cattrs logger = logging.getLogger(__name__) STACK_INPUT_NAMES = "ABCDE" STACK_OUTPUT_NAMES_FEW = "XYZ" # 3 or less var STACK_OUTPUT_NAMES_MANY = "WXYZ" # 4 var VARIABLE_SIZE...
algorandfoundation/puya
scripts/transform_lang_spec.py
Python
NOASSERTION
18,689
#!/usr/bin/env python3 import os import shutil import subprocess import sys import tempfile from pathlib import Path MYPY_REPO = "https://github.com/python/mypy.git" VCS_ROOT = Path(__file__).parent.parent TYPESHED_README = """ This is PuyaPy's custom typeshed, which is a curated subset of the official MyPy typeshed. ...
algorandfoundation/puya
scripts/vendor_mypy.py
Python
NOASSERTION
3,730
algorandfoundation/puya
src/_puya_lib/__init__.py
Python
NOASSERTION
0
from algopy import ( Bytes, UInt64, subroutine, urange, ) from algopy.op import ( btoi, bzero, extract, extract_uint16, getbit, itob, replace, select_uint64, setbit_bytes, substring, ) UINT16_SIZE = 2 UINT64_SIZE = 8 UINT16_OFFSET = UINT64_SIZE - UINT16_SIZE @s...
algorandfoundation/puya
src/_puya_lib/arc4.py
Python
NOASSERTION
12,234
from algopy import Bytes, UInt64, op, subroutine @subroutine def is_substring(item: Bytes, sequence: Bytes) -> bool: """ Search for a shorter string in a larger one. """ start = UInt64(0) while start + item.length <= sequence.length: if item == op.substring(sequence, start, start + item.l...
algorandfoundation/puya
src/_puya_lib/bytes_.py
Python
NOASSERTION
388
from algopy import ( Bytes, OnCompleteAction, OpUpFeeSource, TransactionType, UInt64, op, subroutine, ) @subroutine def ensure_budget(required_budget: UInt64, fee_source: OpUpFeeSource) -> None: # A budget buffer is necessary to deal with an edge case of ensure_budget(): # if the...
algorandfoundation/puya
src/_puya_lib/util.py
Python
NOASSERTION
1,326
algorandfoundation/puya
src/puya/__init__.py
Python
NOASSERTION
0
import argparse from importlib.metadata import version from pathlib import Path import attrs from puya.log import LogFormat, LogLevel, configure_logging from puya.main import main @attrs.define(kw_only=True) class _PuyaCLIArgs: options: Path | None = None awst: Path | None = None source_annotations: Pat...
algorandfoundation/puya
src/puya/__main__.py
Python
NOASSERTION
1,862
ZERO_ADDRESS = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ" ENCODED_ADDRESS_LENGTH = 58 PUBLIC_KEY_HASH_LENGTH = 32 ADDRESS_CHECKSUM_LENGTH = 4 MAX_BIGUINT_BITS = 512 MAX_UINT64 = 2**64 - 1 MAX_BIGUINT_BYTES = MAX_BIGUINT_BITS // 8 MAX_BYTES_LENGTH = 4096 MAX_SCRATCH_SLOT_NUMBER = 255 MAX_GLOBAL_STATE_K...
algorandfoundation/puya
src/puya/algo_constants.py
Python
NOASSERTION
925
import base64 import json import typing from collections.abc import Collection, Mapping, Sequence from puya import ( artifact_metadata as md, log, ) from puya.avm import OnCompletionAction from puya.awst.nodes import ( AppStorageKind, ARC4CreateOption, ) from puya.parse import SourceLocation OCA_ARC32...
algorandfoundation/puya
src/puya/arc32.py
Python
NOASSERTION
7,940
import base64 import itertools import typing from collections import defaultdict from collections.abc import Iterable, Mapping, Sequence from importlib.metadata import version as metadata_version from cattrs.preconf.json import make_converter from packaging import version from puya import ( arc56_models as models...
algorandfoundation/puya
src/puya/arc56.py
Python
NOASSERTION
11,621
# ruff: noqa: N815 import enum import typing from collections.abc import Mapping, Sequence import attrs ABIType = str """An ABI-encoded type""" StructName = str """The name of a defined struct""" ProgramType = typing.Literal["approval", "clear"] class AVMType(enum.StrEnum): """A native AVM type""" bytes = ...
algorandfoundation/puya
src/puya/arc56_models.py
Python
NOASSERTION
11,510
import re import typing from collections.abc import Sequence import attrs from immutabledict import immutabledict from puya import avm from puya.avm import AVMType from puya.awst import nodes as awst_nodes from puya.parse import SourceLocation from puya.program_refs import ContractReference, LogicSigReference @attr...
algorandfoundation/puya
src/puya/artifact_metadata.py
Python
NOASSERTION
4,366
import graphlib import typing from collections.abc import Iterable, Mapping, Sequence import attrs from puya import log from puya.errors import CodeError from puya.ir.models import CompiledContractReference, CompiledLogicSigReference, ModuleArtifact from puya.ir.visitor import IRTraverser from puya.parse import Sourc...
algorandfoundation/puya
src/puya/artifact_sorter.py
Python
NOASSERTION
3,355
import enum @enum.unique class AVMType(enum.Flag): bytes = enum.auto() uint64 = enum.auto() any = bytes | uint64 # values and names are matched to AVM definitions class OnCompletionAction(enum.IntEnum): NoOp = 0 OptIn = 1 CloseOut = 2 ClearState = 3 UpdateApplication = 4 DeleteAp...
algorandfoundation/puya
src/puya/avm.py
Python
NOASSERTION
453
algorandfoundation/puya
src/puya/awst/__init__.py
Python
NOASSERTION
0
from immutabledict import immutabledict from puya.awst import wtypes from puya.errors import CodeError from puya.parse import SourceLocation def wtype_to_arc4(wtype: wtypes.WType, loc: SourceLocation | None = None) -> str: match wtype: case wtypes.ARC4Type(arc4_name=arc4_name): return arc4_na...
algorandfoundation/puya
src/puya/awst/arc4_types.py
Python
NOASSERTION
2,393
import typing from puya.awst import nodes as awst_nodes from puya.awst.function_traverser import FunctionTraverser from puya.awst.visitors import ContractMemberVisitor, RootNodeVisitor class AWSTTraverser(FunctionTraverser, RootNodeVisitor[None], ContractMemberVisitor[None]): @typing.override def visit_subro...
algorandfoundation/puya
src/puya/awst/awst_traverser.py
Python
NOASSERTION
1,085
import typing import puya.awst.visitors from puya.awst import nodes as awst_nodes class FunctionTraverser( puya.awst.visitors.ExpressionVisitor[None], puya.awst.visitors.StatementVisitor[None], ): @typing.override def visit_assignment_statement(self, statement: awst_nodes.AssignmentStatement) -> None...
algorandfoundation/puya
src/puya/awst/function_traverser.py
Python
NOASSERTION
12,822
import abc import decimal import enum import typing from abc import ABC, abstractmethod from collections.abc import Iterator, Mapping, Sequence, Set from functools import cached_property import attrs from immutabledict import immutabledict from puya.algo_constants import SUPPORTED_AVM_VERSIONS from puya.avm import AV...
algorandfoundation/puya
src/puya/awst/nodes.py
Python
NOASSERTION
57,974
import decimal import enum import functools import typing from collections.abc import Mapping import cattrs from cattrs import ClassValidationError, IterableValidationError, transform_error from cattrs.preconf.json import make_converter from cattrs.strategies import configure_tagged_union, include_subclasses from immu...
algorandfoundation/puya
src/puya/awst/serialize.py
Python
NOASSERTION
4,052
import base64 import typing from collections.abc import Iterable, Iterator, Mapping from puya.awst import nodes, wtypes from puya.awst.visitors import ( ContractMemberVisitor, ExpressionVisitor, RootNodeVisitor, StatementVisitor, ) from puya.errors import InternalError class ToCodeVisitor( RootNo...
algorandfoundation/puya
src/puya/awst/to_code_visitor.py
Python
NOASSERTION
25,304
# ruff: noqa: PIE796 import enum import typing import attrs from puya.avm import AVMType from puya.awst import wtypes __all__ = [ "TxnField", ] @attrs.frozen(eq=False, hash=False) class _TxnFieldData: wtype: wtypes.WType num_values: int = attrs.field(default=1, validator=attrs.validators.ge(1), kw_only...
algorandfoundation/puya
src/puya/awst/txn_fields.py
Python
NOASSERTION
6,085
algorandfoundation/puya
src/puya/awst/validation/__init__.py
Python
NOASSERTION
0
from collections.abc import Iterator import attrs from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.awst_traverser import AWSTTraverser logger = log.get_logger(__name__) class ARC4CopyValidator(AWSTTraverser): @classmethod def validate(cls, module: awst_node...
algorandfoundation/puya
src/puya/awst/validation/arc4_copy.py
Python
NOASSERTION
7,770
import contextlib import typing from collections.abc import Iterator from puya import log from puya.awst import nodes as awst_nodes from puya.awst.awst_traverser import AWSTTraverser from puya.awst.nodes import ( ContractMethodTarget, InstanceMethodTarget, InstanceSuperMethodTarget, SubroutineID, ) lo...
algorandfoundation/puya
src/puya/awst/validation/base_invoker.py
Python
NOASSERTION
2,702
from puya import log from puya.awst import nodes as awst_nodes from puya.awst.awst_traverser import AWSTTraverser logger = log.get_logger(__name__) class ImmutableValidator(AWSTTraverser): @classmethod def validate(cls, module: awst_nodes.AWST) -> None: validator = cls() for module_statement ...
algorandfoundation/puya
src/puya/awst/validation/immutable.py
Python
NOASSERTION
1,818
import contextlib from collections.abc import Iterator from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.awst_traverser import AWSTTraverser from puya.awst.wtypes import WInnerTransaction, WInnerTransactionFields from puya.parse import SourceLocation logger = log.get_l...
algorandfoundation/puya
src/puya/awst/validation/inner_transactions.py
Python
NOASSERTION
13,153
from collections import defaultdict from puya import log from puya.awst import nodes as awst_nodes from puya.awst.function_traverser import FunctionTraverser logger = log.get_logger(__name__) class LabelsValidator(FunctionTraverser): @classmethod def validate(cls, module: awst_nodes.AWST) -> None: f...
algorandfoundation/puya
src/puya/awst/validation/labels.py
Python
NOASSERTION
1,741
from puya.awst import nodes as awst_nodes from puya.awst.validation.arc4_copy import ARC4CopyValidator from puya.awst.validation.base_invoker import BaseInvokerValidator from puya.awst.validation.immutable import ImmutableValidator from puya.awst.validation.inner_transactions import ( InnerTransactionsValidator, ...
algorandfoundation/puya
src/puya/awst/validation/main.py
Python
NOASSERTION
1,064
from collections.abc import Collection, Iterator from puya import log from puya.awst import nodes as awst_nodes from puya.awst.awst_traverser import AWSTTraverser from puya.parse import SourceLocation logger = log.get_logger(__name__) class ScratchSlotReservationValidator(AWSTTraverser): @classmethod def va...
algorandfoundation/puya
src/puya/awst/validation/scratch_slots.py
Python
NOASSERTION
1,972
import typing from collections import defaultdict from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.awst_traverser import AWSTTraverser from puya.awst.nodes import AppStorageKind from puya.utils import set_add logger = log.get_logger(__name__) class StorageTypesValid...
algorandfoundation/puya
src/puya/awst/validation/storage.py
Python
NOASSERTION
2,223
from __future__ import annotations # needed to break import cycle import typing as t from abc import ABC, abstractmethod if t.TYPE_CHECKING: import puya.awst.nodes class StatementVisitor[T](ABC): @abstractmethod def visit_block(self, statement: puya.awst.nodes.Block) -> T: ... @abstractmethod ...
algorandfoundation/puya
src/puya/awst/visitors.py
Python
NOASSERTION
9,483
import typing from collections.abc import Iterable, Mapping from functools import cached_property import attrs from immutabledict import immutabledict from puya import log from puya.avm import AVMType, TransactionType from puya.errors import CodeError, InternalError from puya.parse import SourceLocation from puya.uti...
algorandfoundation/puya
src/puya/awst/wtypes.py
Python
NOASSERTION
16,805
import abc import typing from collections.abc import Mapping, Sequence import attrs from puya.artifact_metadata import ContractMetaData, LogicSignatureMetaData from puya.parse import SourceLocation from puya.program_refs import ContractReference, LogicSigReference TemplateValue = tuple[int | bytes, SourceLocation | ...
algorandfoundation/puya
src/puya/compilation_artifacts.py
Python
NOASSERTION
2,895
import itertools import shutil import typing from collections import defaultdict from collections.abc import Iterator, Mapping, Sequence, Set from pathlib import Path import attrs from cattrs.preconf.json import make_converter from immutabledict import immutabledict from puya import log from puya.arc32 import create_...
algorandfoundation/puya
src/puya/compile.py
Python
NOASSERTION
16,225
import typing from collections.abc import Mapping, Sequence from pathlib import Path import attrs from immutabledict import immutabledict from puya import log from puya.artifact_metadata import StateTotals from puya.compilation_artifacts import TemplateValue from puya.options import PuyaOptions from puya.parse import...
algorandfoundation/puya
src/puya/context.py
Python
NOASSERTION
3,629
import contextlib import enum import sys import traceback from collections.abc import Iterator from puya import log from puya.parse import SourceLocation logger = log.get_logger(__name__) class ErrorExitCode(enum.IntEnum): code = 1 internal = 2 class PuyaError(Exception): def __init__(self, msg: str, ...
algorandfoundation/puya
src/puya/errors.py
Python
NOASSERTION
1,408
IR_SSA = "ssa" IR_OPTIMIZATION = "pass" IR_FINAL = "final" IR_ALL = (IR_SSA, IR_OPTIMIZATION, IR_FINAL)
algorandfoundation/puya
src/puya/ir/__init__.py
Python
NOASSERTION
105
import typing from collections.abc import Mapping import attrs import puya.ir.models as ir from puya import ( artifact_metadata as models, log, ) from puya.avm import AVMType, OnCompletionAction from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.arc4_types import maybe_avm_to_arc4_e...
algorandfoundation/puya
src/puya/ir/_arc4_default_args.py
Python
NOASSERTION
9,586
import contextlib import typing from collections import Counter from collections.abc import Iterable, Iterator, Mapping, Sequence from operator import itemgetter import attrs from immutabledict import immutabledict import puya.artifact_metadata as models from puya import algo_constants, log from puya.avm import AVMTy...
algorandfoundation/puya
src/puya/ir/_contract_metadata.py
Python
NOASSERTION
14,260
from collections import deque from collections.abc import Iterator from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.ir import models from puya.ir.models import Parameter, Subroutine from puya.ir.types_ import wtype_to_ir_type, wtype_to_ir_types from puya.ir.utils import format_tuple_index from ...
algorandfoundation/puya
src/puya/ir/_utils.py
Python
NOASSERTION
2,124
import typing from collections.abc import Iterable, Mapping, Sequence import attrs from puya import ( artifact_metadata as md, log, ) from puya.avm import OnCompletionAction from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.arc4_types import maybe_avm_to_arc4_equivalent_type from p...
algorandfoundation/puya
src/puya/ir/arc4_router.py
Python
NOASSERTION
17,332
# AUTO GENERATED BY scripts/generate_avm_ops.py, DO NOT EDIT import enum from collections.abc import Sequence from puya.errors import InternalError from puya.ir.avm_ops_models import ( AVMOpData, DynamicVariants, ImmediateKind, OpSignature, RunMode, StackType, Variant, ) class AVMOp(enum....
algorandfoundation/puya
src/puya/ir/avm_ops.py
Python
NOASSERTION
240,926
import enum from collections.abc import Sequence import attrs class StackType(enum.StrEnum): uint64 = enum.auto() bytes = "[]byte" bool = enum.auto() address = enum.auto() address_or_index = enum.auto() any = enum.auto() bigint = enum.auto() box_name = "boxName" asset = enum.auto(...
algorandfoundation/puya
src/puya/ir/avm_ops_models.py
Python
NOASSERTION
1,398
algorandfoundation/puya
src/puya/ir/builder/__init__.py
Python
NOASSERTION
0
from collections.abc import Sequence from puya.awst import wtypes from puya.errors import InternalError from puya.ir.context import IRFunctionBuildContext from puya.ir.models import Register, Value, ValueProvider, ValueTuple from puya.ir.types_ import IRType, get_wtype_arity, sum_wtypes_arity, wtype_to_ir_type from pu...
algorandfoundation/puya
src/puya/ir/builder/_tuple_util.py
Python
NOASSERTION
2,203
import typing from collections.abc import Sequence import attrs from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.errors import InternalError from puya.ir.avm_ops import AVMOp from puya.ir.context import TMP_VAR_INDICATOR, IRFunctionBuildContext from puya.ir.models import ( Assignment, ...
algorandfoundation/puya
src/puya/ir/builder/_utils.py
Python
NOASSERTION
13,454
from collections.abc import Sequence from itertools import zip_longest import attrs from puya import log from puya.avm import AVMType from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.errors import CodeError, InternalError from puya.ir.avm_ops import AVMOp from puya.ir.builder._utils import ( ...
algorandfoundation/puya
src/puya/ir/builder/arc4.py
Python
NOASSERTION
54,081
import typing from collections.abc import Sequence from puya import log from puya.avm import AVMType from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.errors import CodeError, InternalError from puya.ir.avm_ops import AVMOp from puya.ir.builder import arc4 from puya.ir.builder._tuple_util import...
algorandfoundation/puya
src/puya/ir/builder/assignment.py
Python
NOASSERTION
10,805
import contextlib import typing from collections.abc import Iterator, Sequence import attrs from puya import log from puya.awst import nodes as awst_nodes from puya.errors import InternalError from puya.ir.models import ( Assignment, BasicBlock, ControlOp, Goto, Op, Register, ) from puya.ir.ss...
algorandfoundation/puya
src/puya/ir/builder/blocks.py
Python
NOASSERTION
8,792
from puya.awst import nodes as awst_nodes from puya.ir.avm_ops import AVMOp from puya.ir.builder._utils import assign_intrinsic_op, assign_temp from puya.ir.context import IRFunctionBuildContext from puya.ir.models import Intrinsic, UInt64Constant, Value, ValueProvider from puya.ir.types_ import IRType from puya.parse ...
algorandfoundation/puya
src/puya/ir/builder/bytes.py
Python
NOASSERTION
6,766
from collections.abc import Sequence import attrs from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.errors import CodeError from puya.ir.builder._tuple_util import build_tuple_item_names from puya.ir.builder._utils import assign_targets, new_register_version from puya.ir.co...
algorandfoundation/puya
src/puya/ir/builder/callsub.py
Python
NOASSERTION
5,028
from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.errors import InternalError from puya.ir import intrinsic_factory from puya.ir.builder._tuple_util import build_tuple_registers from puya.ir.builder._utils import assign_targets, new_register_version from puya.ir.context impor...
algorandfoundation/puya
src/puya/ir/builder/flow_control.py
Python
NOASSERTION
8,727
import typing from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.nodes import Expression from puya.errors import CodeError, InternalError from puya.ir.avm_ops import AVMOp from puya.ir.builder import arc4 from puya.ir.builder._tuple_util import build_tuple_registers, get...
algorandfoundation/puya
src/puya/ir/builder/iteration.py
Python
NOASSERTION
22,778
import typing from collections.abc import Mapping, Sequence import attrs import puya.awst.txn_fields from puya import log from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.function_traverser import FunctionTraverser from puya.awst.to_code_visitor import ToCodeVisitor from puya.awst.wtypes ...
algorandfoundation/puya
src/puya/ir/builder/itxn.py
Python
NOASSERTION
29,467
import typing from collections.abc import Iterator, Sequence import attrs import puya.awst.visitors import puya.ir.builder.storage from puya import algo_constants, log, utils from puya.avm import AVMType from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.awst.nodes import BigUIntBinaryOperator, ...
algorandfoundation/puya
src/puya/ir/builder/main.py
Python
NOASSERTION
56,636
import typing from puya.avm import AVMType from puya.awst import ( nodes as awst_nodes, wtypes, ) from puya.ir import intrinsic_factory from puya.ir.avm_ops import AVMOp from puya.ir.builder._utils import assert_value, assign_targets, mktemp from puya.ir.context import IRFunctionBuildContext from puya.ir.model...
algorandfoundation/puya
src/puya/ir/builder/storage.py
Python
NOASSERTION
6,336
import contextlib import itertools import typing from collections import defaultdict from collections.abc import Iterator, Mapping from functools import cached_property import attrs import puya.awst.nodes as awst_nodes from puya.context import CompileContext from puya.errors import CodeError, log_exceptions from puya...
algorandfoundation/puya
src/puya/ir/context.py
Python
NOASSERTION
5,307
algorandfoundation/puya
src/puya/ir/destructure/__init__.py
Python
NOASSERTION
0
import itertools import typing import typing as t from collections.abc import Iterable import attrs from puya import log from puya.avm import AVMType from puya.ir import models from puya.ir.types_ import IRType from puya.ir.visitor_mem_replacer import MemoryReplacer from puya.ir.vla import VariableLifetimeAnalysis fr...
algorandfoundation/puya
src/puya/ir/destructure/coalesce_locals.py
Python
NOASSERTION
6,658
import attrs from puya import log from puya.context import CompileContext from puya.ir import models from puya.ir.destructure.coalesce_locals import coalesce_locals from puya.ir.destructure.optimize import post_ssa_optimizer from puya.ir.destructure.parcopy import sequentialize_parallel_copies from puya.ir.destructure...
algorandfoundation/puya
src/puya/ir/destructure/main.py
Python
NOASSERTION
965
import contextlib import itertools from puya import log from puya.ir import models from puya.ir.optimize.collapse_blocks import BlockReferenceReplacer from puya.utils import unique logger = log.get_logger(__name__) def post_ssa_optimizer(sub: models.Subroutine, optimization_level: int) -> None: logger.debug(f"P...
algorandfoundation/puya
src/puya/ir/destructure/optimize.py
Python
NOASSERTION
2,880
import itertools from collections.abc import Callable, Iterable from puya import log from puya.ir import models from puya.ir.context import TMP_VAR_INDICATOR logger = log.get_logger(__name__) def sequentialize_parallel_copies(sub: models.Subroutine) -> None: logger.debug(f"Sequentializing parallel copies in {su...
algorandfoundation/puya
src/puya/ir/destructure/parcopy.py
Python
NOASSERTION
3,997