Skip to content

Commit

Permalink
feat: rename stubs from puyapy to algopy
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Any imports from `puyapy` should be replaced with `algopy`.
  • Loading branch information
achidlow committed Mar 26, 2024
1 parent d419e24 commit 31052e3
Show file tree
Hide file tree
Showing 349 changed files with 4,962 additions and 4,962 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ examples/**/*.trace
/docs/_build/
# autogenerated doc
/docs/apidocs/
/docs/puyapy-stubs/
/docs/algopy-stubs/
# ignore AWST from generated clients
/examples/**/out/out/**/client_*.awst
/test_cases/**/out/out/**/client_*.awst
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ and also define standalone functions and reference them. This also works across
packages - in other words, you can have a Python library with common functions and re-use that
library across multiple projects!

All contracts must inherit from the base class `puyapy.Contract` - either directly or indirectly,
which can include inheriting from `puyapy.ARC4Contract`. For a non-ARC4 contract, a contract class
All contracts must inherit from the base class `algopy.Contract` - either directly or indirectly,
which can include inheriting from `algopy.ARC4Contract`. For a non-ARC4 contract, a contract class
must implement an `approval_program` and a `clear_state_program` method. For ARC4 contracts, these
methods will be implemented for you, although you can optionally provide a `clear_state_program`
(the default implementation just always approves).

As an example, this is a valid contract that always approves:

```python
import puyapy
import algopy

class Contract(puyapy.Contract):
class Contract(algopy.Contract):
def approval_program(self) -> bool:
return True

Expand All @@ -81,23 +81,23 @@ class Contract(puyapy.Contract):
```

The return value of these methods can be either a `bool` that indicates whether the transaction
should approve or not, or a `puyapy.UInt64` value, where `UInt64(0)` indicates that the transaction
should approve or not, or a `algopy.UInt64` value, where `UInt64(0)` indicates that the transaction
should be rejected and any other value indicates that it should be approved.

And here is a valid ARC4 contract:

```python
import puyapy
import algopy

class ABIContract(puyapy.ARC4Contract):
class ABIContract(algopy.ARC4Contract):
"""This contract can be created, but otherwise does nothing"""
pass
```

### Primitive types

The primitive types of the AVM, `uint64` and `bytes[]` are represented by `puyapy.UInt64` and
`puyapy.Bytes` respectively. `puyapy.BigUInt` is also available for AVM supported wide-math
The primitive types of the AVM, `uint64` and `bytes[]` are represented by `algopy.UInt64` and
`algopy.Bytes` respectively. `algopy.BigUInt` is also available for AVM supported wide-math
(up to 512 bits).

Note that Python builtin types such as `int` cannot be used as variables, for semantic compatibility
Expand All @@ -107,7 +107,7 @@ permitted in expressions.
For example:

```python
from puyapy import UInt64, subroutine
from algopy import UInt64, subroutine

SCALE = 100000
SCALED_PI = 314159
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Hide the first element of attribute like items as puyapy stubs are more like interfaces and as such
Hide the first element of attribute like items as algopy stubs are more like interfaces and as such
should not indicate a specific "value" for variables
*/
.py.data,.py.attribute {
Expand Down
4 changes: 4 additions & 0 deletions docs/api-algopy.arc4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```{autodoc2-object} algopy.arc4
render_plugin = "myst"
```
4 changes: 4 additions & 0 deletions docs/api-algopy.gtxn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```{autodoc2-object} algopy.gtxn
render_plugin = "myst"
```
4 changes: 4 additions & 0 deletions docs/api-algopy.itxn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```{autodoc2-object} algopy.itxn
render_plugin = "myst"
```
2 changes: 1 addition & 1 deletion docs/api-puyapy.md → docs/api-algopy.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```{autodoc2-object} puyapy
```{autodoc2-object} algopy
render_plugin = "myst"
```
2 changes: 1 addition & 1 deletion docs/api-puyapy.op.md → docs/api-algopy.op.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```{autodoc2-object} puyapy.op
```{autodoc2-object} algopy.op
render_plugin = "myst"
```
4 changes: 0 additions & 4 deletions docs/api-puyapy.arc4.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/api-puyapy.gtxn.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/api-puyapy.itxn.md

This file was deleted.

10 changes: 5 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
maxdepth: 4
---
api-puyapy
api-puyapy.arc4
api-puyapy.gtxn
api-puyapy.itxn
api-puyapy.op
api-algopy
api-algopy.arc4
api-algopy.gtxn
api-algopy.itxn
api-algopy.op
```
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"autodoc2.dup_item",
]
nitpick_ignore = [
("py:class", "puyapy.arc4.AllowedOnCompletes"),
("py:class", "algopy.arc4.AllowedOnCompletes"),
]
nitpick_ignore_regex = [
("py:class", r"puyapy.*\._.*"),
("py:class", r"algopy.*\._.*"),
]

