From 9b832dae8c54b942af3da9324aa9d84f9cdc253d Mon Sep 17 00:00:00 2001 From: Ivan Kalinin Date: Fri, 27 Dec 2024 19:47:42 +0100 Subject: [PATCH] Bump version - Fix build - Add `to_base64` for address --- .github/workflows/CI.yml | 8 ++++---- Cargo.lock | 4 ++-- Cargo.toml | 2 +- pyproject.toml | 1 + python/nekoton/nekoton.pyi | 12 ++++++++++++ src/models.rs | 5 +++++ tests/basic.py | 3 +++ 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7e0ad31..4315edd 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -18,7 +18,7 @@ jobs: platform: - runner: ubuntu-latest target: x86_64 - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - uses: goto-bus-stop/setup-zig@v2 @@ -45,7 +45,7 @@ jobs: platform: - runner: windows-latest target: x64 - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -71,9 +71,9 @@ jobs: platform: - runner: macos-latest target: x86_64 - - runner: macos-12 + - runner: macos-13 target: aarch64 - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/Cargo.lock b/Cargo.lock index 025a802..f11db41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -999,7 +999,7 @@ dependencies = [ [[package]] name = "nekoton-python" -version = "0.1.20" +version = "0.1.21" dependencies = [ "ahash", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 594cd7a..478f92e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nekoton-python" -version = "0.1.20" +version = "0.1.21" edition = "2021" [lib] diff --git a/pyproject.toml b/pyproject.toml index e74e1e6..0072833 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,3 +13,4 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] +dynamic = ["version"] diff --git a/python/nekoton/nekoton.pyi b/python/nekoton/nekoton.pyi index 456946c..71576da 100644 --- a/python/nekoton/nekoton.pyi +++ b/python/nekoton/nekoton.pyi @@ -1762,6 +1762,18 @@ class Address: """Hash of the initial state.""" ... + def to_base64(self, url_safe: bool = True, bounce: bool = False): + """ + Encodes address to a base64 format. + """ + ... + + def __str__(self): + """ + Encodes address to a raw format. + """ + ... + def __eq__(self, other) -> Any: ... def __ge__(self, other) -> Any: ... diff --git a/src/models.rs b/src/models.rs index cc02bbc..796db26 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1421,6 +1421,11 @@ impl Address { PyBytes::new(py, &bytes) } + #[pyo3(signature = (url_safe = true, bounce = false))] + fn to_base64(&self, url_safe: bool, bounce: bool) -> PyResult { + nt::utils::pack_std_smc_addr(url_safe, &self.0, bounce).handle_value_error() + } + fn __str__(&self) -> String { self.0.to_string() } diff --git a/tests/basic.py b/tests/basic.py index 4111c76..d79ef4b 100644 --- a/tests/basic.py +++ b/tests/basic.py @@ -17,6 +17,9 @@ my_addr = Address( '-1:d84e969feb02481933382c4544e9ff24a2f359847f8896baa86c501c3d1b00cf') assert (my_addr.workchain == -1 and len(my_addr.account) == 32) + +assert (my_addr.to_base64() == "Uf_YTpaf6wJIGTM4LEVE6f8kovNZhH-IlrqobFAcPRsAzwXV") + my_addr.workchain = 0 assert (my_addr.workchain == 0) assert (my_addr.__hash__() == my_addr.__hash__())