Compare commits

..

No commits in common. "d02666fe3196f2fb2acd33a896e90f01c8b93cd9" and "0dc42bc60116c098bad3fe62715e86614b0592a4" have entirely different histories.

10 changed files with 56 additions and 85 deletions

View File

@ -3,7 +3,7 @@ on:
push: push:
tags: tags:
- 'v[0-9]+.[0-9]+.[0-9]+' - 'v[0-9]+.[0-9]+.[0-9]+'
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"]
jobs: jobs:
Package: Package:

View File

@ -2,7 +2,7 @@ name: Run Python tests (through Pytest)
on: on:
push: push:
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"]
jobs: jobs:
Test: Test:

View File

@ -2,7 +2,7 @@ name: Verify Python project can be installed, loaded and have version checked
on: on:
push: push:
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"]
jobs: jobs:
Test: Test:

View File

@ -1,17 +0,0 @@
When contributing code to this project, you MUST follow these principles:
- Code should be easy to read and understand.
- Keep the code as simple as possible. Avoid unnecessary complexity.
- Use meaningful names for variables, functions, etc. Names should reveal intent.
- Functions should be small and do one thing well. They should not exceed a few lines.
- Function names should describe the action being performed.
- Only use comments when necessary, as they can become outdated. Instead, strive to make the code self-explanatory.
- When comments are used, they should add useful information that is not readily apparent from the code itself.
- Properly handle errors and exceptions to ensure the software's robustness.
- Use exceptions rather than error codes for handling errors.
- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks.
- Documentation should document semantics, not syntax.
- Prefer importing modules, not individual items from modules.
- Do not use f-strings in logging statements.
- Loop variables and walrus-expression-variables should be deleted when
unneeded to keep scope clean, and to avoid accidental use.

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2023-2025 Jon Michael Aanes Copyright (c) 2023-2024 Jon Michael Aanes
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -8,12 +8,9 @@
![Test program/library](https://gitfub.space/Jmaa/pbcabi/actions/workflows/python-test.yml/badge.svg) ![Test program/library](https://gitfub.space/Jmaa/pbcabi/actions/workflows/python-test.yml/badge.svg)
Unofficial utility library for parsing and processing the Partisia Blockchain ABI Format. Utility library for parsing and processing the Partisia Blockchain ABI Format.
The format is specified here: [Partisia Blockchain's ABI format](https://partisiablockchain.gitlab.io/documentation/smart-contracts/smart-contract-binary-formats.html). The format is specified here: [Partisia Blockchain's ABI format](https://partisiablockchain.gitlab.io/documentation/smart-contracts/smart-contract-binary-formats.html)..
This library is not officially associated with Partisia Blockchain nor Partisia
Group ApS.
## Example usage ## Example usage
@ -44,11 +41,21 @@ print(token_state['balances'][my_address])
> 213112 > 213112
``` ```
## Legalese
This project is licensed under MIT Licence, see `LICENSE` for full text.
This project is not associated with, nor supported by any of:
- Partisia Applications A/S
- Partisia Infrastructure A/S
- Partisia Blockchain Foundation
Use at own risk.
## Dependencies ## Dependencies
This project requires [Python](https://www.python.org/) 3.8 or newer. All requirements can be installed easily using:
All required libraries can be installed easily using:
```bash ```bash
pip install -r requirements.txt pip install -r requirements.txt
@ -59,34 +66,12 @@ Full list of requirements:
- [frozendict](https://pypi.org/project/frozendict/) - [frozendict](https://pypi.org/project/frozendict/)
## Contributing
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
### Testing
Testing requires the [pytest](https://docs.pytest.org/en/stable/) library.
Run tests with the following command:
```sh
pytest test
```
Test coverage can be run using the [`pytest-cov`](https://pypi.org/project/pytest-cov/) extension:
```sh
pytest --cov=pbcabi test
```
## License ## License
``` ```
MIT License MIT License
Copyright (c) 2023-2025 Jon Michael Aanes Copyright (c) 2023-2024 Jon Michael Aanes
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,11 +1,8 @@
"""# Partisia Blockchain ABI client. """# Partisia Blockchain ABI client.
Unofficial utility library for parsing and processing the Partisia Blockchain ABI Format. Utility library for parsing and processing the Partisia Blockchain ABI Format.
The format is specified here: [Partisia Blockchain's ABI format](https://partisiablockchain.gitlab.io/documentation/smart-contracts/smart-contract-binary-formats.html). The format is specified here: [Partisia Blockchain's ABI format](https://partisiablockchain.gitlab.io/documentation/smart-contracts/smart-contract-binary-formats.html)..
This library is not officially associated with Partisia Blockchain nor Partisia
Group ApS.
## Example usage ## Example usage
@ -35,6 +32,18 @@ print(token_state['name'])
print(token_state['balances'][my_address]) print(token_state['balances'][my_address])
> 213112 > 213112
``` ```
## Legalese
This project is licensed under MIT Licence, see `LICENSE` for full text.
This project is not associated with, nor supported by any of:
- Partisia Applications A/S
- Partisia Infrastructure A/S
- Partisia Blockchain Foundation
Use at own risk.
""" """
__all__ = ['model', 'binaryreader', '__version__'] __all__ = ['model', 'binaryreader', '__version__']

View File

@ -1 +1 @@
__version__ = '0.1.29' __version__ = '0.1.28'

View File

@ -237,9 +237,6 @@ class MapTypeSpec(TypeSpec):
type_key: TypeSpec type_key: TypeSpec
type_value: TypeSpec type_value: TypeSpec
@enforce_typing.enforce_types @enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, slots=True) @dataclasses.dataclass(frozen=True, slots=True)
class AvlTreeTypeSpec(MapTypeSpec): class AvlTreeTypeSpec(MapTypeSpec):
@ -255,18 +252,8 @@ class AvlTreeTypeSpec(MapTypeSpec):
''' '''
type_key = TypeSpec.read_from(reader) type_key = TypeSpec.read_from(reader)
type_value = TypeSpec.read_from(reader) type_value = TypeSpec.read_from(reader)
return AvlTreeTypeSpec(type_key, type_value) type_spec = AvlTreeTypeSpec(type_key, type_value)
return type_spec
def read_element_from(self, reader: BinaryReader, type_env,
mode: SerializeMode) -> 'AvlTreeId':
avl_tree_id = SIZE_SIMPLE_TYPE_SPEC.read_element_from(reader, type_env, mode)
return AvlTreeId(avl_tree_id, self)
@enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, slots=True)
class AvlTreeId:
avl_tree_id: int
type_spec: AvlTreeTypeSpec
@enforce_typing.enforce_types @enforce_typing.enforce_types
@dataclasses.dataclass(frozen=True, slots=True) @dataclasses.dataclass(frozen=True, slots=True)
@ -708,13 +695,11 @@ class ContractAbi:
return self.named_types_by_id[type_name].read_element_from( return self.named_types_by_id[type_name].read_element_from(
rpc, self.named_types_by_idx, SerializeMode.RPC) rpc, self.named_types_by_idx, SerializeMode.RPC)
def read_state(self, reader: BinaryReader | bytes, explicit_type: TypeSpec | None = None): def read_state(self, reader: BinaryReader):
if not isinstance(reader, BinaryReader): if not isinstance(reader, BinaryReader):
reader = BinaryReader(reader) reader = BinaryReader(reader)
explicit_type = explicit_type or self.state_type return self.state_type.read_element_from(reader, self.named_types_by_idx,
return explicit_type.read_element_from(reader, self.named_types_by_idx,
SerializeMode.STATE) SerializeMode.STATE)
def get_fn_abi_from_shortname(self, shortname: int) -> FnAbi: def get_fn_abi_from_shortname(self, shortname: int) -> FnAbi:
@ -722,7 +707,7 @@ class ContractAbi:
if derp.shortname == shortname: if derp.shortname == shortname:
return derp return derp
def read_invocation(self, reader: BinaryReader | bytes) -> ParsedInvocation: def read_invocation(self, reader: BinaryReader) -> ParsedInvocation:
if not isinstance(reader, BinaryReader): if not isinstance(reader, BinaryReader):
reader = BinaryReader(reader) reader = BinaryReader(reader)
shortname = reader.readLeb128() shortname = reader.readLeb128()
@ -745,7 +730,7 @@ class FileAbi:
contract: ContractAbi contract: ContractAbi
@staticmethod @staticmethod
def read_from(reader: BinaryReader | bytes): def read_from(reader: BinaryReader):
''' '''
Deserialize 'FileAbi' from 'BinaryReader'. Deserialize 'FileAbi' from 'BinaryReader'.
''' '''

View File

@ -13,12 +13,9 @@ PACKAGE_NAME = 'pbcabi'
PACKAGE_DESCRIPTION = """ PACKAGE_DESCRIPTION = """
# Partisia Blockchain ABI client. # Partisia Blockchain ABI client.
Unofficial utility library for parsing and processing the Partisia Blockchain ABI Format. Utility library for parsing and processing the Partisia Blockchain ABI Format.
The format is specified here: [Partisia Blockchain's ABI format](https://partisiablockchain.gitlab.io/documentation/smart-contracts/smart-contract-binary-formats.html). The format is specified here: [Partisia Blockchain's ABI format](https://partisiablockchain.gitlab.io/documentation/smart-contracts/smart-contract-binary-formats.html)..
This library is not officially associated with Partisia Blockchain nor Partisia
Group ApS.
## Example usage ## Example usage
@ -48,10 +45,22 @@ print(token_state['name'])
print(token_state['balances'][my_address]) print(token_state['balances'][my_address])
> 213112 > 213112
``` ```
## Legalese
This project is licensed under MIT Licence, see `LICENSE` for full text.
This project is not associated with, nor supported by any of:
- Partisia Applications A/S
- Partisia Infrastructure A/S
- Partisia Blockchain Foundation
Use at own risk.
""".strip() """.strip()
PACKAGE_DESCRIPTION_SHORT = """ PACKAGE_DESCRIPTION_SHORT = """
Unofficial utility library for parsing and processing the Partisia Blockchain ABI Format.""".strip() Utility library for parsing and processing the Partisia Blockchain ABI Format.""".strip()
def parse_version_file(text: str) -> str: def parse_version_file(text: str) -> str: