Skip to content

Commit

Permalink
feat: ARC-56 application specifications can now be output using the `…
Browse files Browse the repository at this point in the history
…--output-arc56` option
  • Loading branch information
daniel-makerx committed Nov 8, 2024
1 parent 3283027 commit 710fb7d
Show file tree
Hide file tree
Showing 803 changed files with 26,179 additions and 6,084 deletions.
7 changes: 4 additions & 3 deletions docs/compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,20 @@ puyapy [-h] [--version] [-O {0,1,2}]
### Options

| Option | Description | Default |
|----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| ----------------------- |
|----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| `-h`, `--help` | Show the help message and exit | N/A |
| `--version` | Show program's version number and exit | N/A |
| `-O {0,1,2}` <br />`--optimization-level {0,1,2}` | Set optimization level of output TEAL / AVM bytecode | `1` |
| `--output-teal`, `--no-output-teal` | Output TEAL | `True` |
| `--output-arc32`, `--no-output-arc32` | Output {contract}.arc32.json ARC-32 app spec file if the contract is an ARC-4 contract | `True` |
| `--output-arc56`, `--no-output-arc56` | Output {contract}.arc56.json ARC-56 app spec file if the contract is an ARC-4 contract | `False` |
| `--output-client`, `--no-output-client` | Output Algorand Python contract client for typed ARC4 ABI calls | `False` |
| `--output-bytecode`, `--no-output-bytecode` | Output AVM bytecode | `False` |
| `--out-dir OUT_DIR` | The path for outputting artefacts | Same folder as contract |
| `--log-level {notset,debug,info,warning,error,critical}` | Minimum level to log to console | `info` |
| `-g {0,1,2}`, `--debug-level {0,1,2}` | Output debug information level<br /> `0` = No debug annotations <br /> `1` = Output debug annotations <br /> `2` = Reserved for future use, currently the same as `1` | `1` |
| `--template-var` | Allows specifying template values. Can be used multiple times, see below for examples | N/A |
| `--template-vars-prefix` | Prefix to use for template variables | "TMPL_" |
| `--template-var` | Allows specifying template values. Can be used multiple times, see below for examples | N/A |
| `--template-vars-prefix` | Prefix to use for template variables | "TMPL_" |
### Defining template values
Expand Down
8 changes: 5 additions & 3 deletions docs/lg-arc4.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ class HelloWorldContract(ARC4Contract):
...
```

## ARC-32
## ARC-32 and ARC-56

[ARC32](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0032.md) extends the concepts in ARC4 to include an Application Specification which more holistically describes a smart contract and its associated state.

ARC32 Application Specification files are automatically generated by the compiler for ARC4
contracts as `<ContractName>.arc32.json`
ARC-32/ARC-56 Application Specification files are automatically generated by the compiler for ARC4
contracts as `<ContractName>.arc32.json` or `<ContractName>.arc56.json`

## Methods

Individual methods on a smart contract should be annotated with an `abimethod` decorator. This decorator is used to indicate a method which should be externally callable. The decorator itself includes properties to restrict when the method should be callable, for instance only when the application is being created or only when the OnComplete action is OptIn.

A method that should not be externally available should be annotated with a `subroutine` decorator.

Method docstrings will be used when outputting ARC-32 or ARC-56 application specifications, the following docstrings styles are supported ReST, Google, Numpydoc-style and Epydoc.

```python
from algopy import ARC4Contract, subroutine, arc4

Expand Down
22 changes: 11 additions & 11 deletions examples/amm/out/ConstantProductAMM.approval.mir
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ __puya_arc4_router___set_governor_route@2:
// @arc4.abimethod()
txn OnCompletion tmp%3#0
! tmp%4#0
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID tmp%5#0
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txna ApplicationArgs 1 tmp%7#0
Expand All @@ -101,9 +101,9 @@ __puya_arc4_router___bootstrap_route@3:
// @arc4.abimethod()
txn OnCompletion tmp%10#0
! tmp%11#0
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID tmp%12#0
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex tmp%14#0
Expand Down Expand Up @@ -145,9 +145,9 @@ __puya_arc4_router___mint_route@4:
// )
txn OnCompletion tmp%22#0
! tmp%23#0
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID tmp%24#0
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex tmp%26#0
Expand Down Expand Up @@ -203,9 +203,9 @@ __puya_arc4_router___burn_route@5:
// )
txn OnCompletion tmp%37#0
! tmp%38#0
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID tmp%39#0
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex tmp%41#0
Expand Down Expand Up @@ -251,9 +251,9 @@ __puya_arc4_router___swap_route@6:
// )
txn OnCompletion tmp%51#0
! tmp%52#0
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID tmp%53#0
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex tmp%55#0
Expand Down Expand Up @@ -294,7 +294,7 @@ __puya_arc4_router___bare_routing@9:
__puya_arc4_router_____algopy_default_create@10:
txn ApplicationID tmp%63#0
! tmp%64#0
assert // is creating
assert // can only call when creating
int 1 1
retsub 1

Expand Down
22 changes: 11 additions & 11 deletions examples/amm/out/ConstantProductAMM.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ __puya_arc4_router___set_governor_route@2:
// @arc4.abimethod()
txn OnCompletion
!
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txna ApplicationArgs 1
Expand All @@ -87,9 +87,9 @@ __puya_arc4_router___bootstrap_route@3:
// @arc4.abimethod()
txn OnCompletion
!
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex
Expand Down Expand Up @@ -128,9 +128,9 @@ __puya_arc4_router___mint_route@4:
// )
txn OnCompletion
!
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex
Expand Down Expand Up @@ -181,9 +181,9 @@ __puya_arc4_router___burn_route@5:
// )
txn OnCompletion
!
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex
Expand Down Expand Up @@ -225,9 +225,9 @@ __puya_arc4_router___swap_route@6:
// )
txn OnCompletion
!
assert // OnCompletion is NoOp
assert // OnCompletion is not NoOp
txn ApplicationID
assert // is not creating
assert // can only call when not creating
// amm/contract.py:27
// class ConstantProductAMM(ARC4Contract):
txn GroupIndex
Expand Down Expand Up @@ -262,7 +262,7 @@ __puya_arc4_router___bare_routing@9:
bnz __puya_arc4_router___after_if_else@13
txn ApplicationID
!
assert // is creating
assert // can only call when creating
intc_1 // 1
retsub

Expand Down
2 changes: 1 addition & 1 deletion examples/amm/out/ConstantProductAMM.arc32.json

Large diffs are not rendered by default.

Loading

0 comments on commit 710fb7d

Please sign in to comment.