Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/sdk-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ jobs:
python .github/scripts/merge_testnet_so.py sdk/dist sdk/dist-testnet
# Every runner here matches its wheel's platform, so install and smoke
# test the actual artifact — importing BOTH networks — before it ships.
# Install by path: --find-links also consults PyPI, and once this
# version is published there pip may prefer the PyPI wheel over the
# one just built (tag-order tie on macOS/Windows).
- name: Smoke test wheel
shell: bash
run: |
pip install --find-links sdk/dist aleo-sdk
pip install sdk/dist/aleo_sdk-*.whl
python -c "
from aleo.mainnet import PrivateKey as MainnetPrivateKey
from aleo.testnet import PrivateKey as TestnetPrivateKey
Expand Down Expand Up @@ -187,7 +190,7 @@ jobs:
- name: Smoke test wheel
shell: bash
run: |
pip install --find-links sdk-abi/dist aleo-contract-abi-generator
pip install sdk-abi/dist/*.whl
python -c "import aleo_abi; print(aleo_abi.generate_abi.__name__)"
- name: Upload wheel
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -251,8 +254,8 @@ jobs:
python -m build shield-swap-sdk --outdir shield-swap-sdk/dist
- name: Test against the built aleo-sdk wheel
run: |
pip install --find-links sdk-dist aleo-sdk
pip install --find-links shield-swap-sdk/dist "shield-swap-sdk[async,mcp]" pytest pytest-asyncio
pip install sdk-dist/aleo_sdk-*.whl
pip install "$(ls shield-swap-sdk/dist/*.whl)[async,mcp]" pytest pytest-asyncio
cd shield-swap-sdk && python -m pytest
- name: AGENTS.md up to date
run: python shield-swap-sdk/codegen/gen_context.py --check
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ jobs:
maturin build --release --no-default-features --features testnet --out dist-testnet
mv pyproject.toml.bak pyproject.toml
python ../.github/scripts/merge_testnet_so.py dist dist-testnet
# Install the built wheel by path: --find-links also consults PyPI, and
# once the branch's version is published there pip may prefer the PyPI
# wheel over the one just built (tag-order tie on macOS/Windows).
- name: Install wheel + test deps
run: |
pip install --find-links dist aleo-sdk
pip install dist/aleo_sdk-*.whl
pip install pytest pytest-xdist httpx pynacl responses pytest-asyncio
# Fast, offline tests; -n auto parallelizes across cores.
- name: pytest (fast suite)
Expand Down Expand Up @@ -116,7 +119,7 @@ jobs:
python ../.github/scripts/merge_testnet_so.py dist dist-testnet
- name: Install wheel + test deps
run: |
pip install --find-links dist aleo-sdk
pip install dist/aleo_sdk-*.whl
pip install pytest httpx pynacl responses pytest-asyncio
# The two slow tests share one module-scoped proven execution; xdist
# would prove twice, so they run in a single worker on purpose.
Expand Down Expand Up @@ -169,7 +172,7 @@ jobs:
maturin build --release --manifest-path sdk-abi/Cargo.toml --out dist
- name: Install wheels
run: |
pip install --find-links dist aleo-sdk aleo-contract-abi-generator
pip install dist/*.whl
# Run each suite from inside its package dir so pytest uses that
# package's own pytest.ini (sdk-abi/pytest.ini, sdk/pytest.ini) rather
# than walking up to the stale legacy root setup.cfg.
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/aleo/_aleolib_mainnet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ class Program:
def get_record_members(self, record_name: str) -> dict[str, Any]: ...
def get_struct_members(self, struct_name: str) -> list[dict[str, Any]]: ...
def address(self) -> Address: ...
def is_arc20(self) -> bool: ...
def is_arc22(self) -> bool: ...


class ProgramID:
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/aleo/_aleolib_testnet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ class Program:
def get_record_members(self, record_name: str) -> dict[str, Any]: ...
def get_struct_members(self, struct_name: str) -> list[dict[str, Any]]: ...
def address(self) -> Address: ...
def is_arc20(self) -> bool: ...
def is_arc22(self) -> bool: ...


class ProgramID:
Expand Down
228 changes: 228 additions & 0 deletions sdk/python/tests/fixtures/arc20_token.aleo
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
program arc20_token.aleo;

record Token:
owner as address.private;
amount as u128.private;

struct approval:
approver as address;
spender as address;

mapping account:
key as address.public;
value as u128.public;

mapping approvals:
key as field.public;
value as u128.public;

mapping settings:
key as u8.public;
value as u128.public;

mapping token_info:
key as u8.public;
value as u8.public;

function transfer_public:
input r0 as address.public;
input r1 as u128.public;
async transfer_public self.caller r0 r1 into r2;
output r2 as arc20_token.aleo/transfer_public.future;

finalize transfer_public:
input r0 as address.public;
input r1 as address.public;
input r2 as u128.public;
get account[r0] into r3;
sub r3 r2 into r4;
set r4 into account[r0];
get.or_use account[r1] 0u128 into r5;
add r5 r2 into r6;
set r6 into account[r1];

function transfer_private:
input r0 as Token.record;
input r1 as address.private;
input r2 as u128.private;
sub r0.amount r2 into r3;
cast r0.owner r3 into r4 as Token.record;
cast r1 r2 into r5 as Token.record;
output r4 as Token.record;
output r5 as Token.record;

function transfer_private_to_public:
input r0 as Token.record;
input r1 as address.public;
input r2 as u128.public;
sub r0.amount r2 into r3;
cast r0.owner r3 into r4 as Token.record;
async transfer_private_to_public r1 r2 into r5;
output r4 as Token.record;
output r5 as arc20_token.aleo/transfer_private_to_public.future;

finalize transfer_private_to_public:
input r0 as address.public;
input r1 as u128.public;
get.or_use account[r0] 0u128 into r2;
add r2 r1 into r3;
set r3 into account[r0];

function transfer_public_to_private:
input r0 as address.private;
input r1 as u128.public;
cast r0 r1 into r2 as Token.record;
async transfer_public_to_private self.caller r1 into r3;
output r2 as Token.record;
output r3 as arc20_token.aleo/transfer_public_to_private.future;

finalize transfer_public_to_private:
input r0 as address.public;
input r1 as u128.public;
get account[r0] into r2;
sub r2 r1 into r3;
set r3 into account[r0];

function transfer_public_as_signer:
input r0 as address.public;
input r1 as u128.public;
async transfer_public_as_signer self.signer r0 r1 into r2;
output r2 as arc20_token.aleo/transfer_public_as_signer.future;

finalize transfer_public_as_signer:
input r0 as address.public;
input r1 as address.public;
input r2 as u128.public;
get account[r0] into r3;
sub r3 r2 into r4;
set r4 into account[r0];
get.or_use account[r1] 0u128 into r5;
add r5 r2 into r6;
set r6 into account[r1];

function transfer_from_public:
input r0 as address.public;
input r1 as address.public;
input r2 as u128.public;
async transfer_from_public self.caller r0 r1 r2 into r3;
output r3 as arc20_token.aleo/transfer_from_public.future;

finalize transfer_from_public:
input r0 as address.public;
input r1 as address.public;
input r2 as address.public;
input r3 as u128.public;
cast r1 r0 into r4 as approval;
hash.bhp256 r4 into r5 as field;
get approvals[r5] into r6;
sub r6 r3 into r7;
set r7 into approvals[r5];
get account[r1] into r8;
sub r8 r3 into r9;
set r9 into account[r1];
get.or_use account[r2] 0u128 into r10;
add r10 r3 into r11;
set r11 into account[r2];

function transfer_from_public_to_private:
input r0 as address.public;
input r1 as address.private;
input r2 as u128.public;
cast r1 r2 into r3 as Token.record;
async transfer_from_public_to_private self.caller r0 r2 into r4;
output r3 as Token.record;
output r4 as arc20_token.aleo/transfer_from_public_to_private.future;

finalize transfer_from_public_to_private:
input r0 as address.public;
input r1 as address.public;
input r2 as u128.public;
cast r1 r0 into r3 as approval;
hash.bhp256 r3 into r4 as field;
get approvals[r4] into r5;
sub r5 r2 into r6;
set r6 into approvals[r4];
get account[r1] into r7;
sub r7 r2 into r8;
set r8 into account[r1];

function approve_public:
input r0 as address.public;
input r1 as u128.public;
async approve_public self.caller r0 r1 into r2;
output r2 as arc20_token.aleo/approve_public.future;

finalize approve_public:
input r0 as address.public;
input r1 as address.public;
input r2 as u128.public;
cast r0 r1 into r3 as approval;
hash.bhp256 r3 into r4 as field;
get.or_use approvals[r4] 0u128 into r5;
add r5 r2 into r6;
set r6 into approvals[r4];

function unapprove_public:
input r0 as address.public;
input r1 as u128.public;
async unapprove_public self.caller r0 r1 into r2;
output r2 as arc20_token.aleo/unapprove_public.future;

finalize unapprove_public:
input r0 as address.public;
input r1 as address.public;
input r2 as u128.public;
cast r0 r1 into r3 as approval;
hash.bhp256 r3 into r4 as field;
get approvals[r4] into r5;
sub r5 r2 into r6;
set r6 into approvals[r4];

function join:
input r0 as Token.record;
input r1 as Token.record;
add r0.amount r1.amount into r2;
cast r0.owner r2 into r3 as Token.record;
output r3 as Token.record;

function split:
input r0 as Token.record;
input r1 as u128.private;
sub r0.amount r1 into r2;
cast r0.owner r1 into r3 as Token.record;
cast r0.owner r2 into r4 as Token.record;
output r3 as Token.record;
output r4 as Token.record;

view balance_of:
input r0 as address.public;
get.or_use account[r0] 0u128 into r1;
output r1 as u128.public;

view allowance:
input r0 as address.public;
input r1 as address.public;
cast r0 r1 into r2 as approval;
hash.bhp256 r2 into r3 as field;
get.or_use approvals[r3] 0u128 into r4;
output r4 as u128.public;

view supply:
get.or_use settings[0u8] 0u128 into r0;
output r0 as u128.public;

view max_supply:
get.or_use settings[1u8] 0u128 into r0;
output r0 as u128.public;

view decimals:
get.or_use token_info[0u8] 6u8 into r0;
output r0 as u8.public;

view name:
cast 6577149field into r0 as identifier;
output r0 as identifier.public;

view symbol:
cast 5526356field into r0 as identifier;
output r0 as identifier.public;
Loading
Loading