# -- Options for HTML output -------------------------------------------------
Expand All @@ -61,8 +61,8 @@
# -- Options for autodoc2 ---
autodoc2_packages = [
{
"path": "./puyapy-stubs",
"module": "puyapy",
"path": "./algopy-stubs",
"module": "algopy",
"auto_mode": False,
},
]
Expand All @@ -76,7 +76,7 @@
"dunder",
]
autodoc2_class_inheritance = False
autodoc2_module_all_regexes = [r"puyapy.*"]
autodoc2_module_all_regexes = [r"algopy.*"]
autodoc2_render_plugin = "myst"
autodoc2_sort_names = True
autodoc2_index_template = None
20 changes: 10 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ and also define standalone functions and reference them. This also works across
packages - in other words, you can have a Python library with common functions and re-use that
library across multiple projects!

All contracts must inherit from the base class `puyapy.Contract` - either directly or indirectly,
which can include inheriting from `puyapy.ARC4Contract`. For a non-ARC4 contract, a contract class
All contracts must inherit from the base class `algopy.Contract` - either directly or indirectly,
which can include inheriting from `algopy.ARC4Contract`. For a non-ARC4 contract, a contract class
must implement an `approval_program` and a `clear_state_program` method. For ARC4 contracts, these
methods will be implemented for you, although you can optionally provide a `clear_state_program`
(the default implementation just always approves).

As an example, this is a valid contract that always approves:

```python
import puyapy
import algopy

class Contract(puyapy.Contract):
class Contract(algopy.Contract):
def approval_program(self) -> bool:
return True

Expand All @@ -82,23 +82,23 @@ class Contract(puyapy.Contract):
```

The return value of these methods can be either a `bool` that indicates whether the transaction
should approve or not, or a `puyapy.UInt64` value, where `UInt64(0)` indicates that the transaction
should approve or not, or a `algopy.UInt64` value, where `UInt64(0)` indicates that the transaction
should be rejected and any other value indicates that it should be approved.

And here is a valid ARC4 contract:

```python
import puyapy
import algopy

class ABIContract(puyapy.ARC4Contract):
class ABIContract(algopy.ARC4Contract):
"""This contract can be created, but otherwise does nothing"""
pass
```

### Primitive types

The primitive types of the AVM, `uint64` and `bytes[]` are represented by `puyapy.UInt64` and
`puyapy.Bytes` respectively. `puyapy.BigUInt` is also available for AVM supported wide-math
The primitive types of the AVM, `uint64` and `bytes[]` are represented by `algopy.UInt64` and
`algopy.Bytes` respectively. `algopy.BigUInt` is also available for AVM supported wide-math
(up to 512 bits).

Note that Python builtin types such as `int` cannot be used as variables, for semantic compatibility
Expand All @@ -108,7 +108,7 @@ permitted in expressions.
For example:

