Skip to content

Commit

Permalink
feat: added puyapy.arc4.call_abi for typed contract to contract cal…
Browse files Browse the repository at this point in the history
…ls (#112)

* improved API for `puyapy.arg4.DynamicBytes`
* fixed `puyapy.arg4.UFixedNxM` parsing of decimal strings
* support generating a client for use with `puyapy.arc4.call_abi` from ARC32 specifications or puya contracts

BREAKING CHANGE:
renamed `global_num_byte_slices` -> `global_num_bytes` and `local_num_byte_slices` -> `local_num_bytes` members on transaction types
restrict `puyapy.arc4.String` operators to only be with other String compatible types

---------

Co-authored-by: Adam Chidlow <achidlow@users.noreply.github.com>
  • Loading branch information
daniel-makerx and achidlow authored Mar 14, 2024
1 parent 1b2e504 commit 3d42df3
Show file tree
Hide file tree
Showing 304 changed files with 22,092 additions and 2,032 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ examples/**/*.trace
# autogenerated doc
/docs/apidocs/
/docs/puyapy-stubs/
# ignore AWST from generated clients
/examples/**/out/out/**/client_*.awst
/test_cases/**/out/out/**/client_*.awst
9 changes: 9 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Hide the first element of attribute like items as puyapy stubs are more like interfaces and as such
should not indicate a specific "value" for variables
*/
.py.data,.py.attribute {
dd p:first-child {
display: none;
}
}
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "furo"
# html_static_path = ["_static"]
html_static_path = ["_static"]
html_css_files = [
"custom.css",
]

python_maximum_signature_line_length = 80

Expand Down
49 changes: 49 additions & 0 deletions examples/amm/out/client_ConstantProductAMM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This file is auto-generated, do not modify
# flake8: noqa
# fmt: off
import typing

import puyapy


class ConstantProductAMM(puyapy.arc4.ARC4Client, typing.Protocol):
@puyapy.arc4.abimethod
def set_governor(
self,
new_governor: puyapy.Account,
) -> None: ...

@puyapy.arc4.abimethod
def bootstrap(
self,
seed: puyapy.gtxn.PaymentTransaction,
a_asset: puyapy.Asset,
b_asset: puyapy.Asset,
) -> puyapy.arc4.UInt64: ...

@puyapy.arc4.abimethod(default_args={'pool_asset': 'pool_token', 'a_asset': 'asset_a', 'b_asset': 'asset_b'})
def mint(
self,
a_xfer: puyapy.gtxn.AssetTransferTransaction,
b_xfer: puyapy.gtxn.AssetTransferTransaction,
pool_asset: puyapy.Asset,
a_asset: puyapy.Asset,
b_asset: puyapy.Asset,
) -> None: ...

@puyapy.arc4.abimethod(default_args={'pool_asset': 'pool_token', 'a_asset': 'asset_a', 'b_asset': 'asset_b'})
def burn(
self,
pool_xfer: puyapy.gtxn.AssetTransferTransaction,
pool_asset: puyapy.Asset,
a_asset: puyapy.Asset,
b_asset: puyapy.Asset,
) -> None: ...

@puyapy.arc4.abimethod(default_args={'a_asset': 'asset_a', 'b_asset': 'asset_b'})
def swap(
self,
swap_xfer: puyapy.gtxn.AssetTransferTransaction,
a_asset: puyapy.Asset,
b_asset: puyapy.Asset,
) -> None: ...
4 changes: 2 additions & 2 deletions examples/amm/out/contract.awst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions examples/amm/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions examples/auction/out/client_Auction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file is auto-generated, do not modify
# flake8: noqa
# fmt: off
import typing

import puyapy


class Auction(puyapy.arc4.ARC4Client, typing.Protocol):
@puyapy.arc4.abimethod
def opt_into_asset(
self,
asset: puyapy.Asset,
) -> None: ...

@puyapy.arc4.abimethod
def start_auction(
self,
starting_price: puyapy.arc4.UInt64,
length: puyapy.arc4.UInt64,
axfer: puyapy.gtxn.AssetTransferTransaction,
) -> None: ...

@puyapy.arc4.abimethod
def opt_in(
self,
) -> None: ...

@puyapy.arc4.abimethod
def bid(
self,
pay: puyapy.gtxn.PaymentTransaction,
) -> None: ...

@puyapy.arc4.abimethod
def claim_bids(
self,
) -> None: ...

@puyapy.arc4.abimethod
def claim_asset(
self,
asset: puyapy.Asset,
) -> None: ...
2 changes: 1 addition & 1 deletion examples/auction/out/contract.awst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions examples/auction/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/calculator/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/global_state/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hello_world/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions examples/hello_world_arc4/out/client_HelloWorldContract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is auto-generated, do not modify
# flake8: noqa
# fmt: off
import typing

import puyapy


class HelloWorldContract(puyapy.arc4.ARC4Client, typing.Protocol):
@puyapy.arc4.abimethod
def hello(
self,
name: puyapy.arc4.String,
) -> puyapy.arc4.String: ...
5 changes: 3 additions & 2 deletions examples/hello_world_arc4/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/local_state/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions examples/merkle/out/client_MerkleTree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is auto-generated, do not modify
# flake8: noqa
# fmt: off
import typing

import puyapy


class MerkleTree(puyapy.arc4.ARC4Client, typing.Protocol):
@puyapy.arc4.abimethod(create=True)
def create(
self,
root: puyapy.arc4.StaticArray[puyapy.arc4.Byte, typing.Literal[32]],
) -> None: ...

@puyapy.arc4.abimethod
def verify(
self,
proof: puyapy.arc4.DynamicArray[puyapy.arc4.StaticArray[puyapy.arc4.Byte, typing.Literal[32]]],
leaf: puyapy.arc4.StaticArray[puyapy.arc4.Byte, typing.Literal[32]],
) -> puyapy.arc4.Bool: ...
18 changes: 9 additions & 9 deletions examples/merkle/out/contract.awst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions examples/merkle/puya.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3d42df3

Please sign in to comment.