Dataset Viewer
Auto-converted to Parquet Duplicate
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
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
18