-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop python-native serialization in favour of bindings to antelope-rs
- Loading branch information
Showing
11 changed files
with
170 additions
and
1,595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,10 @@ authors = [{ name = "Guillermo Rodriguez", email = "[email protected]" }] | |
requires-python = ">=3.9" | ||
readme = "README.md" | ||
dependencies = [ | ||
"base58>=2.1.1,<3", | ||
"cryptos>=2.0.9,<3", | ||
"requests<2.32.0", | ||
"ripemd-hash>=1.0.1,<2", | ||
"httpx>=0.28.1,<0.29", | ||
"msgspec>=0.19.0", | ||
"pyo3-antelope-rs", | ||
] | ||
|
||
[dependency-groups] | ||
|
@@ -38,6 +36,12 @@ default-groups = [ | |
"snaps", | ||
] | ||
|
||
[tool.uv.sources.pyo3-antelope-rs] | ||
url = "https://github.com/openrepublic/pyo3-antelope-rs/releases/download/v0.2.0/pyo3_antelope_rs-0.2a1-cp39-abi3-manylinux_2_34_x86_64.whl" | ||
# git = "https://github.com/openrepublic/pyo3-antelope-rs.git" | ||
# rev = "8a0724b0504acdaf2af67e5e97e90a9411da26fa" | ||
# path = "../pyo3-antelope-rs" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = ["src/leap"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import time | ||
import struct | ||
from typing import TypeVar, Generic | ||
|
||
import antelope_rs | ||
from msgspec import Struct | ||
|
||
Name = antelope_rs.Name | ||
SymbolCode = antelope_rs.SymbolCode | ||
Symbol = antelope_rs.Symbol | ||
Asset = antelope_rs.Asset | ||
|
||
|
||
def endian_reverse_u32(x: int) -> int: | ||
# Ensure x fits into 32 bits, then convert to little-endian bytes | ||
# and re-interpret in big-endian to reverse endianness. | ||
return int.from_bytes((x & 0xFFFFFFFF).to_bytes(4, byteorder='little'), byteorder='big') | ||
|
||
def get_tapos_info(block_id: str) -> tuple[int, int]: | ||
block_id_bin = bytes.fromhex(block_id) | ||
|
||
# Unpack the first 16 bytes as two 64-bit little-endian integers | ||
hash0, hash1 = struct.unpack("<QQ", block_id_bin[:16]) | ||
|
||
ref_block_num = endian_reverse_u32(hash0) & 0xFFFF | ||
ref_block_prefix = hash1 & 0xFFFFFFFF | ||
|
||
return ref_block_num, ref_block_prefix | ||
|
||
|
||
def create_and_sign_tx( | ||
chain_id: str, | ||
actions: list[dict], | ||
key: str, | ||
max_cpu_usage_ms=255, | ||
max_net_usage_words=0, | ||
ref_block_num: int = 0, | ||
ref_block_prefix: int = 0 | ||
) -> dict: | ||
return antelope_rs.create_and_sign_tx( | ||
bytes.fromhex(chain_id), | ||
actions, | ||
key, | ||
int(time.time() + 900), | ||
max_cpu_usage_ms, | ||
max_net_usage_words, | ||
ref_block_num, | ||
ref_block_prefix | ||
) | ||
|
||
|
||
T = TypeVar('T') | ||
class GetTableRowsResponse(Struct, Generic[T]): | ||
rows: list[T] | ||
more: bool | ||
ram_payer: list[str] | None = None | ||
next_key: str | None = None | ||
|
||
class ChainErrorResponse(Struct): | ||
code: int | ||
message: str | ||
error: dict |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.