```python
from puyapy import UInt64, subroutine
from algopy import UInt64, subroutine

SCALE = 100000
SCALED_PI = 314159
Expand Down
2 changes: 1 addition & 1 deletion docs/principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ there more broadly.

### Abstraction without obfuscation

PuyaPy is a high level language (like Python), with support for things such as branching logic, operator precedence, etc.,
Algorand Python is a high level language, with support for things such as branching logic, operator precedence, etc.,
and not a set of "macros" for generating TEAL. As such, developers will not be able to directly influence specific TEAL
output, if this is desirable a language such as [Tealish](https://tealish.tinyman.org) is more appropriate.

Expand Down
50 changes: 25 additions & 25 deletions docs/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ The following types are available:

| Group Transactions | Inner Transaction Field sets | Inner Transaction |
|----------------------------------------------------------------------|--------------------------------------------------|--------------------------------------------------------------------------------|
| [PaymentTransaction](puyapy.gtxn.PaymentTransaction) | [Payment](puyapy.itxn.Payment) | [PaymentInnerTransaction](puyapy.itxn.PaymentInnerTransaction) |
| [KeyRegistrationTransaction](puyapy.gtxn.KeyRegistrationTransaction) | [KeyRegistration](puyapy.itxn.KeyRegistration) | [KeyRegistrationInnerTransaction](puyapy.itxn.KeyRegistrationInnerTransaction) |
| [AssetConfigTransaction](puyapy.gtxn.AssetConfigTransaction) | [AssetConfig](puyapy.itxn.AssetConfig) | [AssetConfigInnerTransaction](puyapy.itxn.AssetConfigInnerTransaction) |
| [AssetTransferTransaction](puyapy.gtxn.AssetTransferTransaction) | [AssetTransfer](puyapy.itxn.AssetTransfer) | [AssetTransferInnerTransaction](puyapy.itxn.AssetTransferInnerTransaction) |
| [AssetFreezeTransaction](puyapy.gtxn.AssetFreezeTransaction) | [AssetFreeze](puyapy.itxn.AssetFreeze) | [AssetFreezeInnerTransaction](puyapy.itxn.AssetFreezeInnerTransaction) |
| [ApplicationCallTransaction](puyapy.gtxn.ApplicationCallTransaction) | [ApplicationCall](puyapy.itxn.ApplicationCall) | [ApplicationCallInnerTransaction](puyapy.itxn.ApplicationCallInnerTransaction) |
| [Transaction](puyapy.gtxn.Transaction) | [InnerTransaction](puyapy.itxn.InnerTransaction) | [InnerTransactionResult](puyapy.itxn.InnerTransactionResult) |
| [PaymentTransaction](algopy.gtxn.PaymentTransaction) | [Payment](algopy.itxn.Payment) | [PaymentInnerTransaction](algopy.itxn.PaymentInnerTransaction) |
| [KeyRegistrationTransaction](algopy.gtxn.KeyRegistrationTransaction) | [KeyRegistration](algopy.itxn.KeyRegistration) | [KeyRegistrationInnerTransaction](algopy.itxn.KeyRegistrationInnerTransaction) |
| [AssetConfigTransaction](algopy.gtxn.AssetConfigTransaction) | [AssetConfig](algopy.itxn.AssetConfig) | [AssetConfigInnerTransaction](algopy.itxn.AssetConfigInnerTransaction) |
| [AssetTransferTransaction](algopy.gtxn.AssetTransferTransaction) | [AssetTransfer](algopy.itxn.AssetTransfer) | [AssetTransferInnerTransaction](algopy.itxn.AssetTransferInnerTransaction) |
| [AssetFreezeTransaction](algopy.gtxn.AssetFreezeTransaction) | [AssetFreeze](algopy.itxn.AssetFreeze) | [AssetFreezeInnerTransaction](algopy.itxn.AssetFreezeInnerTransaction) |
| [ApplicationCallTransaction](algopy.gtxn.ApplicationCallTransaction) | [ApplicationCall](algopy.itxn.ApplicationCall) | [ApplicationCallInnerTransaction](algopy.itxn.ApplicationCallInnerTransaction) |
| [Transaction](algopy.gtxn.Transaction) | [InnerTransaction](algopy.itxn.InnerTransaction) | [InnerTransactionResult](algopy.itxn.InnerTransactionResult) |


## Group Transactions
Expand All @@ -27,31 +27,31 @@ Group transactions can be used as parameters in ARC4 method
For example to require a payment transaction in an ARC4 ABI method:

```python
import puyapy
import algopy


