Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
cdfe9a247d | |||
607da4eaaf |
|
@ -1,7 +1,3 @@
|
||||||
# WARNING!
|
|
||||||
# THIS IS AN AUTOGENERATED FILE!
|
|
||||||
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
|
||||||
|
|
||||||
name: Package Python
|
name: Package Python
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -10,24 +6,11 @@ on:
|
||||||
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml']
|
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Package-Python-And-Publish:
|
Package:
|
||||||
runs-on: ubuntu-latest
|
uses: jmaa/workflows/.gitea/workflows/python-package.yaml@v6.21
|
||||||
container:
|
with:
|
||||||
image: node:21-bookworm
|
REGISTRY_DOMAIN: gitfub.space
|
||||||
steps:
|
REGISTRY_ORGANIZATION: jmaa
|
||||||
- name: Setting up Python ${{ env.PYTHON_VERSION }} for ${{runner.arch}} ${{runner.os}}
|
secrets:
|
||||||
run: |
|
PIPY_REPO_USER: ${{ secrets.PIPY_REPO_USER }}
|
||||||
apt-get update
|
PIPY_REPO_PASS: ${{ secrets.PIPY_REPO_PASS }}
|
||||||
apt-get install -y python3 python3-pip
|
|
||||||
- name: Check out repository code
|
|
||||||
if: success()
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Installing Python Dependencies
|
|
||||||
if: success()
|
|
||||||
run: python3 -m pip install --upgrade pip setuptools wheel build twine pytest --break-system-packages
|
|
||||||
- name: Build
|
|
||||||
if: success()
|
|
||||||
run: python3 -m build
|
|
||||||
- name: Publish
|
|
||||||
if: success()
|
|
||||||
run: python3 -m twine upload --repository-url "https://gitfub.space/api/packages/jmaa/pypi" -u ${{ secrets.PIPY_REPO_USER }} -p ${{ secrets.PIPY_REPO_PASS }} dist/*
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
# WARNING!
|
|
||||||
# THIS IS AN AUTOGENERATED FILE!
|
|
||||||
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
|
||||||
|
|
||||||
name: Run Python tests (through Pytest)
|
name: Run Python tests (through Pytest)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
# WARNING!
|
|
||||||
# THIS IS AN AUTOGENERATED FILE!
|
|
||||||
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
|
||||||
|
|
||||||
name: Verify Python project can be installed, loaded and have version checked
|
name: Verify Python project can be installed, loaded and have version checked
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,3 +18,4 @@ __pycache__/
|
||||||
/.coverage
|
/.coverage
|
||||||
/.hypothesis/
|
/.hypothesis/
|
||||||
/htmlcov/
|
/htmlcov/
|
||||||
|
.aider*
|
||||||
|
|
|
@ -1,14 +1,3 @@
|
||||||
<!-- WARNING! -->
|
|
||||||
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
|
||||||
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
|
||||||
|
|
||||||
# Conventions
|
|
||||||
|
|
||||||
When contributing code to this project, you MUST follow the requirements
|
|
||||||
specified here.
|
|
||||||
|
|
||||||
## Code Conventions
|
|
||||||
|
|
||||||
When contributing code to this project, you MUST follow these principles:
|
When contributing code to this project, you MUST follow these principles:
|
||||||
|
|
||||||
- Code should be easy to read and understand.
|
- Code should be easy to read and understand.
|
||||||
|
@ -24,13 +13,3 @@ When contributing code to this project, you MUST follow these principles:
|
||||||
- Documentation should document semantics, not syntax.
|
- Documentation should document semantics, not syntax.
|
||||||
- Prefer importing modules, not individual items from modules.
|
- Prefer importing modules, not individual items from modules.
|
||||||
- Do not use f-strings in logging statements.
|
- 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.
|
|
||||||
|
|
||||||
## Testing
|
|
||||||
|
|
||||||
When contributing test to this project, you MUST follow these principles:
|
|
||||||
|
|
||||||
- Do not use any testing libraries other than `pytest`.
|
|
||||||
- Mocking is the root of all evil. Writing your own stubs is much more
|
|
||||||
preferable.
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<!-- WARNING! -->
|
<!--- WARNING --->
|
||||||
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
<!--- THIS IS AN AUTO-GENERATED FILE --->
|
||||||
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
<!--- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN --->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Partisia Blockchain Client
|
# Partisia Blockchain Client
|
||||||
|
|
|
@ -68,6 +68,40 @@ class Balances:
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class PbcClient:
|
class PbcClient:
|
||||||
|
"""
|
||||||
|
PbcClient provides an interface to interact with the Partisia Blockchain.
|
||||||
|
|
||||||
|
It supports various operations such as sending transactions (both raw and signed),
|
||||||
|
retrieving account balances, fetching blockchain metadata (e.g., chain ID, nonces),
|
||||||
|
and obtaining contract state details.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
session (requests.Session): The HTTP session used for all network communications.
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
send_transaction(contract_address: str, rpc: bytes, gas_cost: int)
|
||||||
|
Sends a transaction request to the blockchain.
|
||||||
|
|
||||||
|
send_signed_transaction(signed_transaction: SignedTransaction)
|
||||||
|
Dispatches a pre-signed transaction to the blockchain.
|
||||||
|
|
||||||
|
get_account_balances(address: str) -> Balances
|
||||||
|
Retrieves the balance information for the given account.
|
||||||
|
|
||||||
|
get_chain_id() -> str
|
||||||
|
Returns the blockchain's chain identifier.
|
||||||
|
|
||||||
|
get_sender_authentication_nonce() -> int
|
||||||
|
Obtains the nonce for sender authentication.
|
||||||
|
|
||||||
|
get_nonce_for_account(address: str) -> int
|
||||||
|
Retrieves the nonce for the specified account.
|
||||||
|
|
||||||
|
get_contract_state(address: str) -> tuple[dict, datetime.datetime]
|
||||||
|
Fetches the state and timestamp of a given contract.
|
||||||
|
|
||||||
|
... (other public methods are similarly available)
|
||||||
|
"""
|
||||||
session: requests.Session
|
session: requests.Session
|
||||||
sender_authentication: SenderAuthentication | None = None
|
sender_authentication: SenderAuthentication | None = None
|
||||||
hostname: str = HOSTNAME_MAINNET
|
hostname: str = HOSTNAME_MAINNET
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.10'
|
__version__ = '0.1.4'
|
||||||
|
|
28
setup.py
28
setup.py
|
@ -1,9 +1,10 @@
|
||||||
# WARNING!
|
# WARNING
|
||||||
# THIS IS AN AUTOGENERATED FILE!
|
#
|
||||||
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
# THIS IS AN AUTOGENERATED FILE.
|
||||||
|
#
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
@ -23,28 +24,13 @@ Unofficial library for reading contract states from Partisia Blockchain.""".stri
|
||||||
|
|
||||||
|
|
||||||
def parse_version_file(text: str) -> str:
|
def parse_version_file(text: str) -> str:
|
||||||
text = re.sub('^#.*', '', text, flags=re.MULTILINE)
|
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
||||||
match = re.match(r'^\s*__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
|
||||||
if match is None:
|
if match is None:
|
||||||
msg = 'Malformed _version.py file!'
|
msg = 'Malformed _version.py file!'
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
return match.group(2)
|
return match.group(2)
|
||||||
|
|
||||||
|
|
||||||
def find_python_packages() -> list[str]:
|
|
||||||
"""
|
|
||||||
Find all python packages. (Directories containing __init__.py files.)
|
|
||||||
"""
|
|
||||||
root_path = Path(PACKAGE_NAME)
|
|
||||||
packages: set[str] = set([PACKAGE_NAME])
|
|
||||||
|
|
||||||
# Search recursively
|
|
||||||
for init_file in root_path.rglob('__init__.py'):
|
|
||||||
packages.add(str(init_file.parent).replace('/', '.'))
|
|
||||||
|
|
||||||
print(f'Found following packages: {packages}')
|
|
||||||
return sorted(packages)
|
|
||||||
|
|
||||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||||
version = parse_version_file(f.read())
|
version = parse_version_file(f.read())
|
||||||
|
|
||||||
|
@ -65,7 +51,7 @@ setup(
|
||||||
author='Jon Michael Aanes',
|
author='Jon Michael Aanes',
|
||||||
author_email='jonjmaa@gmail.com',
|
author_email='jonjmaa@gmail.com',
|
||||||
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
|
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
|
||||||
packages=find_python_packages(),
|
packages=[PACKAGE_NAME],
|
||||||
install_requires=REQUIREMENTS_MAIN,
|
install_requires=REQUIREMENTS_MAIN,
|
||||||
extras_require={
|
extras_require={
|
||||||
'test': REQUIREMENTS_TEST,
|
'test': REQUIREMENTS_TEST,
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
from pbc_client.crypto import SenderAuthentication, sign_transaction
|
from pbc_client.crypto import SenderAuthentication, sign_transaction
|
||||||
from pbc_client.pbc_types import Address
|
|
||||||
|
|
||||||
def test_sender_authentication():
|
|
||||||
sender_authentication = SenderAuthentication('aa')
|
|
||||||
assert str(sender_authentication.sender_address()) == '00e72e44eab933faaf1fd4ce94bb57e08bff98a1ed'
|
|
||||||
|
|
||||||
def test_sender_authentication_2():
|
|
||||||
sender_authentication = SenderAuthentication('2')
|
|
||||||
assert str(sender_authentication.sender_address()) =='00b2e734b5d8da089318d0d2b076c19f59c450855a'
|
|
||||||
|
|
||||||
def test_sign():
|
def test_sign():
|
||||||
sender_authentication = SenderAuthentication('01')
|
sender_authentication = SenderAuthentication('01')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user