class MyContract(puyapy.ARC4Contract):
class MyContract(algopy.ARC4Contract):

@puyapy.arc4.abimethod()
def process_payment(self: puyapy.gtxn.PaymentTransaction) -> None:
@algopy.arc4.abimethod()
def process_payment(self: algopy.gtxn.PaymentTransaction) -> None:
...
```

### Group Index

Group transactions can also be created using the group index of the transaction.
If instantiating one of the type specific transactions they will be checked to ensure the transaction is of the expected type.
[Transaction](puyapy.gtxn.Transaction) is not checked for a specific type and provides access to all transaction fields
[Transaction](algopy.gtxn.Transaction) is not checked for a specific type and provides access to all transaction fields

For example, to obtain a reference to a payment transaction:

```python
import puyapy
import algopy


@puyapy.subroutine()
def process_payment(group_index: puyapy.UInt64) -> None:
pay_txn = puyapy.gtxn.PaymentTransaction(group_index)
@algopy.subroutine()
def process_payment(group_index: algopy.UInt64) -> None:
pay_txn = algopy.gtxn.PaymentTransaction(group_index)
...
```

Expand All @@ -66,7 +66,7 @@ Inner transactions are defined using the parameter types, and can then be submit
#### Create and submit an inner transaction

```python
from puyapy import Account, UInt64, itxn, subroutine
from algopy import Account, UInt64, itxn, subroutine


@subroutine
Expand All @@ -81,7 +81,7 @@ def example(amount: UInt64, receiver: Account) -> None:
#### Accessing result of a submitted inner transaction

```python
from puyapy import Asset, itxn, subroutine
from algopy import Asset, itxn, subroutine


@subroutine
Expand All @@ -99,7 +99,7 @@ def example() -> Asset:
#### Submitting multiple transactions

```python
from puyapy import Asset, Bytes, itxn, log, subroutine
from algopy import Asset, Bytes, itxn, log, subroutine


@subroutine
Expand Down Expand Up @@ -127,7 +127,7 @@ def example() -> tuple[Asset, Bytes]:
#### Create an ARC4 application, and then call it

```python
from puyapy import Bytes, arc4, itxn, subroutine
from algopy import Bytes, arc4, itxn, subroutine

HELLO_WORLD_APPROVAL: bytes = ...
HELLO_WORLD_CLEAR: bytes = ...
Expand Down Expand Up @@ -157,7 +157,7 @@ def example() -> None:
#### Create and submit transactions in a loop

```python
from puyapy import Account, UInt64, itxn, subroutine
from algopy import Account, UInt64, itxn, subroutine


@subroutine
Expand All @@ -176,7 +176,7 @@ Inner transactions are powerful, but currently do have some restrictions in how
#### Inner transaction objects cannot be passed to or returned from subroutines

```python
from puyapy import Application, Bytes, itxn, subroutine
from algopy import Application, Bytes, itxn, subroutine


@subroutine
Expand Down Expand Up @@ -206,7 +206,7 @@ def do_something(txn_id: Bytes): # this is just a regular subroutine
#### Inner transaction parameters cannot be reassigned without a `.copy()`

```python
from puyapy import itxn, subroutine
from algopy import itxn, subroutine


@subroutine
Expand All @@ -219,7 +219,7 @@ def example() -> None:
#### Inner transactions cannot be reassigned

```python
from puyapy import itxn, subroutine
from algopy import itxn, subroutine


@subroutine
Expand All @@ -232,7 +232,7 @@ def example() -> None:
#### Inner transactions methods cannot be called if there is a subsequent inner transaction submitted.

```python
from puyapy import itxn, subroutine
from algopy import itxn, subroutine


@subroutine
Expand Down
2 changes: 1 addition & 1 deletion examples/amm/contract.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WARNING: This code is provided for example only. Do NOT deploy to mainnet.

from puyapy import (
from algopy import (
Account,
ARC4Contract,
Asset,
Expand Down
Loading

0 comments on commit 31052e3

Please sign in to comment.